Unable to find key-Value pairs in a dictionary using windbg

拜拜、爱过 提交于 2020-01-15 09:53:53

问题


I am currently analyzing a application hang issue of a .Net 4.0 Application. Based on the stack traces of few threads my guess is that few key value pairs in a dictionary has been removed some how. To confirm the same, i am trying to analyze the contents of the Dictionary using Windbg

In could see that the 'entries' in the dictionary is a array. So tried to list the entries using '!da', but it does not work.

Tried !dumpvc (i know its does not work for list), but just gave a try

And of course !do also does not work.

Could someone please help me to get the list of values in 'entries' of the dictionary.


回答1:


The !da worked for the example I wrote and it's done the same way in this MSDN article. However, it's not convenient at all, because you just get a bunch of adresses which you then need to split into key and value.

It's much more convenient to use !mdt of the sosex extension. With the -e:<depth> argument, it expands down to keys and values.

0:000> !mdt -e:2 025332a4
025332a4 (System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[DumpDictionaryInWinDbg.Program+A, DumpDictionaryInWinDbg]][], Elements: 3, ElementMT=001951b4)
[0] (System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[DumpDictionaryInWinDbg.Program+A, DumpDictionaryInWinDbg]]) VALTYPE (MT=001951b4, ADDR=025332ac)
    hashCode:0x68d80062 (System.Int32)
    next:0xffffffff (System.Int32)
    key:0253316c (System.String) Length=4, String="keyA"
    value:02533280 (DumpDictionaryInWinDbg.Program+A)
[1] (System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[DumpDictionaryInWinDbg.Program+A, DumpDictionaryInWinDbg]]) VALTYPE (MT=001951b4, ADDR=025332bc)
    hashCode:0x5d730062 (System.Int32)
    next:0xffffffff (System.Int32)
    key:025331a0 (System.String) Length=4, String="keyB"
    value:025332e0 (DumpDictionaryInWinDbg.Program+A)
[2] (System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[DumpDictionaryInWinDbg.Program+A, DumpDictionaryInWinDbg]]) VALTYPE (MT=001951b4, ADDR=025332cc)
    hashCode:0x520e0062 (System.Int32)
    next:0xffffffff (System.Int32)
    key:025331d4 (System.String) Length=4, String="keyC"
    value:025332ec (DumpDictionaryInWinDbg.Program+A)

It also works with NetExt's !wdict, although it does not further print the values (it supports DML, so you can click on the links):

0:004> !wdict 0228320C
Items   : 3
[0]:==============================================(Physical Index: 1)
System.__Canon key = 022831a0 keyB
System.__Canon value = 022832e0
[1]:==============================================(Physical Index: 0)
System.__Canon key = 0228316c keyA
System.__Canon value = 02283280
[2]:==============================================(Physical Index: 2)
System.__Canon key = 022831d4 keyC
System.__Canon value = 022832ec

The SDbgExt2 extension claims to have a !DumpDictionary command, but I was unable to use it.

Similary, PSSCOR4 had a !dc command, but it's deprecated and fails for me (at least on generic dictionaries in .NET 4.6).



来源:https://stackoverflow.com/questions/42959563/unable-to-find-key-value-pairs-in-a-dictionary-using-windbg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!