SOS Extension Commands
There are many WinDbg debugger extensions. Among them SOS extension is pretty popular and useful for .NET debugging. The SOS debugger extension (SOS.dll) helps you debug .NET managed application in the WinDbg by providing information about the internal Common Language Runtime (CLR) environment. All debugger extension commands start with bang(!). The following table shows frequently used SOS extension commands.
Command | Description | Example |
!clrstack | Display a stack trace of managed code only | !clrstack -a |
!comstate | List the COM apartment model for each thread and a Context pointer if available | !comstate |
!dumpdomain | List AppDomain(s) and its assemblies. | !dumpdomain |
!dumpassembly | Display assembly information | !dumpassembly 02fe1bd8 |
!dumpmodule | Displays information about a module at the specified address | !dumpmodule /d 03224014 |
!dumpclass | Display information about the EEClass structure associated with a type | !dumpclass 60be6004 |
!dumpobj | Display information about an object at the specified address | !dumpobj /d 04a0226c |
!dumpvc | Display information about the fields of a value class at the specified address | !dumpvc 61061a90 004ff2c4 |
!dumparray | Display elements of an array object. | !dumparray 1da226ec |
!dumpmt | Display information about a method table at the specified address. The -md option displays a list of all methods defined with the object. | !dumpmt -md 02c74dc0 |
!dumpmd | Display information about a MethodDesc structure at the specified address | !dumpmd 60b474e0 |
!bpmd | Create a breakpoint at the specified method in the specified module | !bpmd Mydll.dll MyNS.Calc..ctor |
!dumpheap | Display the managed heap information and statistics about heap objects. | !dumpheap -stat (display statistical type summary only) |
!dumpil | Display the MSIL that is associated with a method | !dumpil 60b474e0 |
!dumpstack | Display stack trace | !dumpstack |
!dumpstackobjects (!dso) | Display all managed objects found within the bounds of the current stack | !dso |
!eeheap | Display information about process memory consumed by internal CLR data structures | !eeheap |
!eestack | Display stack traces for all threads | !eestack |
!eeversion | Display the CLR version | !eeversion |
!finalizequeue | Display all objects registered for finalization | !finalizequeue |
!gchandles | Display statistics about GC handles | !gchandles |
!gchandleleaks | Check any leak for GC handles | !gchandleleaks |
!gcroot | Display information about references (or roots) to an object | !gcroot 0459226c |
!gcwhere | Display the location and size in the GC heap for an object | !gcwhere 0459226c |
!help (!sos.help) | Display help | !help gcwhere (help about gcwhere) |
!heapstat | Display the generation sizes and free spaces for each heap | !heapstat |
!ip2md | Get the method name for jitted code address | !ip2md 028204fe |
!name2ee | Display the MethodTable and EEClass structure for the specified type or method in the specified module | !name2ee DbgTest.exe DbgTest.Calc |
!objsize | Display the size of the specified object | !objsize 0459226c |
!printexception | Display formatted output of any object derived from the Exception class | !pe 04592260 |
!procinfo | Display environment variables for the process, CPU and memory statistics | !procinfo |
!savemodule | Writes an image, which is loaded in memory at the specified address, to the specified file | !savemodule 001d4014 c:\temp\test.exe |
!stoponexception | Stop the debugger when the specified exception is thrown | !soe -create System.IndexOutOfRangeException 1 |
!syncblk | Display SyncBlock structure(s) | !syncblk |
!threadpool | Display managed thread pool information | !threadpool |
!threads | Display all managed threads in the process | !threads |
!u | Display an annotated disassembly of a managed method. Specify either by a MethodDesc structure pointer for the method or by a code address within the method body. | !u 03244e24 |
!verifyheap | Check the GC heap corruption | !verifyheap |
!vmstat | Display summary view of the virtual address space | !vmstat |