From 6d2f5ceaae21cdff53454ab032848b589abd60f7 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sat, 11 May 2002 23:48:23 +0000 Subject: [PATCH] 2002-05-11 Daniel Jacobowitz * TODO: Remove value_headof/value_from_vtable_info comment. * printcmd.c (print_command_1): Don't call value_from_vtable_info. * values.c (value_headof, value_from_vtable_info): Delete. * value.h (value_from_vtable_info): Delete prototype. --- gdb/ChangeLog | 7 +++++ gdb/TODO | 4 --- gdb/printcmd.c | 19 ------------- gdb/value.h | 3 -- gdb/values.c | 89 ---------------------------------------------------------- 5 files changed, 7 insertions(+), 115 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4340f6b..affa3b5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2002-05-11 Daniel Jacobowitz + + * TODO: Remove value_headof/value_from_vtable_info comment. + * printcmd.c (print_command_1): Don't call value_from_vtable_info. + * values.c (value_headof, value_from_vtable_info): Delete. + * value.h (value_from_vtable_info): Delete prototype. + 2002-05-11 Andrew Cagney * Makefile.in: Replace gdb_assert.h with $(gdb_assert_h), diff --git a/gdb/TODO b/gdb/TODO index ea46e9b..f743ae7 100644 --- a/gdb/TODO +++ b/gdb/TODO @@ -247,10 +247,6 @@ New languages come onto the scene all the time. Re: Various C++ things -value_headof/value_from_vtable_info are worthless, and should be -removed. The one place in printcmd.c that uses it should use the RTTI -functions. - RTTI for g++ should be using the typeinfo functions rather than the vtables. The typeinfo functions are always at offset 4 from the beginning of the vtable, and are always right. The vtables will have diff --git a/gdb/printcmd.c b/gdb/printcmd.c index b74f558..de306f0 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -923,25 +923,6 @@ print_command_1 (char *exp, int inspect, int voidprint) old_chain = make_cleanup (free_current_contents, &expr); cleanup = 1; val = evaluate_expression (expr); - - /* C++: figure out what type we actually want to print it as. */ - type = VALUE_TYPE (val); - - if (objectprint - && (TYPE_CODE (type) == TYPE_CODE_PTR - || TYPE_CODE (type) == TYPE_CODE_REF) - && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT - || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_UNION)) - { - struct value *v; - - v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type)); - if (v != 0) - { - val = v; - type = VALUE_TYPE (val); - } - } } else val = access_value_history (0); diff --git a/gdb/value.h b/gdb/value.h index 62dc490..d960fe8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -405,9 +405,6 @@ extern struct value *value_repeat (struct value *arg1, int count); extern struct value *value_subscript (struct value *array, struct value *idx); -extern struct value *value_from_vtable_info (struct value *arg, - struct type *type); - extern struct value *value_being_returned (struct type *valtype, char *retbuf, int struct_return); diff --git a/gdb/values.c b/gdb/values.c index 9445d9c..225dd21 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -41,8 +41,6 @@ void _initialize_values (void); /* Prototypes for local functions. */ -static struct value *value_headof (struct value *, struct type *, struct type *); - static void show_values (char *, int); static void show_convenience (char *, int); @@ -1020,93 +1018,6 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty return v; } -/* ARG is a pointer to an object we know to be at least - a DTYPE. BTYPE is the most derived basetype that has - already been searched (and need not be searched again). - After looking at the vtables between BTYPE and DTYPE, - return the most derived type we find. The caller must - be satisfied when the return value == DTYPE. - - FIXME-tiemann: should work with dossier entries as well. - NOTICE - djb: I see no good reason at all to keep this function now that - we have RTTI support. It's used in literally one place, and it's - hard to keep this function up to date when it's purpose is served - by value_rtti_type efficiently. - Consider it gone for 5.1. */ - -static struct value * -value_headof (struct value *in_arg, struct type *btype, struct type *dtype) -{ - /* First collect the vtables we must look at for this object. */ - struct value *arg; - struct value *vtbl; - struct symbol *sym; - char *demangled_name; - struct minimal_symbol *msymbol; - - btype = TYPE_VPTR_BASETYPE (dtype); - CHECK_TYPEDEF (btype); - arg = in_arg; - if (btype != dtype) - arg = value_cast (lookup_pointer_type (btype), arg); - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF) - { - /* - * Copy the value, but change the type from (T&) to (T*). - * We keep the same location information, which is efficient, - * and allows &(&X) to get the location containing the reference. - */ - arg = value_copy (arg); - VALUE_TYPE (arg) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg))); - } - if (VALUE_ADDRESS(value_field (value_ind(arg), TYPE_VPTR_FIELDNO (btype)))==0) - return arg; - - vtbl = value_ind (value_field (value_ind (arg), TYPE_VPTR_FIELDNO (btype))); - /* Turn vtable into typeinfo function */ - VALUE_OFFSET(vtbl)+=4; - - msymbol = lookup_minimal_symbol_by_pc ( value_as_address(value_ind(vtbl)) ); - if (msymbol == NULL - || (demangled_name = SYMBOL_NAME (msymbol)) == NULL) - { - /* 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. - FIXME: there has to be a better way to do this. */ - struct type *error_type = (struct type *) xmalloc (sizeof (struct type)); - memcpy (error_type, VALUE_TYPE (in_arg), sizeof (struct type)); - TYPE_NAME (error_type) = savestring ("suspicious *", sizeof ("suspicious *")); - VALUE_TYPE (in_arg) = error_type; - return in_arg; - } - demangled_name = cplus_demangle(demangled_name,DMGL_ANSI); - *(strchr (demangled_name, ' ')) = '\0'; - - sym = lookup_symbol (demangled_name, 0, VAR_NAMESPACE, 0, 0); - if (sym == NULL) - error ("could not find type declaration for `%s'", demangled_name); - - arg = in_arg; - VALUE_TYPE (arg) = lookup_pointer_type (SYMBOL_TYPE (sym)); - return arg; -} - -/* ARG is a pointer object of type TYPE. If TYPE has virtual - function tables, probe ARG's tables (including the vtables - of its baseclasses) to figure out the most derived type that ARG - could actually be a pointer to. */ - -struct value * -value_from_vtable_info (struct value *arg, struct type *type) -{ - /* Take care of preliminaries. */ - if (TYPE_VPTR_FIELDNO (type) < 0) - fill_in_vptr_fieldno (type); - if (TYPE_VPTR_FIELDNO (type) < 0) - return 0; - - return value_headof (arg, 0, type); -} /* Unpack a field FIELDNO of the specified TYPE, from the anonymous object at VALADDR. -- 2.7.4