1

As most of you know, Windbg can be used for debugging programs, but now I'd like to do just the opposite: I'd like to debug what I'm doing in Windbg, let me show you why:

I've found an interesting native visualiser, containing following entries:

<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>

These entries make sure that CMap objects get shown in a nice way, one under the other. Together with another internal entry, this gives following result in a Visual Studio watch-window:

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)

When I try to do the same in Windbg (using the dx commands), this gives similar information, but it ends at entry number 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 *>]

(By clicking on the entries, I get more information, which is correctly rendered by the mentioned other native visualiser entry)

I'd like to know the reason why the display of the CMap entries stops at 49. I already know I can get more entries by clicking on ... (which adds -c 100, -c 200, ... to the dx command) but if I could get more information (like the output window of Visual Studio with the option "Debugging, Output Window, General Output Settings, Natvis diagnostics messages" set to "Verbose"), I'd be able to diagnose and solve my problems.

Does anybody know how to do this?
Thanks in advance

Dominique
  • 16,450
  • 15
  • 56
  • 112

2 Answers2

5

At the moment, there are not 'extended diagnostics' available for NatVis in WinDbg similar to what you can get with Visual Studio.

That said -- the 'dx' command will, by default, display the first 100 entries of any container and display a DML link for continuation (the [...]). If you want more than 100 entries, you can use a format specifier to indicate how many entries to display (these are the same as with Visual Studio).

For example:

dx <container expression>,1000

would display 1000 entries of whatever evaluated to before a continuation link instead of the default 100.

William Messmer
  • 261
  • 1
  • 3
3

windbg can debug windbg the child windbg debugging your actual binary

iirc it is callef daisy wheeling

open a command prompt

type windbg windbg app and hit enter

if you dont mind using the console version windbg has an inbuilt command

.dbgdbg

this will spawn a parent debugger to an existing instance

blabb
  • 8,674
  • 1
  • 18
  • 27