【问题标题】:Is there an easy way to look at key-value pairs in a Dictionary using sos?有没有一种简单的方法可以使用 sos 来查看字典中的键值对?
【发布时间】:2012-04-25 18:42:42
【问题描述】:

我通过 WinDBG 使用 SOS.dll 查看故障转储。给定 Dictionary 对象的地址,是否有一种简单的方法可以转储它的内容,例如..

Key1 -> Value1
Key2 -> Value2
...
KeyN -> ValueN

我看到没有 !DumpDictionary 命令:(

【问题讨论】:

    标签: .net dictionary windbg sos


    【解决方案1】:

    没有,但 PSSCOR2/4 提供了一些收集支持。尤其是 !dc。 SOSEX 支持这一点:!mdt -e:2。该命令表示转储指定的对象并将其扩展 2 级。

    【讨论】:

    • 我在通用字典上试过,但它抱怨:0:012> !do 014ba5d0 名称:System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Int32 , mscorlib]] 0:012> !dc 014ba5d0 将转储通过的集合。 0x014ba5d0 不是受支持的 Collection 对象 .chain 显示:psscor4:图像 4.0.0.4,API 1.0.0,于 2011 年 2 月 1 日星期二 15:39:38 构建
    • 好的,我认为 !dc 支持字典。试试 !sosex.mdt -e:2 或 -e:3。
    • 成功了!看起来我的一个开发人员有一个错误,因为密钥为空:0:012> !mdt 014ba5d0 -e:3 014ba5d0 (System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Int32, mscorlib]]) Count = 1 [0] (System.Collections.Generic.Dictionary2+Entry[[System.String, mscorlib], [System.Int32, mscorlib]]) VALTYPE (MT=73a90790, ADDR=014be4f0) key:NULL (System.__Canon) value:0x0 (System.Int32)
    • 注意查看字典计数属性。由于 KeyValuePair Collection 分配是动态的,因此框架会分配更多的块(以执行更少的分配)。在我的情况下 dictionary.count = 60d 并且我的条目集合有 89 个元素。从第 61 到第 89 的每个元素都是 null(键和值)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 2012-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    相关资源
    最近更新 更多