Hacking and debugging Firefox.

Last week I typed about building Firefox and navigating the source code. Today I will talk about how to hack and debug Firefox effectively.

One of the first things I found was that most of my previous techniques would not fly in a code base this big. It is just not effective to insert a log message and recompile. It will take too long to compile, and the data you log will just be too little too late. This technique may still be viable, but just in a limited space. I also have a technique for seeing what code does, by commenting it out, and running the program to see what the program no longer does. This is also not viable because of the size and compile time.

The simple technique of reading code will also only get you so far. This code is just too big; you need stack traces, breakpoints, and the ability to see the value of every variable in scope.

I tried two things to get the tools I needed to do this.

First I tried GDB (GNU Debugger). I am currently using Windows, so this was a bit of a challenge, and I got it kinda working. But, I still don’t think it was enough, because I could only get break points and stack traces; I did not get the ability to see variable values.

Second was to try Visual Studio. This was actually much easier than I expected. I used this guide. I was happy to finally find some instructions that were not fragmented, but up to date and on my system and versions that I am running. So it all went smoothly, which I did not expect. This allows me to set a break point right in the source, run the program, and it will stop execution at those points and let me explore the scope and stack trace. This, along with Mozilla’s cross reference (MXR) will allow me to hack and debug Firefox.

I now have a really nice workflow.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: