WinDbg SOS cheatsheet

SOS (Son of Strike) WinDbg extensions allows you to debug (and monitor resource usage, find leaks, help spot deadlocks) .NET applications. Here are some useful SOS commands which may be executed in WinDbg or Visual Studio’s immediate window. All SOS command can be found here:

.loadby sos clr
loads SOS extension

clears the screen

Memory stuff:

!eeheap -gc
information about managed heap

!dumpheap -stat
lists loaded classes, number of instances of each class and addres of Method Table (MT)

!dumpheap -mt [MT]
dumps objects of given class (i.e. of class which has method table at address)

!do [object's address]
dumps particular managed object

du [object's address]
dumps particular not-necessarily managed object

!gcroot [object's address]
shows reference chain to given object

Stack stuff:

~* e !clrstack
for every (*) thread (~) execute (e) command !clrstack (which prints current stack)

lists synchronization blocks owned by active threads (.i.e you may check if some thread is being blocked)

prints information about thread 30 and sets current “debugging context” to thread 30, so then one can call

to print stack for previously set thread

threadpool info


~* kb
prints native stack for all threads

  1. Leave a comment

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: