Here’s how I’m currently debugging Electrolysis stuff on OS X using gdb. It involves multiple terminal windows. I live with that.
# In Terminal Window 1, I execute my Firefox build with MOZ_DEBUG_CHILD_PROCESS=1. # That environment variable makes it so that the parent process spits out the child # process ID as soon as it forks out. I also use my e10s profile so as to not muck up # my default profile. MOZ_DEBUG_CHILD_PROCESS=1 ./mach run -P e10s # So, now my Firefox is spawned up and ready to go. I have # browser.tabs.remote.autostart set to "true" in my about:config, which means I'm # using out-of-process tabs by default. That means that right away, I see the # child process ID dumped into the console. Maybe you get the same thing if # browser.tabs.remote.autostart is false. I haven't checked. CHILDCHILDCHILDCHILD debug me @ 45326 # ^-- so, this is what comes out in Terminal Window 1.
So, the next step is to open another terminal window. This one will connect to the parent process.
# Maybe there are smarter ways to find the firefox process ID, but this is what I # use in my new Terminal Window 2. ps aux | grep firefox # And this is what I get back: mikeconley 45391 17.2 5.3 3985032 883932 ?? S 2:39pm 1:58.71 /Applications/FirefoxAurora.app/Contents/MacOS/firefox mikeconley 45322 0.0 0.4 3135172 69748 s000 S+ 2:36pm 0:06.48 /Users/mikeconley/Projects/mozilla-central/obj-x86_64-apple-darwin12.5.0/dist/Nightly.app/Contents/MacOS/firefox -no-remote -foreground -P e10s mikeconley 45430 0.0 0.0 2432768 612 s002 R+ 2:44pm 0:00.00 grep firefox mikeconley 44878 0.0 0.0 0 0 s000 Z 11:46am 0:00.00 (firefox) # That second one is what I want to attach to. I can tell, because the executable # path lies within my local build's objdir. The first row is my main Firefox I just # use for work browsing. I definitely don't want to attach to that. The third line # is just me looking for the process with grep. Not sure what that last one is. # I use sudo to attach to the parent because otherwise, OS X complains about permissions # for process attachment. I attach to the parent like this: sudo gdb firefox 45322 # And now I have a gdb for the parent process. Easy peasy.
And finally, to debug the child, I open yet another terminal window.
# That process ID that I got from Terminal Window 1 comes into play now. sudo gdb firefox 45326 # Boom - attached to child process now.
Setting breakpoints for things like TabChild::foo or TabParent::bar can be done like this:
# In Terminal Window 3, attached to the child: b mozilla::dom::TabChild::foo # In Terminal Window 2, attached to the parent: b mozilla::dom::TabParent::bar
And now we’re cookin’.