public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Douglas Evans" <dje@google.com>
To: "Peng Yu" <pengyu.ut@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: gdb does not print the reference to the base class members
Date: Mon, 19 Nov 2007 08:39:00 -0000	[thread overview]
Message-ID: <e394668d0711190039y582ad602s3502e2ed145550d2@mail.gmail.com> (raw)
In-Reply-To: <366c6f340711181635x47116762nf7ec620eb5801dd2@mail.gmail.com>

I  believe this is gcc bug 27574.

On Nov 18, 2007 4:35 PM, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> I try to print reference x for the following problem. But gdb does not
> print the one in class B refered to class A? Do you know how to print
> its value?
>
> Thanks,
> Peng
>
> (gdb) b 22
> Breakpoint 1 at 0x8048694: file main.cc, line 22.
> (gdb) b 14
> Breakpoint 2 at 0x8048706: file main.cc, line 14.
> (gdb) r
> Failed to read a valid object file image from memory.
>
> Breakpoint 1, main () at main.cc:22
> 22        B b(10);
> (gdb) p x
> $1 = (int &) @0xbffd86cc: 5
> (gdb) c
>
> Breakpoint 2, B (this=0xbffd86c8, a=10) at main.cc:14
> 14            std::cout << x << std::endl;
> (gdb) p x
> No symbol "x" in current context.
>
>
>
> #include <iostream>
>
> class A {
>   public:
>     A(int a) : _a(a) { }
>   protected:
>     int _a;
> };
>
> class B : public A {
>   public:
>     B(int a) : A(a) {
>       int &x = A::_a;//can not print from gdb, Line 12
>       std::cout << x << std::endl;
>     }
> };
>
>
> int main(){
>   int a = 5;
>   int &x = a;//this one can be printed in gdb, Line 22
>   B b(10);
>   std::cout << x << std::endl;
> }
>

  reply	other threads:[~2007-11-19  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-19  0:35 Peng Yu
2007-11-19  8:39 ` Douglas Evans [this message]
2007-11-21  4:55   ` Peng Yu
2007-11-21  6:59     ` Douglas 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=e394668d0711190039y582ad602s3502e2ed145550d2@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb@sourceware.org \
    --cc=pengyu.ut@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).