aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:16 -0700
commitb50db09ff9c0a5d2220e73ddcff3a05e2e887b0e (patch)
tree4838f121ae33a1850b63ed9b8f4685372ca9613b /gdb
parente6e01e16c547b21be2e3fc6b0783492aea98c427 (diff)
downloadgdb-b50db09ff9c0a5d2220e73ddcff3a05e2e887b0e.zip
gdb-b50db09ff9c0a5d2220e73ddcff3a05e2e887b0e.tar.gz
gdb-b50db09ff9c0a5d2220e73ddcff3a05e2e887b0e.tar.bz2
Introduce string_operation
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c2
-rw-r--r--gdb/expop.h24
3 files changed, 30 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 05f67b8..ddf9342 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * expop.h (class string_operation): New.
+ * eval.c (eval_op_string): No longer static.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* expop.h (class internalvar_operation): New.
* ax-gdb.c (internalvar_operation::do_generate_ax): New method.
diff --git a/gdb/eval.c b/gdb/eval.c
index 4601c92..e68a93d 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1284,7 +1284,7 @@ eval_op_register (struct type *expect_type, struct expression *exp,
/* Helper function that implements the body of OP_STRING. */
-static struct value *
+struct value *
eval_op_string (struct type *expect_type, struct expression *exp,
enum noside noside, int len, const char *string)
{
diff --git a/gdb/expop.h b/gdb/expop.h
index d143815..802be81 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -61,6 +61,10 @@ extern struct value *eval_op_func_static_var (struct type *expect_type,
extern struct value *eval_op_register (struct type *expect_type,
struct expression *exp,
enum noside noside, const char *name);
+extern struct value *eval_op_string (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, int len,
+ const char *string);
namespace expr
{
@@ -681,6 +685,26 @@ protected:
override;
};
+class string_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
+ {
+ const std::string &str = std::get<0> (m_storage);
+ return eval_op_string (expect_type, exp, noside,
+ str.size (), str.c_str ());
+ }
+
+ enum exp_opcode opcode () const override
+ { return OP_STRING; }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */