This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fe13dfecbf7d5a9ba3a5d9f52e33e0ddacb39bcc

commit fe13dfecbf7d5a9ba3a5d9f52e33e0ddacb39bcc
Author: Pedro Alves <palves@redhat.com>
Date:   Mon Sep 4 20:21:14 2017 +0100

    evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.
    
    A following patch will want to call the new evaluate_var_value
    function in another spot.
    
    gdb/ChangeLog:
    2017-09-04  Pedro Alves  <palves@redhat.com>
    
    	* eval.c (evaluate_var_value): New function, factored out from ...
    	(evaluate_subexp_standard): ... here.

Diff:
---
 gdb/ChangeLog |  5 +++++
 gdb/eval.c    | 67 ++++++++++++++++++++++++++++++++---------------------------
 2 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2f0e8dd..7859c64 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2017-09-04  Pedro Alves  <palves@redhat.com>
 
+	* eval.c (evaluate_var_value): New function, factored out from ...
+	(evaluate_subexp_standard): ... here.
+
+2017-09-04  Pedro Alves  <palves@redhat.com>
+
 	* eval.c (evaluate_subexp_standard) <UNOP_COMPLEMENT, UNOP_ADDR>:
 	Remove useless assignments to 'op'.
 
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,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]