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:27:58 -0700 |
commit | 14a1c64a139777db0c20c1017e5fecdf3b3db5ac (patch) | |
tree | d03c364f02d11e6737c7aab7f921b4600d91bd97 | |
parent | ffff730bf6a939490b5e93a323ba2e4026d27818 (diff) | |
download | binutils-14a1c64a139777db0c20c1017e5fecdf3b3db5ac.zip binutils-14a1c64a139777db0c20c1017e5fecdf3b3db5ac.tar.gz binutils-14a1c64a139777db0c20c1017e5fecdf3b3db5ac.tar.bz2 |
Split out eval_op_string
This splits OP_STRING into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_string): New function.
(evaluate_subexp_standard): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/eval.c | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9d50fe0..d2ee9d4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_string): New function. + (evaluate_subexp_standard): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_register): New function. (evaluate_subexp_standard): Use it. @@ -1281,6 +1281,19 @@ eval_op_register (struct type *expect_type, struct expression *exp, return val; } +/* Helper function that implements the body of OP_STRING. */ + +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, @@ -1395,10 +1408,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. */ |