summaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorMark Alexander <marka@cygnus>1998-12-31 01:29:30 +0000
committerMark Alexander <marka@cygnus>1998-12-31 01:29:30 +0000
commit1b0df0adcb6f15845bac5e209617d5e0af346569 (patch)
treeb738ffdbc4e82f1813e7ce4b72cfa4a1be1bf017 /gdb/values.c
parentd98ee4f5af86e164d340813bea98afeb2e272d13 (diff)
downloadbinutils-gdb-1b0df0adcb6f15845bac5e209617d5e0af346569.tar.gz
* value.c (value_virtual_fn_field): Handle the situation where
vtbl is a pointer to a structure instead of a pointer to an array.
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/gdb/values.c b/gdb/values.c
index ecc11fec2b1..7b6dd6b9e7d 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -1040,15 +1040,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)