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<*,*>"> <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<QHashNode<$T1,$T2> *>(next)</Item> </Expand> </Type> <Type Name="QHash<*,*>"> <DisplayString>{{ size={d->size} buckets={d->numBuckets} }}</DisplayString> <Expand> <IndexListItems> <Size>d->numBuckets</Size> <ValueNode Condition="reinterpret_cast<QHashNode<$T1,$T2> *>(d->buckets[$i]) != e">reinterpret_cast<QHashNode<$T1,$T2> *>(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<QHashNode< $T1,$T2> *>(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)
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.
c ++ qt visual-studio-2012
brx Dec 6 '12 at 16:35 2012-12-06 16:35
source share