[003/203] Split out eval_op_var_msym_value

Message ID 20210101214723.1784144-4-tom@tromey.com
State New
Headers show
Series
  • Refactor expressions
Related show

Commit Message

Tom Tromey Jan. 1, 2021, 9:44 p.m.
This splits OP_VAR_MSYM_VALUE into a new function for future use.

gdb/ChangeLog
2021-01-01  Tom Tromey  <tom@tromey.com>

	* eval.c (eval_op_var_msym_value): New function.
	(evaluate_subexp_standard): Use it.
---
 gdb/ChangeLog |  5 +++++
 gdb/eval.c    | 26 +++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

-- 
2.26.2

Comments

Andrew Burgess Jan. 4, 2021, 11:43 a.m. | #1
* Tom Tromey <tom@tromey.com> [2021-01-01 14:44:03 -0700]:

> This splits OP_VAR_MSYM_VALUE into a new function for future use.

> 

> gdb/ChangeLog

> 2021-01-01  Tom Tromey  <tom@tromey.com>

> 

> 	* eval.c (eval_op_var_msym_value): New function.

> 	(evaluate_subexp_standard): Use it.

> ---

>  gdb/ChangeLog |  5 +++++

>  gdb/eval.c    | 26 +++++++++++++++++---------

>  2 files changed, 22 insertions(+), 9 deletions(-)

> 

> diff --git a/gdb/eval.c b/gdb/eval.c

> index 745333d31f9..e896baa3dec 100644

> --- a/gdb/eval.c

> +++ b/gdb/eval.c

> @@ -1215,6 +1215,20 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,

>    return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame);

>  }

>  

> +static struct value *

> +eval_op_var_msym_value (struct type *expect_type, struct expression *exp,

> +			enum noside noside,

> +			minimal_symbol *msymbol, struct objfile *objfile)


The first couple of patches included a header comment for these new
helper functions.  Starting from this patch these header comments are
hit and miss.

Maybe these should be added?  I haven't commented on each patch where
this is an issue, that didn't feel very helpful.

Thanks,
Andrew



> +{

> +  value *val = evaluate_var_msym_value (noside, objfile, msymbol);

> +

> +  struct type *type = value_type (val);

> +  if (type->code () == TYPE_CODE_ERROR

> +      && (noside != EVAL_AVOID_SIDE_EFFECTS || pc != 0))

> +    error_unknown_type (msymbol->print_name ());

> +  return val;

> +}

> +

>  struct value *

>  evaluate_subexp_standard (struct type *expect_type,

>  			  struct expression *exp, int *pos,

> @@ -1277,15 +1291,9 @@ evaluate_subexp_standard (struct type *expect_type,

>  	(*pos) += 3;

>  

>  	minimal_symbol *msymbol = exp->elts[pc + 2].msymbol;

> -	value *val = evaluate_var_msym_value (noside,

> -					      exp->elts[pc + 1].objfile,

> -					      msymbol);

> -

> -	type = value_type (val);

> -	if (type->code () == TYPE_CODE_ERROR

> -	    && (noside != EVAL_AVOID_SIDE_EFFECTS || pc != 0))

> -	  error_unknown_type (msymbol->print_name ());

> -	return val;

> +	return eval_op_var_msym_value (expect_type, exp, noside,

> +				       msymbol,

> +				       exp->elts[pc + 1].objfile);

>        }

>  

>      case OP_VAR_ENTRY_VALUE:

> -- 

> 2.26.2

>
Tom Tromey Feb. 13, 2021, 7:37 p.m. | #2
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:


>> 

>> +static struct value *

>> +eval_op_var_msym_value (struct type *expect_type, struct expression *exp,

>> +			enum noside noside,

>> +			minimal_symbol *msymbol, struct objfile *objfile)


Andrew> The first couple of patches included a header comment for these new
Andrew> helper functions.  Starting from this patch these header comments are
Andrew> hit and miss.

Andrew> Maybe these should be added?  I haven't commented on each patch where
Andrew> this is an issue, that didn't feel very helpful.

I went through the "Split" patches and I've added comments where they
were missing.

Tom

Patch

diff --git a/gdb/eval.c b/gdb/eval.c
index 745333d31f9..e896baa3dec 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1215,6 +1215,20 @@  eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
   return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame);
 }
 
+static struct value *
+eval_op_var_msym_value (struct type *expect_type, struct expression *exp,
+			enum noside noside,
+			minimal_symbol *msymbol, struct objfile *objfile)
+{
+  value *val = evaluate_var_msym_value (noside, objfile, msymbol);
+
+  struct type *type = value_type (val);
+  if (type->code () == TYPE_CODE_ERROR
+      && (noside != EVAL_AVOID_SIDE_EFFECTS || pc != 0))
+    error_unknown_type (msymbol->print_name ());
+  return val;
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
 			  struct expression *exp, int *pos,
@@ -1277,15 +1291,9 @@  evaluate_subexp_standard (struct type *expect_type,
 	(*pos) += 3;
 
 	minimal_symbol *msymbol = exp->elts[pc + 2].msymbol;
-	value *val = evaluate_var_msym_value (noside,
-					      exp->elts[pc + 1].objfile,
-					      msymbol);
-
-	type = value_type (val);
-	if (type->code () == TYPE_CODE_ERROR
-	    && (noside != EVAL_AVOID_SIDE_EFFECTS || pc != 0))
-	  error_unknown_type (msymbol->print_name ());
-	return val;
+	return eval_op_var_msym_value (expect_type, exp, noside,
+				       msymbol,
+				       exp->elts[pc + 1].objfile);
       }
 
     case OP_VAR_ENTRY_VALUE: