public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix modification of cplus_struct_default
@ 2010-06-27 13:17 Jan Kratochvil
  2010-06-28 18:46 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-06-27 13:17 UTC (permalink / raw)
  To: gdb-patches

Hi,

(gdb) set print object on
(gdb) print rtti_data
$2 = (RTTI_base) {_vptr.RTTI_base = 0x400bd0}
->
(gdb) set print object on
(gdb) print rtti_data
$2 = {base = {_vptr.RTTI_base = 0x400bd0}, data = 1}

as rtti_data has no RTTI and it falsely interpreted RTTI from its first data
field.  gnuv3_dynamic_class has protection against !TYPE_CPLUS_DYNAMIC - but
it could not work.

No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.


Thanks,
Jan


gdb/
2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix modification of cplus_struct_default.
	* dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
	Call ALLOCATE_CPLUS_STRUCT_TYPE.
	* gdbtypes.c (cplus_struct_default): New empty initializer, comment it.

gdb/testsuite/
2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
	(main) <rtti_data>: New.
	* gdb.cp/virtbase.exp (print rtti_data): New.

--- 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;
 	}
     }
--- 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)
--- 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
 }
--- a/gdb/testsuite/gdb.cp/virtbase.exp
+++ b/gdb/testsuite/gdb.cp/virtbase.exp
@@ -60,3 +60,8 @@ gdb_test "print *(D *) e" " = {<C> = {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\}"

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

* Re: [patch] Fix modification of cplus_struct_default
  2010-06-27 13:17 [patch] Fix modification of cplus_struct_default Jan Kratochvil
@ 2010-06-28 18:46 ` Tom Tromey
  2010-06-28 20:13   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-06-28 18:46 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> 2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	Fix modification of cplus_struct_default.
Jan> 	* dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
Jan> 	Call ALLOCATE_CPLUS_STRUCT_TYPE.
Jan> 	* gdbtypes.c (cplus_struct_default): New empty initializer, comment it.

Jan> 2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	* gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
Jan> 	(main) <rtti_data>: New.
Jan> 	* gdb.cp/virtbase.exp (print rtti_data): New.

This is ok, thanks.

Tom

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

* Re: [patch] Fix modification of cplus_struct_default
  2010-06-28 18:46 ` Tom Tromey
@ 2010-06-28 20:13   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-06-28 20:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, 28 Jun 2010 20:46:02 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> 2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	Fix modification of cplus_struct_default.
> Jan> 	* dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
> Jan> 	Call ALLOCATE_CPLUS_STRUCT_TYPE.
> Jan> 	* gdbtypes.c (cplus_struct_default): New empty initializer, comment it.
> 
> Jan> 2010-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	* gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
> Jan> 	(main) <rtti_data>: New.
> Jan> 	* gdb.cp/virtbase.exp (print rtti_data): New.
> 
> This is ok, thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-06/msg00196.html


Thanks,
Jan

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

end of thread, other threads:[~2010-06-28 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-27 13:17 [patch] Fix modification of cplus_struct_default Jan Kratochvil
2010-06-28 18:46 ` Tom Tromey
2010-06-28 20:13   ` Jan Kratochvil

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