Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fred Fish <fnf@gofish.ninemoons.com>
To: jimb@cygnus.com (Jim Blandy)
Cc: fnf@redhat.com, gdb-patches@sources.redhat.com
Subject: Re: RFA: Patch for SIGSEGV in evaluate_subexp_standard
Date: Mon, 10 Dec 2001 14:58:00 -0000	[thread overview]
Message-ID: <200112102254.fBAMsPw14998@gofish.ninemoons.com> (raw)
In-Reply-To: <npofl6241k.fsf@zwingli.cygnus.com> from "Jim Blandy" at Dec 10, 2001 03:50:15 PM

> Approved, if you address Daniel's suggestion somehow.

OK, I've tweaked the call site to handle a NULL return, which is a
normal result and tested for by other callers.  There was already a
test present, it was just not in the right place and needed to be
moved up a couple lines.  Here is the updated patch and ChangeLog
entry.

-Fred

2001-12-10  Fred Fish  <fnf@redhat.com>
 
	* 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].

Index: values.c
===================================================================
RCS file: /cvs/src/src/gdb/values.c,v
retrieving revision 1.29
diff -u -p -r1.29 values.c
--- values.c	2001/11/30 17:47:51	1.29
+++ values.c	2001/12/10 22:50:01
@@ -954,28 +954,40 @@ value_field (register value_ptr arg1, re
 
 /* 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,
 		int offset)
 {
   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)
     {

Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.16
diff -u -p -r1.16 eval.c
--- eval.c	2001/11/12 21:20:18	1.16
+++ eval.c	2001/12/10 22:49:57
@@ -917,6 +917,8 @@ evaluate_subexp_standard (struct type *e
 
       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 *e
 	  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  */
 


  reply	other threads:[~2001-12-10 22:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-10  9:51 Fred Fish
2001-12-10 11:44 ` Daniel Jacobowitz
2001-12-10 12:49 ` Jim Blandy
2001-12-10 14:58   ` Fred Fish [this message]
2001-12-11 10:56     ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200112102254.fBAMsPw14998@gofish.ninemoons.com \
    --to=fnf@gofish.ninemoons.com \
    --cc=fnf@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox