This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
C++ PATCH: Fix gdb/778
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 2 Oct 2002 18:04:23 -0400
- Subject: C++ PATCH: Fix gdb/778
Somehow, on Solaris, GCC manages to generate a class whose baseclass is
TYPE_CODE_TYPEDEF. We haven't figured out how to reproduce this in a small
testcase yet, but I can at least fix the bug:
- Blast through typedefs in fill_in_vptr_fieldno
- Don't crash this easily in gnu-v3-abi.c
Committed trunk and branch.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2002-10-02 Daniel Jacobowitz <drow@mvista.com>
Fix PR gdb/778
* gdbtypes.c (fill_in_vptr_fieldno): Call check_typedef
before recursing.
* gnu-v3-abi.c (gnuv3_virtual_fn_field): Check return value
of fill_in_vptr_fieldno.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.58
diff -u -p -r1.58 gdbtypes.c
--- gdbtypes.c 14 Sep 2002 15:39:52 -0000 1.58
+++ gdbtypes.c 2 Oct 2002 21:47:35 -0000
@@ -1276,13 +1276,12 @@ fill_in_vptr_fieldno (struct type *type)
virtual (and hence we cannot share the table pointer). */
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
- fill_in_vptr_fieldno (TYPE_BASECLASS (type, i));
- if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0)
+ struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
+ fill_in_vptr_fieldno (baseclass);
+ if (TYPE_VPTR_FIELDNO (baseclass) >= 0)
{
- TYPE_VPTR_FIELDNO (type)
- = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i));
- TYPE_VPTR_BASETYPE (type)
- = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type, i));
+ TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass);
+ TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass);
break;
}
}
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.13
diff -u -p -r1.13 gnu-v3-abi.c
--- gnu-v3-abi.c 30 Jul 2002 13:45:13 -0000 1.13
+++ gnu-v3-abi.c 2 Oct 2002 21:47:35 -0000
@@ -324,6 +324,9 @@ gnuv3_virtual_fn_field (struct value **v
type now. */
if (TYPE_VPTR_FIELDNO (vfn_base) < 0)
fill_in_vptr_fieldno (vfn_base);
+ if (TYPE_VPTR_FIELDNO (vfn_base) < 0)
+ error ("Could not find virtual table pointer for class \"%s\".",
+ TYPE_TAG_NAME (vfn_base) ? TYPE_TAG_NAME (vfn_base) : "<unknown>");
/* Now that we know which base class is defining our virtual
function, cast our value to that baseclass. This takes care of