public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11226] New: gdb cannot print member in base class
@ 2010-01-27 18:42 duanhuaiyu at gmail dot com
2010-01-27 19:20 ` [Bug c++/11226] " tromey at redhat dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: duanhuaiyu at gmail dot com @ 2010-01-27 18:42 UTC (permalink / raw)
To: gdb-prs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11226] gdb cannot print member in base class
2010-01-27 18:42 [Bug c++/11226] New: gdb cannot print member in base class duanhuaiyu at gmail dot com
@ 2010-01-27 19:20 ` tromey at redhat dot com
2010-01-27 21:45 ` tromey at redhat dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-01-27 19:20 UTC (permalink / raw)
To: gdb-prs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2010-01-27 19:20:10
date| |
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11226] gdb cannot print member in base class
2010-01-27 18:42 [Bug c++/11226] New: gdb cannot print member in base class duanhuaiyu at gmail dot com
2010-01-27 19:20 ` [Bug c++/11226] " tromey at redhat dot com
@ 2010-01-27 21:45 ` tromey at redhat dot com
2010-02-02 16:45 ` cvs-commit at gcc dot gnu dot org
2010-02-02 16:48 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-01-27 21:45 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-01-27 21:45 -------
I'm testing a patch.
Thanks for the concise test case.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at sourceware dot|tromey at redhat dot com
|org |
Status|NEW |ASSIGNED
Last reconfirmed|2010-01-27 19:20:10 |2010-01-27 21:45:36
date| |
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11226] gdb cannot print member in base class
2010-01-27 18:42 [Bug c++/11226] New: gdb cannot print member in base class duanhuaiyu at gmail dot com
2010-01-27 19:20 ` [Bug c++/11226] " tromey at redhat dot com
2010-01-27 21:45 ` tromey at redhat dot com
@ 2010-02-02 16:45 ` cvs-commit at gcc dot gnu dot org
2010-02-02 16:48 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2010-02-02 16:45 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2010-02-02 16:45 -------
Subject: Bug 11226
CVSROOT: /cvs/src
Module name: src
Changes by: tromey@sourceware.org 2010-02-02 16:45:18
Modified files:
gdb : ChangeLog c-lang.h c-valprint.c cp-valprint.c
language.h valops.c
gdb/python : py-prettyprint.c
gdb/testsuite : ChangeLog
gdb/testsuite/gdb.cp: userdef.exp
Added files:
gdb/testsuite/gdb.cp: virtbase.cc virtbase.exp
Log message:
gdb
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* valops.c (search_struct_field): Compute nbases after calling
CHECK_TYPEDEF.
(check_field): Call CHECK_TYPEDEF.
* cp-valprint.c (cp_print_value): Pass correct address to
baseclass_offset. Fix check for virtual base past the end of the
object. Don't offset address passed to cp_print_value_fields or
apply_val_pretty_printer.
(cp_print_value_fields): Fix call to val_print.
(cp_print_value_fields_rtti): New function.
* c-valprint.c (c_val_print): Use cp_print_value_fields_rtti.
* p-valprint.c (pascal_object_print_value_fields): Fix call to
val_print.
* python/py-prettyprint.c (apply_val_pretty_printer): Add embedded
offset to address.
* language.h (struct language_defn) <la_val_print>: Document.
* c-lang.h (cp_print_value_fields_rtti): Declare.
gdb/testsuite
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* gdb.cp/virtbase.cc: New file.
* gdb.cp/virtbase.exp: New file.
* gdb.cp/userdef.exp: Allow 'struct' or 'class'.
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11313&r2=1.11314
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/c-lang.h.diff?cvsroot=src&r1=1.26&r2=1.27
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/c-valprint.c.diff?cvsroot=src&r1=1.66&r2=1.67
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-valprint.c.diff?cvsroot=src&r1=1.62&r2=1.63
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/language.h.diff?cvsroot=src&r1=1.62&r2=1.63
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/valops.c.diff?cvsroot=src&r1=1.233&r2=1.234
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/python/py-prettyprint.c.diff?cvsroot=src&r1=1.4&r2=1.5
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2117&r2=1.2118
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/virtbase.cc.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/virtbase.exp.diff?cvsroot=src&r1=NONE&r2=1.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/userdef.exp.diff?cvsroot=src&r1=1.12&r2=1.13
--
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11226] gdb cannot print member in base class
2010-01-27 18:42 [Bug c++/11226] New: gdb cannot print member in base class duanhuaiyu at gmail dot com
` (2 preceding siblings ...)
2010-02-02 16:45 ` cvs-commit at gcc dot gnu dot org
@ 2010-02-02 16:48 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-02-02 16:48 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-02-02 16:48 -------
Fix checked in.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-02 16:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-27 18:42 [Bug c++/11226] New: gdb cannot print member in base class duanhuaiyu at gmail dot com
2010-01-27 19:20 ` [Bug c++/11226] " tromey at redhat dot com
2010-01-27 21:45 ` tromey at redhat dot com
2010-02-02 16:45 ` cvs-commit at gcc dot gnu dot org
2010-02-02 16:48 ` tromey at redhat dot com
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).