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

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

    Join 1,680 other followers

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:

@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

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

.load Debuggers\clr11\sos.dll
~*k
!EEStack
.detach
q

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: