Windbg is a multipurpose debugger for Microsoft windows. Whilst it’s initially an unmanaged debugger, extensions can be installed that allow it to “understand” managed code, allowing users to attach to a managed code process such as w3wp.exe
It used to be a simple download, but is now part of the Debugging tools for Windows SDK (http://www.microsoft.com/whdc/devtools/debugging/default.mspx). To avoid the full 1GB download, uncheck everything except 'redistribuble' which contains the debugging tools (about 60mb)
Once downloaded, navigate to C:\Program Files\Microsoft SDKs\Windows\v7.1\Redist\Debugging Tools for Windows and select the relevant tools (about 40mb)
The Debugging Tools are listed in two places on the Installation Options screen in the Windows SDK Setup Wizard:
Select the Debugging Tools option under the Common Utilities if you want the x86 version of Debugging Tools and you are installing on an x86 computer. This option automatically detects the CPU architecture of the computer on which you are installing the tools and it is the fastest method of installing the tools.
Select the Debugging Tools option under the Redistributable Packages to download all three versions of Debugging Tools (x86, x64, Itanium)
Once installed, we need to work with a managed code extension. As part of .net , SOS (son of strike) is available, but other popular extensions exist:
- SoSEx – created by a 3rd party company, can be downloaded from http://www.stevestechspot.com/
- PSSCor2 – created by Microsoft's PSS team, can be downloaded from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5c068e9f-ebfe-48a5-8b2f-0ad6ab454ad4&displaylang=en
- PSSCor4 - .net 4.0 version of PSSCor2 - http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a06a0fea-a4d4-434e-a527-d6afa2e552dd
Common commands:
- sxe - this means stop on event
- sxi -ignore event
- sxn -notify event
- sxe clr - stop on a clr event
- clrstack
- dumpobj
- !dumpheap
- !CLRUsage
- !DumpAllExceptions
- !ASPXPages
- !DumpASPNETCache
- !DumpHttpRuntime
- !FindDebugTrue
- !FindDebugModules
References