I wrote a simple C # application:
static void Main(string[] args)
{
var list = new List<int> {500,400,300,200,100};
var listEnumerator = list.GetEnumerator();
listEnumerator.MoveNext();
}
I set a breakpoint at the end, launched it using Visual Studio, then activated windbg and bound it to the process (with the "non-invasive" checkbox enabled).
Then I entered the following commands:
.load C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\sosex.dll
!mframe 17
!mdt listEnumerator
The result I got was clearly wrong (the fields are all messed up, it seems to report the value “index” under “current”, the value “current” in “version" and the value of version 'under "index". He received only one field on the right - the first one.
Local #0: (System.Collections.Generic.List`1+Enumerator) VALTYPE (MT=72dfd838, ADDR=0029efb8)
list:02632464 (System.Collections.Generic.List`1[[System.Int32, mscorlib]])
index:0x5 (System.Int32)
version:0x1f4 (System.Int32)
current:00000001 (T)
Then I tried to use SOS! DumpVC and got the same confusion:
0:000> !DumpVC 72dfd838 0029efb8
Name: System.Collections.Generic.List`1+Enumerator
MethodTable: 72dfd838
EEClass: 72a32d38
Size: 24(0x18) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
736ae16c 4000c99 0 ...Generic.List`1[T] 0 instance 02632464 list
72e03aa4 4000c9a 8 System.Int32 1 instance 5 index
72e03aa4 4000c9b c System.Int32 1 instance 500 version
00000000 4000c9c 4 VAR 0 instance 00000001 current
Why is this happening?
source
share