This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] cp-valprint.c: Improve virtual table printing with stabs gcc-2.95.2
- From: "Peter.Schauer" <Peter dot Schauer at regent dot e-technik dot tu-muenchen dot de>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 15 Mar 2002 11:44:01 MET
- Subject: [RFA] cp-valprint.c: Improve virtual table printing with stabs gcc-2.95.2
Having `set print vtable on' and printing an object is often a great
debugging aid, as it shows which virtual functions will actually be called.
Unfortunately gcc-2.95.2 changed the format of the virtual function tables
and GDB had not been updated accordingly.
gcc-3.x will need more GDB code surgery, I hope to address this in a future
patch.
GDB will unfortunately also loose with vtable thunks and dwarf2, but anyway,
this patch at least improves vtable handling for gcc-2.95.2 with stabs.
OK to commit ?
2002-03-15 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
* cp-valprint.c (cp_is_vtbl_ptr_type): Handle vtbl field type
for gcc versions after gcc-2.8.1.
--- ./cp-valprint.c.orig Tue Jan 8 03:09:31 2002
+++ ./cp-valprint.c Sat Mar 2 11:32:33 2002
@@ -201,6 +201,8 @@ cp_is_vtbl_ptr_type (struct type *type)
int
cp_is_vtbl_member (struct type *type)
{
+ /* With older versions of g++, the vtbl field pointed to an array
+ of structures. Nowadays it points directly to the structure. */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
type = TYPE_TARGET_TYPE (type);
@@ -214,6 +216,17 @@ cp_is_vtbl_member (struct type *type)
to virtual functions. */
return cp_is_vtbl_ptr_type (type);
}
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) /* if not using thunks */
+ {
+ return cp_is_vtbl_ptr_type (type);
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_PTR) /* if using thunks */
+ {
+ /* The type name of the thunk pointer is NULL when using dwarf2.
+ We could test for a pointer to a function, but there is
+ no type info for the virtual table either, so it wont help. */
+ return cp_is_vtbl_ptr_type (type);
}
}
return 0;
--
Peter Schauer pes@regent.e-technik.tu-muenchen.de