aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/ada-lang.c163
-rw-r--r--gdb/ada-lang.h2
-rw-r--r--gdb/ada-typeprint.c4
-rw-r--r--gdb/ada-valprint.c3
5 files changed, 138 insertions, 54 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1a74a3b..4f89bc9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
+2009-11-19 Jerome Guitton <guitton@adacore.com>
+
+ * ada-lang.c (packed_array_type): Rename to...
+ (constrained_packed_array_type): ...and update comment.
+ (decode_packed_array, decode_constrained_packed_array): Ditto.
+ (decode_packed_array_type, decode_constrained_packed_array_type):
+ Ditto.
+ (ada_is_constrained_packed_array_type): New function.
+ (ada_is_unconstrained_packed_array_type): New function.
+ (decode_packed_array_bitsize): New function, extracted from
+ decode_packed_array_type.
+ (ada_type_of_array): Add support for unconstrained packed arrays.
+ (ada_coerce_to_simple_array_ptr, ada_coerce_to_simple_array)
+ (ada_array_bound_from_type, ada_array_bound, ada_array_length)
+ (ada_prefer_type, to_fixed_array_type, ada_evaluate_subexp): Resync.
+ * ada-lang.h (ada_is_packed_array_type,
+ ada_is_constrained_packed_array_type): Renaming.
+ * ada-valprint.c (ada_val_print_1): Resync.
+ * ada-typeprint.c (print_array_type, ada_print_type): Resync.
+
2009-11-19 Joel Brobecker <brobecker@adacore.com>
Wrong function used to perform address addition/subtraction.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 74336d8..6cea84e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -173,11 +173,17 @@ static struct type *static_unwrap_type (struct type *type);
static struct value *unwrap_value (struct value *);
-static struct type *packed_array_type (struct type *, long *);
+static struct type *constrained_packed_array_type (struct type *, long *);
-static struct type *decode_packed_array_type (struct type *);
+static struct type *decode_constrained_packed_array_type (struct type *);
-static struct value *decode_packed_array (struct value *);
+static long decode_packed_array_bitsize (struct type *);
+
+static struct value *decode_constrained_packed_array (struct value *);
+
+static int ada_is_packed_array_type (struct type *);
+
+static int ada_is_unconstrained_packed_array_type (struct type *);
static struct value *value_subscript_packed (struct value *, int,
struct value **);
@@ -1622,15 +1628,23 @@ ada_is_bogus_array_descriptor (struct type *type)
struct type *
ada_type_of_array (struct value *arr, int bounds)
{
- if (ada_is_packed_array_type (value_type (arr)))
- return decode_packed_array_type (value_type (arr));
+ if (ada_is_constrained_packed_array_type (value_type (arr)))
+ return decode_constrained_packed_array_type (value_type (arr));
if (!ada_is_array_descriptor_type (value_type (arr)))
return value_type (arr);
if (!bounds)
- return
- ada_check_typedef (desc_data_target_type (value_type (arr)));
+ {
+ struct type *array_type =
+ ada_check_typedef (desc_data_target_type (value_type (arr)));
+
+ if (ada_is_unconstrained_packed_array_type (value_type (arr)))
+ TYPE_FIELD_BITSIZE (array_type, 0) =
+ decode_packed_array_bitsize (value_type (arr));
+
+ return array_type;
+ }
else
{
struct type *elt_type;
@@ -1658,6 +1672,10 @@ ada_type_of_array (struct value *arr, int bounds)
longest_to_int (value_as_long (low)),
longest_to_int (value_as_long (high)));
elt_type = create_array_type (array_type, elt_type, range_type);
+
+ if (ada_is_unconstrained_packed_array_type (value_type (arr)))
+ TYPE_FIELD_BITSIZE (elt_type, 0) =
+ decode_packed_array_bitsize (value_type (arr));
}
return lookup_pointer_type (elt_type);
@@ -1679,8 +1697,8 @@ ada_coerce_to_simple_array_ptr (struct value *arr)
return NULL;
return value_cast (arrType, value_copy (desc_data (arr)));
}
- else if (ada_is_packed_array_type (value_type (arr)))
- return decode_packed_array (arr);
+ else if (ada_is_constrained_packed_array_type (value_type (arr)))
+ return decode_constrained_packed_array (arr);
else
return arr;
}
@@ -1700,8 +1718,8 @@ ada_coerce_to_simple_array (struct value *arr)
check_size (TYPE_TARGET_TYPE (value_type (arrVal)));
return value_ind (arrVal);
}
- else if (ada_is_packed_array_type (value_type (arr)))
- return decode_packed_array (arr);
+ else if (ada_is_constrained_packed_array_type (value_type (arr)))
+ return decode_constrained_packed_array (arr);
else
return arr;
}
@@ -1713,8 +1731,8 @@ ada_coerce_to_simple_array (struct value *arr)
struct type *
ada_coerce_to_simple_array_type (struct type *type)
{
- if (ada_is_packed_array_type (type))
- return decode_packed_array_type (type);
+ if (ada_is_constrained_packed_array_type (type))
+ return decode_constrained_packed_array_type (type);
if (ada_is_array_descriptor_type (type))
return ada_check_typedef (desc_data_target_type (type));
@@ -1724,8 +1742,8 @@ ada_coerce_to_simple_array_type (struct type *type)
/* Non-zero iff TYPE represents a standard GNAT packed-array type. */
-int
-ada_is_packed_array_type (struct type *type)
+static int
+ada_is_packed_array_type (struct type *type)
{
if (type == NULL)
return 0;
@@ -1736,6 +1754,54 @@ ada_is_packed_array_type (struct type *type)
&& strstr (ada_type_name (type), "___XP") != NULL;
}
+/* Non-zero iff TYPE represents a standard GNAT constrained
+ packed-array type. */
+
+int
+ada_is_constrained_packed_array_type (struct type *type)
+{
+ return ada_is_packed_array_type (type)
+ && !ada_is_array_descriptor_type (type);
+}
+
+/* Non-zero iff TYPE represents an array descriptor for a
+ unconstrained packed-array type. */
+
+static int
+ada_is_unconstrained_packed_array_type (struct type *type)
+{
+ return ada_is_packed_array_type (type)
+ && ada_is_array_descriptor_type (type);
+}
+
+/* Given that TYPE encodes a packed array type (constrained or unconstrained),
+ return the size of its elements in bits. */
+
+static long
+decode_packed_array_bitsize (struct type *type)
+{
+ char *raw_name = ada_type_name (ada_check_typedef (type));
+ char *tail;
+ long bits;
+
+ if (!raw_name)
+ raw_name = ada_type_name (desc_base_type (type));
+
+ if (!raw_name)
+ return 0;
+
+ tail = strstr (raw_name, "___XP");
+
+ if (sscanf (tail + sizeof ("___XP") - 1, "%ld", &bits) != 1)
+ {
+ lim_warning
+ (_("could not understand bit size information on packed array"));
+ return 0;
+ }
+
+ return bits;
+}
+
/* Given that TYPE is a standard GDB array type with all bounds filled
in, and that the element size of its ultimate scalar constituents
(that is, either its elements, or, if it is an array of arrays, its
@@ -1746,7 +1812,7 @@ ada_is_packed_array_type (struct type *type)
in bits. */
static struct type *
-packed_array_type (struct type *type, long *elt_bits)
+constrained_packed_array_type (struct type *type, long *elt_bits)
{
struct type *new_elt_type;
struct type *new_type;
@@ -1757,8 +1823,9 @@ packed_array_type (struct type *type, long *elt_bits)
return type;
new_type = alloc_type_copy (type);
- new_elt_type = packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
- elt_bits);
+ new_elt_type =
+ constrained_packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
+ elt_bits);
create_array_type (new_type, new_elt_type, TYPE_INDEX_TYPE (type));
TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits;
TYPE_NAME (new_type) = ada_type_name (type);
@@ -1779,10 +1846,11 @@ packed_array_type (struct type *type, long *elt_bits)
return new_type;
}
-/* The array type encoded by TYPE, where ada_is_packed_array_type (TYPE). */
+/* The array type encoded by TYPE, where
+ ada_is_constrained_packed_array_type (TYPE). */
static struct type *
-decode_packed_array_type (struct type *type)
+decode_constrained_packed_array_type (struct type *type)
{
struct symbol *sym;
struct block **blocks;
@@ -1821,24 +1889,18 @@ decode_packed_array_type (struct type *type)
return NULL;
}
- if (sscanf (tail + sizeof ("___XP") - 1, "%ld", &bits) != 1)
- {
- lim_warning
- (_("could not understand bit size information on packed array"));
- return NULL;
- }
-
- return packed_array_type (shadow_type, &bits);
+ bits = decode_packed_array_bitsize (type);
+ return constrained_packed_array_type (shadow_type, &bits);
}
-/* Given that ARR is a struct value *indicating a GNAT packed array,
- returns a simple array that denotes that array. Its type is a
+/* Given that ARR is a struct value *indicating a GNAT constrained packed
+ array, returns a simple array that denotes that array. Its type is a
standard GDB array type except that the BITSIZEs of the array
target types are set to the number of bits in each element, and the
type length is set appropriately. */
static struct value *
-decode_packed_array (struct value *arr)
+decode_constrained_packed_array (struct value *arr)
{
struct type *type;
@@ -1853,7 +1915,7 @@ decode_packed_array (struct value *arr)
if (TYPE_CODE (value_type (arr)) == TYPE_CODE_PTR)
arr = value_ind (arr);
- type = decode_packed_array_type (value_type (arr));
+ type = decode_constrained_packed_array_type (value_type (arr));
if (type == NULL)
{
error (_("can't unpack array"));
@@ -2486,8 +2548,8 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which)
gdb_assert (which == 0 || which == 1);
- if (ada_is_packed_array_type (arr_type))
- arr_type = decode_packed_array_type (arr_type);
+ if (ada_is_constrained_packed_array_type (arr_type))
+ arr_type = decode_constrained_packed_array_type (arr_type);
if (arr_type == NULL || !ada_is_simple_array_type (arr_type))
return (LONGEST) - which;
@@ -2536,8 +2598,8 @@ ada_array_bound (struct value *arr, int n, int which)
{
struct type *arr_type = value_type (arr);
- if (ada_is_packed_array_type (arr_type))
- return ada_array_bound (decode_packed_array (arr), n, which);
+ if (ada_is_constrained_packed_array_type (arr_type))
+ return ada_array_bound (decode_constrained_packed_array (arr), n, which);
else if (ada_is_simple_array_type (arr_type))
return ada_array_bound_from_type (arr_type, n, which);
else
@@ -2555,8 +2617,8 @@ ada_array_length (struct value *arr, int n)
{
struct type *arr_type = ada_check_typedef (value_type (arr));
- if (ada_is_packed_array_type (arr_type))
- return ada_array_length (decode_packed_array (arr), n);
+ if (ada_is_constrained_packed_array_type (arr_type))
+ return ada_array_length (decode_constrained_packed_array (arr), n);
if (ada_is_simple_array_type (arr_type))
return (ada_array_bound_from_type (arr_type, n, 1)
@@ -6586,7 +6648,7 @@ ada_prefer_type (struct type *type0, struct type *type1)
return 0;
else if (TYPE_NAME (type1) == NULL && TYPE_NAME (type0) != NULL)
return 1;
- else if (ada_is_packed_array_type (type0))
+ else if (ada_is_constrained_packed_array_type (type0))
return 1;
else if (ada_is_array_descriptor_type (type0)
&& !ada_is_array_descriptor_type (type1))
@@ -7158,14 +7220,14 @@ to_fixed_array_type (struct type *type0, struct value *dval,
{
struct type *index_type_desc;
struct type *result;
- int packed_array_p;
+ int constrained_packed_array_p;
if (TYPE_FIXED_INSTANCE (type0))
return type0;
- packed_array_p = ada_is_packed_array_type (type0);
- if (packed_array_p)
- type0 = decode_packed_array_type (type0);
+ constrained_packed_array_p = ada_is_constrained_packed_array_type (type0);
+ if (constrained_packed_array_p)
+ type0 = decode_constrained_packed_array_type (type0);
index_type_desc = ada_find_parallel_type (type0, "___XA");
if (index_type_desc == NULL)
@@ -7187,7 +7249,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
/* Make sure we always create a new array type when dealing with
packed array types, since we're going to fix-up the array
type length and element bitsize a little further down. */
- if (elt_type0 == elt_type && !packed_array_p)
+ if (elt_type0 == elt_type && !constrained_packed_array_p)
result = type0;
else
result = create_array_type (alloc_type_copy (type0),
@@ -7230,7 +7292,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
error (_("array type with dynamic size is larger than varsize-limit"));
}
- if (packed_array_p)
+ if (constrained_packed_array_p)
{
/* So far, the resulting type has been created as if the original
type was a regular (non-packed) array type. As a result, the
@@ -8842,7 +8904,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
goto nosideret;
}
- if (ada_is_packed_array_type (desc_base_type (value_type (argvec[0]))))
+ if (ada_is_constrained_packed_array_type
+ (desc_base_type (value_type (argvec[0]))))
argvec[0] = ada_coerce_to_simple_array (argvec[0]);
else if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_ARRAY
&& TYPE_FIELD_BITSIZE (value_type (argvec[0]), 0) != 0)
@@ -8955,7 +9018,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
TYPE_TARGET_TYPE (value_type (array)) =
ada_aligned_type (TYPE_TARGET_TYPE (value_type (array)));
- if (ada_is_packed_array_type (value_type (array)))
+ if (ada_is_constrained_packed_array_type (value_type (array)))
error (_("cannot slice a packed array"));
/* If this is a reference to an array or an array lvalue,
@@ -9120,7 +9183,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
{
arg1 = ada_coerce_ref (arg1);
- if (ada_is_packed_array_type (value_type (arg1)))
+ 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,
@@ -9175,8 +9238,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
{
LONGEST low, high;
- if (ada_is_packed_array_type (type_arg))
- type_arg = decode_packed_array_type (type_arg);
+ 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)
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 8a465d4..cf4bebc 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -243,7 +243,7 @@ extern struct type *ada_parent_type (struct type *);
extern int ada_is_ignored_field (struct type *, int);
-extern int ada_is_packed_array_type (struct type *);
+extern int ada_is_constrained_packed_array_type (struct type *);
extern struct value *ada_value_primitive_packed_val (struct value *,
const gdb_byte *,
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 9fabd68..fe902e2 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -352,7 +352,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
int bitsize;
int n_indices;
- if (ada_is_packed_array_type (type))
+ if (ada_is_constrained_packed_array_type (type))
type = ada_coerce_to_simple_array_type (type);
bitsize = 0;
@@ -770,7 +770,7 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
if (ada_is_aligner_type (type))
ada_print_type (ada_aligned_type (type), "", stream, show, level);
- else if (ada_is_packed_array_type (type))
+ else if (ada_is_constrained_packed_array_type (type))
{
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 565172c..5fb44b1 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -686,7 +686,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
type = ada_check_typedef (type);
- if (ada_is_array_descriptor_type (type) || ada_is_packed_array_type (type))
+ if (ada_is_array_descriptor_type (type)
+ || ada_is_constrained_packed_array_type (type))
{
int retn;
struct value *mark = value_mark ();