From 06dc61b9dfe5f76740b46be8f6e61ea699268fb1 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Introduce objc_nsstring_operation This adds class objc_nsstring_operation, which implements OP_OBJC_NSSTRING. gdb/ChangeLog 2021-03-08 Tom Tromey * eval.c: Include c-exp.h. * c-exp.h (class objc_nsstring_operation): New. --- gdb/ChangeLog | 5 +++++ gdb/c-exp.h | 22 ++++++++++++++++++++++ gdb/eval.c | 1 + 3 files changed, 28 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5dd766606bb..2b7afb1dd68 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * eval.c: Include c-exp.h. + * c-exp.h (class objc_nsstring_operation): New. + 2021-03-08 Tom Tromey * c-lang.c (c_string_operation::evaluate): New method. diff --git a/gdb/c-exp.h b/gdb/c-exp.h index 5558a773e98..a7b11b5a25d 100644 --- a/gdb/c-exp.h +++ b/gdb/c-exp.h @@ -21,6 +21,7 @@ #define C_EXP_H #include "expop.h" +#include "objc-lang.h" namespace expr { @@ -41,6 +42,27 @@ public: { return OP_STRING; } }; +class objc_nsstring_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 + { + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + const std::string &str = std::get<0> (m_storage); + return value_nsstring (exp->gdbarch, str.c_str (), str.size () + 1); + } + + enum exp_opcode opcode () const override + { return OP_OBJC_NSSTRING; } +}; + }/* namespace expr */ #endif /* C_EXP_H */ diff --git a/gdb/eval.c b/gdb/eval.c index c667925b1bf..f1553dadbdb 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -41,6 +41,7 @@ #include "typeprint.h" #include #include "expop.h" +#include "c-exp.h" /* Prototypes for local functions. */ -- 2.30.2