简体   繁体   English

Visual Studio 2012 Natvis跳过IndexListItems

[英]Visual Studio 2012 Natvis skip IndexListItems

I am creating a natvis file for the Qt classes and I ran into a problem. 我正在为Qt类创建一个natvis文件,我遇到了一个问题。

In order to visualize QHash objects I created these two types: 为了可视化QHash对象,我创建了以下两种类型:

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

It pretty much works, but since the QHash is not continuous in memory, there are a lot of invalid entries. 它几乎可以工作,但由于QHash在内存中不连续,因此存在大量无效条目。 The condition 条件

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

already filters those out that are invalid, but they are still shown as <Unable to display value> . 已经过滤掉那些无效的,但它们仍显示为<Unable to display value>

Does anyone know if there is a way to completely skip those entries? 有谁知道是否有办法完全跳过这些条目?

I never really worked with the autoexp.dat file which was the old way to do it, but when looking at the file with the Qt-plugin installed it seems to me that the statement 我从来没有真正使用过autoexp.dat文件,这是旧的方法,但是在查看安装了Qt-plugin的文件时,我觉得这个声明

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

does exactly that, so I hope that there maybe is a way to do it in the natvis file as well? 确切地说,所以我希望有可能在natvis文件中做到这一点吗?

If anyone's interested, I can give you the natvis file, but I only have QString, QByteArray, QList, QVector, QMap and (the problematic) QHash until now. 如果有人感兴趣,我可以给你natvis文件,但我到目前为止只有QString,QByteArray,QList,QVector,QMap和(有问题的)QHash。

According to the MSDN page on writing type visualizers , <IndexListItems> are by definition contiguous: 根据写入类型可视化器MSDN页面<IndexListItems>根据定义是连续的:

IndexListItems Expansion IndexListItems扩展

ArrayItems assume array elements are laid out contiguously in memory. ArrayItems假设数组元素在内存中连续排列。 Debugger gets to the next element by simply incrementing its pointer to the current element. 调试器通过简单地将其指针递增到当前元素来获取下一个元素。 To support cases where you need to manipulate the index to the value node, index list items can be used. 要支持需要操作索引到值节点的情况,可以使用索引列表项。 Here's a visualizer using 'IndexListItems' node: [....] The only difference between ArrayItems and IndexListItems is that the 'ValueNode' expects the full expression to the ith element with the implicit '$i' parameter. 这是一个使用'IndexListItems'节点的可视化器:[....] ArrayItems和IndexListItems之间唯一的区别是'ValueNode'需要带有隐式'$ i'参数的第i个元素的完整表达式。

Also, might I point you at the Qt Labs VSTools repository and its documentation ? 另外,我可以您指向Qt Labs VSTools存储库 及其文档吗? In particular tools/Qt4EEAddin/qt5.natvis looks a great deal like what I think you're trying to write? 特别是tools/Qt4EEAddin/qt5.natvis看起来很像我认为你想写的东西? (Or is it actually what you're writing? ^_^) Either way, I think the best you can do is what is in qt5.natvis , which has a special <DisplayString> for empty QHashNodes but does not try to elide empty buckets in the QHash . (或者它实际上是你在写什么?^ _ ^)无论哪种方式,我认为你能做的最好的是qt5.natvis ,它有一个特殊的<DisplayString>用于空的QHashNodes但不会尝试为空QHash中的QHash

it seems to me, just html tags. 在我看来,只是HTML标签。

replace it with '<' , '>' 将其替换为'<','>'

more information, see here 更多信息,请看这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM