Revision 59702 of How to get a stacktrace with WinDbg

  • Revision slug: How_to_get_a_stacktrace_with_WinDbg
  • Revision title: How to get a stacktrace with WinDbg
  • Revision id: 59702
  • Created:
  • Creator: zzxc
  • Is current revision? No
  • Comment 8 words added, 8 words removed

Revision Content

 

Introduction

Sometimes you need to get a stacktrace (call stack) for a Firefox crash or hang but Talkback or Breakpad fail because it's a special crasher or a hang. This article describes how to get a stacktrace in those cases with WinDbg on Windows.

Requirements

To get such a stacktrace you need to install the following software:

Debugging Tools for Windows

Microsoft distributes the Debugging Tools for Windows for free, those include WinDbg which you will need here. Download it from Install Debugging Tools for Windows 32-bit Version for 32-bit versions of Windows (if you own a 64-bit version of Windows, follow the link on that page to the 64-bit version). Then install it, the standard settings in the installation process are fine.

A Firefox nightly or release

You need a Firefox version for which symbols are availables from the Mozilla symbol server to use with WinDbg. You can use any official nightly build or release from MoFo. You can find the latest trunk nightly builds under http://ftp.mozilla.org/pub/mozilla.o.../latest-trunk/.

Debugging

To begin debugging, run WinDbg from the Start menu.  (Start->All Programs->Debugging Tools for Windows->WinDbg)  Next, open the firefox.exe executable (in your Firefox program folder) by opening the File menu and choosing Open Executable...

You should now see a "Command" text window with debug output at the top and an input box at the bottom.  Before debugging can start, several commands must be entered into the one-line input box at the bottom of the Command window.

First, you need to configure your WinDbg to download symbols from the Mozilla symbol server.  To load the symbols, enter the three commands below, pressing enter after each one.  (More details are available at Using the Mozilla symbol server)

.sympath SRV*c:\symbols*http://symbols.mozilla.org/firefox
.symfix+ c:\symbols
.reload /f

Now wait for the symbols to download.  This may take some time depending on your connection speed; the total size of the download is around 70MB.   WinDbg will show "Busy" at the bottom of the application window until the download is complete.

Once the download is complete, you need to configure WinDbg to examine child processes and ignore a specific event caused by Flash Player.  You will also want to open a log file to save data you collect.  To do this, enter these three commands, pressing enter after each one.

.childdbg 1
sxn gp
.logopen /t c:\firefox-debug.log

Now run Firefox by opening the Debug and clicking Go.  Try to reproduce the crash or hanging issue that you are seeing.  Once it crashes or hangs, you should return to WinDbg and for an error (such as "Access violation") in the Command window.  (If Firefox is hung, open the Debug menu and choose Break to start debugging.)

Finally, you need to capture the debug information to include in a bug comment or support request.  Enter these three commands, one at a time, to get the stacktrace, crash analysis, and log of loaded modules.  (Again, press Enter after each command)

kp
!analyze -v -f
lm

After this is complete, find the file c:\firefox-debug-(Today's Date).txt on your hard drive.  To provide the information to the development community, submit this file with a support request or attach it to a related bug on Bugzilla.

FAQ

Q: The first four frames of my stack trace look like this

0012fe20 7c90e89a ntdll!KiFastSystemCallRet
0012fe24 7c81cd96 ntdll!ZwTerminateProcess+0xc
0012ff20 7c81cdee kernel32!_ExitProcess+0x62
0012ff34 6000179e kernel32!ExitProcess+0x14

This looks wrong to me?!

A: You ran the application without the "Debug child processes also" check box being checked. You need to detach the debugger and open the application again, this time with the check box being checked.

See Also

Revision Source

<p> </p>
<h3 name="Introduction">Introduction</h3>
<p>Sometimes you need to get a stacktrace (call stack) for a Firefox crash or hang but <a class="external" href="http://kb.mozillazine.org/Talkback">Talkback</a> or <a class="external" href="http://kb.mozillazine.org/Breakpad" title="http://kb.mozillazine.org/Breakpad">Breakpad</a> fail because it's a special crasher or a hang. This article describes how to get a stacktrace in those cases with WinDbg on Windows.</p>
<h3 name="Requirements">Requirements</h3>
<p>To get such a stacktrace you need to install the following software:</p>
<h4 name="Debugging_Tools_for_Windows">Debugging Tools for Windows</h4>
<p>Microsoft distributes the Debugging Tools for Windows for free, those include WinDbg which you will need here. Download it from <a class="external" href="http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx">Install Debugging Tools for Windows 32-bit Version</a> for 32-bit versions of Windows (if you own a 64-bit version of Windows, follow the link on that page to the 64-bit version). Then install it, the standard settings in the installation process are fine.</p>
<h4 name="A_Firefox_nightly_or_release">A Firefox nightly or release</h4>
<p>You need a Firefox version for which symbols are availables from the <a href="/en/Using_the_Mozilla_symbol_server" title="en/Using_the_Mozilla_symbol_server">Mozilla symbol server</a> to use with WinDbg. You can use any <a class="external" href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/">official nightly build</a> or release from MoFo. You can find the latest trunk nightly builds under <a class=" external" href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/" rel="freelink">http://ftp.mozilla.org/pub/mozilla.o.../latest-trunk/</a>.</p>
<h3 name="Debugging">Debugging</h3>
<p>To begin debugging, run WinDbg from the Start menu.  (Start-&gt;All Programs-&gt;Debugging Tools for Windows-&gt;WinDbg)  Next, open the firefox.exe executable (in your Firefox program folder) by opening the<strong> File</strong> menu and choosing <strong>Open Executable... </strong></p>
<p>You should now see a "Command" text window with debug output at the top and an input box at the bottom.  Before debugging can start, several commands must be entered into the one-line input box at the bottom of the Command window.</p>
<p>First, you need to configure your WinDbg to download symbols from the Mozilla symbol server.  To load the symbols, enter the three commands below, pressing enter after each one.  (More details are available at <a href="/en/Using_the_Mozilla_symbol_server" title="en/Using_the_Mozilla_symbol_server">Using the Mozilla symbol server</a>)</p>
<pre>.sympath SRV*c:\symbols*http://symbols.mozilla.org/firefox
.symfix+ c:\symbols
.reload /f
</pre>
<p>Now wait for the symbols to download.  This may take some time depending on your connection speed; the total size of the download is around 70MB.   WinDbg will show "Busy" at the bottom of the application window until the download is complete.</p>
<p>Once the download is complete, you need to configure WinDbg to examine child processes and ignore a specific event caused by Flash Player.  You will also want to open a log file to save data you collect.  To do this, enter these three commands, pressing enter after each one.</p>
<pre>.childdbg 1
sxn gp
.logopen /t c:\firefox-debug.log</pre>
<p>Now run Firefox by opening the <strong>Debug</strong> and clicking <strong>Go</strong>.  Try to reproduce the crash or hanging issue that you are seeing.  Once it crashes or hangs, you should return to WinDbg and for an error (such as "Access violation") in the Command window.  (If Firefox is hung, open the <strong>Debug</strong> menu and choose <strong>Break </strong>to start debugging.)</p>
<p>Finally, you need to capture the debug information to include in a bug comment or support request.  Enter these three commands, one at a time, to get the stacktrace, crash analysis, and log of loaded modules.  (Again, press Enter after each command)</p>
<pre>kp
!analyze -v -f
lm</pre>
<p>After this is complete, find the file <strong>c:\firefox-debug-(Today's Date).txt</strong> on your hard drive.  To provide the information to the development community, submit this file with a <a class="external" href="http://support.mozilla.com/" title="http://support.mozilla.com/">support request</a> or attach it to a related bug on <a class="link-https" href="https://bugzilla.mozilla.org/" title="https://bugzilla.mozilla.org/">Bugzilla</a>.</p>
<h3 name="FAQ">FAQ</h3>
<p>Q: The first four frames of my stack trace look like this</p>
<pre>0012fe20 7c90e89a ntdll!KiFastSystemCallRet
0012fe24 7c81cd96 ntdll!ZwTerminateProcess+0xc
0012ff20 7c81cdee kernel32!_ExitProcess+0x62
0012ff34 6000179e kernel32!ExitProcess+0x14
</pre>
<p>This looks wrong to me?!</p>
<p>A: You ran the application without the "Debug child processes also" check box being checked. You need to detach the debugger and open the application again, this time with the check box being checked.</p>
<h3 name="See_Also">See Also</h3>
<ul> <li><a href="/en/Using_the_Mozilla_symbol_server" title="en/Using_the_Mozilla_symbol_server">symbol server</a> Maps addresses to human readable strings.</li> <li><a href="/en/Using_the_Mozilla_source_server" title="en/Using_the_Mozilla_source_server">source server</a> Maps addresses to source code lines</li>
</ul>
Revert to this revision