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:25 -0700 |
commit | 085734dd954dd2b3da9445dc517bfdb10f9ca117 (patch) | |
tree | 398e7c71d53b1ee5000c6f20a59ee16442d15c8d /gdb | |
parent | e82a5afcedd98a2ca9c1915bef2938c77e967959 (diff) | |
download | gdb-085734dd954dd2b3da9445dc517bfdb10f9ca117.zip gdb-085734dd954dd2b3da9445dc517bfdb10f9ca117.tar.gz gdb-085734dd954dd2b3da9445dc517bfdb10f9ca117.tar.bz2 |
Introduce objc_msgcall_operation
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/c-exp.h | 17 | ||||
-rw-r--r-- | gdb/eval.c | 39 |
3 files changed, 61 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f6680e..37fe24a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 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-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) diff --git a/gdb/c-exp.h b/gdb/c-exp.h index dcb4557..2d224c8 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<CORE_ADDR, operation_up, + std::vector<operation_up>> +{ +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 */ @@ -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<operation_up> &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, |