大多数人都知道,Windbg 可以用于调试程序,但现在我想做相反的事情:我想调试我在 Windbg 中所做的事情,让我告诉你为什么:
我发现了一个有趣的原生可视化工具,其中包含以下条目:
<Type Name='CMap<*,*,*,*>'>
<AlternativeType Name="CMapStringToString"/>
<AlternativeType Name="CMapStringToPtr"/>
<DisplayString>{{size = {m_nCount} }}</DisplayString>
<Expand>
<CustomListItems>
<Variable Name='pHashtable' InitialValue='m_pHashTable'/>
<Variable Name='hashtable_index' InitialValue='0'/>
<Variable Name='pList' InitialValue='*m_pHashTable'/>
<Variable Name='i' InitialValue='0'/>
<Loop Condition='hashtable_index < m_nHashTableSize'>
<Exec>pList = pHashtable[hashtable_index]</Exec>
<Loop Condition='pList '>
<Item Name='{i}: [{pList->key}]'>pList->value</Item>
<Exec>pList = pList->pNext</Exec>
<Exec>++i</Exec>
</Loop>
<Exec>++hashtable_index</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name='CMap<*,*,*,*>' IncludeView='keys'>
<AlternativeType Name="CMapStringToString::CAssoc"/>
<AlternativeType Name="CMapStringToPtr::CAssoc"/>
<DisplayString>{{size = {m_nCount} }}</DisplayString>
<Expand>
<CustomListItems>
<Variable Name='pHashtable' InitialValue='m_pHashTable'/>
<Variable Name='hashtable_index' InitialValue='0'/>
<Variable Name='pList' InitialValue='*m_pHashTable'/>
<Variable Name='i' InitialValue='0'/>
<Loop Condition='hashtable_index < m_nHashTableSize'>
<Exec>pList = pHashtable[hashtable_index]</Exec>
<Loop Condition='pList '>
<Item Name='[{i}].key:'>pList->key</Item>
<Item Name=' [{i}].value:'>pList->value</Item>
<Exec>pList = pList->pNext</Exec>
<Exec>++i</Exec>
</Loop>
<Exec>++hashtable_index</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
这些条目确保 CMap 对象以一种很好的方式显示,一个在另一个之下。与另一个内部条目一起,这会在 Visual Studio 监视窗口中产生以下结果:
0x000000005b9c95d0 Element L"Element1" (ID1/SubID1.1, L"interesting_information.1"/L"1.0.0.0")
0x0000000059484d20 Element L"Element2" (ID1/SubID1.2, L"interesting_information.2"/L"2.0.0.0")
0x000000004caa6110 Element L"Element3" (ID2/SubID2.1, L"interesting_information.3"/L"3.0.0.0")
...
(this goes until the end of the CMap)
当我尝试在 Windbg 中做同样的事情(使用dx
命令)时,这会提供类似的信息,但它在条目号 49 处结束:
Windbg Prompt>dx -r1 (*((<application>!CMap<unsigned __int64,unsigned __int64,CElement *,CElement *> *)0x13fbd2ae0))
[" [0].value:"] : 0x6dce7fd0 [Type: CElement *]
["[1].key:"] : 0x7984000007a3 [Type: unsigned __int64]
[" [1].value:"] : 0x5b9c95d0 [Type: CElement *]
["[2].key:"] : 0x79840000053f [Type: unsigned __int64]
...
[" [49].value:"] : 0x1bab05b0 [Type: CElement *]
[...] [Type: CMap<unsigned __int64,unsigned __int64,CElement *,CElement *>]
(通过单击条目,我可以获得更多信息,这些信息由提到的其他本机可视化器条目正确呈现)
我想知道CMap
条目显示在 49 处停止的原因。我已经知道我可以通过单击...
(将-c 100
, -c 200
, ... 添加到dx
命令)来获得更多条目,但如果我可以获得更多信息(比如Visual Studio 的输出窗口,选项“调试、输出窗口、常规输出设置、Natvis 诊断消息”设置为“详细”),我将能够诊断和解决我的问题。
有人知道怎么做这个吗?
提前致谢