Tuesday, September 22, 2009

WinDbg with managed code

Loading the correct version of SOS is done by: .loadby sos mscorwks.

Useful commands in SOS:
List CLR threads: !threads
Dump managed stack of current thread: !CLRStack
Dump managed stack of current thread with parameters and locals: !CLRStack -a
Dump managed and native stack of current thread: !DumpStack
Break on first chance CLR exceptions: sxe clr
Get IL of method: !ip2md address, then !u result
Display last exception info: !pe (use Event Filters to run the command whenever a CLR exception is thrown)

Another useful tool is SOSEX, which supports deadlock detection, etc.

I was unable to get WinDbg to be the postmortem debugger for all crashes - installing it only seems to work for native applications.

Native commands:
List O/S threads: ~
Change thread by: ~{threadnumber}s or ~~[{threadid}]s
Handle tracing: !htrace

This cheat sheet is also useful.

0 comments:

Post a Comment