From 9655fd1aecac0e494b53902baaf50cf53f899526 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 28 Jun 2010 20:12:53 +0000 Subject: [PATCH] gdb/ Fix modification of cplus_struct_default. * dwarf2read.c (dwarf2_add_member_fn) : Call ALLOCATE_CPLUS_STRUCT_TYPE. * gdbtypes.c (cplus_struct_default): New empty initializer, comment it. gdb/testsuite/ * gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data) (main) : New. * gdb.cp/virtbase.exp (print rtti_data): New. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2read.c | 1 + gdb/gdbtypes.c | 3 ++- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.cp/virtbase.cc | 14 +++++++++++++- gdb/testsuite/gdb.cp/virtbase.exp | 5 +++++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4341e7209d7..196f89962df 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2010-06-28 Jan Kratochvil + + Fix modification of cplus_struct_default. + * dwarf2read.c (dwarf2_add_member_fn) : + Call ALLOCATE_CPLUS_STRUCT_TYPE. + * gdbtypes.c (cplus_struct_default): New empty initializer, comment it. + 2010-06-28 Joel Brobecker * NEWS: Add entry announcing the python directory. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 43e7120c80c..6893e08ac7c 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -4954,6 +4954,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, complaint (&symfile_complaints, _("Member function \"%s\" (offset %d) is virtual but the vtable offset is not specified"), fieldname, die->offset); + ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_CPLUS_DYNAMIC (type) = 1; } } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b7fb11001ef..5d1d4203e79 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1733,7 +1733,8 @@ check_stub_method_group (struct type *type, int method_id) } } -const struct cplus_struct_type cplus_struct_default; +/* Ensure it is in .rodata (if available) by workarounding GCC PR 44690. */ +const struct cplus_struct_type cplus_struct_default = { }; void allocate_cplus_struct_type (struct type *type) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index cb8545315b0..e187d045e9e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-06-28 Jan Kratochvil + + * gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data) + (main) : New. + * gdb.cp/virtbase.exp (print rtti_data): New. + 2010-06-28 Jan Kratochvil Joel Brobecker diff --git a/gdb/testsuite/gdb.cp/virtbase.cc b/gdb/testsuite/gdb.cp/virtbase.cc index fed5927db55..1e6874fd3b0 100644 --- a/gdb/testsuite/gdb.cp/virtbase.cc +++ b/gdb/testsuite/gdb.cp/virtbase.cc @@ -74,8 +74,19 @@ public: virtual void b() {} }; +class RTTI_base +{ +public: + virtual ~RTTI_base() {} +}; - +class RTTI_data +{ +public: + RTTI_base base; + int data; + RTTI_data() : data(1) {} +}; int main() { ph::Derived tst; @@ -84,6 +95,7 @@ int main() { E *e = new E; RHB *b = new RHC(); + RTTI_data rtti_data; return 0; // breakpoint 3 } diff --git a/gdb/testsuite/gdb.cp/virtbase.exp b/gdb/testsuite/gdb.cp/virtbase.exp index 1f845a79f84..b9bde081063 100644 --- a/gdb/testsuite/gdb.cp/virtbase.exp +++ b/gdb/testsuite/gdb.cp/virtbase.exp @@ -60,3 +60,8 @@ gdb_test "print *(D *) e" " = { = {v = 11}, _vptr.D = $hex}" # https://bugzilla.redhat.com/show_bug.cgi?id=560741 gdb_test_no_output "set print object on" gdb_test "print/x b->mA" " = 0xaaaaaaaa" + +# A regression test reported to Red Hat bugzilla, see: +# https://bugzilla.redhat.com/show_bug.cgi?id=606660 +# `set print object on' is expected. +gdb_test "print rtti_data" " = .*, data = 1\}" -- 2.30.2