[binutils-gdb] Introduce objc_nsstring_operation

Tom Tromey tromey@sourceware.org
Mon Mar 8 14:52:57 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=06dc61b9dfe5f76740b46be8f6e61ea699268fb1

commit 06dc61b9dfe5f76740b46be8f6e61ea699268fb1
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Mar 8 07:27:57 2021 -0700

    Introduce objc_nsstring_operation
    
    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.

Diff:
---
 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  <tom@tromey.com>
+
+	* eval.c: Include c-exp.h.
+	* c-exp.h (class objc_nsstring_operation): New.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
 	* 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<std::string>
+{
+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 <ctype.h>
 #include "expop.h"
+#include "c-exp.h"
 
 /* Prototypes for local functions.  */


More information about the Gdb-cvs mailing list