Archive for December, 2013

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:¬†https://msdn.microsoft.com/en-us/library/bb190764(v=vs.110).aspx

.loadby sos clr
loads SOS extension

.cls
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)

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

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

!clrstack
to print stack for previously set thread

!threadpool
threadpool info

!threads

~* kb
prints native stack for all threads

Advertisements

Leave a comment