jit-debug 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. * Debugging information
  2. Compile your programs using the `-g' flag in MCS, that will all a special
  3. resource containing debugging information to your executable.
  4. To get stack traces with line number information, you need to run your
  5. program like this:
  6. <b>
  7. mono --debug program.exe
  8. </b>
  9. Notice that the program will need to be compiled with the -g
  10. flag and that running with --debug will slow down the execution.
  11. * Debugging with GDB
  12. If you use GDB to debug your mono process, you can use the function
  13. print_method_from_ip(void *address) to obtain the name of a method
  14. given an address.
  15. For example:
  16. <pre>
  17. (gdb) where
  18. #0 ves_icall_System_String_GetHashCode (me=0x80795d0) at string-icalls.c:861
  19. #1 0x0817f490 in ?? ()
  20. #2 0x0817f42a in ?? ()
  21. #3 0x0817f266 in ?? ()
  22. #4 0x0817f1a5 in ?? ()
  23. </pre>
  24. You can now use:
  25. <pre>
  26. (gdb) p print_method_from_ip (0x0817f490)
  27. IP 0x817f490 at offset 0x28 of method (wrapper managed-to-native) System.String:GetHashCode () (0x817f468 0x817f4a4)
  28. $1 = void
  29. (gdb) p print_method_from_ip (0x0817f42a)
  30. IP 0x817f42a at offset 0x52 of method System.Collections.Hashtable:GetHash (object) (0x817f3d8 0x817f43b)
  31. $2 = void
  32. </pre>
  33. Mono support libraries use a couple of signals internally that
  34. confuse gdb, you might want to add this to your .gdbinit file:
  35. <pre>
  36. handle SIGPWR nostop noprint
  37. handle SIGXCPU nostop noprint
  38. </pre>
  39. * Mono Debugger
  40. The Mono debugger is written in C# and can debug both managed
  41. and unmanaged applications, support for multiple-threaded
  42. applications and should be relatively easy to port to new
  43. platforms.
  44. Details of the release are available in <a
  45. href="http://lists.ximian.com/archives/public/mono-list/2003-January/011415.html">post</a>.
  46. The debugger contains both Gtk# and command line interfaces.
  47. The debugging file format used in Dwarf (it's already supported
  48. by our class libraries and the Mono C# compiler; To debug C
  49. applications, you need a recent GCC, or to pass the -gdwarf-2
  50. flag to gcc).
  51. You can download the releases from <a
  52. href="http://primates.ximian.com/~martin/debugger/">Martin Baulig's
  53. home page.</a>