【问题标题】:Why !dumpvc in windbg can dump out the array element?为什么windbg中的!dumpvc可以转储出数组元素?
【发布时间】:2013-12-27 04:08:02
【问题描述】:

Dumping the contents of a dictionary object using Windbg and SOS.dll 在这个博客上,这个命令:

0:009> !dumpvc 000007fe984b57d8 000000018003ead8

他想查看数组中的一个元素, 这里元素类型是

System.Collections.Generic.Dictionary`2+Entry[[System.Guid, mscorlib],[Microsoft.TeamFoundation.Framework.Server.TeamFoundationPerformanceCounters, Microsoft.TeamFoundation.Framework.Server]]

从我的角度来看,我认为!dumpvc是用来探索值类型的,类型'Dictionary`2+Entry...'不是值类型。

出现这种情况的原因是什么?

我试过这个:转储一个字节数组。

0:000> !da -length 3  -nofields 00000001ba9f63b0
-nofields has no effect unless -details is specified
Name:        System.Byte[]
MethodTable: 000007fee3a20b50
EEClass:     000007fee35a2330
Size:        148(0x94) bytes
Array:       Rank 1, Number of elements 124, Type Byte
Element Methodtable: 000007fee3a1c168
[0] 00000001ba9f63c0
[1] 00000001ba9f63c1
[2] 00000001ba9f63c2

0:000> !do 00000001ba9f63c0
<Note: this object has an invalid CLASS field>
0:000> !dumpvc 000007fee3a1c168 00000001ba9f63c0
Name:        System.Byte
MethodTable: 000007fee3a1c168
EEClass:     000007fee35a03b8
Size:        24(0x18) bytes
File:        C:\Windows\Microsoft.Net\assembly\....\mscorlib.dll
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007fee3a1c168  4000276        0          System.Byte  1 instance               62 m_value

它显示了我预期的结果。 !dumpvc 可以在我调试的时候到处探索数组元素吗?

【问题讨论】:

    标签: windbg dump


    【解决方案1】:

    Byte[] 是一个引用类型,您可以使用 !do 转储它。
    Byte 是一种值类型,如果有很多,则使用 !da 转储它。

    这同样适用于字典:

    Dictionary`2 是一个引用类型,使用 !do 转储。
    这些条目的类型是 Dictionary`2+Entry,它似乎是一个包含指向键和值的指针的结构(类似于 KeyValuePair)。结构是值类型,由!da 转储,您可以在它们上使用!dumpvc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-14
      • 2015-12-22
      • 2010-12-10
      • 2018-07-12
      • 2018-02-13
      相关资源
      最近更新 更多