Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 07/13] evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.
Date: Thu, 13 Jul 2017 15:38:00 -0000	[thread overview]
Message-ID: <1499959929-29497-8-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1499959929-29497-1-git-send-email-palves@redhat.com>

A following patch will want to call the new evaluate_var_value
function in another spot.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* eval.c (evaluate_var_value): New function, factored out from ...
	(evaluate_subexp_standard): ... here.
---
 gdb/eval.c | 67 +++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 36 insertions(+), 31 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index cb41a4a..a97f4a9 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -676,6 +676,39 @@ make_params (int num_types, struct type **param_types)
   return type;
 }
 
+/* Helper for evaluating an OP_VAR_VALUE.  */
+
+static value *
+evaluate_var_value (enum noside noside, const block *blk, symbol *var)
+{
+  /* JYG: We used to just return value_zero of the symbol type if
+     we're asked to avoid side effects.  Otherwise we return
+     value_of_variable (...).  However I'm not sure if
+     value_of_variable () has any side effect.  We need a full value
+     object returned here for whatis_exp () to call evaluate_type ()
+     and then pass the full value to value_rtti_target_type () if we
+     are dealing with a pointer or reference to a base class and print
+     object is on.  */
+
+  struct value *ret = NULL;
+
+  TRY
+    {
+      ret = value_of_variable (var, blk);
+    }
+
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+      if (noside != EVAL_AVOID_SIDE_EFFECTS)
+	throw_exception (except);
+
+      ret = value_zero (SYMBOL_TYPE (var), not_lval);
+    }
+  END_CATCH
+
+  return ret;
+}
+
 /* Helper for evaluating an OP_VAR_MSYM_VALUE.  */
 
 static value *
@@ -763,37 +796,9 @@ evaluate_subexp_standard (struct type *expect_type,
       (*pos) += 3;
       if (noside == EVAL_SKIP)
 	return eval_skip_value (exp);
-
-      /* JYG: We used to just return value_zero of the symbol type
-	 if we're asked to avoid side effects.  Otherwise we return
-	 value_of_variable (...).  However I'm not sure if
-	 value_of_variable () has any side effect.
-	 We need a full value object returned here for whatis_exp ()
-	 to call evaluate_type () and then pass the full value to
-	 value_rtti_target_type () if we are dealing with a pointer
-	 or reference to a base class and print object is on.  */
-
-      {
-	struct value *ret = NULL;
-
-	TRY
-	  {
-	    ret = value_of_variable (exp->elts[pc + 2].symbol,
-				     exp->elts[pc + 1].block);
-	  }
-
-	CATCH (except, RETURN_MASK_ERROR)
-	  {
-	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
-	      ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol),
-				not_lval);
-	    else
-	      throw_exception (except);
-	  }
-	END_CATCH
-
-	return ret;
-      }
+      return evaluate_var_value (noside,
+				 exp->elts[pc + 1].block,
+				 exp->elts[pc + 2].symbol);
     case OP_VAR_MSYM_VALUE:
       (*pos) += 3;
       return evaluate_var_msym_value (noside,
-- 
2.5.5


  parent reply	other threads:[~2017-07-13 15:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 15:32 [PATCH v2 00/13] No-debug-info debugging improvements Pedro Alves
2017-07-13 15:32 ` [PATCH v2 10/13] Handle "p S::method()::static_var" in the C++ parser Pedro Alves
2017-07-13 15:32 ` [PATCH v2 05/13] evaluate_subexp_standard: Eliminate one goto Pedro Alves
2017-07-13 15:32 ` [PATCH v2 02/13] Stop assuming no-debug-info functions return int Pedro Alves
2017-07-13 15:32 ` [PATCH v2 09/13] Eliminate UNOP_MEMVAL_TLS Pedro Alves
2017-07-13 15:32 ` [PATCH v2 03/13] Introduce OP_VAR_MSYM_VALUE Pedro Alves
2017-07-13 15:32 ` [PATCH v2 01/13] Fix calling prototyped functions via function pointers Pedro Alves
2017-07-13 15:32 ` [PATCH v2 11/13] Handle "p 'S::method()::static_var'" (quoted) in symbol lookup Pedro Alves
2017-07-13 15:32 ` [PATCH v2 06/13] evaluate_subexp_standard: Remove useless assignments Pedro Alves
2017-07-13 15:37 ` [PATCH v2 12/13] Make "p S::method() const::static_var" work too Pedro Alves
2017-07-13 15:38 ` [PATCH v2 08/13] Stop assuming no-debug-info variables have type int Pedro Alves
2017-12-07 23:30   ` [RFA] Adjust gdb.arch/i386-sse-stack-align.exp print statement Sergio Durigan Junior
2017-12-08 10:47     ` Pedro Alves
2017-12-08 16:28       ` Sergio Durigan Junior
2017-07-13 15:38 ` Pedro Alves [this message]
2017-07-13 15:38 ` [PATCH v2 13/13] Document "no debug info debugging" improvements Pedro Alves
2017-07-13 16:11   ` Eli Zaretskii
2017-07-13 16:31     ` Pedro Alves
2017-07-13 17:54       ` Eli Zaretskii
2017-07-13 15:39 ` [PATCH v2 04/13] Make ptype/whatis print function name of functions with no debug info too Pedro Alves
2017-09-04 19:21 ` [PATCH v2 00/13] No-debug-info debugging improvements Pedro Alves

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=1499959929-29497-8-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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