Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Weimin Pan <weimin.pan@oracle.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH PR gdb/16841] virtual inheritance via typedef cannot find base
Date: Tue, 24 Jul 2018 22:18:00 -0000	[thread overview]
Message-ID: <9fb7e028-44c2-1cec-32e0-b1431c95f074@ericsson.com> (raw)
In-Reply-To: <1532128565-75923-1-git-send-email-weimin.pan@oracle.com>

On 2018-07-20 07:16 PM, Weimin Pan wrote:
> Finding data member in virtual base class
> 
> This patch fixes the original problem - printing member in a virtual base,
> using various expressions, do not yield the same value. Simple test case
> below demonstrates the problem:
> 
> % cat t.cc
> struct base { int i; };
> typedef base tbase;
> struct derived: virtual tbase { void func() { } };
> int main() { derived().func(); }
> % g++ -g t.cc
> % gdb a.out
> (gdb) break derived::func
> (gdb) run
> (gdb) p i
> $1 = 0
> (gdb) p base::i
> $2 = 0
> (gdb) p derived::base::i
> $3 = 0
> (gdb) p derived::i
> $4 = 4196392
> 
> To fix the problem, the virtual-base offset, relative to its derived class,
> needs to be fetched, via baseclass_offset(), and used in calculating the
> address of its data member in value_struct_elt_for_reference().

Hi Weimin,

I have looked at this a little bit, but unfortunately I don't really understand
what's going on (maybe somebody else does and could review it?).  I understand
the issue, and can see that your patch fixes it, but I don't understand how it
does it.  It would help if you could walk us through your code.  It maybe also
means that some comments would be appropriate, to explain what's going on.

Thanks,

Simon


  reply	other threads:[~2018-07-24 22:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 23:50 Weimin Pan
2018-07-24 22:18 ` Simon Marchi [this message]
2018-07-24 23:26   ` Weimin Pan
2018-07-29  2:28 ` Tom Tromey
2018-07-30 17:58   ` Wei-min Pan
2018-07-31 15:42     ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2018-06-15 23:45 Weimin Pan
2018-06-17  1:06 ` Simon Marchi
2018-06-18 16:12   ` Wei-min Pan

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=9fb7e028-44c2-1cec-32e0-b1431c95f074@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=weimin.pan@oracle.com \
    /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