diff options
author | Joel Brobecker <brobecker@adacore.com> | 2014-02-06 23:44:20 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2014-02-10 13:15:43 +0400 |
commit | aa4fb036e90f5c976f57cd08f2c024cb0fe24897 (patch) | |
tree | 60e0046ff631e59ebd0bef7cd86a68956fe4d617 /gdb/ada-lang.c | |
parent | 9dee8cc6aa668228309de7d0e23e1775beb7d12f (diff) | |
download | gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.zip gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.tar.gz gdb-aa4fb036e90f5c976f57cd08f2c024cb0fe24897.tar.bz2 |
Wrong type for 'Length result.
Consider the following code:
type Color is (Black, Red, Green, Blue, White);
type Primary_Table is array (Color range Red .. Blue) of Boolean;
Prim : Primary_Table := (True, False, False);
GDB prints the length of arrays in a fairly odd way:
(gdb) p prim'length
$2 = blue
The length returned should be an integer, not the array index type,
and this patch fixes this.
gdb/ChangeLog:
* ada-lang.c (ada_evaluate_subexp): Set the type of the value
returned by the 'Length attribute to integer.
testsuite/ChangeLog:
* gdb.ada/tick_length_array_enum_idx: New testcase.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a4accac..e69ed81 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10410,10 +10410,15 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, if (ada_is_constrained_packed_array_type (value_type (arg1))) arg1 = ada_coerce_to_simple_array (arg1); - type = ada_index_type (value_type (arg1), tem, - ada_attribute_name (op)); - if (type == NULL) + if (op == OP_ATR_LENGTH) type = builtin_type (exp->gdbarch)->builtin_int; + else + { + type = ada_index_type (value_type (arg1), tem, + ada_attribute_name (op)); + if (type == NULL) + type = builtin_type (exp->gdbarch)->builtin_int; + } if (noside == EVAL_AVOID_SIDE_EFFECTS) return allocate_value (type); @@ -10466,9 +10471,14 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, if (ada_is_constrained_packed_array_type (type_arg)) type_arg = decode_constrained_packed_array_type (type_arg); - type = ada_index_type (type_arg, tem, ada_attribute_name (op)); - if (type == NULL) + if (op == OP_ATR_LENGTH) type = builtin_type (exp->gdbarch)->builtin_int; + else + { + type = ada_index_type (type_arg, tem, ada_attribute_name (op)); + if (type == NULL) + type = builtin_type (exp->gdbarch)->builtin_int; + } if (noside == EVAL_AVOID_SIDE_EFFECTS) return allocate_value (type); |