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: 59693
  • Created:
  • Creator: Mossop
  • Is current revision? No
  • Comment /* A Firefox nightly or release */

Revision Content

Introduction

Sometimes you need to get a stacktrace (call stack) for a Firefox crash or hang but Talkback fails 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.org/firefox/nightly/latest-trunk/.

Debugging

First you have to start WinDbg via Start->Programs->Debugging Tools for Windows->WinDbg. Now open the firefox.exe executable you downloaded before via File->Open Executable... Make sure that the "Debug child processes also" check box is checked.

You need to configure your WinDbg to download symbols from the Mozilla symbol server. To do that, you can follow the instruction from the page Using the Mozilla symbol server or just use the commands below.

You should now see a text window with some output in it and a input field below it. Enter in the input field these lines

.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 since it needs to download about 60MB. Now run Firefox via Debug->Go and try to reproduce the crasher or hang you are seeing. Switch back to WinDbg and look if there is some new text in the WinDbg Command window saying "Access violation" or similar. If there is not, click on Debug->Break (most likely you have to do this when you want to debug a hang). You should now see a input field again, enter <tt>kp</tt> there, this will give you the so-called stacktrace. Wait until it is done, then mark the text in that window and copy it into your clipboard with Ctrl+C so you can paste the stacktrace as a bug comment if needed.

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> fails 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">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 http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/.
</p>
<h3 name="Debugging"> Debugging </h3>
<p>First you have to start WinDbg via Start-&gt;Programs-&gt;Debugging Tools for Windows-&gt;WinDbg. 
Now open the firefox.exe executable you downloaded before via File-&gt;Open Executable... 
Make sure that the "Debug child processes also" check box is checked.
</p><p>You need to configure your WinDbg to download symbols from the Mozilla symbol server. To do that, you can follow the instruction from the page <a href="en/Using_the_Mozilla_symbol_server">Using the Mozilla symbol server</a> or just use the commands below.
</p><p>You should now see a text window with some output in it and a input field below it. Enter in the input field these lines
</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 since it needs to download about 60MB. Now run Firefox via Debug-&gt;Go and try to reproduce the crasher or hang you are seeing. Switch back to WinDbg and look if there is some new text in the WinDbg Command window saying "Access violation" or similar. If there is not, click on Debug-&gt;Break (most likely you have to do this when you want to debug a hang). You should now see a input field again, enter <tt>kp</tt> there, this will give you the so-called stacktrace. Wait until it is done, then mark the text in that window and copy it into your clipboard with Ctrl+C so you can paste the stacktrace as a bug comment if needed.
</p>
Revert to this revision