简体   繁体   English

如何使用 natvis Visual Studio C++ 调试器可视化工具对单一类型进行多个列表扩展

[英]How to make multiple list expansions for a single type using natvis Visual Studio C++ debugger visualizer

I'm trying to make debugger visualizer for container that stores values in chunks.我正在尝试为以块形式存储值的容器制作调试器可视化工具。 I want to make list expansion both for values and for chunks, but as far as I can see single type can have only one list expansion.我想为值和块进行列表扩展,但据我所知,单一类型只能有一个列表扩展。 There may be multiple Expand subnodes like ArrayItems but they all produce single list.可能有多个Expand子节点,如ArrayItems ,但它们都生成单个列表。 Yes, I can make chunks expansion for container and then make value expansion for each chunk.是的,我可以为容器进行块扩展,然后为每个块进行值扩展。 But I want two container subnodes with expandsions like this:但我想要两个具有如下扩展的容器子节点:

MyList
|-values
| |-0
| |-1
|
|-chunks
| |-0
| |-1

Is there a way to do it using natvis xml?有没有办法使用 natvis xml 来做到这一点?

You can use <Synthetic> for that.您可以为此使用<Synthetic> The code inside <Synthetic> can be for example <Item> or <ArrayItems> , but also any other item type. <Synthetic>中的代码可以是例如<Item><ArrayItems> ,也可以是任何其他项目类型。

<Type Name="MyList">
  <DisplayString>...</DisplayString>
  <Expand>
    <Synthetic Name="values">
      <DisplayString>...</DisplayString>
      <Expand>
        <!-- code for displaying as values -->
      </Expand>
    </Synthetic>
    <Synthetic Name="chunks">
      <DisplayString>...</DisplayString>
      <Expand>
        <!-- code for displaying as chunks-->
      </Expand>
    </Synthetic>
  </Expand>
</Type>

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

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