aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:37 -0700
commit413403fc34156cf695b09553fca91e0990520787 (patch)
treebf463e2ea8f074b198caca43014951dca5253d5c /gdb/parse.c
parentb0f9164cc6d738db3a71c1ea83aa6567f0387bca (diff)
downloadgdb-413403fc34156cf695b09553fca91e0990520787.zip
gdb-413403fc34156cf695b09553fca91e0990520787.tar.gz
gdb-413403fc34156cf695b09553fca91e0990520787.tar.bz2
Add an expr::operation_up to struct expression
This adds an expr::operation_up to struct expression, and then modifies various parts of GDB to use this member when it is non-null. The list of such spots was a bit surprising to me, and found only after writing most of the code and then noticing what no longer compiled. In a few spots, new accessor methods are added to operation subclasses, so that code that dissects an expression will work with the new scheme. After this change, code that constructs an expression can be switched to the new form without breaking. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-exp.h (class ada_var_value_operation) <get_symbol>: Remove; now in superclass. * value.h (fetch_subexp_value): Add "op" parameter. * value.c (init_if_undefined_command): Update. * tracepoint.c (validate_actionline, encode_actions_1): Update. * stap-probe.c (stap_probe::compile_to_ax): Update. * printcmd.c (set_command): Update. * ppc-linux-nat.c (ppc_linux_nat_target::check_condition): Update. * parser-defs.h (struct expr_builder) <set_operation>: New method. * parse.c (parse_exp_in_context, exp_uses_objfile): Update. * expression.h (struct expression) <first_opcode>: Update. <op>: New member. * expprint.c (dump_raw_expression, dump_prefix_expression): Update. * expop.h (class var_value_operation) <get_symbol>: New method. (class register_operation) <get_name>: New method. (class equal_operation): No longer a typedef, now a subclass. (class unop_memval_operation) <get_type>: New method. (class assign_operation) <get_lhs>: New method. (class unop_cast_operation) <get_type>: New method. * eval.c (evaluate_expression, evaluate_type) (evaluate_subexpression_type): Update. (fetch_subexp_value): Add "op" parameter. (parse_and_eval_type): Update. * dtrace-probe.c (dtrace_probe::compile_to_ax): Update. * breakpoint.c (update_watchpoint, watchpoint_check) (watchpoint_exp_is_const, watch_command_1): Update. * ax-gdb.c (gen_trace_for_expr, gen_eval_for_expr, gen_printf): Update.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 884a008..68386f1 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -50,6 +50,7 @@
#include "user-regs.h"
#include <algorithm>
#include "gdbsupport/gdb_optional.h"
+#include "c-exp.h"
/* Standard set of definitions for printing, dumping, prefixifying,
* and evaluating expressions. */
@@ -1073,7 +1074,6 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
expr_completion_state *cstate)
{
const struct language_defn *lang = NULL;
- int subexp;
if (*stringptr == 0 || **stringptr == 0)
error_no_arg (_("expression to compute"));
@@ -1153,7 +1153,8 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
/* If parsing for completion, allow this to succeed; but if no
expression elements have been written, then there's nothing
to do, so fail. */
- if (! ps.parse_completion || ps.expout_ptr == 0)
+ if (! ps.parse_completion
+ || (ps.expout->op == nullptr && ps.expout_ptr == 0))
throw;
}
@@ -1168,12 +1169,17 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
dump_raw_expression (result.get (), gdb_stdlog,
"before conversion to prefix form");
- subexp = prefixify_expression (result.get (),
- ps.m_completion_state.expout_last_struct);
- if (out_subexp)
- *out_subexp = subexp;
+ if (result->op == nullptr)
+ {
+ int subexp = prefixify_expression (result.get (),
+ ps.m_completion_state.expout_last_struct);
+ if (out_subexp)
+ *out_subexp = subexp;
- lang->post_parser (&result, &ps);
+ lang->post_parser (&result, &ps);
+ }
+ else
+ result->op->set_outermost ();
if (expressiondebug)
dump_prefix_expression (result.get (), gdb_stdlog);
@@ -1441,6 +1447,9 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile)
{
gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
+ if (exp->op != nullptr)
+ return exp->op->uses_objfile (objfile);
+
return exp_iterate (exp, exp_uses_objfile_iter, objfile);
}