aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
AgeCommit message (Collapse)AuthorFilesLines
2021-04-15Use block_symbol in var_value_operationTom Tromey1-11/+13
I noticed that var_value_operation takes a block and a symbol, and most callers destructure a block_symbol to pass in. It seems better for this class to simply hold a block_symbol instead. Tested on x86-64 Fedora 32. gdb/ChangeLog 2021-04-15 Tom Tromey <tromey@adacore.com> * rust-exp.y (rust_parser::convert_ast_to_expression): Update. * parse.c (parser_state::push_symbol, parser_state::push_dollar): Update. * p-exp.y (variable): Update. * m2-exp.y (variable): Update. * go-exp.y (variable): Update. * expprint.c (dump_for_expression): New overload. * expop.h (check_objfile): New overload. (check_constant): New overload. (class var_value_operation): Use block_symbol. <get_symbol>: Rewrite. * eval.c (var_value_operation::evaluate) (var_value_operation::evaluate_funcall) (var_value_operation::evaluate_for_address) (var_value_operation::evaluate_for_address) (var_value_operation::evaluate_with_coercion) (var_value_operation::evaluate_for_sizeof) (var_value_operation::evaluate_for_cast): Update. * d-exp.y (PrimaryExpression): Update. * c-exp.y (variable): Update. * ax-gdb.c (var_value_operation::do_generate_ax): Update. * ada-lang.c (ada_var_value_operation::evaluate_for_cast) (ada_var_value_operation::evaluate) (ada_var_value_operation::resolve) (ada_funcall_operation::resolve): Update. * ada-exp.y (write_var_from_sym, write_object_renaming) (write_ambiguous_var, write_var_or_type, write_name_assoc) (maybe_overload): Update. * ada-exp.h (class ada_var_value_operation) <get_block>: Rewrite.
2021-03-24gdb: remove current_top_target functionSimon Marchi1-2/+3
The current_top_target function is a hidden dependency on the current inferior. Since I'd like to slowly move towards reducing our dependency on the global current state, remove this function and make callers use current_inferior ()->top_target () There is no expected change in behavior, but this one step towards making those callers use the inferior from their context, rather than refer to the global current inferior. gdb/ChangeLog: * target.h (current_top_target): Remove, make callers use the current inferior instead. * target.c (current_top_target): Remove. Change-Id: Iccd457036f84466cdaa3865aa3f9339a24ea001d
2021-03-09Fix function call regression in new evaluatorTom Tromey1-1/+9
The internal AdaCore test suite revealed a bug in the new evaluator. A hunk of evaluate_funcall was not correctly transcribed. This was not caught in my original testing because the feature in question was apparently not tested in gdb. This patch fixes the oversight. The idea here is that ordinary function calls should use the function's formal parameter types as the expected types of subexpressions. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * eval.c (operation::evaluate_funcall): Use function formal parameter types when evaluating. gdb/testsuite/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * gdb.base/cast-call.exp: New file. * gdb.base/cast-call.c: New file.
2021-03-08Use bound_minimal_symbol in var_msym_value_operationTom Tromey1-14/+11
This changes var_msym_value_operation to use a bound_minimal_symbol rather than separate minsym and objfile parameters. The main benefit of this is removing the possibly-confusing check_objfile overload for a plain minimal symbol. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * parse.c (parser_state::push_symbol, parser_state::push_dollar): Update. * p-exp.y (variable): Update. * go-exp.y (variable): Update. * expprint.c (dump_for_expression): Use bound_minimal_symbol. Remove overload for objfile. * expop.h (eval_op_var_msym_value): Use bound_minimal_symbol parameter. (check_objfile): Likewise. (dump_for_expression): Likewise. Remove overload for objfile. (class var_msym_value_operation): Use bound_minimal_symbol. * eval.c (eval_op_var_msym_value): Use bound_minimal_symbol parameter. (var_msym_value_operation::evaluate_for_address) (var_msym_value_operation::evaluate_for_sizeof) (var_msym_value_operation::evaluate_for_cast): Update. * d-exp.y (PrimaryExpression): Update. * c-exp.y (variable): Update. * ax-gdb.c (var_msym_value_operation::do_generate_ax): Update. * ada-lang.c (ada_var_msym_value_operation::evaluate_for_cast): Update. * ada-exp.y (write_var_or_type): Update.
2021-03-08Remove EVAL_SKIPTom Tromey1-94/+9
EVAL_SKIP was needed in the old expression implementation due to its linearized tree structure. This is not needed in the new implementation, because it is trivial to not evaluate a subexpression. This patch removes the last vestiges of EVAL_SKIP. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * value.h (eval_skip_value): Don't declare. * opencl-lang.c (eval_opencl_assign): Update. * m2-lang.c (eval_op_m2_high, eval_op_m2_subscript): Update. * f-lang.c (eval_op_f_abs, eval_op_f_mod, eval_op_f_ceil) (eval_op_f_floor, eval_op_f_modulo, eval_op_f_cmplx): Remove. * expression.h (enum noside) <EVAL_SKIP>: Remove. * expop.h (typeof_operation::evaluate) (decltype_operation::evaluate, unop_addr_operation::evaluate) (unop_sizeof_operation::evaluate, assign_operation::evaluate) (cxx_cast_operation::evaluate): Update. * eval.c (eval_skip_value): Remove. (eval_op_scope, eval_op_var_entry_value) (eval_op_func_static_var, eval_op_string, eval_op_objc_selector) (eval_op_concat, eval_op_ternop, eval_op_structop_struct) (eval_op_structop_ptr, eval_op_member, eval_op_add, eval_op_sub) (eval_op_binary, eval_op_subscript, eval_op_equal) (eval_op_notequal, eval_op_less, eval_op_gtr, eval_op_geq) (eval_op_leq, eval_op_repeat, eval_op_plus, eval_op_neg) (eval_op_complement, eval_op_lognot, eval_op_ind) (eval_op_memval, eval_op_preinc, eval_op_predec) (eval_op_postinc, eval_op_postdec, eval_op_type) (eval_binop_assign_modify, eval_op_objc_msgcall) (eval_multi_subscript, logical_and_operation::evaluate) (logical_or_operation::evaluate, array_operation::evaluate) (operation::evaluate_for_cast) (var_msym_value_operation::evaluate_for_cast) (var_value_operation::evaluate_for_cast): Update. * c-lang.c (c_string_operation::evaluate): Update. * c-exp.h (objc_nsstring_operation::evaluate) (objc_selector_operation::evaluate): Update. * ada-lang.c (ada_assign_operation::evaluate) (eval_ternop_in_range, ada_unop_neg, ada_unop_in_range) (ada_atr_size): Update.
2021-03-08Merge namespace scopes in eval.cTom Tromey1-10/+0
The big deletion patch left some identical namespace scopes sitting next to one another. This patch removes the redundant "namespace expr"s. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c: Merge "namespace" scopes.
2021-03-08Remove union exp_elementTom Tromey1-1617/+7
This removes union exp_element functions that either create such elements or walk them. struct expression no longer holds exp_elements. A couple of language_defn methods are also removed, as they are obsolete. Note that this patch also removes the print_expression code. The only in-tree caller of this was from dump_prefix_expression, which is only called when expression debugging is enabled. Implementing this would involve a fair amount of code, and it seems to me that prefix dumping is preferable anyway, as it is unambiguous. So, I have not reimplemented this feature. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * value.h (evaluate_subexp_with_coercion): Don't declare. * parse.c (exp_descriptor_standard): Remove. (expr_builder::expr_builder, expr_builder::release): Update. (expression::expression): Remove size_t parameter. (expression::~expression): Simplify. (expression::resize): Remove. (write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym) (write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile) (write_exp_elt_longcst, write_exp_elt_floatcst) (write_exp_elt_type, write_exp_elt_intern, write_exp_string) (write_exp_string_vector, write_exp_bitstring): Remove. * p-lang.h (class pascal_language) <opcode_print_table, op_print_tab>: Remove. * p-lang.c (pascal_language::op_print_tab): Remove. * opencl-lang.c (class opencl_language) <opcode_print_table>: Remove. * objc-lang.c (objc_op_print_tab): Remove. (class objc_language) <opcode_print_table>: Remove. * m2-lang.h (class m2_language) <opcode_print_table, op_print_tab>: Remove. * m2-lang.c (m2_language::op_print_tab): Remove. * language.h (struct language_defn) <post_parser, expression_ops, opcode_print_table>: Remove. * language.c (language_defn::expression_ops) (auto_or_unknown_language::opcode_print_table): Remove. * go-lang.h (class go_language) <opcode_print_table, op_print_tab>: Remove. * go-lang.c (go_language::op_print_tab): Remove. * f-lang.h (class f_language) <opcode_print_table>: Remove <op_print_tab>: Remove. * f-lang.c (f_language::op_print_tab): Remove. * expression.h (union exp_element): Remove. (struct expression): Remove size_t parameter from constructor. <resize>: Remove. <first_opcode>: Update. <nelts, elts>: Remove. (EXP_ELEM_TO_BYTES, BYTES_TO_EXP_ELEM): Remove. (evaluate_subexp_standard, print_expression, op_string) (dump_raw_expression): Don't declare. * expprint.c (print_expression, print_subexp) (print_subexp_funcall, print_subexp_standard, op_string) (dump_raw_expression, dump_subexp, dump_subexp_body) (dump_subexp_body_funcall, dump_subexp_body_standard): Remove. (dump_prefix_expression): Update. * eval.c (evaluate_subexp): Remove. (evaluate_expression, evaluate_type): Update. (evaluate_subexpression_type): Remove. (fetch_subexp_value): Remove "pc" parameter. Update. (extract_field_op, evaluate_struct_tuple, evaluate_funcall) (evaluate_subexp_standard, evaluate_subexp_for_address) (evaluate_subexp_with_coercion, evaluate_subexp_for_sizeof) (evaluate_subexp_for_cast): Remove. (parse_and_eval_type): Update. * dtrace-probe.c (dtrace_probe::compile_to_ax): Update. * d-lang.c (d_op_print_tab): Remove. (class d_language) <opcode_print_table>: Remove. * c-lang.h (c_op_print_tab): Don't declare. * c-lang.c (c_op_print_tab): Remove. (class c_language, class cplus_language, class asm_language, class minimal_language) <opcode_print_table>: Remove. * breakpoint.c (update_watchpoint, watchpoint_check) (watchpoint_exp_is_const, watch_command_1): Update. * ax-gdb.h (union exp_element): Don't declare. * ax-gdb.c (const_var_ref, const_expr, maybe_const_expr) (gen_repeat, gen_sizeof, gen_expr_for_cast, gen_expr) (gen_expr_binop_rest): Remove. (gen_trace_for_expr, gen_eval_for_expr, gen_printf): Update. * ada-lang.c (ada_op_print_tab): Remove. (class ada_language) <post_parser, opcode_print_table>: Remove.
2021-03-08Add an expr::operation_up to struct expressionTom Tromey1-5/+25
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.
2021-03-08Implement function call operationsTom Tromey1-0/+280
This implement function call operations. The current function call code relies on some very lengthy code (evaluate_funcall is 398 lines...) to distinguish between the different opcodes that might appear in the callee position. Rather than try to replicate this, and have a function that tried to dissect many different kinds of operation subclass, this patch instead puts the work into the callee. A new operation::evaluate_funcall method is added, and then this is overridden in the classes that require special treatment. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expression.h (class operation) <evaluate_funcall>: New methods. * expop.h (class scope_operation) <evaluate_funcall>: New method. (class var_value_operation) <evaluate_funcall>: New method. (class structop_base_operation) <evaluate_funcall>: New method. (class var_msym_value_operation) <evaluate_funcall>: New method. (class structop_member_base): New class. (class structop_member_operation): Derive from structop_member_base. (class structop_mptr_operation): Derive from structop_member_base. (class funcall_operation): New class. * eval.c (operation::evaluate_funcall) (var_value_operation::evaluate_funcall) (scope_operation::evaluate_funcall) (structop_member_base::evaluate_funcall) (structop_base_operation::evaluate_funcall): New methods.
2021-03-08Introduce array_operationTom Tromey1-0/+200
This adds class array_operation, which implements OP_ARRAY. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class array_operation): New. * eval.c (array_operation::evaluate_struct_tuple) (array_operation::evaluate): New methods.
2021-03-08Introduce class adl_func_operationTom Tromey1-0/+23
This adds class adl_func_operation, which implements argument-dependent lookup function calls. Other function calls will be handled in a different way. However, because ADL calls were created in a single spot in the C++ parser, and because they had different semantics from the other cases, it was convenient to treat them specially. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class adl_func_operation): New. * eval.c (adl_func_operation::evaluate): New method.
2021-03-08Implement the "&&" and "||" operatorsTom Tromey1-0/+63
This implements the "&&" and "||" operators. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class logical_and_operation) (class logical_or_operation): New. * eval.c (logical_and_operation::evaluate) (logical_or_operation::evaluate): New methods. * ax-gdb.c (logical_and_operation::do_generate_ax) (logical_or_operation::do_generate_ax): New methods.
2021-03-08Introduce multi_subscript_operationTom Tromey1-0/+13
This adds class multi_subscript_operation, which implements MULTI_SUBSCRIPT. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class multi_subscript_operation): New. * eval.c (multi_subscript_operation::evaluate): New method.
2021-03-08Introduce objc_msgcall_operationTom Tromey1-0/+39
This adds class objc_msgcall_operation, which implements OP_OBJC_MSGCALL. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (objc_msgcall_operation::evaluate): New method. * c-exp.h (class objc_msgcall_operation): New.
2021-03-08Introduce var_value_operationTom Tromey1-0/+112
This adds class var_value_operation, which implements OP_VAR_VALUE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class var_value_operation): New. * eval.c (var_value_operation::evaluate) (var_value_operation::evaluate_for_address) (var_value_operation::evaluate_with_coercion) (var_value_operation::evaluate_for_sizeof) (var_value_operation::evaluate_for_cast): New methods. * ax-gdb.c (var_value_operation::do_generate_ax): New method.
2021-03-08Introduce assign_modify_operationTom Tromey1-1/+1
This adds class assign_modify_operation, which implements BINOP_ASSIGN_MODIFY. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class assign_modify_operation): New. * eval.c (eval_binop_assign_modify): No longer static. * ax-gdb.c (assign_modify_operation::do_generate_ax): New method.
2021-03-08Introduce type_instance_operationTom Tromey1-0/+18
This adds class type_instance_operation, which implements TYPE_INSTANCE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class type_instance_operation): New. * eval.c (type_instance_operation::evaluate): New method.
2021-03-08Implement UNOP_MEMVAL and UNOP_MEMVAL_TYPETom Tromey1-1/+36
This adds class unop_memval_operation and unop_memval_type_operation, which implement UNOP_MEMVAL and UNOP_MEMVAL_TYPE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_memval_operation) (class unop_memval_type_operation): New. * eval.c (eval_op_memval): No longer static. (unop_memval_operation::evaluate_for_address) (unop_memval_type_operation::evaluate_for_address) (unop_memval_operation::evaluate_for_sizeof) (unop_memval_type_operation::evaluate_for_sizeof): New methods. * ax-gdb.c (unop_memval_operation::do_generate_ax) (unop_memval_type_operation::do_generate_ax): New methods.
2021-03-08Introduce unop_alignof_operationTom Tromey1-1/+1
This adds class unop_alignof_operation, which implements UNOP_ALIGNOF. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_alignof_operation): New. * eval.c (eval_op_alignof): No longer static.
2021-03-08Introduce type_operationTom Tromey1-1/+1
This adds class type_operation, which implements OP_TYPE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class type_operation): New. * eval.c (eval_op_type): No longer static.
2021-03-08Introduce unop_ind_operationTom Tromey1-5/+40
This adds class unop_ind_operation, which implements UNOP_IND. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_ind_base_operation) (class unop_ind_operation): New. * eval.c (eval_op_ind): No longer static. Remove "op" parameter. (unop_ind_base_operation::evaluate_for_address) (unop_ind_base_operation::evaluate_for_sizeof): New method. * ax-gdb.c (gen_expr_unop) <case UNOP_IND>: New.
2021-03-08Implement unary increment and decrement operationsTom Tromey1-4/+4
This implements the unary increment and decrement operations, "++" and "--". gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (unop_incr_operation): New template. (preinc_operation, predec_operation, postinc_operation) (postdec_operation): New typedefs. * eval.c (eval_op_preinc, eval_op_predec, eval_op_postinc) (eval_op_postdec): No longer static.
2021-03-08Implement some unary operationsTom Tromey1-4/+4
This introduces a couple of new template classes and then uses them to implement some simple unary operations. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (unary_ftype): New typedef. (unop_operation, usual_ax_binop_operation): New templates. (unary_plus_operation, unary_neg_operation) (unary_complement_operation, unary_logical_not_operation): New typedefs. * eval.c (eval_op_plus, eval_op_neg, eval_op_complement) (eval_op_lognot): No longer static. * ax-gdb.c (gen_expr_unop): New function.
2021-03-08Introduce repeat_operationTom Tromey1-3/+3
This adds class repeat_operation, which implements BINOP_REPEAT. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class repeat_operation): New. * eval.c (eval_op_repeat): No longer static. Remove "op" parameter. (evaluate_subexp_standard): Update. * ax-gdb.c (repeat_operation::do_generate_ax): New method.
2021-03-08Implement binary comparison operationsTom Tromey1-6/+6
This implements the binary comparison operations via a template class. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class comparison_operation): New. (equal_operation, notequal_operation, less_operation) (gtr_operation, geq_operation, leq_operation): New typedefs. * eval.c (eval_op_equal, eval_op_notequal, eval_op_less) (eval_op_gtr, eval_op_geq, eval_op_leq): No longer static.
2021-03-08Introduce subscript_operationTom Tromey1-1/+34
This adds class subscript_operation, which implements BINOP_SUBSCRIPT. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class subscript_operation): New. * eval.c (eval_op_subscript): No longer static.
2021-03-08Introduce binop_operationTom Tromey1-1/+1
This adds two new template classes, binop_operation and usual_ax_binop_operation, and then uses these to implement a number of binary operations that follow similar patterns. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class binop_operation, class usual_ax_binop_operation): New. (exp_operation, intdiv_operation, mod_operation, mul_operation) (div_operation, rem_operation, lsh_operation, rsh_operation) (bitwise_and_operation, bitwise_ior_operation) (bitwise_xor_operation): New typedefs. * eval.c (eval_op_binary): No longer static.
2021-03-08Introduce sub_operationTom Tromey1-5/+5
This adds class sub_operation, which implements BINOP_SUB. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class sub_operation): New. * eval.c (eval_op_sub): No longer static. Remove "op" parameter. (evaluate_subexp_standard): Update.
2021-03-08Introduce add_operationTom Tromey1-5/+5
This adds class add_operation, which implements BINOP_ADD. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class add_operation): New. * eval.c (eval_op_add): No longer static. Remove "op" parameter. (evaluate_subexp_standard): Update.
2021-03-08Introduce concat_operationTom Tromey1-6/+5
This adds class concat_operation, which implements BINOP_CONCAT. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class concat_operation): New. * eval.c (eval_op_concat): No longer static. Remove "op" parameter. (evaluate_subexp_standard): Update.
2021-03-08Introduce structop_member_operation and structop_mptr_operationTom Tromey1-1/+1
This adds class structop_member_operation and structop_mptr_operation, which implement STRUCTOP_MEMBER and STRUCTOP_MPTR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class structop_member_operation) (class structop_mptr_operation): New. * eval.c (eval_op_member): No longer static.
2021-03-08Introduce structop_ptr_operationTom Tromey1-5/+5
This adds class structop_ptr_operation, which implements STRUCTOP_PTR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class structop_ptr_operation): New. * eval.c (eval_op_structop_ptr): No longer static. Remove "op" parameter.
2021-03-08Introduce structop_operationTom Tromey1-1/+1
This adds class structop_base_operation and structop_operation, which implement STRUCTOP_STRUCT. The base class exists to unify the completion code between STRUCTOP_STRUCT and STRUCTOP_PTR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class structop_base_operation) (class structop_operation): New. * eval.c (eval_op_structop_struct): No longer static.
2021-03-08Introduce objc_selector_operationTom Tromey1-1/+1
This adds class objc_selector_operation, which implements OP_OBJC_SELECTOR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_objc_selector): No longer static. * c-exp.h (class objc_selector_operation): New.
2021-03-08Introduce objc_nsstring_operationTom Tromey1-0/+1
This adds class objc_nsstring_operation, which implements OP_OBJC_NSSTRING. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c: Include c-exp.h. * c-exp.h (class objc_nsstring_operation): New.
2021-03-08Introduce ternop_slice_operationTom Tromey1-1/+1
This adds class ternop_slice_operation, which implements TERNOP_SLICE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class ternop_slice_operation): New. * eval.c (eval_op_ternop): No longer static.
2021-03-08Introduce string_operationTom Tromey1-1/+1
This adds string_operation, which implements OP_STRING for most languages (C has its own variant). gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class string_operation): New. * eval.c (eval_op_string): No longer static.
2021-03-08Introduce register_operationTom Tromey1-1/+1
This adds class register_operation, which implements OP_REGISTER. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class register_operation): New. * eval.c (eval_op_register): No longer static. * ax-gdb.c (register_operation::do_generate_ax): New method.
2021-03-08Introduce func_static_var_operationTom Tromey1-1/+1
This adds class func_static_var_operation, which implements OP_FUNC_STATIC_VAR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class func_static_var_operation): New. * eval.c (eval_op_func_static_var): No longer static.
2021-03-08Introduce var_entry_value_operationTom Tromey1-1/+1
This adds class var_entry_value_operation, which implements OP_VAR_ENTRY_VALUE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class var_entry_value_operation): New. * eval.c (eval_op_var_entry_value): No longer static.
2021-03-08Introduce var_msym_value_operationTom Tromey1-1/+68
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 <tom@tromey.com> * expression.h (class operation) <set_outermost>: 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.
2021-03-08Introduce scope_operationTom Tromey1-1/+13
This adds class scope_operation, an implementation of OP_SCOPE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class scope_operation): New. * eval.c (eval_op_scope): No longer static. (scope_operation::evaluate_for_address): New method. * ax-gdb.c (scope_operation::do_generate_ax): New method.
2021-03-08Introduce class operationTom Tromey1-0/+36
This patch introduces class operation, the new base class for all expression operations. In the new approach, an operation is simply a class that presents a certain interface. Operations own their operands, and management is done via unique_ptr. The operation interface is largely ad hoc, based on the evolution of expression handling in GDB. Parts (for example, evaluate_with_coercion) are probably redundant; however I took this approach to try to avoid mixing different kinds of refactorings. In some specific situations, rather than add a generic method across the entire operation class hierarchy, I chose instead to use dynamic_cast and specialized methods on certain concrete subclasses. This will appear in some subsequent patches. One goal of this work is to avoid the kinds of easy-to-make errors that affected the old implementation. To this end, some helper subclasses are also added here. These helpers automate the implementation of the 'dump', 'uses_objfile', and 'constant_p' methods. Nearly every concrete operation that is subsequently added will use these facilities. (Note that the 'dump' implementation is only outlined here, the body appears in the next patch.) gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expression.h (expr::operation): New class. (expr::make_operation): New function. (expr::operation_up): New typedef. * expop.h: New file. * eval.c (operation::evaluate_for_cast) (operation::evaluate_for_address, operation::evaluate_for_sizeof): New methods. * ax-gdb.c (operation::generate_ax): New method.
2021-03-08Split out eval_multi_subscriptTom Tromey1-33/+42
This splits MULTI_SUBSCRIPT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_multi_subscript): New function. (evaluate_subexp_standard): Use it.
2021-03-08Split out eval_op_objc_msgcallTom Tromey1-249/+281
This splits OP_OBJC_MSGCALL into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_objc_msgcall): New function. (evaluate_subexp_standard): Use it.
2021-03-08Split out eval_binop_assign_modifyTom Tromey1-27/+38
This splits BINOP_ASSIGN_MODIFY into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_binop_assign_modify): New function. (evaluate_subexp_standard): Use it.
2021-03-08Split helper functionsTom Tromey1-23/+42
This splits a couple of address-of and sizeof functions, so that the body can be reused by the (coming) new expression code. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (evaluate_subexp_for_address_base): New function. (evaluate_subexp_for_address): Use it. (evaluate_subexp_for_sizeof_base): New function. (evaluate_subexp_for_sizeof): Use it.
2021-03-08Split out eval_op_typeTom Tromey1-6/+15
This splits OP_TYPE into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_type): New function. (evaluate_subexp_standard): Use it.
2021-03-08Split out eval_op_postdecTom Tromey1-25/+35
This splits UNOP_POSTDECREMENT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_postdec): New function. (evaluate_subexp_standard): Use it.
2021-03-08Split out eval_op_postincTom Tromey1-24/+35
This splits UNOP_POSTINCREMENT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_postinc): New function. (evaluate_subexp_standard): Use it.