Using CustomListItems in VSCode/Natvis

一曲冷凌霜 提交于 2021-02-05 11:35:39

问题


I am developing some debug visualizations for my custom classes in VSCode using Natvis. Using CustomListItems with a simple example and I can't get it to work. Basically, I think the following code should display 16 items all with value 1 but I get only the basic type of the class..

  <Type Name="vq23_t">
    <DisplayString>16 x q23 Array</DisplayString>
    <Expand>
        <CustomListItems>
            <Size>16</Size>
            <Variable Name="ind" InitialValue="0" />
            <Loop Condition="ind &lt; 16">
                <Item Name="{ind}"> 1 </Item>
                <exec> ++ind </exec>
            </Loop>
        </CustomListItems>
    </Expand>
  </Type>

What I get:

pout: 16 x q23 Array
>[Raw View]: 0x56594b40 <xin>

Spent a lot of time trying various things out so I reduced the problem to this basic level and can't get it to work.


回答1:


As described on MSDN you can activate logging for debugging natvis.

The solution for your case is to change the order of Size and Variable and to change exec to Exec.

  <Type Name="vq23_t">
    <DisplayString>16 x q23 Array</DisplayString>
    <Expand>
      <CustomListItems>
        <Variable Name="ind" InitialValue="0" />
        <Size>16</Size>
        <Loop Condition="ind &lt; 16">
          <Item Name="{ind}"> 1 </Item>
          <Exec> ++ind </Exec>
        </Loop>
      </CustomListItems>
    </Expand>
  </Type>


来源:https://stackoverflow.com/questions/65742034/using-customlistitems-in-vscode-natvis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!