Visual studio调试器-监视指针转换

visual studio debugger - watch pointer casting

本文关键字:指针 转换 监视 studio 调试器 Visual      更新时间:2023-10-16

我有一些丑陋的遗留代码,我试图理解并想要调试。

:

class A{
// some members and functions
// but no virtual ones
};
class B:public A
{
// contains virtual methods
}
class C:public B
{}
// now somewhere there is an array of pointers to A;
A* someList[FixSize];
// and another struct contains a pointer to that someList.
struct T{
 A** list;
}t;

someList的数组元素实际上是C类型的。由于A不包含任何虚拟方法,调试器只显示该列表中的A元素,而不提供其子类成员在其树视图。

list指针转换为C**显然不起作用,因为在C -对象和它的A部分之间存在偏移。

如果将(C*)(t->list[0])设置为手表,则调试器显示正确的数据。但是用这种方法检查50个对象不是很方便。

有没有人知道一些聪明的方法来处理这个问题

(C**)t->list,10正在Visual Studio 2010中进行工作测试。根据您的struct T {} t定义,它应该是(C**)(t.list),10