From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Introduce objc_msgcall_operation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=085734dd954dd2b3da9445dc517bfdb10f9ca117;p=binutils-gdb.git Introduce objc_msgcall_operation This adds class objc_msgcall_operation, which implements OP_OBJC_MSGCALL. gdb/ChangeLog 2021-03-08 Tom Tromey * eval.c (objc_msgcall_operation::evaluate): New method. * c-exp.h (class objc_msgcall_operation): New. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f6680ee230..37fe24a89ca 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * eval.c (objc_msgcall_operation::evaluate): New method. + * c-exp.h (class objc_msgcall_operation): New. + 2021-03-08 Tom Tromey * expop.h (class var_value_operation): New. diff --git a/gdb/c-exp.h b/gdb/c-exp.h index dcb4557b2d5..2d224c8c633 100644 --- a/gdb/c-exp.h +++ b/gdb/c-exp.h @@ -88,6 +88,23 @@ public: { return OP_OBJC_SELECTOR; } }; +/* An Objective C message call. */ +class objc_msgcall_operation + : public tuple_holding_operation> +{ +public: + + using tuple_holding_operation::tuple_holding_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override; + + enum exp_opcode opcode () const override + { return OP_OBJC_MSGCALL; } +}; + }/* namespace expr */ #endif /* C_EXP_H */ diff --git a/gdb/eval.c b/gdb/eval.c index 9d3b5ae8762..91965179a14 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2436,6 +2436,45 @@ eval_multi_subscript (struct type *expect_type, struct expression *exp, return (arg1); } +namespace expr +{ + +value * +objc_msgcall_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) +{ + enum noside sub_no_side = EVAL_NORMAL; + struct type *selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr; + + if (noside == EVAL_AVOID_SIDE_EFFECTS) + sub_no_side = EVAL_NORMAL; + else + sub_no_side = noside; + value *target + = std::get<1> (m_storage)->evaluate (selector_type, exp, sub_no_side); + + if (value_as_long (target) == 0) + sub_no_side = EVAL_AVOID_SIDE_EFFECTS; + else + sub_no_side = noside; + std::vector &args = std::get<2> (m_storage); + value **argvec = XALLOCAVEC (struct value *, args.size () + 3); + argvec[0] = nullptr; + argvec[1] = nullptr; + for (int i = 0; i < args.size (); ++i) + argvec[i + 2] = args[i]->evaluate_with_coercion (exp, sub_no_side); + argvec[args.size () + 2] = nullptr; + + return eval_op_objc_msgcall (expect_type, exp, noside, std:: + get<0> (m_storage), target, + gdb::make_array_view (argvec, + args.size () + 3)); +} + +} + + struct value * evaluate_subexp_standard (struct type *expect_type, struct expression *exp, int *pos,