Search This Blog

Monday 2 October 2017

Some small contributions to your debugging experience


A couple of issues have kept me bugging for years whenever I debugged managed code (sos.dll) in Windbg, so finally, I decided to do something about them exploiting the fact that .NET Core is fully hosted on GitHub. Unfortunately the source of the desktop .NET Framework is still not exposed there, so submitting fixes and reporting issues is much more difficult, if not impossible for that version.

One problem was really annoying if you got used to clicking on DML output as the !DumpArray sos command emitted invalid DML for value-typed list elements. The output was really confusing as no error message was shown and the element type was displayed incorrectly.

0:007> !DumpArray /d 02b16574
Name:        WindowsFormsApplication2_SOS_bug.Test[]
MethodTable: 011c82ec
EEClass:     011c8290
Size:        412(0x19c) bytes
Array:       Rank 1, Number of elements 100, Type VALUETYPE
Element Methodtable: 011c824c
[0] 02b1657c => **wrong DML generated**

Fortunately, the fix was very simple.

Another problem that I fixed was with the !HeapStat command as it emitted difficult to read output. The percentage column was not padded properly.

Heap             Gen0         Gen1         Gen2          LOH
Heap0         5067096       941836    231688916     27653832

Free space:                                                 Percentage
Heap0          108724         6660     41310400      2438136SOH: 17% LOH:  8%

Unrooted objects:                                           Percentage
Heap0         4699412       755996       312864            0SOH:  2% LOH:  0%

I also opened an issue for the famous “first sos command throws an exception error”. 
As it turned out this had already been worked around for .NET Core 2.0.

Too bad these will not be fixed for the full .Net Framework automatically…

No comments:

Post a Comment