Changes

Jump to: navigation, search

Dive into Mozilla Debugging Mozilla Lab

852 bytes added, 13:56, 19 March 2007
no edit summary
* In VS.NET, click '''File > Open > Project/Solution....''' Navigate to your debug-built firefox.exe, perhaps in '''mozilla/objdir/dist/bin'''. This will create a '''Solution File (.sln)''' in the same directory as firefox.exe.
* Now right-click firefox.exe in '''Solution Explorer''' and add '''MOZ_NO_REMOTEXPCOM_DEBUG_BREAK=1warn''' to the list of '''Environment variables'''. Next, add the following to the '''Command Arguments''' list: '''-p ''development'' --no-remote''' where ''development'' is the name of a profile you've created for testing (NOTE: use -Profilemanager if you haven't done this yet, and create one).
* Open a source file ('''File > Open > File...'''), for example, '''mozilla/widget/src/windows/nsWindow.cpp''', and set a breakpoint. You do this by clicking to the left of the line numbers--you should see a '''red circle'''. For example, you could set a breakpoint on the [http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsWindow.cpp#5253 mouse scrollwheel code] at '''line 52565261''' to see when it gets executed and how it works:
4289 PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue)
5254 #ifndef WINCE
5255 if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL) {
'''5256 static int iDeltaPerLine, iDeltaPerChar;''' <-- breakpoint here
5257 static ULONG ulScrollLines, ulScrollChars = 1;
5258 static int currentVDelta, currentHDelta;
5259 static HWND currentWindow = 0;
5260
5261 '''PRBool isVertical = msg == WM_MOUSEWHEEL;''' <-- breakpoint here
...
$ make
* Run your browser (i.e., restart if you install as an add-on, or run your build) and you'll have a new option in your '''Tools ''' menu: '''JavaScript Debugger'''
* By default, Mozilla's JavaScript files are not visible. Venkman is set to debug the current web application instead. We need to add these manually:
http://lxr.mozilla.org/seamonkey/source/calendar/providers/wcap/calWcapCalendar.js#128
=== Exercise: debugging FirstXpcom ===
 
Using the same techniques we've just learned, we can also debug [[Dive into Mozilla First XPCOM Component|FirstXpcom's]] C++ code (we'll write a XUL/JS extension in a later lab).
 
Try adding breakpoints to the methods in '''FirstXpcom.cpp''', for example in '''::Add'''.
 
Use the [[Dive_into_Mozilla_First_XPCOM_Component#Accessing_FirstXpcom_from_the_JavaScript_Shell|JavaScript Shell]] to write some code in order to create and call the methods of FirstXpcom. Make sure you can see your code being executed via the breakpoints you've set in VS.NET.
== Resources ==

Navigation menu