aboutsummaryrefslogtreecommitdiff
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:11 -0700
commit68c757358fc3d41ec26b2159cdbcac4f757dc3a2 (patch)
treec6cead7b624835284c413f5838c67c6b0b78ac1f
parent020dbabe22262ee118c29c768d7b9d66b1c65e67 (diff)
downloadgdb-68c757358fc3d41ec26b2159cdbcac4f757dc3a2.zip
gdb-68c757358fc3d41ec26b2159cdbcac4f757dc3a2.tar.gz
gdb-68c757358fc3d41ec26b2159cdbcac4f757dc3a2.tar.bz2
Split out ada_atr_size
This splits OP_ATR_SIZE into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_atr_size): New function. (ada_evaluate_subexp): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-lang.c41
2 files changed, 31 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0afbe4f..2a20313 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * ada-lang.c (ada_atr_size): New function.
+ (ada_evaluate_subexp): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (ada_atr_tag): New function.
(ada_evaluate_subexp): Use it.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a1d990c..cfd85d3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10025,6 +10025,31 @@ ada_atr_tag (struct type *expect_type,
return ada_value_tag (arg1);
}
+/* A helper function for OP_ATR_SIZE. */
+
+static value *
+ada_atr_size (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1)
+{
+ struct type *type = value_type (arg1);
+
+ /* If the argument is a reference, then dereference its type, since
+ the user is really asking for the size of the actual object,
+ not the size of the pointer. */
+ if (type->code () == TYPE_CODE_REF)
+ type = TYPE_TARGET_TYPE (type);
+
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval);
+ else
+ return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
+ TARGET_CHAR_BIT * TYPE_LENGTH (type));
+}
+
/* Implement the evaluate_exp routine in the exp_descriptor structure
for the Ada language. */
@@ -10802,21 +10827,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
case OP_ATR_SIZE:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type = value_type (arg1);
-
- /* If the argument is a reference, then dereference its type, since
- the user is really asking for the size of the actual object,
- not the size of the pointer. */
- if (type->code () == TYPE_CODE_REF)
- type = TYPE_TARGET_TYPE (type);
-
- if (noside == EVAL_SKIP)
- goto nosideret;
- else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval);
- else
- return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
- TARGET_CHAR_BIT * TYPE_LENGTH (type));
+ return ada_atr_size (expect_type, exp, noside, op, arg1);
case OP_ATR_VAL:
evaluate_subexp (nullptr, exp, pos, EVAL_SKIP);