[PATCH 006/203] Split out eval_op_string

Tom Tromey
2021-01-01T21:47:34Z

This splits OP_STRING into a new function for future use.

gdb/ChangeLog
2021-01-01 Tom Tromey <tom@tromey.com>

* eval.c (eval_op_string): New function.
(evaluate_subexp_standard): Use it.
---
gdb/ChangeLog | 5 +++++
gdb/eval.c | 17 +++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index cff323bba46..3bdc2094d49 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1272,6 +1272,17 @@ eval_op_register (struct type *expect_type, struct expression *exp,
return val;
}

+static struct value *
+eval_op_string (struct type *expect_type, struct expression *exp,
+ enum noside noside, int len, const char *string)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ struct type *type = language_string_char_type (exp->language_defn,
+ exp->gdbarch);
+ return value_string (string, len, type);
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1386,10 +1397,8 @@ evaluate_subexp_standard (struct type *expect_type,
case OP_STRING:
tem = longest_to_int (exp->elts[pc + 1].longconst);
(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- type = language_string_char_type (exp->language_defn, exp->gdbarch);
- return value_string (&exp->elts[pc + 2].string, tem, type);
+ return eval_op_string (expect_type, exp, noside, tem,
+ &exp->elts[pc + 2].string);

case OP_OBJC_NSSTRING: /* Objective C Foundation Class
NSString constant. */
--
2.26.2