Electrolysis/Debugging: Difference between revisions

(orphaned e10s page containing obsolete data. page is still indexed and shows up in search results.)
 
(18 intermediate revisions by 10 users not shown)
Line 1: Line 1:
= Windows =


('''TODO''') Apparently Windows has a magic debugger that works great with multiple processes.
== Linux ==
To debug only the parent process with emacs gud-gdb, just run
M-x gdb, gdb --annotate 3 --args $objdir/dist/bin/firefox-bin -no-remote -P [GARBAGE PROFILE]
as you would for any other process.
'''NOTE''': you'll need to make sure firefox's $objdir/dist/lib is in your LD_LIBRARY_PATH.  Normally firefox -g would do this, but it doesn't play well with gud-gdb.  Rather than add $objdir/dist/lib to your main LD_LIBRARY_PATH, you can set it only for gdb by adding this line to your ~/.gdbinit
  set environment LD_LIBRARY_PATH=$objdir/dist/lib:/usr/lib/debug
(On Ubuntu, /usr/lib/debug contains libraries with better debug info if they're installed.  If you don't have them installed or you use another another distro, you probably want /usr/lib instead.)
'''WARNING''': if the first time you run firefox after a rebuild is from within gdb, gdb will crash when firefox restarts itself.  You can stop firefox from restarting itself by setting the NO_EM_RESTART environment variable.  Or you can just run firefox once from the shell, outside of gdb.
To debug child processes only, run firefox from the shell as
MOZ_DEBUG_CHILD_PROCESS=1 $objdir/dist/bin/firefox -no-remote -P [GARBAGE PROFILE]
Each time a child process is launched, lines like this will be printed
CHILDCHILDCHILD
debug me @ [PID]
and you can attach to the newly launched child process in emacs gud-gdb with M-x gdb, gdb --annotate 3 attach PID.
To debug both the parent and children, make sure MOZ_DEBUG_CHILD_PROCESS is set in the environment you'll launch the parent from, and launch the parent process in gud-gdb as above.  Unfortunately, as far as the author knows gud-gdb can't handle multiple gdb sessions ('''TODO: is that true?''').  So to debug child processes, you'll need to pull up a new shell for each and attach to them with good old "gdb attach PID".
Don't forget to check out the [https://developer.mozilla.org/en/Debugging_Mozilla_with_gdb main Mozilla gdb guide].
Also the [http://code.google.com/p/chromium/wiki/LinuxDebugging#GDB Google Chromium debugging guide for Linux] has some tips that also apply to our codebase, but we don't support all the tricks they show yet.
'''TODO''' other debuggers?

Latest revision as of 18:22, 2 December 2016