Debugging Mozilla Firefox in Visual Studio 2012

While debugging Mozilla Firefox either you can create a debug .exe using mozilla build or you can generate a visual studio solution (.sln). In the first case you cannot browse through the code while in the second you can.

Debug Build from Mozilla Build

  1. If you want to debug mozilla in VS2012, compile it in debug mode. Add the following lines to mozilla-release\mozconfig
    ac_add_options --enable-debug
    ac_add_options --disable-optimize
  2. After that create firefox.exe
    cd mozilla-release
    ./mach build
  3. Create a new solution in VS2012 adding the newly created mozilla-release\obj-i686-pc-mingw32\dist\bin\firefox.exe
  4. Open any source file that you believe will definitely run. Mark a break point.
  5. Right click on firefox in Solution Explorer and click Debug > Step Into new instance

A Better Approach

The approach has a problem. You cannot browse through the code. If you want to do that

  1. Create a VisualStudio solution
    cd mozilla-release
    ./mach configure
    ./mach build-backend -b VisualStudio
  2. It will create a VS solution in \mozilla-release\obj-i686-pc-mingw32\msvc\mozilla,sln
  3. Open it in VS2012. It may update the solution to latest format.
  4. That’t it.