Display more than one variable of same type using Natvis

133 Views Asked by At

I am trying to demonstrate here the approach which I have followed to display two uint32_t * type variable using Natvis.

  • sample.cpp

#include<iostream>
int main()
{
    uint32_t foo_array[5] = {5,15,96,8,77};
    obj_1.pointer_array = foo_array;
    uint32_t * pointer_array_1 = foo_array;

    uint32_t limit_array[10];
    for(int i = 0; i < 10; i++)
    {
        limit_array[i] = i*5;
    }
    uint32_t *limit_ptr = limit_array;

    return 0;
}

I have tried to display both pointer_array_1 and limit_ptr by the following way, but unfortunately I can only see the value of pointer_array_1 in the field of limit_ptr. Even if the DisplayString is also same.

  • test_file.natvis
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="uint32_t *">
        <DisplayString>Test IndexListItems</DisplayString>
        <Expand>
            <IndexListItems>
                <Size>5</Size>
                <ValueNode>pointer_array_1[$i]</ValueNode>
            </IndexListItems>
        </Expand>
    </Type>

    <Type Name="uint32_t *">
      <DisplayString>Would like to observe limited or preferred ranged value</DisplayString>
      <Expand>
        <IndexListItems>
          <Size>10</Size>
          <ValueNode>limit_ptr[$i]</ValueNode>
        </IndexListItems>
      </Expand>
    </Type>

</AutoVisualizer>

The output is shown in the following figure:

enter image description here

My desire to see in the window of limit_ptr the value 0,5,10,15,20,.....,45

I have tried to use the following style of natvis but failed too.

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="uint32_t *">
        <DisplayString>Test IndexListItems</DisplayString>
        <Expand>
            <IndexListItems>
              <Size>5</Size>
              <ValueNode>pointer_array_1[$i]</ValueNode>
            </IndexListItems>

            <IndexListItems>
              <Size>10</Size>
              <ValueNode>limit_ptr[$i]</ValueNode>
            </IndexListItems>
      </Expand>
    </Type>

</AutoVisualizer>

Right now, both values are glued to each other. I have got same output for both variables.

enter image description here

Is there any way, to display multiple variables of the same type using Natvis?

0

There are 0 best solutions below