This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] cp-valprint.c: Improve virtual table printing with stabs gcc-2.95.2


Thanks, committed.

2002-03-16  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;

> On Fri, Mar 15, 2002 at 11:44:01AM +0100, Peter.Schauer wrote:
> > 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 ?
> 
> Yes, thank you.
> 
> > 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.
> 
> -- 
> Daniel Jacobowitz                           Carnegie Mellon University
> MontaVista Software                         Debian GNU/Linux Developer

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]