【问题标题】:Using CustomListItems in VSCode/Natvis在 VSCode/Natvis 中使用 CustomListItems
【发布时间】:2021-04-20 19:59:41
【问题描述】:

我正在使用 Natvis 为我在 VSCode 中的自定义类开发一些调试可视化。 使用 CustomListItems 和一个简单的例子,我无法让它工作。 基本上,我认为下面的代码应该显示 16 个值都为 1 的项目,但我只得到了类的基本类型..

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

我得到了什么:

噘嘴:16 x q23 阵列
>[原始视图]:0x56594b40

花了很多时间尝试各种事情,所以我将问题减少到这个基本级别并且无法解决它。

【问题讨论】:

    标签: visual-studio-code natvis


    【解决方案1】:

    MSDN 所述,您可以激活日志记录以调试 natvis。

    您的情况的解决方案是更改SizeVariable 的顺序并将exec 更改为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>
    

    【讨论】:

    • 因为我使用 VSCode,MSDN 链接对我不起作用。有什么想法吗 ?我也用你的更改尝试了代码,它仍然无法正常工作 - 没有显示任何内容.. Gopal
    • @gopalraghavan Sortry,我不知道您使用的是 VS cdoe 而不是 VS。然而code.visualstudio.com/docs/cpp/natvis 链接到 MSVC natvis 页面。但它也表示 MSVC 工具链调试支持完整功能集,但 gdb/clang 工具链调试不支持。你用的是哪一个?
    • 我正在使用 gdb 工具链。所以你是对的,可能存在差异。
    • 我终于安装了 Visual Studio,它的表现与我预期的一样。因此,正如您所想,这似乎是 VSCode 特有的问题。我在github.com/microsoft/MIEngine/issues/1095 将此发布到 VSCode 支持。
    • 简单回答:VSCode 不支持循环。这是来自微软的答案:默认的 Windows C++ 项目使用与 MIEngine 不同的 natvis 阅读器。我相信 MIEngine 不支持 Loop。要在 Visual Studio 中使用 MIEngine,您需要为 WSL 创建一个项目或为 Linux 项目使用 SSH。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多