Useful Windbg commands

I’ve found some really useful infos on the links below:
http://www.jayway.com/2011/04/26/getting-started-with-managed-dump-files-using-windbg/
http://www.virtualdub.org/blog/pivot/entry.php?id=215
http://msdn.microsoft.com/en-us/library/bb190764.aspx
http://labs.snort.org/awbo/windbg.txt
Another interesting point is if you need a dump from a 32 bit process on a 64 bit machine, check it here: http://stackoverflow.com/questions/16422577/sos-does-not-support-the-current-target-architecture
Wolfgan Kroneder’s workshop gave the base for the list below:

Loads the sos dll for .NET 4

.loadby sos clr

Sets the symbols path

.sympath <path>

Hooks up the Microsoft symbol server

.symfix+
// with load anything option if simple symfix doesn't work
.symopt+ 0x40

Loads the sosex dll

.load sosex

Display current stack

!clrstack

Displays the stack of all managed threads (sos must be loaded)

!EEStack

List threads

~
~*kb

Change to thread

~~[1d8c]s
where 1d8c is the threadID number

Lists the current thread with locals and parameters (sosex must be loaded)

!mk –a

Displays the size and locations of the managed heaps (sos must be loaded)

!sos.eeheap [-gc|-loader]

Displays statistics of all managed objects still in memory (sos must be loaded)

!sos.dumpheap –stat

Displays statistics of all managed objects of a specific type still in memory (sos must be loaded)

!sos.dumpheap –mt <MethodTable>
!sos.dumpheap –type <type>

Displays the size of a specific object and all it’s children (sos must be loaded)

!sos.objsize <addr>

Displays who is holding on to a specific object (sos must be loaded)

!sos.gcroot <addr>

Displays all appdomains and the assemblies that are loaded in each domain (sos must be loaded)

!sos.dumpdomain

Dump object and dump array

!do addr
!da addr

Dump object and value (e.g. for string) (sosex must be loaded)

!mdt addr

Travers in the object hierarchy and referencing arrays and objects (sosex must be loaded)
It was extremly useful when I was searching for some values of some objects in the heap.

!sosex.refs addr

Write a log for the CLR Profiler

!TraverseHeap
Advertisements

About Tamas Nemeth

Husband and proud father of two daughters in Nürnberg. I'm working as a Senior Software Developer and an enthusiastic Clean-Coder. I spend most of my free time with my family (playing, hiking, etc...). I also play table-tennis and badminton sometimes...
This entry was posted in Technical Interest and tagged , . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s