是否可以推断gdb中指针指向的对象的类名

Is it possible to infer the class name of the object that a pointer points to in gdb?

本文关键字:对象 指针 gdb 是否      更新时间:2023-10-16

假设我有这个basePointer指针指向基类对象。

(gdb) ptype basePointer
type = class Base {
  public:
    Base(void);
    virtual ~Base(void);
    virtual void hello();
} *
(gdb) p basePointer
$1 = (Base *) 0x100104c00

如果我知道0x100104c00,是否可以推断出gdb中basePointer指向的对象的类名?

在gdb中尝试p (Derived *)basePointer铸造工作,就像在C 中一样