Mono remote debugging

Source: Internet
Author: User

Mono allows. net programs to run on Linux. So the. NET programmer turned to cross-platform after mono. But the open environment is usually in windows, so there is such a need. Can I use the source code in Windows to debug programs in Linux?

Xamarin is now widely used in mobile platform application development and can support real-machine debugging.

Generally, a TCP connection is maintained internally to pass the call stack information.

After reading some documents and stackoverflow search results, you can see the following description:

Remote debugging is actually really easy with the mono soft debugger. the IDE sends commands over TCP/IP to the mono soft debugger agent inside the runtime. depending how you launch the debuggee, you can either have it connect to the IDE over TCP, or have it open a port and wait for the IDE to connect to it.

For simple prototyping purposes, you can just setMONODEVELOP_SDB_TESTEnv var, and a new "Run-> run with-> Custom soft Debugger" command will show up in xamarin studio/monodevelop, and you can specify an arbitrary IP and port or connect or listen on, and Optionally a command to run. then you just have to start the debuggee with the correct--debugger-agentArguments (see the mono manpage for details), start the connection, and start debugging.

For a production workflow, You 'd typically create a monodevelop addin with a debugger engine and session subclassing the soft debugger classes, and overriding how to launch the app and set up the connection parameters. you 'd typically have a custom project type too subclassing the dotnetproject, So you cocould override how the project was built and executed, and so that the new debugger engine cocould be the primary Debugger for projects of that type. you 'd get all the default. net/Mono Project and debugger functionality "for free ".

Well, just like debugging on mobile phones, running mono on Linux is also very convenient to remotely use xamarinstudio for debugging.

My test code is as follows:

Public static void main (string [] ARGs)

{
Console. writeline ("Hello world! ");
While (true ){
String input = console. Readline ();
Console. writeline (input); // breakpoint can be set here.
If (input = "Q "){
Break;
}
}
Console. writeline ("Byebye ");
Console. readkey ();
}

First, add parameters when running mono.

For example: Mono -- debug -- debugger-agent = transport = dt_socket, address = 127.0.0.1: 8088, Server = Y, suspend = y myapp.exe

Because I set the server parameter to Y, it indicates that this is the socket listener, and then suspend = y. Myapp.exe does not start running, but waits for a connection.

Then, install monodevelop (xamarinstudio) on the other end, such as Windows, and configure the environment variables.

Monodevelop_sdb_test = 1

Start monodevelop, open the project, and set the default F5 (run) to "run-> run with-> Custom soft Debugger"

In the dialog box, enter the IP address and port of the mono running machine to be connected, so select connect (of course, if the parameter server of Mono Runtime is N, it is the opposite ).

After the connection is successful, the Linux interface outputs Hello world, and then enter the string at will. Press enter to get the breakpoint in windows. Check the variable value and call the stack OK command to obtain the data successfully.

The remote debugging test is successful.

How do you feel like using unity?

Yes. Check the related information.

 

In addition, if you want to run myapp.exe without waiting for a connection, set suspend to n. The program runs first without blocking the connection.

However, I still don't know how to disconnect the debugging process after the connection and don't end the process. I hope my friends can help me.

 

Note that there is another -- debug parameter that is very important. It matches the. MDB file generated by the EXE (DLL) assembly. Mono debugging information includes the source code path, the corresponding code lines, and so on. This information is required during remote debugging.

Otherwise, even if the connection is established, Mono does not know how to associate the data with the local code. So do not move directories easily in the source code.

The. MDB file can be generated using monodevelop, or you can find the MDB generation tool in the bin folder under the mono installation directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.