Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: hex <heixia108@gmail.com>
To: gdb@sourceware.org
Subject: Could GDB get offset of a field in virtual base class through NULL pointer
Date: Sat, 28 Sep 2013 16:23:00 -0000	[thread overview]
Message-ID: <CAB_AMN7niBPRf4Mc6Tq=NXnbQacc7DKmM4btodcmKJ4TjOf8Bw@mail.gmail.com> (raw)

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!


             reply	other threads:[~2013-09-28 16:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28 16:23 hex [this message]
2013-09-28 18:39 ` Jan Kratochvil
2013-09-29  1:59   ` hex
2013-09-30  8:16     ` Jan Kratochvil
2013-09-30 14:29       ` hex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB_AMN7niBPRf4Mc6Tq=NXnbQacc7DKmM4btodcmKJ4TjOf8Bw@mail.gmail.com' \
    --to=heixia108@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox