[英]Natvis TreeItems definition not working on map<int,int>
我在使用visual studio 2015的natvis擴展時遇到了麻煩。在我的努力中,我需要訪問一個地圖,但natvis的TreeItems
節點似乎對我不起作用。 我實際上是在使用示例代碼:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="std::map<*>">
<DisplayString>{{size = {_Mysize}}}</DisplayString>
<Expand>
<Item Name="[size]">_Mysize</Item>
<Item Name="[comp]">comp</Item>
<TreeItems>
<Size>_Mysize</Size>
<HeadPointer>_Myhead->_Parent</HeadPointer>
<LeftPointer>_Left</LeftPointer>
<RightPointer>_Right</RightPointer>
<ValueNode Condition="!((bool)_Isnil)">_Myval</ValueNode>
</TreeItems>
</Expand>
</Type>
</AutoVisualizer>
但是我在map <int,int>上得到了這個錯誤:
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定義已經改變,但我找不到任何東西。 也許示例代碼不應該工作,但我發現很難從一個不起作用的例子開始。
我猜std :: map的實現已經改變,natvis示例不是最新的。
以下內容適用於Visual Studio 2017:
<Type Name="std::map<*>">
<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->_Parent</HeadPointer>
<LeftPointer>_Left</LeftPointer>
<RightPointer>_Right</RightPointer>
<ValueNode Condition="!((bool)_Isnil)">_Myval</ValueNode>
</TreeItems>
</Expand>
</Type>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.