0

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 Answers1

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>
Werner Henze
  • 16,404
  • 12
  • 44
  • 69
  • SInce i use VSCode, the MSDN link does not work for me. Any thoughts ? Also I tried the code with your changes, it still does not work - nothing is shown.. Gopal – gopal raghavan Jan 16 '21 at 21:17
  • @gopalraghavan Sortry, I did not recognize you are using VS cdoe and not VS. Yet https://code.visualstudio.com/docs/cpp/natvis links to the MSVC natvis page. But it also says that full feature set is supported for MSVC tool chain debugging but not for gdb/clang tool chain debugging. Which one are you using? – Werner Henze Jan 17 '21 at 14:05
  • I am using gdb tool chain. So you are correct there might be differences. – gopal raghavan Jan 18 '21 at 18:01
  • @gopalraghavan Can you please check exchanging the order of the lines with `Item` and `Exec`!? https://code.visualstudio.com/docs/cpp/natvis shows `Exec` first, then `Item`. – Werner Henze Jan 18 '21 at 19:57
  • 1
    I finally got visual studio installed and it behaved as I would expect. So it seems to be a problem specific to VSCode as you thought. I posted this to VSCode support at https://github.com/microsoft/MIEngine/issues/1095. – gopal raghavan Jan 18 '21 at 20:10
  • i tried the code with the order changed and no difference. – gopal raghavan Jan 18 '21 at 20:11
  • 2
    Simple answer: VSCode does not support loop. Here is the answer from microsoft: The default Windows C++ project uses a different natvis reader than MIEngine. I believe MIEngine does not support Loop. To use MIEngine in Visual Studio, you will need to create a project for WSL or use SSH for a Linux Project. – gopal raghavan Jan 22 '21 at 05:22
  • @gopalraghavan if one has no option `to create a project for WSL or use SSH for a Linux Project` and have to work with `VSCode in Linux system` then any woraround to use `natvis loop`? I am stucked in one issue, if you have time would be great if you can take a look [here](https://stackoverflow.com/questions/72359355/extend-display-range-of-arrayitems-indexlistitems-using-natvis?noredirect=1#comment127858705_72359355). – user10634362 May 27 '22 at 06:32
  • 1
    I just reported this (and some of my other problems) to the MIEngine team: https://github.com/microsoft/MIEngine/issues/1368 – Ofek Shilon Nov 05 '22 at 15:44