+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.
{
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. */
return evaluate_expression (expr.get ());
}
\f
-/* 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
{
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. */
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.
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);