This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/11226] New: gdb cannot print member in base class
- From: "duanhuaiyu at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 27 Jan 2010 18:42:37 -0000
- Subject: [Bug c++/11226] New: gdb cannot print member in base class
- Reply-to: sourceware-bugzilla at sourceware dot org
Here is a simple example. (Although "virtual" is not necessary here, but my big code has it.)
===============================
using namespace std;
namespace mc {
class Base {
protected:
int x;
public:
Base(void) { x = 2; };
};
}
namespace ph {
class Middle: public virtual mc::Base {
protected:
int y;
public:
Middle(void): mc::Base() { y = 3; };
int get_y(void)
{ return y; };
};
class Derived: public virtual Middle {
protected:
int z;
public:
Derived(void): Middle() { z = 4; };
int get_z(void)
{ return z; };
};
}
int main() {
ph::Derived tst;
tst.get_y();
tst.get_z();
return 0;
}
===============================
Here is the gdb session. It is on Ubuntu 9.04.
===============================
$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-
bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-
c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-
gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --
program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --
enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --
host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
$ g++ -g -Wall tst.cc
$ gdb a.out
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) b ph::Middle::get_y
Breakpoint 1 at 0x400862: file tst.cc, line 24.
(gdb) b ph::Derived::get_z
Breakpoint 2 at 0x4008d0: file tst.cc, line 35.
(gdb) r
Starting program: /home/hduan/tmp/a.out
Breakpoint 1, ph::Middle::get_y (this=0x7fff5295f2d0) at tst.cc:24
24 { return y; };
(gdb) p *this
$1 = {<mc::Base> = {x = 4196952}, _vptr.Middle = 0x400a58, y = 3}
(gdb) p x
$2 = 4196952
(gdb) c
Continuing.
Breakpoint 2, ph::Derived::get_z (this=0x7fff5295f2c0) at tst.cc:35
35 { return z; };
(gdb) p *this
$3 = {<ph::Middle> = {<mc::Base> = {x = 2}, _vptr.Middle = 0x400a58, y = 3},
_vptr.Derived = 0x400a40, z = 4}
(gdb) p x
There is no member or method named x.
===============================
--
Summary: gdb cannot print member in base class
Product: gdb
Version: 6.8
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at sourceware dot org
ReportedBy: duanhuaiyu at gmail dot com
CC: gdb-prs at sourceware dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=11226
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.