aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/dtrace-probe.c2
-rw-r--r--gdb/eval.c2
-rw-r--r--gdb/expression.h7
-rw-r--r--gdb/stack.c4
-rw-r--r--gdb/tracepoint.c4
-rw-r--r--gdb/typeprint.c2
-rw-r--r--gdb/value.c2
-rw-r--r--gdb/varobj.c7
9 files changed, 31 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 464054c..58075c9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
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.
+ * tracepoint.c (validate_actionline): Use first_opcode.
+ (encode_actions_1): Use first_opcode.
+ * stack.c (return_command): Use first_opcode.
+ * expression.h (struct expression) <first_opcode>: New method.
+ * eval.c (parse_and_eval_type): Use first_opcode.
+ * dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.
+
+2020-12-15 Tom Tromey <tom@tromey.com>
+
* f-lang.c (evaluate_subexp_f): Update.
* expression.h (evaluate_subexp_do_call): Update.
* eval.c (evaluate_subexp_do_call): Add callee parameter. Replace
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 3ea047f..b709390 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -492,7 +492,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
{
}
- if (expr != NULL && expr.get ()->elts[0].opcode == OP_TYPE)
+ if (expr != NULL && expr->first_opcode () == OP_TYPE)
type = value_type (evaluate_type (expr.get ()));
args.emplace_back (type, std::move (type_str), std::move (expr));
diff --git a/gdb/eval.c b/gdb/eval.c
index 6066a32..2d088c8 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -3104,7 +3104,7 @@ parse_and_eval_type (const char *p, int length)
tmp[length + 2] = '0';
tmp[length + 3] = '\0';
expression_up expr = parse_expression (tmp);
- if (expr->elts[0].opcode != UNOP_CAST)
+ if (expr->first_opcode () != UNOP_CAST)
error (_("Internal error in eval_type."));
return expr->elts[1].type;
}
diff --git a/gdb/expression.h b/gdb/expression.h
index 0c4dc7b..c07111c 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -91,6 +91,13 @@ struct expression
void resize (size_t);
+ /* Return the opcode for the outermost sub-expression of this
+ expression. */
+ enum exp_opcode first_opcode () const
+ {
+ return elts[0].opcode;
+ }
+
/* Language it was entered in. */
const struct language_defn *language_defn;
/* Architecture it was parsed in. */
diff --git a/gdb/stack.c b/gdb/stack.c
index 7618f72..943b3db 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2770,8 +2770,8 @@ return_command (const char *retval_exp, int from_tty)
return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
if (return_type == NULL)
{
- if (retval_expr->elts[0].opcode != UNOP_CAST
- && retval_expr->elts[0].opcode != UNOP_CAST_TYPE)
+ if (retval_expr->first_opcode () != UNOP_CAST
+ && retval_expr->first_opcode () != UNOP_CAST_TYPE)
error (_("Return value type not available for selected "
"stack frame.\n"
"Please use an explicit cast of the value to return."));
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index c2f923b..cb2b3b6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -687,7 +687,7 @@ validate_actionline (const char *line, struct breakpoint *b)
expression_up exp = parse_exp_1 (&p, loc->address,
block_for_pc (loc->address), 1);
- if (exp->elts[0].opcode == OP_VAR_VALUE)
+ if (exp->first_opcode () == OP_VAR_VALUE)
{
if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
{
@@ -1383,7 +1383,7 @@ encode_actions_1 (struct command_line *action,
block_for_pc (tloc->address),
1);
- switch (exp->elts[0].opcode)
+ switch (exp->first_opcode ())
{
case OP_REGISTER:
{
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 2f671d9..4987771 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -493,7 +493,7 @@ whatis_exp (const char *exp, int show)
val = evaluate_type (expr.get ());
type = value_type (val);
- if (show == -1 && expr->elts[0].opcode == OP_TYPE)
+ if (show == -1 && expr->first_opcode () == OP_TYPE)
{
/* The user expression names a type directly. */
diff --git a/gdb/value.c b/gdb/value.c
index eba5bce..9584fc1 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1981,7 +1981,7 @@ init_if_undefined_command (const char* args, int from_tty)
/* Validate the expression.
Was the expression an assignment?
Or even an expression at all? */
- if (expr->nelts == 0 || expr->elts[0].opcode != BINOP_ASSIGN)
+ if (expr->nelts == 0 || expr->first_opcode () != BINOP_ASSIGN)
error (_("Init-if-undefined requires an assignment expression."));
/* Extract the variable from the parsed expression.
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 19a90c7..6a95e1e 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -311,9 +311,10 @@ varobj_create (const char *objname,
}
/* Don't allow variables to be created for types. */
- if (var->root->exp->elts[0].opcode == OP_TYPE
- || var->root->exp->elts[0].opcode == OP_TYPEOF
- || var->root->exp->elts[0].opcode == OP_DECLTYPE)
+ enum exp_opcode opcode = var->root->exp->first_opcode ();
+ if (opcode == OP_TYPE
+ || opcode == OP_TYPEOF
+ || opcode == OP_DECLTYPE)
{
fprintf_unfiltered (gdb_stderr, "Attempt to use a type name"
" as an expression.\n");