aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-valprint.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2005-10-03 21:21:20 +0000
committerJoel Brobecker <brobecker@gnat.com>2005-10-03 21:21:20 +0000
commite79af960e264269f6719a008ca84c56487f2aec2 (patch)
tree328581511cb723c9ac15215a0e1adee8bc4f08bf /gdb/ada-valprint.c
parent043f5962ba69d000b6106d923792f4ce2fbb37b1 (diff)
downloadgdb-e79af960e264269f6719a008ca84c56487f2aec2.zip
gdb-e79af960e264269f6719a008ca84c56487f2aec2.tar.gz
gdb-e79af960e264269f6719a008ca84c56487f2aec2.tar.bz2
2005-10-03 Joel Brobecker <brobecker@adacore.com>
* language.h (language_defn): New field la_print_array_index. (LA_PRINT_ARRAY_INDEX): New macro. (default_print_array_index): Add declaration. * language.c (default_print_array_index): new function. (unknown_language): Add value for new field. (auto_language): Likewise. (local_language): Likewise. * ada-lang.c (ada_print_array_index): New function. (ada_language_defn): Add value for new field. * c-lang.c (c_language_defn): Likewise. (cpluc_language_defn): Likewise. (asm_language_defn): Likewise. (minimal_language_defn): Likewise. * f-lang.c (f_language_defn): Likewise. * jv-lang.c (java_language_defn): Likewise. * m2-lang.c (m2_language_defn): Likewise. * objc-lang.c (objc_language_defn): Likewise. * p-lang.c (pascal_language_defn): Likewise. * scm-lang.c (scm_language_defn): Likewise. * valprint.h (print_array_indexes_p): Add declaration. (get_array_low_bound): Add declaration. (maybe_print_array_index): Add declaration. * valprint.c (print_array_indexes): New static variable. (show_print_array_indexes): New function. (print_array_indexes_p): New function. (get_array_low_bound): New function. (maybe_print_array_index): New function. (val_print_array_elements): Print the index of each element if requested by the user. (_initialize_valprint): Add new array-indexes "set/show print" command. * ada-valprint.c (print_optional_low_bound): Replace extracted code by call to ada_get_array_low_bound_and_type(). Stop printing the low bound if indexes will be printed for all elements of the array. (val_print_packed_array_elements): Print the index of each element of the array if necessary.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r--gdb/ada-valprint.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 0fbb9c9..a02bf6e 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -86,21 +86,14 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
struct type *index_type;
long low_bound;
- index_type = TYPE_INDEX_TYPE (type);
- low_bound = 0;
-
- if (index_type == NULL)
+ if (print_array_indexes_p ())
return 0;
- if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
- {
- low_bound = TYPE_LOW_BOUND (index_type);
- if (low_bound > TYPE_HIGH_BOUND (index_type))
- return 0;
- index_type = TYPE_TARGET_TYPE (index_type);
- }
- else
+
+ if (!get_array_low_bound (type, &low_bound))
return 0;
+ index_type = TYPE_INDEX_TYPE (type);
+
switch (TYPE_CODE (index_type))
{
case TYPE_CODE_ENUM:
@@ -137,16 +130,18 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
unsigned int i;
unsigned int things_printed = 0;
unsigned len;
- struct type *elttype;
+ struct type *elttype, *index_type;
unsigned eltlen;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0);
struct value *mark = value_mark ();
+ LONGEST low = 0;
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
+ index_type = TYPE_INDEX_TYPE (type);
{
- LONGEST low, high;
+ LONGEST high;
if (get_discrete_bounds (TYPE_FIELD_TYPE (type, 0), &low, &high) < 0)
len = 1;
else
@@ -174,6 +169,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
}
}
wrap_here (n_spaces (2 + 2 * recurse));
+ maybe_print_array_index (index_type, i + low, stream, format, pretty);
i0 = i;
v0 = ada_value_primitive_packed_val (NULL, valaddr,
@@ -219,6 +215,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
fprintf_filtered (stream, ", ");
}
wrap_here (n_spaces (2 + 2 * recurse));
+ maybe_print_array_index (index_type, j + low,
+ stream, format, pretty);
}
val_print (elttype, value_contents (v0), 0, 0, stream, format,
0, recurse + 1, pretty);