1How to get a stacktrace with WinDbg 2=================================== 3 4+--------------------------------------------------------------------+ 5| This page is an import from MDN and the contents might be outdated | 6+--------------------------------------------------------------------+ 7 8Introduction 9------------ 10 11Sometimes you need to get a stacktrace (call stack) for a crash or hang 12but `Breakpad <http://kb.mozillazine.org/Breakpad>`__ fails because it's 13a special crash or a hang. This article describes how to get a 14stacktrace in those cases with WinDbg on Windows. (To get a stacktrace 15for Thunderbird or some other product, substitute the product name where 16ever you see Firefox in this instructions.) 17 18Requirements 19------------ 20 21To get such a stacktrace you need to install the following software: 22 23Debugging Tools for Windows 24~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 26Microsoft distributes the Debugging Tools for Windows for free, those 27include WinDbg which you will need here. Download it from `Install 28Debugging Tools for 29Windows <https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk>`__. 30(*You'll want the 32-bit version*, even if you are using a 64-bit 31version of Windows) Then install it, the standard settings in the 32installation process are fine. 33 34A Firefox nightly or release 35~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36 37You need a Firefox version for which symbols are availables from the 38:ref:`symbol server <Using The Mozilla Symbol Server>` to use 39with WinDbg. You can use any `official nightly 40build <https://ftp.mozilla.org/pub/firefox/nightly/>`__ or released 41version of Firefox from Mozilla. You can find the latest trunk nightly 42builds under 43`http://ftp.mozilla.org/pub/mozilla.o.../latest-trunk/ <https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central/>`__. 44 45 46Debugging 47--------- 48 49To begin debugging, ensure that Firefox is not already running and open 50WinDbg from the Start menu. (Start->All Programs->Debugging Tools for 51Windows->WinDbg) Next, open the **"File"** menu and choose **"Open 52Executable..."**. In the file chooser window that appears, open the 53firefox.exe executable in your Firefox program folder (C:\Program 54Files\Mozilla Firefox). 55 56You should now see a "Command" text window with debug output at the top 57and an input box at the bottom. Before debugging can start, several 58commands must be entered into the one-line input box at the bottom of 59the Command window. 60 61.. note:: 62 63 Tip: All commands must be entered exactly as written, one line at a 64 time, into the bottom of the Command box. 65 66 - Copying and pasting each line is the easiest method to avoid 67 mistakes 68 - Some commands start with a period (.) or a pipe character (|), 69 which is required. (The keystroke for a pipe character on US 70 keyboards is SHIFT+\) 71 - Submit the log file on a bug or via the support site, even if 72 nothing seems to happen during the debug process 73 74 75Start debugging 76~~~~~~~~~~~~~~~ 77 78Now that Firefox is opened in the debugger, you need to configure your 79WinDbg to download symbols from the Mozilla symbol server. To load the 80symbols, enter the three commands below, pressing enter after each one. 81(More details are available at :ref:`symbol server <Using The Mozilla Symbol Server>`.) 82 83:: 84 85 .sympath SRV*c:\symbols*http://symbols.mozilla.org/firefox;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols 86 .symfix+ c:\symbols 87 .reload /f 88 89Now wait for the symbols to download. This may take some time depending 90on your connection speed; the total size of the Mozilla and Microsoft 91symbols download is around 1.4GB. WinDbg will show "Busy" at the bottom 92of the application window until the download is complete. 93 94Once the download is complete, you need to configure WinDbg to examine 95child processes, ignore a specific event caused by Flash Player, and 96record a log of loaded modules. You will also want to open a log file to 97save data you collect. To do this, enter these four commands, pressing 98enter after each one. 99 100:: 101 102 .logopen /t c:\temp\firefox-debug.log 103 .childdbg 1 104 .tlist 105 sxn gp 106 lm 107 108If you see firefox.exe listed in the output from .tlist more than once, 109then you are already running the application and need to close the 110running instance first before you start debugging, otherwise you won't 111get useful results. 112 113Now run Firefox by opening the **Debug** menu and clicking **Go**. 114**While Firefox is running, you will not be able to type any commands 115into the debugger.** After it starts, try to reproduce the crash or 116hanging issue that you are seeing. 117 118.. note:: 119 120 If Firefox fails to start, and you see lines of text followed by a 121 command prompt in the debugger, a "breakpoint" may have been 122 triggered. If you are prompted for a command but don't see an error 123 about a crash, go back to the **Debug** menu and press **Go**. 124 125Once the browser crashes, you will see an error (such as "Access 126violation") in the WinDbg Command window. If Firefox hangs and there is 127no command prompt available in the debugger, open the **Debug** menu and 128choose **Break.** Once the browser has crashed or been stopped, continue 129with the steps below. 130 131 132After the crash or hang 133~~~~~~~~~~~~~~~~~~~~~~~ 134 135You need to capture the debug information to include in a bug comment or 136support request. Enter these three commands, one at a time, to get the 137stacktrace, crash/hang analysis and log of loaded modules. (Again, press 138Enter after each command.) 139 140:: 141 142 ~* kp 143 !analyze -v -f 144 lm 145 146After these steps are completed, find the file 147**c:\temp\firefox-debug-(Today's Date).txt** on your hard drive. To 148provide the information to the development community, submit this file 149with a `support request <https://support.mozilla.com/>`__ or attach it 150to a related bug on `Bugzilla <https://bugzilla.mozilla.org/>`__. 151 152 153Producing a minidump 154~~~~~~~~~~~~~~~~~~~~ 155 156Sometimes the stacktrace alone is not enough information for a developer 157to figure out what went wrong. A developer may ask you for a "minidump" 158or a "full memory dump", which are files containing more information 159about the process. :ref:`You can easily produce minidumps from WinDBG and 160provide them to developers <Capturing a minidump>`. 161 162FAQ 163 164Q: I am running Windows 7 (32-bit or 64-bit) and I see an exception in 165the WinDbg command window that says 'ntdll32!LdrpDoDebuggerBreak+0x2c' 166or 'ntdll32!LdrpDoDebuggerBreak+0x30'. What do I do now? 167 168A: If you see 'int 3' after either of those exceptions, you will need to 169execute the following commands in WinDbg. 170 171:: 172 173 bp ntdll!LdrpDoDebuggerBreak+0x30 174 bp ntdll!LdrpDoDebuggerBreak+0x2c 175 eb ntdll!LdrpDoDebuggerBreak+0x30 0x90 176 eb ntdll!LdrpDoDebuggerBreak+0x2c 0x90 177 178| Make sure you enter them one at a time and press enter after each one. 179 If you use the 64-bit version of Windows, you need to replace "ntdll" 180 in these commands with "ntdll32". 181| Q: The first four frames of my stack trace look like this: 182 183:: 184 185 0012fe20 7c90e89a ntdll!KiFastSystemCallRet 186 0012fe24 7c81cd96 ntdll!ZwTerminateProcess+0xc 187 0012ff20 7c81cdee kernel32!_ExitProcess+0x62 188 189 0012ff34 6000179e kernel32!ExitProcess+0x14 190 191This looks wrong to me?! 192 193A: You ran the application without the "Debug child processes also" 194check box being checked. You need to detach the debugger and open the 195application again, this time with the check box being checked. 196 197Q: WinDbg tells me that it is unable to verify checksum for firefox.exe. 198Is this normal? 199 200A: Yes, this is normal and can be ignored. 201 202Q: Should I click yes or no when WinDbg asks me to "Save information for 203workspace?" 204 205A: Click yes and WinDbg will save you from having to enter in the symbol 206location for Firefox.exe in the future. Click no if you'd rather not 207having WinDbg save this information. 208 209Q: I'm seeing "wow64" on top of each thread, is that ok ? 210 211A: No, you are running a 64 bit version of Windbg and trying to debug a 21232 bit version of the mozilla software. Redownload and install the 32 213bit version of windbg. 214 215 216Troubleshooting: Symbols will not download 217~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 218 219If symbols will not download no matter what you do, the problem may be 220that Internet Explorer has been set to the **Work Offline** mode. You 221will not receive any warnings of this in Windbg, Visual C++ or Visual 222Studio. Even using the command line with symchk.exe to download symbols 223will fail. This is because Microsoft uses Internet Explorer's internet & 224proxy settings to download the symbol files. Check the File menu of 225Internet Explorer to ensure "Work Offline" is unchecked. 226 227 228See also 229-------- 230 231- :ref:`symbol server <Using The Mozilla Symbol Server>` Maps addresses to human readable strings. 232- :ref:`source server <Using The Mozilla Source Server>` Maps addresses to source code lines 233