aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1994-05-05 00:19:33 +0000
committerPer Bothner <per@bothner.com>1994-05-05 00:19:33 +0000
commit36a2283dad09124b2d980d10adfca84d31aaedcb (patch)
tree4f5c5c0cfbe4d19d0640f1b50d34372ab24ae551 /gdb/values.c
parentd32a92614da2060c30a286d11bfb03146bc8dca6 (diff)
downloadfsf-binutils-gdb-36a2283dad09124b2d980d10adfca84d31aaedcb.zip
fsf-binutils-gdb-36a2283dad09124b2d980d10adfca84d31aaedcb.tar.gz
fsf-binutils-gdb-36a2283dad09124b2d980d10adfca84d31aaedcb.tar.bz2
Add partial support for g++ code compiled with -fvtable-thunks.
* c-valprint.c (c_val_print): Add vtblprint support when using thunks. * cp-valprint.c (cp_is_vtbl_member): A vtable can be an array of pointers (if using thunks) as well as array of structs (otherwise). * cp-valprint.c (vtbl_ptr_name_old, vtbl_ptr_name): Move to global level, and make the latter non-static (so define_symbol can use it). * stabsread.c (define_symbol): If the type being defined is a pointer type named "__vtbl_ptr_type", set the TYPE_NAME to that name. * symtab.h (VTBL_PREFIX_P): Allow "_VT" as well as "_vt". * values.c (value_virtual_fn_field): Handle thunks. * values.c (value_headof): Minor efficiency hack. * values.c (value_headof): Incomplete thunk support. FIXME.
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/gdb/values.c b/gdb/values.c
index 244d877..1c833af 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -880,16 +880,23 @@ value_virtual_fn_field (arg1p, f, j, type, offset)
a virtual function. */
entry = value_subscript (vtbl, vi);
- /* Move the `this' pointer according to the virtual function table. */
- VALUE_OFFSET (arg1) += value_as_long (value_field (entry, 0))/* + offset*/;
-
- if (! VALUE_LAZY (arg1))
+ if (TYPE_CODE (VALUE_TYPE (entry)) == TYPE_CODE_STRUCT)
{
- VALUE_LAZY (arg1) = 1;
- value_fetch_lazy (arg1);
- }
+ /* Move the `this' pointer according to the virtual function table. */
+ VALUE_OFFSET (arg1) += value_as_long (value_field (entry, 0));
+
+ if (! VALUE_LAZY (arg1))
+ {
+ VALUE_LAZY (arg1) = 1;
+ value_fetch_lazy (arg1);
+ }
- vfn = value_field (entry, 2);
+ vfn = value_field (entry, 2);
+ }
+ else if (TYPE_CODE (VALUE_TYPE (entry)) == TYPE_CODE_PTR)
+ vfn = entry;
+ else
+ error ("I'm confused: virtual function table has bad type");
/* Reinstantiate the function pointer with the correct type. */
VALUE_TYPE (vfn) = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j));
@@ -931,7 +938,8 @@ value_headof (in_arg, btype, dtype)
/* Check that VTBL looks like it points to a virtual function table. */
msymbol = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtbl));
if (msymbol == NULL
- || !VTBL_PREFIX_P (demangled_name = SYMBOL_NAME (msymbol)))
+ || (demangled_name = SYMBOL_NAME (msymbol)) == NULL
+ || !VTBL_PREFIX_P (demangled_name))
{
/* If we expected to find a vtable, but did not, let the user
know that we aren't happy, but don't throw an error.
@@ -950,6 +958,9 @@ value_headof (in_arg, btype, dtype)
{
entry = value_subscript (vtbl, value_from_longest (builtin_type_int,
(LONGEST) i));
+ /* This won't work if we're using thunks. */
+ if (TYPE_CODE (VALUE_TYPE (entry)) != TYPE_CODE_STRUCT)
+ break;
offset = longest_to_int (value_as_long (value_field (entry, 0)));
/* If we use '<=' we can handle single inheritance
* where all offsets are zero - just use the first entry found. */