1

大多数人都知道,Windbg 可以用于调试程序,但现在我想做相反的事情:我想调试我在 Windbg 中所做的事情,让我告诉你为什么:

我发现了一个有趣的原生可视化工具,其中包含以下条目:

<Type Name='CMap&lt;*,*,*,*&gt;'>
  <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 &lt; 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&lt;*,*,*,*&gt;' 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 &lt; 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 诊断消息”设置为“详细”),我将能够诊断和解决我的问题。

有人知道怎么做这个吗?
提前致谢

4

2 回答 2

4

目前,在 WinDbg 中没有可用于 NatVis 的“扩展诊断”,类似于您可以使用 Visual Studio 获得的。

也就是说——默认情况下,'dx' 命令将显示任何容器的前 100 个条目并显示 DML 链接以供继续([...])。如果需要超过 100 个条目,可以使用格式说明符来指示要显示的条目数(这些与 Visual Studio 相同)。

例如:

dx <container expression>,1000

将在延续链接之前显示 1000 个评估的条目,而不是默认的 100 个。

于 2018-07-27T15:17:23.207 回答
3

windbg 可以调试 windbg 子 windbg 调试您的实际二进制文件

iirc 是 callef daisy wheeling

打开命令提示符

输入 windbg windbg app 并回车

如果您不介意使用控制台版本,windbg 有一个内置命令

.dbgdbg

这将为现有实例生成一个父调试器

于 2018-07-28T07:14:58.440 回答