aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-12-15 18:35:13 -0700
committerTom Tromey <tom@tromey.com>2020-12-15 18:57:07 -0700
commitefd7ff149a42c865cac422e3bafdf386c91c5373 (patch)
tree1ad19dfafeaca30bc40c43adf55e826327ead802 /gdb
parent2adab65cc07f07a581d57b05dfbc100952fab748 (diff)
downloadgdb-efd7ff149a42c865cac422e3bafdf386c91c5373.zip
gdb-efd7ff149a42c865cac422e3bafdf386c91c5373.tar.gz
gdb-efd7ff149a42c865cac422e3bafdf386c91c5373.tar.bz2
Add expected type parameter to evaluate_expression
While working on the expression rewrite, I found a few spots that called the internal functions of the expression evaluator, just to pass in an expected type. This patch adds a parameter to evaluate_expression so that these functions can avoid this dependency. Regression tested on x86-64 Fedora 28. gdb/ChangeLog 2020-12-15 Tom Tromey <tom@tromey.com> * stap-probe.c (stap_probe::evaluate_argument): Use evaluate_expression. * dtrace-probe.c (dtrace_probe::evaluate_argument): Use evaluate_expression. * value.h (evaluate_expression): Add expect_type parameter. * objc-lang.c (print_object_command): Call evaluate_expression. * eval.c (evaluate_expression): Add expect_type parameter.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/dtrace-probe.c4
-rw-r--r--gdb/eval.c8
-rw-r--r--gdb/objc-lang.c6
-rw-r--r--gdb/stap-probe.c4
-rw-r--r--gdb/value.h9
6 files changed, 26 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 58075c9..91bf0a2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2020-12-15 Tom Tromey <tom@tromey.com>
+ * stap-probe.c (stap_probe::evaluate_argument): Use
+ evaluate_expression.
+ * dtrace-probe.c (dtrace_probe::evaluate_argument): Use
+ evaluate_expression.
+ * value.h (evaluate_expression): Add expect_type parameter.
+ * objc-lang.c (print_object_command): Call evaluate_expression.
+ * eval.c (evaluate_expression): Add expect_type parameter.
+
+2020-12-15 Tom Tromey <tom@tromey.com>
+
* varobj.c (varobj_create): Use first_opcode.
* value.c (init_if_undefined_command): Use first_opcode.
* typeprint.c (whatis_exp): Use first_opcode.
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index b709390..c105763 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -714,11 +714,9 @@ dtrace_probe::evaluate_argument (unsigned n,
{
struct gdbarch *gdbarch = this->get_gdbarch ();
struct dtrace_probe_arg *arg;
- int pos = 0;
arg = this->get_arg_by_number (n, gdbarch);
- return evaluate_subexp_standard (arg->type, arg->expr.get (), &pos,
- EVAL_NORMAL);
+ return evaluate_expression (arg->expr.get (), arg->type);
}
/* Implementation of the compile_to_ax method. */
diff --git a/gdb/eval.c b/gdb/eval.c
index 2d088c8..c781fde 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -120,17 +120,15 @@ parse_to_comma_and_eval (const char **expp)
return evaluate_expression (expr.get ());
}
-/* Evaluate an expression in internal prefix form
- such as is constructed by parse.y.
- See expression.h for info on the format of an expression. */
+/* See value.h. */
struct value *
-evaluate_expression (struct expression *exp)
+evaluate_expression (struct expression *exp, struct type *expect_type)
{
int pc = 0;
- return evaluate_subexp (nullptr, exp, &pc, EVAL_NORMAL);
+ return evaluate_subexp (expect_type, exp, &pc, EVAL_NORMAL);
}
/* Evaluate an expression, avoiding all memory references
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 4cd8532..10220c8 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1194,10 +1194,10 @@ print_object_command (const char *args, int from_tty)
{
expression_up expr = parse_expression (args);
- int pc = 0;
- object = evaluate_subexp (builtin_type (expr->gdbarch)->builtin_data_ptr,
- expr.get (), &pc, EVAL_NORMAL);
+ object
+ = evaluate_expression (expr.get (),
+ builtin_type (expr->gdbarch)->builtin_data_ptr);
}
/* Validate the address for sanity. */
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 9a70471..ffcded3 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1389,12 +1389,10 @@ struct value *
stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
{
struct stap_probe_arg *arg;
- int pos = 0;
struct gdbarch *gdbarch = get_frame_arch (frame);
arg = this->get_arg_by_number (n, gdbarch);
- return evaluate_subexp_standard (arg->atype, arg->aexpr.get (), &pos,
- EVAL_NORMAL);
+ return evaluate_expression (arg->aexpr.get (), arg->atype);
}
/* Compile the probe's argument N (indexed from 0) to agent expression.
diff --git a/gdb/value.h b/gdb/value.h
index 25937f3..98012a5 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -905,7 +905,14 @@ extern int using_struct_return (struct gdbarch *gdbarch,
struct value *function,
struct type *value_type);
-extern struct value *evaluate_expression (struct expression *exp);
+/* Evaluate the expression EXP. If set, EXPECT_TYPE is passed to the
+ outermost operation's evaluation. This is ignored by most
+ operations, but may be used, e.g., to determine the type of an
+ otherwise untyped symbol. The caller should not assume that the
+ returned value has this type. */
+
+extern struct value *evaluate_expression (struct expression *exp,
+ struct type *expect_type = nullptr);
extern struct value *evaluate_type (struct expression *exp);