The Visual Studio MI Debug Engine ("MIEngine") provides an open-source Visual Studio Debugger extension that works with MI-enabled debuggers such as gdb and lldb.
MIT License
818
stars
219
forks
source link
Natvis framework cannot display more than 50 content during debugging with ArrayItems or IndexListItems #1307
First all, I will be very sorry if this is not the right place to ask the question related to natvis debugging. If I have chosen the wrong platform to ask the query would be great if anyone can point me the right location (except stackoverflow) will be grateful.
Now the issue. I am trying to visualize a stack of memory content (eg: Value from index 0 to 500 or more. Depends on which size is given by me in <size>size_val</size> field) using natvis which is pointed by a pointer. I have also tried to use std::vector. But every time the problem I am facing is that, during debugging the visualizer can show only first 50 entry (index 0 to 49).
I am giving here a very minimal example. Suppose, the pointer_array is a member of Foo class. In the driver file an array of size 5000 is created which is pointed by the array. I would like to observe the value of the array with the variable pointer_array. Also I have tried to understand how natvis reacts with std::vector and that's why as a member variable a vector (foo_vec) is also declared.
#include "foo.h"
# define ARRAY_SIZE 5000
int main()
{
Foo obj_1;
uint32_t foo_array[ARRAY_SIZE];
for(int i = 0; i < ARRAY_SIZE; i++)
{
foo_array[i] = i*2;
}
obj_1.pointer_array = foo_array;
for(uint32_t i = 0; i < ARRAY_SIZE; i++)
{
obj_1.foo_vec.push_back(i*3);
}
return 0;
}
The following natvis file I have used.
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="Foo">
<DisplayString>Testing_Natvis</DisplayString>
<Expand>
<ArrayItems>
<Size>5000</Size>
<ValuePointer>pointer_array</ValuePointer>
</ArrayItems>
<!-- Tested with IndexListItems but failed to fetch all data, still only first 49 entry -->
<!-- <IndexListItems>
<Size>5000</Size>
<ValueNode>pointer_array[$i]</ValueNode>
</IndexListItems> -->
<!-- Same result as like as pointer_array. Only first 49 entry is appeared -->
<!-- <IndexListItems>
<Size>foo_vec.size()</Size>
<ValueNode>foo_vec[$i]</ValueNode>
</IndexListItems> -->
<!-- <ArrayItems>
<Size>foo_vec.size()</Size>
<ValuePointer>&foo_vec[0]</ValuePointer>
</ArrayItems> -->
</Expand>
</Type>
</AutoVisualizer>
In the launch.json I have added extra only the following two lines
For better understanding I am giving here a screenshot of the output where in natvis file I have used IndexListItems and given size 80 to see value from index 0 to 79 but the displayed last value is from index 49.
And the following image is showing that I have given the size value 6 and natvis perfectly is showing value from index 0 to 5.
If any workaround is guided to achieve all entry of the memory using Natvis, it would be very beneficial for me.
First all, I will be very sorry if this is not the right place to ask the question related to
natvis debugging
. If I have chosen the wrong platform to ask the query would be great if anyone can point me the right location (exceptstackoverflow
) will be grateful.Now the issue. I am trying to visualize a stack of memory content (eg: Value from
index 0 to 500 or more
. Depends on whichsize
is given by me in<size>size_val</size>
field) using natvis which is pointed by a pointer. I have also tried to usestd::vector
. But every time the problem I am facing is that, during debugging the visualizer can show only first50 entry (index 0 to 49)
.I am giving here a very minimal example. Suppose, the
pointer_array
is a member ofFoo
class. In the driver file anarray
of size 5000 is created which is pointed by the array. I would like to observe the value of the array with the variablepointer_array
. Also I have tried to understand hownatvis
reacts withstd::vector
and that's why as a member variable a vector (foo_vec
) is also declared.foo.h
main.cpp
The following
natvis file
I have used.In the
launch.json
I have added extra only the following two linesIndexListItems
and given size80
to see value fromindex 0 to 79
but the displayed last value is fromindex 49
.size
value 6 andnatvis
perfectly is showing value fromindex 0 to 5
.If any workaround is guided to achieve all entry of the memory using Natvis, it would be very beneficial for me.