From: Mark Alexander Date: Mon, 21 Dec 1998 21:34:39 +0000 (+0000) Subject: Fix for PR 18470: X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a1b8bb2772ab175320d83668f4c9d1f7acb02c5;p=binutils-gdb.git Fix for PR 18470: * value.c (value_virtual_fn_field): Handle the situation where vtbl is a pointer to a structure instead of a pointer to an array. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f10a472a85b..171e48967ee 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Mon Dec 21 13:30:34 1998 Mark Alexander + + * value.c (value_virtual_fn_field): Handle the situation where + vtbl is a pointer to a structure instead of a pointer to an array. + +Mon Dec 21 10:38:11 1998 Andrew Cagney + + * mips-tdep.c: (MIPS_DEFAULT_FPU_TYPE): Default to + MIPS_FPU_DOUBLE. + 1998-12-17 J.T. Conklin * blockframe.c (get_frame_saved_regs): If the saved_regs_addr ptr diff --git a/gdb/values.c b/gdb/values.c index db6f204af9a..9ddf159d00d 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -910,15 +910,31 @@ value_virtual_fn_field (arg1p, f, j, type, offset) /* The virtual function table is now an array of structures which have the form { int16 offset, delta; void *pfn; }. */ - vtbl = value_ind (value_primitive_field (arg1, 0, - TYPE_VPTR_FIELDNO (context), - TYPE_VPTR_BASETYPE (context))); - - /* Index into the virtual function table. This is hard-coded because - looking up a field is not cheap, and it may be important to save - time, e.g. if the user has set a conditional breakpoint calling - a virtual function. */ - entry = value_subscript (vtbl, vi); + vtbl = value_primitive_field (arg1, 0, TYPE_VPTR_FIELDNO (context), + TYPE_VPTR_BASETYPE (context)); + + /* With older versions of g++, the vtbl field pointed to an array + of structures. Nowadays it points directly to the structure. */ + if (TYPE_CODE (VALUE_TYPE (vtbl)) == TYPE_CODE_PTR + && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (vtbl))) == TYPE_CODE_ARRAY) + { + /* Handle the case where the vtbl field points to an + array of structures. */ + vtbl = value_ind (vtbl); + + /* Index into the virtual function table. This is hard-coded because + looking up a field is not cheap, and it may be important to save + time, e.g. if the user has set a conditional breakpoint calling + a virtual function. */ + entry = value_subscript (vtbl, vi); + } + else + { + /* Handle the case where the vtbl field points directly to a structure. */ + vtbl = value_add (vtbl, vi); + entry = value_ind (vtbl); + } + entry_type = check_typedef (VALUE_TYPE (entry)); if (TYPE_CODE (entry_type) == TYPE_CODE_STRUCT)