Electrolysis/Debugging
Windows
(TODO) Apparently Windows has a magic debugger that works great with multiple processes.
Linux
To debug only the parent process
With GDB: just pass "-g" to your regular command line, ex:
$objdir/dist/bin/firefox -no-remote -P JunkProfile -g -chrome chrome://global/content/test-ipc.xul
With emacs gud-gdb: run
M-x gdb, gdb --annotate 3 --args $objdir/dist/bin/firefox-bin -no-remote -P JunkProfile -chrome chrome://global/content/test-ipc.xul
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 JunkProfile -chrome chrome://global/content/test-ipc.xul
Each time a child process is launched, lines like this will be printed
CHILDCHILDCHILD debug me @ [PID]
(If you don't see this message, make sure you have set "dom.ipc.tabs.enabled" to "true", as described the Build and Run Instructions)
You can attach to the newly launched child process with "gdb attach [PID]", or, for 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 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".)
More Resources
Don't forget to check out the main Mozilla gdb guide.
Also the 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?