Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Doug Evans" <dje@google.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA] patch for 2384, dangling TYPE_VPTR_BASETYPE
Date: Fri, 14 Dec 2007 20:44:00 -0000	[thread overview]
Message-ID: <e394668d0712141237m5b7a0e87y76aa5ee741907a71@mail.gmail.com> (raw)
In-Reply-To: <20071214002920.GA1208@caradoc.them.org>

On Dec 13, 2007 4:29 PM, Daniel Jacobowitz <drow@false.org> wrote:
> On Thu, Dec 13, 2007 at 04:10:55PM -0800, Doug Evans wrote:
> > Ok to check in?  Or any suggestions for what's needed instead?
>
> Your patch seems strange to me.  Do we need the new fieldno /
> basetype, or not?  If we don't, we shouldn't be calculating it at all;
> if we do, there should be something detectable which breaks when you
> do this.  It's not just a cache, since the interface doesn't offer any
> other way to return the new fieldno / basetype besides in-place
> modification.

For the test case in the patch, type info for the derived class is left
as opaque/stub, and when the vptr is needed check_typedef is called
which notices the fact that is has an incomplete type and does a lookup
by name to get the complete typo info.  In this case check_typedef
notices it has a cross-objfile reference and returns a pointer to the
complete type info without updating the original type. This way cross-objfile
pointers don't get created and the required data is still obtained when needed.

There are other use cases.  If base and derived are both in the
same compilation unit then dwarf2read.c will fill in
TYPE_VPTR_{BASETYPE,FIELDNO} (and presumably stabsread.c
but I don't know offhand), and fill_in_vptr_fieldno is a nop.

Another use case is if base and derived are in different compilation
units but in the same objfile.  Here dwarf2read.c will leave the base
class as a stub for derived's type info.  Later when vptr is needed
fill_in_vptr_fieldno is called and it will notice fieldno < 0 and call
check_typedef on the base type.  check_typedef will see that
orig_type and newtype are in the same objfile and will call
make_cv_type to update the original type with the complete
type info.

> I happen to know that for GNU v3 - which is in practice the only thing
> that any GDB users use nowadays - we don't need these fields any more.
> We still use them, but we could do without, since the ABI is quite
> clear on where to find the vtable pointer.
>
> For GNU v2, which is theoretically still supported, we do need this
> information.

Clearly fill_in_vptr_fieldno can't create cross-objfile pointers.
All callers of fill_in_vptr_fieldno (should) expect that it may fail.

I'm not quite sure what you're suggesting, as it relates to the patch.
The v3 abi still needs logic to handle cross-objfile references,
though it could be done without the use of fill_in_vptr_fieldno.


  reply	other threads:[~2007-12-14 20:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14  0:26 Doug Evans
2007-12-14  6:23 ` Daniel Jacobowitz
2007-12-14 20:44   ` Doug Evans [this message]
2007-12-14 21:27     ` Doug Evans
2007-12-15 13:15   ` Doug Evans
2007-12-20 19:49   ` Doug Evans
2008-01-28 19:05     ` Doug Evans
2008-01-30  1:23     ` Daniel Jacobowitz
2008-02-03 22:19       ` Doug Evans

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=e394668d0712141237m5b7a0e87y76aa5ee741907a71@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@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