Electrolysis/Debugging: Difference between revisions

Jump to navigation Jump to search
Line 1: Line 1:
= Windows =
= Windows =


('''TODO''') Apparently Windows has a magic debugger that works great with multiple processes.
Debugging under Windows is very straightforward using Microsoft Visual Studio 2005 (MSVC8).
 
'''Note :''' Debugging E10s using MSVC9 should not be any different from MSVC8.
 
=== Creating a project  ===
 
First you need a 'Makefile' project. Open the "New Project" windows by hitting CTRL-SHIFT-N. Choose "Win32 Console Application" and type in whatever name and location you want for your new project. Hit the "OK" button.
 
Then, open your project's properties by right-clicking the project name in the "Solution Explorer" view. Choose "Makefile" for the "Configuration Type" field in the "Configuration Properties / General" section.
 
In "General Properties / NMake" section, do the following :
 
*type whatever make commands you want to use for building electrolysis, in the "general" subsection.
*type "OS_WIN;WIN32;XP_WIN;DEBUG;_DEBUG;MOZ_IPC" in the "Preprocessor Definitions" field of the "Intellisense" subsection.
 
In "General Properties / Debugging" section, do the following :
 
*type "<your_objdir>\browser\dist\bin\firefox.exe"
*type "-no-remote -P <your_electrolysis_profile_if_any> -chrome chrome://global/content/test-ipc.xul"
*type "MOZ_DEBUG_CHILD_PROCESS=1" in the "Environment" field
 
=== Debugging E10s  ===
 
First, make sure you've got a DEBUG build. If that's the case, you're all set ! Just hit F5 in MSVC. You should see the program's console with the main process output in it.
 
Now when the output stops updating, it means it's reached this code in nsEmbedFunctions.cpp :
 
<pre>
  if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS")) {
#ifdef OS_POSIX
      printf("\n\nCHILDCHILDCHILDCHILD\n  debug me @%d\n\n", getpid());
      sleep(30);
#elif defined(OS_WIN)
      Sleep(30000);
#endif
  }
</pre>
 
You now have 30 seconds to hook up to the newly created child process. Do the following :
*Hit CTRL-ALT-P to bring up the "attach to process" dialog
*Double-click "mozilla-runtime.exe" in the "Available Processes" listbox.
 
MSVC is going to load all the symbols from that newly attached process and, basically, you're done ! You should see two processes in your "processes" windows. You can break either one, or break all. You can switch from one to another by double-clicking on it, etc...
 
And for a better debugging experience, don't forget to add breakpoints ! heh!


= Linux =
= Linux =

Navigation menu