diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-04-24 01:01:09 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-04-24 01:01:09 +0000 |
commit | e532974c430c3e8ead63286558d5e950b10f44d9 (patch) | |
tree | 3527813b495a99e37cfbd207df2b02e51c60a573 /gdb/values.c | |
parent | 9107291db4840152f7ecff059d89f659965be4b2 (diff) | |
download | gdb-e532974c430c3e8ead63286558d5e950b10f44d9.zip gdb-e532974c430c3e8ead63286558d5e950b10f44d9.tar.gz gdb-e532974c430c3e8ead63286558d5e950b10f44d9.tar.bz2 |
values.c (value_virtual_fn_field): If there is no fcontext,
then do things the way GDB 3.x did.
valops.c (search_struct_method): Add type to value_virtual_fn_field
arguments.
Diffstat (limited to 'gdb/values.c')
-rw-r--r-- | gdb/values.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gdb/values.c b/gdb/values.c index 2449da5..88ceb3d 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -839,12 +839,15 @@ value_fn_field (arg1, fieldno, subfieldno) table pointer. ARG1 is side-effected in calling this function. F is the list of member functions which contains the desired virtual function. - J is an index into F which provides the desired virtual function. */ + J is an index into F which provides the desired virtual function. + + TYPE is the type in which F is located. */ value -value_virtual_fn_field (arg1, f, j) +value_virtual_fn_field (arg1, f, j, type) value arg1; struct fn_field *f; int j; + struct type *type; { /* First, get the virtual function table pointer. That comes with a strange type, so cast it to type `pointer to long' (which @@ -853,11 +856,21 @@ value_virtual_fn_field (arg1, f, j) value entry, vfn, vtbl; value vi = value_from_long (builtin_type_int, (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j)); - struct type *context = lookup_pointer_type (TYPE_FN_FIELD_FCONTEXT (f, j)); + struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j); + struct type *context; + if (fcontext == NULL) + /* We don't have an fcontext (e.g. the program was compiled with + g++ version 1). Try to get the vtbl from the TYPE_VPTR_BASETYPE. + This won't work right for multiple inheritance, but at least we + should do as well as GDB 3.x did. */ + fcontext = TYPE_VPTR_BASETYPE (type); + context = lookup_pointer_type (fcontext); + /* Now context is a pointer to the basetype containing the vtbl. */ if (TYPE_TARGET_TYPE (context) != VALUE_TYPE (arg1)) arg1 = value_ind (value_cast (context, value_addr (arg1))); context = VALUE_TYPE (arg1); + /* Now context is the basetype containing the vtbl. */ /* This type may have been defined before its virtual function table was. If so, fill in the virtual function table entry for the |