首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Natvis TreeItems定义不适用于map<int、int>

Natvis TreeItems定义不适用于map<int、int>
EN

Stack Overflow用户
提问于 2016-03-10 00:42:39
回答 1查看 1K关注 0票数 3

我在使用visual studio 2015的natvis扩展时遇到了问题。在我的工作中,我需要访问地图,但是natvis的TreeItems节点似乎不适合我。我实际上使用的是示例代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?> 
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

  <Type Name="std::map&lt;*&gt;">
    <DisplayString>{{size = {_Mysize}}}</DisplayString>
    <Expand>
      <Item Name="[size]">_Mysize</Item>
      <Item Name="[comp]">comp</Item>
      <TreeItems>
        <Size>_Mysize</Size>
        <HeadPointer>_Myhead-&gt;_Parent</HeadPointer>
        <LeftPointer>_Left</LeftPointer>
        <RightPointer>_Right</RightPointer>
        <ValueNode Condition="!((bool)_Isnil)">_Myval</ValueNode>
      </TreeItems>
    </Expand>
  </Type>
</AutoVisualizer>

但是我在int>的map

代码语言:javascript
复制
Error: Function std::_Tree_comp_alloc<std::_Tmap_traits<int,int,std::less<int>,std::allocator<std::pair<int const ,int> >,0> >::_Mysize has no address, possibly due to compiler optimizations.
    Error while evaluating '_Mysize' in the context of type 'Program.exe!std::map<int,int,std::less<int>,std::allocator<std::pair<int const ,int> > >'.

我正在调试模式下构建,并仔细检查了优化是否已禁用(\Od)

也许msvc2015的natvis定义已经改变了,但我找不到任何东西。也许示例代码不应该工作,但我发现很难从一个不能工作的示例开始。

EN

回答 1

Stack Overflow用户

发布于 2017-07-04 04:25:46

我猜std::map的实现已经改变了,natvis示例不是最新的。

下面是我在Visual Studio 2017上的工作:

代码语言:javascript
复制
<Type Name="std::map&lt;*&gt;">
    <DisplayString>{{size = {_Mypair._Myval2._Myval2._Mysize}}}</DisplayString>
    <Expand>
      <Item Name="[size]">_Mypair._Myval2._Myval2._Mysize</Item>
      <Item Name="[comp]">_Mypair</Item>
      <Item Name="[first element]">_Mypair._Myval2._Myval2._Myhead</Item>
      <TreeItems>
        <Size>_Mypair._Myval2._Myval2._Mysize</Size>
        <HeadPointer>_Mypair._Myval2._Myval2._Myhead-&gt;_Parent</HeadPointer>
        <LeftPointer>_Left</LeftPointer>
        <RightPointer>_Right</RightPointer>
        <ValueNode Condition="!((bool)_Isnil)">_Myval</ValueNode>
      </TreeItems>
    </Expand>
  </Type>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35897513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档