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.
This commit is contained in:
parent
2adab65cc0
commit
efd7ff149a
6 changed files with 26 additions and 15 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
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>
|
2020-12-15 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* varobj.c (varobj_create): Use first_opcode.
|
* varobj.c (varobj_create): Use first_opcode.
|
||||||
|
|
|
@ -714,11 +714,9 @@ dtrace_probe::evaluate_argument (unsigned n,
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = this->get_gdbarch ();
|
struct gdbarch *gdbarch = this->get_gdbarch ();
|
||||||
struct dtrace_probe_arg *arg;
|
struct dtrace_probe_arg *arg;
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
arg = this->get_arg_by_number (n, gdbarch);
|
arg = this->get_arg_by_number (n, gdbarch);
|
||||||
return evaluate_subexp_standard (arg->type, arg->expr.get (), &pos,
|
return evaluate_expression (arg->expr.get (), arg->type);
|
||||||
EVAL_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of the compile_to_ax method. */
|
/* Implementation of the compile_to_ax method. */
|
||||||
|
|
|
@ -120,17 +120,15 @@ parse_to_comma_and_eval (const char **expp)
|
||||||
return evaluate_expression (expr.get ());
|
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 *
|
struct value *
|
||||||
evaluate_expression (struct expression *exp)
|
evaluate_expression (struct expression *exp, struct type *expect_type)
|
||||||
{
|
{
|
||||||
int pc = 0;
|
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
|
/* Evaluate an expression, avoiding all memory references
|
||||||
|
|
|
@ -1194,10 +1194,10 @@ print_object_command (const char *args, int from_tty)
|
||||||
|
|
||||||
{
|
{
|
||||||
expression_up expr = parse_expression (args);
|
expression_up expr = parse_expression (args);
|
||||||
int pc = 0;
|
|
||||||
|
|
||||||
object = evaluate_subexp (builtin_type (expr->gdbarch)->builtin_data_ptr,
|
object
|
||||||
expr.get (), &pc, EVAL_NORMAL);
|
= evaluate_expression (expr.get (),
|
||||||
|
builtin_type (expr->gdbarch)->builtin_data_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate the address for sanity. */
|
/* Validate the address for sanity. */
|
||||||
|
|
|
@ -1389,12 +1389,10 @@ struct value *
|
||||||
stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
|
stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
|
||||||
{
|
{
|
||||||
struct stap_probe_arg *arg;
|
struct stap_probe_arg *arg;
|
||||||
int pos = 0;
|
|
||||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||||
|
|
||||||
arg = this->get_arg_by_number (n, gdbarch);
|
arg = this->get_arg_by_number (n, gdbarch);
|
||||||
return evaluate_subexp_standard (arg->atype, arg->aexpr.get (), &pos,
|
return evaluate_expression (arg->aexpr.get (), arg->atype);
|
||||||
EVAL_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compile the probe's argument N (indexed from 0) to agent expression.
|
/* Compile the probe's argument N (indexed from 0) to agent expression.
|
||||||
|
|
|
@ -905,7 +905,14 @@ extern int using_struct_return (struct gdbarch *gdbarch,
|
||||||
struct value *function,
|
struct value *function,
|
||||||
struct type *value_type);
|
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);
|
extern struct value *evaluate_type (struct expression *exp);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue