jit-debug 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. How to use the debug support in the jit.
  2. ----------------------------------------
  3. You need to run mono inside gdb. The following command line swicthes
  4. are available:
  5. --stabs
  6. --debug methodName
  7. --stabs will create an assemblyname-stabs.s file for each assembly the
  8. CLR program uses. Note that to properly display source code lines,
  9. you need to disassemble the CLR executables with monodis before running
  10. mono. Each IL assembly file needs to have the name <assemblyname>.il.
  11. --debug methodName will insert a breakpoin at the beginning of
  12. methodName's code, so that control is trasnfered to the debugger as soon
  13. as it is entered. You may use this switch multiple times.
  14. So, suppose you use the --debug switch, or hit a segfault inside a
  15. jitted method. In a shell you need to compile the stab information
  16. created with the --stabs option with the assembler:
  17. as assemblyname-stabs.s -o assemblyname-stabs.o
  18. Now, inside gdb, you can load the debug information with:
  19. add-symbol-file assemblyname-stabs.o 0
  20. And at this point the debugger should be able to print a correct
  21. backtrace, you should be able to inspect method parameters and local
  22. variables, disassemble methods and step through the code.
  23. Note that apparently you can't unload a symbol file from gdb, so you
  24. need to restart it if you restart the program to debug.
  25. Name mangling.
  26. -------------
  27. Currently CLR methods are exposed as C functions, so, if they are not
  28. static, their first argument will be called 'this'.
  29. Method names are mangled in the following way: a long name is created
  30. concatting namespace, class name and method name. '.' chars are changed
  31. to underscaore '_'. To allow for overloading, the address of the
  32. MonoMethod from wich the method was created is appended to the end of
  33. the name (i's also handy since you can use the address in gdb to inspect
  34. the MonoMethod).