Electrolysis/Debugging: Difference between revisions

Jump to navigation Jump to search
Line 3: Line 3:
('''TODO''') Apparently Windows has a magic debugger that works great with multiple processes.
('''TODO''') Apparently Windows has a magic debugger that works great with multiple processes.


== Linux ==
= Linux =


To debug only the parent process with emacs gud-gdb, just run
== To debug only the parent process ==
  M-x gdb, gdb --annotate 3 --args $objdir/dist/bin/firefox-bin -no-remote -P [GARBAGE PROFILE]
 
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.
as you would for any other process.


Line 15: Line 22:
'''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.
'''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
== To debug child processes only ==
  MOZ_DEBUG_CHILD_PROCESS=1 $objdir/dist/bin/firefox -no-remote -P [GARBAGE PROFILE]
 
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
Each time a child process is launched, lines like this will be printed
  CHILDCHILDCHILD
  CHILDCHILDCHILD
  debug me @ [PID]
  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".
''(If you don't see this message, make sure you have set "dom.ipc.tabs.enabled" to "true", as described the [[Content Processes/Build|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 [https://developer.mozilla.org/en/Debugging_Mozilla_with_gdb main Mozilla gdb guide].
Don't forget to check out the [https://developer.mozilla.org/en/Debugging_Mozilla_with_gdb main Mozilla gdb guide].
Confirmed users
431

edits

Navigation menu