The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 719 other subscribers

Some notes/links on Windows Debugging CLR applications

Posted by jpluimers on 2014/07/02

I only need it every once in a while, so finding the right links and tips to help me usually takes too much time.

So here is a small list to get started:

Keywords: CLR, SOS.DLL, WinDbg, mscordacwks.dll, PSSCOR4

Some tips:

  • Except for .NET 1.x, get the SOS.DLL and mscordacwks.dll from the system you want to debug on (I tried maintaining a directory with each and every version: too hard to keep that complete).
    For .NET 1.x, get the SOS.DLL from Download and Install Debugging Tools for Windows or from a Windows Server 2003 installation.
  • Favour .loadby over .load
  • Favour PSSCOR4 over SOS
.NET Framework version CLR version CLR filename
1.1 1.1 mscorwks.dll
2.0 2.0 mscorwks.dll
3.0 2.0 mscorwks.dll
3.5 2.0 mscorwks.dll
4.0 4.0 clr.dll
4.5 4.0 clr.dll

DumpStacks.bat Batch file I use for dumping the stack of a .NET 1.x process:

[sourcecode language=”text”]
@echo on
if "%1" == "" goto :usage
if NOT "%2" == "" goto :run

:usage
echo Usage: %0 ^<pid^> ^<dumpfile^>
goto :quit

:run
setlocal
set output=%~f2
pushd %~dp0
Debuggers\ntsd -pv -p %1 -cf DumpStacks.ntsd.debugscript -logo %output%
popd
endlocal

:: .load C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\sos.dll
:: .load Debuggers\clr11\sos.dll

:quit
[/sourcecode]

It assumes the file DumpStacks.ntsd.debugscript exists in the same directory as the batch file:

[sourcecode language=”text”]
.load Debuggers\clr11\sos.dll
~*k
!EEStack
.detach
q
[/sourcecode]

This assumes a Debuggers directory under the directory of the batch file, which has a clr11 directory containing sos.dll

I copied the Debuggers directory after installing the Download and Install Debugging Tools for Windows.

–jeroen

Leave a Comment