My SOS cheat sheet

 There are some handy sos commands that I need to use frequently while debugging, there are several other handy sos cheat sheets available that I use as well, check this one for example. 

Breaking and Breakpoints

  

sxe -c "!pe;g" clr

You can run .logopen “C:\MyErrors.log” before this command and .LogClose after it so all you errors will be logged to the file

 

Break on specific exception type

!soe -Create System.Data.SqlClient.SqlException

Place a breakpoint

Check this link for more details.

!Name2EE Microsoft_TeamFoundation_Framework_Server!Microsoft.TeamFoundation.Framework.Server.TeamFoundationApplication

!DumpMT -MD 000007ff0030fe28

!bpmd -md 000007ff0030fd50

Conditional breakpoint

bp Address ".if (Condition) {OptionalCommands} .else {gc}"

 

Dumping objects and Arrays

 

Dump all objects of specific type:

 

000007fc76a73e48 47 6768 System.Configuration.SectionInformation

!dumpheap -type System.Configuration.SectionInformation

 

Recursively dump all objects of a certain type

.foreach (obj { !dumpheap -type Microsoft.TeamFoundation.Framework.Server.IdentityDescriptor -short }) { !mdt ${obj} -r}

 

Dump a specific property of all objects from this type

 

First get the offset of the property you need to print (easiest way is to just dump one of the objects and copy the offset)

 

0:033> !do 0000001834b180b8

Name: System.Configuration.SectionInformation

MethodTable: 000007fc76a73e48

EEClass: 000007fc76a14c58

Size: 144(0x90) bytes

File: D:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll

Fields:

              MT Field Offset Type VT Attr Value Name

000007fc76a732d0 40001be        8 ...figurationSection 0 instance 0000001834b17c78 _configurationSection

000007fc76a73788 40001bf       68 ...n.SafeBitVector32 1 instance 0000001834b18120 _flags

000007fc76a73740 40001c0       70 ...SimpleBitVector32 1 instance 0000001834b18128 _modifiedFlags

000007fc76a76220 40001c1       60 System.Int32 1 instance 300 _allowDefinition

000007fc76a76280 40001c2       64 System.Int32 1 instance 100 _allowExeDefinition

000007fc76a75ed8 40001c3       10 ...nfigurationRecord 0 instance 0000000000000000 _configRecord

000007fc782faee0 40001c4       18 System.String 0 instance 000000183469a030 _configKey

000007fc782faee0 40001c5       20 System.String 0 instance 0000001834699908 _group

000007fc782faee0 40001c6       28        System.String 0 instance 0000001834699ef0 _name

000007fc782faee0 40001c7       30 System.String 0 instance 0000001834699f28 _typeName

000007fc782faee0 40001c8       38 System.String 0 instance 0000000000000000 _rawXml

000007fc782faee0 40001c9       40 System.String 0 instance 0000000000000000 _configSource

000007fc782faee0 40001ca       48 System.String 0 instance 0000000000000000 _configSourceStreamName

000007fc76a7a048 40001cb       50 ...igurationProvider 0 instance 0000000000000000 _protectionProvider

000007fc782faee0 40001cc       58 System.String 0 instance 0000000000000000 _protectionProviderName

000007fc76a73a50 40001cd       78 ...errideModeSetting 1 instance 0000001834b18130 _overrideModeDefault

000007fc76a73a50 40001ce       80 ...errideModeSetting 1 instance 0000001834b18138 _overrideMode

 

And then loop through all objects of this type and dump this property

.foreach (foo {!DumpHeap -type System.Configuration.SectionInformation -short}) {!do poi(${foo}+28)}

 

Sample Output

Name: System.String

MethodTable: 000007fc782faee0

EEClass: 000007fc77c63720

Size: 32(0x20) bytes

File: D:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll

String: uri

Fields:

              MT Field Offset Type VT Attr Value Name

000007fc782fdc90 40000aa        8 System.Int32 1 instance 3 m_stringLength

000007fc782fc1c8 40000ab        c System.Char 1 instance 75 m_firstChar

000007fc782faee0 40000ac       18 System.String 0 shared static Empty

                                 >> Domain:Value 0000001833796360:NotInit 00000018337ed9e0:NotInit <<

Name: System.String

MethodTable: 000007fc782faee0

EEClass: 000007fc77c63720

Size: 60(0x3c) bytes

File: D:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll

String: webRequestModules

Fields:

              MT Field Offset Type VT Attr Value Name

000007fc782fdc90 40000aa        8 System.Int32 1 instance 17 m_stringLength

000007fc782fc1c8 40000ab        c System.Char 1 instance 77 m_firstChar

000007fc782faee0 40000ac       18 System.String 0 shared static Empty

                                 >> Domain:Value 0000001833796360:NotInit 00000018337ed9e0:NotInit <<

Name: System.String

MethodTable: 000007fc782faee0

EEClass: 000007fc77c63720

Size: 50(0x32) bytes

File: D:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll

String: defaultProxy

Fields:

              MT Field Offset Type VT Attr Value Name

000007fc782fdc90 40000aa        8 System.Int32 1 instance 12 m_stringLength

000007fc782fc1c8 40000ab        c System.Char 1 instance 64 m_firstChar

000007fc782faee0 40000ac       18 System.String 0 shared static Empty

                                 >> Domain:Value 0000001833796360:NotInit 00000018337ed9e0:NotInit <<