From 0c8effa32e9326ca80f3e7cd74635e1dc44b3db5 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: Introduce var_msym_value_operation This adds class var_msym_value_operation, which implements OP_VAR_MSYM_VALUE. A new method is added to class operation in order to support a special case in minsym evaluation. gdb/ChangeLog 2021-03-08 Tom Tromey * expression.h (class operation) : New method. * expop.h (class var_msym_value_operation): New. * eval.c (eval_op_var_msym_value): No longer static. (var_msym_value_operation::evaluate_for_address) (var_msym_value_operation::evaluate_for_sizeof) (var_msym_value_operation::evaluate_for_cast): New methods. * ax-gdb.c (var_msym_value_operation::do_generate_ax): New method. --- gdb/expop.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'gdb/expop.h') diff --git a/gdb/expop.h b/gdb/expop.h index ed883be..345cac2 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -45,6 +45,12 @@ extern struct value *eval_op_scope (struct type *expect_type, struct expression *exp, enum noside noside, struct type *type, const char *string); +extern struct value *eval_op_var_msym_value (struct type *expect_type, + struct expression *exp, + enum noside noside, + bool outermost_p, + minimal_symbol *msymbol, + struct objfile *objfile); namespace expr { @@ -481,6 +487,52 @@ protected: override; }; +class var_msym_value_operation + : public maybe_constant_operation +{ +public: + + using maybe_constant_operation::maybe_constant_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + return eval_op_var_msym_value (expect_type, exp, noside, m_outermost, + std::get<0> (m_storage), + std::get<1> (m_storage)); + } + + value *evaluate_for_sizeof (struct expression *exp, enum noside noside) + override; + + value *evaluate_for_address (struct expression *exp, enum noside noside) + override; + + value *evaluate_for_cast (struct type *expect_type, + struct expression *exp, + enum noside noside) override; + + enum exp_opcode opcode () const override + { return OP_VAR_MSYM_VALUE; } + + void set_outermost () override + { + m_outermost = true; + } + +protected: + + /* True if this is the outermost operation in the expression. */ + bool m_outermost = false; + + void do_generate_ax (struct expression *exp, + struct agent_expr *ax, + struct axs_value *value, + struct type *cast_type) + override; +}; + } /* namespace expr */ #endif /* EXPOP_H */ -- cgit v1.1