Visual Studio 2012 Natvis skip IndexListItems

I am creating a natvis file for Qt classes and I ran into a problem.

To visualize QHash objects, I created these two types:

<Type Name="QHashNode&lt;*,*&gt;"> <DisplayString Condition="next->next == 0">{{ key={key} value={value} h={h}}}</DisplayString> <DisplayString>{{ key={key} value={value} h={h} withCollision }}</DisplayString> <Expand> <Item Name="NextNode">reinterpret_cast&lt;QHashNode&lt;$T1,$T2&gt; *&gt;(next)</Item> </Expand> </Type> <Type Name="QHash&lt;*,*&gt;"> <DisplayString>{{ size={d->size} buckets={d->numBuckets} }}</DisplayString> <Expand> <IndexListItems> <Size>d->numBuckets</Size> <ValueNode Condition="reinterpret_cast&lt;QHashNode&lt;$T1,$T2&gt; *&gt;(d->buckets[$i]) != e">reinterpret_cast&lt;QHashNode&lt;$T1,$T2&gt; *&gt;(d->buckets[$i])</ValueNode> </IndexListItems> </Expand> </Type> 

This works pretty much, but since QHash is not continuous in memory, there are many invalid entries. Condition

 reinterpret_cast&lt;QHashNode&lt; $T1,$T2&gt; *&gt;(d->buckets[$i]) != e 

already filters those that are invalid, but they still display as <Unable to display value> .

Does anyone know if there is a way to completely skip these entries?

I never worked with the autoexp.dat file, which was an old way to do this, but when viewing a file with the Qt plugin installed, it seems to me that the statement

 #switch ($e.next != 0) #case 1 ( $e ) 

does just that, so I hope there is perhaps a way to do this in the natvis file too?

If anyone is interested, I can give you a natvis file, but I have QString, QByteArray, QList, QVector, QMap and (problematic) QHash so far.

+49
c ++ qt visual-studio-2012
Dec 6 '12 at 16:35
source share
2 answers

According to MSDN pages, when visualizing font types, <IndexListItems> by definition contiguous:

IndexListItems Extension

ArrayItems assume that the elements of an array are arranged sequentially in memory. The debugger moves on to the next element, simply increasing the pointer to the current element. To support cases where you need to manipulate an index with a node value, you can use index list items. Heres a visualizer using the "IndexListItems" node: [....] The only difference between ArrayItems and IndexListItems is that "ValueNode" expects a full expression for the ith element with the implicit parameter "$ i".

Also, can I point you to the Qt Labs VSTools repository and its documentation ? In particular, tools/Qt4EEAddin/qt5.natvis very similar to what I think you're trying to write? (Or is this really what you are writing? ^ _ ^) Anyway, I think the best you can do is what is in qt5.natvis , which has a special <DisplayString> for empty QHashNodes , but it does not try to elide empty buckets in QHash .

+2
Sep 24 '13 at 3:25
source share
— -

it seems to me just html tags.

replace it with '<', '>'

see here for more information

0
Sep 19 '13 at 6:15
source share



All Articles