diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:37 -0700 |
commit | 413403fc34156cf695b09553fca91e0990520787 (patch) | |
tree | bf463e2ea8f074b198caca43014951dca5253d5c /gdb/expop.h | |
parent | b0f9164cc6d738db3a71c1ea83aa6567f0387bca (diff) | |
download | gdb-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/expop.h')
-rw-r--r-- | gdb/expop.h | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/gdb/expop.h b/gdb/expop.h index 9a9c6bc..a719b0d 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -654,6 +654,12 @@ public: enum exp_opcode opcode () const override { return OP_VAR_VALUE; } + /* Return the symbol referenced by this object. */ + symbol *get_symbol () const + { + return std::get<0> (m_storage); + } + protected: void do_generate_ax (struct expression *exp, @@ -823,6 +829,12 @@ public: enum exp_opcode opcode () const override { return OP_REGISTER; } + /* Return the name of the register. */ + const char *get_name () const + { + return std::get<0> (m_storage).c_str (); + } + protected: void do_generate_ax (struct expression *exp, @@ -1329,7 +1341,24 @@ public: } }; -using equal_operation = comparison_operation<BINOP_EQUAL, eval_op_equal>; +class equal_operation + : public comparison_operation<BINOP_EQUAL, eval_op_equal> +{ +public: + + using comparison_operation::comparison_operation; + + operation *get_lhs () const + { + return std::get<0> (m_storage).get (); + } + + operation *get_rhs () const + { + return std::get<1> (m_storage).get (); + } +}; + using notequal_operation = comparison_operation<BINOP_NOTEQUAL, eval_op_notequal>; using less_operation = comparison_operation<BINOP_LESS, eval_op_less>; @@ -1759,6 +1788,12 @@ public: enum exp_opcode opcode () const override { return UNOP_MEMVAL; } + /* Return the type referenced by this object. */ + struct type *get_type () const + { + return std::get<1> (m_storage); + } + protected: void do_generate_ax (struct expression *exp, @@ -1884,6 +1919,12 @@ public: enum exp_opcode opcode () const override { return BINOP_ASSIGN; } + /* Return the left-hand-side of the assignment. */ + operation *get_lhs () const + { + return std::get<0> (m_storage).get (); + } + protected: void do_generate_ax (struct expression *exp, @@ -1942,6 +1983,12 @@ public: enum exp_opcode opcode () const override { return UNOP_CAST; } + /* Return the type referenced by this object. */ + struct type *get_type () const + { + return std::get<1> (m_storage); + } + protected: void do_generate_ax (struct expression *exp, |