我正在使用基于STL的C++解决方案,并且使用CPtrList集合。
这里有一个包含CPtrList条目的void *集合,我想使用一个natvis文件自动输入这些条目。
目前,我的意见如下:
<Type Name="CList<*,*>">
<AlternativeType Name="CObList"></AlternativeType>
<AlternativeType Name="CPtrList"></AlternativeType>
<AlternativeType Name="CStringList"></AlternativeType>
<AlternativeType Name="CTypedPtrList<*,*>"></AlternativeType>
<DisplayString>{{iets anders Count = {m_nCount}}}</DisplayString>
<Expand>
<Item Name="Count">m_nCount</Item>
<LinkedListItems>
<Size>m_nCount</Size>
<HeadPointer>m_pNodeHead</HeadPointer>
<NextPointer>pNext</NextPointer>
<ValueNode>data</ValueNode>
</LinkedListItems>
</Expand>
</Type>因此,我的CPtrList条目如下所示:
0x<something> void *
0x<something else> void *
...我希望把这些条目输入如下:
<information> CElement::SL_SET_PARAMETER*
<information else> CElement::SL_SET_PARAMETER*一旦我知道如何做到这一点,我就可以在我的natvis中添加一个"SL_SET_PARAMETER“条目,并决定如何显示它,因此我首先需要向natvis解释,每个CPtrList条目都应该被抛入一个"SL_SET_PARAMETER”对象中。
有人知道怎么做吗?
发布于 2018-02-13 17:28:24
您必须使用<CustomListItems>标记(有关详细信息,请参阅CustomListItems展开项在MS文档中)。这是显示类型的最通用规范,它允许局部变量和循环。
它们在文档中使用的示例如下:
<Type Name="ATL::CAtlMap<*,*,*,*>">
<AlternativeType Name="ATL::CMapToInterface<*,*,*>"/>
<AlternativeType Name="ATL::CMapToAutoPtr<*,*,*>"/>
<DisplayString>{{Count = {m_nElements}}}</DisplayString>
<Expand>
<CustomListItems MaxItemsPerView="5000" ExcludeView="Test">
<Variable Name="iBucket" InitialValue="-1" />
<Variable Name="pBucket" InitialValue="m_ppBins == nullptr ? nullptr : *m_ppBins" />
<Variable Name="iBucketIncrement" InitialValue="-1" />
<Size>m_nElements</Size>
<Exec>pBucket = nullptr</Exec>
<Loop>
<If Condition="pBucket == nullptr">
<Exec>iBucket++</Exec>
<Exec>iBucketIncrement = __findnonnull(m_ppBins + iBucket, m_nBins - iBucket)</Exec>
<Break Condition="iBucketIncrement == -1" />
<Exec>iBucket += iBucketIncrement</Exec>
<Exec>pBucket = m_ppBins[iBucket]</Exec>
</If>
<Item>pBucket,na</Item>
<Exec>pBucket = pBucket->m_pNext</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type> 它唯一的小问题是,如果您从一个监视窗口复制它创建的表达式,它将看起来像一个被抛到您想要的类型的指针的数字,而不是像语法一样有一个漂亮的数组,因此如果内存位置移动,它就不会被更新。如果引用包含对象的父对象,这不是什么大问题,只是很烦人。
https://stackoverflow.com/questions/48305121
复制相似问题