Could GDB get offset of a field in virtual base class through NULL pointer

hex <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAB_AMN7niBPRf4Mc6Tq=NXnbQacc7DKmM4btodcmKJ4TjOf8Bw@mail.gmail.com>
Hi All,

I defined two classes as following:
// test.cpp
class A{
public:
     int a;
};
class B: public virtual A{
public:
     int b;
};

GDB could print &(((B *)0)->a), but it could not print &(((B *)0)->a).
I debugged GDB, and found it try to visit the virtual table of (B *)0,
then it failed.  It is reasonable. But I think whether GDB could
support this case, it could just regard the NULL pointer as a special
case: it could get offset using TYPE_BASECLASS_BITPOS().  But the
TYPE_BASECLASS_BITPOS() returns 0 now because we have not set a value
for virtual base class. Then problem is whether we could store an
offset for virtual base class to support above case.  But I do not
know how to get this offset from sections of its binary. Could you
give some suggestions please? Thank you!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.