gpt4 book ai didi

c++ - 如何避免 native 可视化器中的递归?

转载 作者:搜寻专家 更新时间:2023-10-31 02:04:19 24 4
gpt4 key购买 nike

我正在调试一个 C++ 程序,其中包含相当多的 CPtrArray 对象。
使用自定义的 heap_stat 脚本,我知道 CPtrArray 对象的指针值,其中包含很多条目。

使用 native 可视化工具,我确实可以看到每个 CPtrArray 对象中的条目数量,特此是我对应的 natvis 条目:

<Type Name="CArray&lt;*,*&gt;">
<AlternativeType Name="CPtrArray"/>
<DisplayString>{{size = {m_nSize}}}</DisplayString>

问题是:这显示了元素的数量,而不是指针值。我想到了使用以下 natvis 条目很容易地解决这个问题:

<Type Name="CArray&lt;*,*&gt;">
<AlternativeType Name="CPtrArray"/>
<DisplayString>{{size = {m_nSize}, pointer = {this}}}</DisplayString>

然而,这向我展示了指针值,还有更多::-)

{size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 {size = , pointer = }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

有人知道如何避免这种递归吗?

在第一次评论和回答后编辑

我已经按如下方式调整了我的 heap_stat 脚本:

if type_name.endswith("CPtrArray"):
collection_Size = typedVar('CPtrArray', ptr).m_nSize
...
dprintln(("0x" + pointer_format + "\t%s\t Size:[%d]") % (ptr, type_name, collection_Size))

因此,我在 heap_stat 报告中得到了 CPtrArray(和其他)对象的大小:

0x0732517c  mfc110u!CStringArray     Size:[0]
0x073256d4 mfc110u!CPtrArray Size:[584]

我有 COLUMN 对象,它们有一个 CPtrArray 属性,我想知道哪个对应于那个特定的 CPtrArray 对象,因此我在监 window 口中添加了所有 COLUMN 对象:

((COLUMN*)0x073256d0)->paData   {size = 584, pointer = 0x073256d4 {size = 584, pointer = 0x073256d4 ...
((COLUMN*)0x07325780)->paData {size = 0, pointer = 0x01234567 {size = 0, pointer = 0x01234567 ...
((COLUMN*)0x07325830)->paData {size = 0, pointer = 0x02345678 {size = 0, pointer = 0x02345678 ...

如您所见,递归为我提供了大量信息(并严重降低了我的分析性能),因此我想避免它,而无需扩展每个 COLUMN 用于查看所需信息的对象。

跟进后编辑

由于这个问题看起来像是 Natvis 处理中的错误,我决定在 MSDN 网站上写一篇重复的帖子。 That post 最近被标记为“Triaged”,我希望这意味着它已被 MSDN 开发人员考虑在内。

提前致谢

最佳答案

完成递归扩展是因为调试器知道thisCArray 类型以及该类型应该如何显示。如果您只想要不扩展的指针,您可以通过将指针转换为 void* 来放弃 CArray 类型的知识,如

<DisplayString>{{size = {m_nSize}, pointer = {(void*)this}}}</DisplayString>

关于c++ - 如何避免 native 可视化器中的递归?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53709340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com