Search
Close this search box.

WinDbg / SOS Cheat Sheet

Here are the WinDbg / SOS commands I talked about at Code Camp NY.  These are the basic commands to get you going with WinDbg / SOS.

Starting, Attaching, Executing and Exiting

 Start -> All Programs -> Debugging Tools for Windows -> WinDbg
F6attach to process
Ctrl-Breakinterrupt debugee
.detachdetach from a process
gcontinue debugee execution
qexit WinDbg

Getting Help

?help on commands that affect the debugee
.helphelp on commands that affect the debugger
.hh commandview the on line help file
!helphelp on the extension dll at the top of the chain (e. g., SOS)

Issuing Commands

up arrow, down arrow, enterscroll through command history
Right mouse buttonpaste into command window

Examining the Unmanaged Environment

lmflist loaded modules with full path
lmtlist loaded modules with last modified timestamp
~list unmanaged threads
~thread sselect a thread for thread specific commands
!token -nview thread permissions
kview the unmanaged call stack
!runawayview thread CPU consumption
bpset a breakpoint
.dump pathdump small memory image
.dump /ma pathdump complete memory image

Working with Extension DLLs (e. g., SOS)

.chainlist extensions dlls
.load clr10\sosload SOS for debugging framework 1.0 / 1.1
.unload clr10\sosunload SOS
.loadby sos mscorwksload SOS for debugging framework 2.0

SOS Commands

!threadsview managed threads
!clrstackview the managed call stack
!dumpstackview combined unmanaged & managed call stack
!clrstack -pview function call arguments
!clrstack –lview stack (local) variables
!name2ee module classview addresses associated with a class or method
!dumpmt –md addressview the method table & methods for a class
!dumpmd addressview detailed information about a method
!do addressview information about an object
!dumpheap –statview memory consumption by type
!dumpheap –min sizeview memory consumption by object when at least size
!dumpheap –type typeview memory consumption for all objects of type type
!gcroot addressview which object are holding a reference to address
!syncblkview information about managed locks

SOS 2.0 Commands

!bpmd module methodset breakpoint
!DumpArray addressview contents of an array
!PrintExceptionview information about most recent exception
This article is part of the GWB Archives. Original Author: DAVID DOUGLASS

Related Posts