From 0478d61cc28c9072f5261920744b734d17202862 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Mon, 10 Dec 2001 23:05:00 +0000 Subject: [PATCH] Approved by Jim Blandy: 2001-12-10 Fred Fish * values.c (value_fn_field): Add physname variable. Use a minimal symbol if we don't find a full symbol. Remove setting of the new value's type since that was already done by allocate_value(). Remove obsolete commented out error call since callees need to handle a NULL return, which is possible result not an error. * eval.c (evaluate_subexp_standard): Move check for inlined functions to precede attempt to dereference a NULL argvec[0]. --- gdb/ChangeLog | 10 ++++++++++ gdb/eval.c | 4 ++-- gdb/values.c | 30 +++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c0363dfc54d..6dc2b770052 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2001-12-10 Fred Fish + + * values.c (value_fn_field): Add physname variable. Use a minimal + symbol if we don't find a full symbol. Remove setting of the new + value's type since that was already done by allocate_value(). + Remove obsolete commented out error call since callees need to + handle a NULL return, which is possible result not an error. + * eval.c (evaluate_subexp_standard): Move check for inlined + functions to precede attempt to dereference a NULL argvec[0]. + 2001-12-10 Fred Fish * arm-linux-tdep.c (skip_hurd_resolver): Use NULL rather than diff --git a/gdb/eval.c b/gdb/eval.c index c15b236568c..8a41d30c9cf 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -917,6 +917,8 @@ evaluate_subexp_standard (struct type *expect_type, if (noside == EVAL_SKIP) goto nosideret; + if (argvec[0] == NULL) + error ("Cannot evaluate function -- may be inlined"); if (noside == EVAL_AVOID_SIDE_EFFECTS) { /* If the return type doesn't look like a function type, call an @@ -934,8 +936,6 @@ evaluate_subexp_standard (struct type *expect_type, else error ("Expression of type other than \"Function returning ...\" used as function"); } - if (argvec[0] == NULL) - error ("Cannot evaluate function -- may be inlined"); return call_function_by_hand (argvec[0], nargs, argvec + 1); /* pai: FIXME save value from call_function_by_hand, then adjust pc by adjust_fn_pc if +ve */ diff --git a/gdb/values.c b/gdb/values.c index 5647097e1b9..b8407e123fb 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -954,7 +954,11 @@ value_field (register value_ptr arg1, register int fieldno) /* Return a non-virtual function as a value. F is the list of member functions which contains the desired method. - J is an index into F which provides the desired method. */ + J is an index into F which provides the desired method. + + We only use the symbol for its address, so be happy with either a + full symbol or a minimal symbol. + */ value_ptr value_fn_field (value_ptr *arg1p, struct fn_field *f, int j, struct type *type, @@ -962,20 +966,28 @@ value_fn_field (value_ptr *arg1p, struct fn_field *f, int j, struct type *type, { register value_ptr v; register struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); + char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); struct symbol *sym; + struct minimal_symbol *msym; - sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_NAMESPACE, 0, NULL); + sym = lookup_symbol (physname, 0, VAR_NAMESPACE, 0, NULL); if (!sym) + { + msym = lookup_minimal_symbol (physname, NULL, NULL); + } + + if (!sym && !msym) return NULL; -/* - error ("Internal error: could not find physical method named %s", - TYPE_FN_FIELD_PHYSNAME (f, j)); - */ v = allocate_value (ftype); - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); - VALUE_TYPE (v) = ftype; + if (sym) + { + VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); + } + else + { + VALUE_ADDRESS (v) = SYMBOL_VALUE_ADDRESS (msym); + } if (arg1p) { -- 2.30.2