public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb does not print the reference to the base class members
@ 2007-11-19  0:35 Peng Yu
  2007-11-19  8:39 ` Douglas Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2007-11-19  0:35 UTC (permalink / raw)
  To: gdb

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;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gdb does not print the reference to the base class members
  2007-11-19  0:35 gdb does not print the reference to the base class members Peng Yu
@ 2007-11-19  8:39 ` Douglas Evans
  2007-11-21  4:55   ` Peng Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Douglas Evans @ 2007-11-19  8:39 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

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;
> }
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gdb does not print the reference to the base class members
  2007-11-19  8:39 ` Douglas Evans
@ 2007-11-21  4:55   ` Peng Yu
  2007-11-21  6:59     ` Douglas Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2007-11-21  4:55 UTC (permalink / raw)
  To: Douglas Evans; +Cc: gdb

Hi,

This is the version that I'm using. Will the problem be solved if I
upgrade to the latest version, GDB version 6.7.1?

Thanks,
Peng

$ gdb --version
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux".


On Nov 19, 2007 2:39 AM, Douglas Evans <dje@google.com> wrote:
> 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;
> > }
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gdb does not print the reference to the base class members
  2007-11-21  4:55   ` Peng Yu
@ 2007-11-21  6:59     ` Douglas Evans
  0 siblings, 0 replies; 4+ messages in thread
From: Douglas Evans @ 2007-11-21  6:59 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

Hi.  The bug is in gcc, not gdb, so no change in gdb version is going
to fix this.  See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27574
for details of the bug.

On Nov 20, 2007 8:55 PM, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> This is the version that I'm using. Will the problem be solved if I
> upgrade to the latest version, GDB version 6.7.1?
>
> Thanks,
> Peng
>
> $ gdb --version
> GNU gdb 6.6-debian
> Copyright (C) 2006 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i386-linux".
>
>
>
> On Nov 19, 2007 2:39 AM, Douglas Evans <dje@google.com> wrote:
> > 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;
> > > }
> > >
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-21  6:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-19  0:35 gdb does not print the reference to the base class members Peng Yu
2007-11-19  8:39 ` Douglas Evans
2007-11-21  4:55   ` Peng Yu
2007-11-21  6:59     ` Douglas Evans

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).