aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2010-06-03 06:50:49 +0000
committerPierre Muller <muller@sourceware.org>2010-06-03 06:50:49 +0000
commitdf1784511914208f03f111bc06e42ab3d75dcbd5 (patch)
tree1918a82ddd9b0bfd6a9b61c430f4f7e24a0060f2
parent416a7ddd02bd7e6e95c2275008d82a469ca0de1e (diff)
downloadfsf-binutils-gdb-df1784511914208f03f111bc06e42ab3d75dcbd5.zip
fsf-binutils-gdb-df1784511914208f03f111bc06e42ab3d75dcbd5.tar.gz
fsf-binutils-gdb-df1784511914208f03f111bc06e42ab3d75dcbd5.tar.bz2
* valprint.h (get_array_bounds): Change low and high parameter types
to LONGEST *. * valprint.c (get_array_bounds): Use get_discrete_bounds call to compute bounds. (val_print_array_elements): Adapt to change above. * ada-valprint.c (print_optional_low_bound): Adapt to change above. * p-valprint.c (pascal_val_print): Likewise.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/ada-valprint.c6
-rw-r--r--gdb/p-valprint.c2
-rw-r--r--gdb/valprint.c49
-rw-r--r--gdb/valprint.h4
5 files changed, 32 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dcb8214..e226bd1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2010-06-03 Pierre Muller <muller@ics.u-strasbg.fr>
+
+ * valprint.h (get_array_bounds): Change low and high parameter types
+ to LONGEST *.
+ * valprint.c (get_array_bounds): Use get_discrete_bounds call to
+ compute bounds.
+ (val_print_array_elements): Adapt to change above.
+ * ada-valprint.c (print_optional_low_bound): Adapt to change above.
+ * p-valprint.c (pascal_val_print): Likewise.
+
2010-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* symfile.c (init_filename_language_table): New extensions .for, .FOR,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index c56d221..7e93e3a 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -85,8 +85,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
const struct value_print_options *options)
{
struct type *index_type;
- long low_bound;
- long high_bound;
+ LONGEST low_bound;
+ LONGEST high_bound;
if (options->print_array_indexes)
return 0;
@@ -131,7 +131,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
break;
}
- ada_print_scalar (index_type, (LONGEST) low_bound, stream);
+ ada_print_scalar (index_type, low_bound, stream);
fprintf_filtered (stream, " => ");
return 1;
}
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 1c2f36d..e58f9d2 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -60,7 +60,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int i = 0; /* Number of characters printed */
unsigned len;
- long low_bound, high_bound;
+ LONGEST low_bound, high_bound;
struct type *elttype;
unsigned eltlen;
int length_pos, length_size, string_pos;
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 517e607..2b06579 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1034,44 +1034,27 @@ print_char_chars (struct ui_file *stream, struct type *type,
Return 1 if the operation was successful. Return zero otherwise,
in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified.
-
- Computing the array upper and lower bounds is pretty easy, but this
- function does some additional verifications before returning them.
- If something incorrect is detected, it is better to return a status
- rather than throwing an error, making it easier for the caller to
- implement an error-recovery plan. For instance, it may decide to
- warn the user that the bounds were not found and then use some
- default values instead. */
+
+ We now simply use get_discrete_bounds call to get the values
+ of the low and high bounds.
+ get_discrete_bounds can return three values:
+ 1, meaning that index is a range,
+ 0, meaning that index is a discrete type,
+ or -1 for failure. */
int
-get_array_bounds (struct type *type, long *low_bound, long *high_bound)
+get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
{
struct type *index = TYPE_INDEX_TYPE (type);
- long low = 0;
- long high = 0;
-
+ LONGEST low = 0;
+ LONGEST high = 0;
+ int res;
+
if (index == NULL)
return 0;
- if (TYPE_CODE (index) == TYPE_CODE_RANGE)
- {
- low = TYPE_LOW_BOUND (index);
- high = TYPE_HIGH_BOUND (index);
- }
- else if (TYPE_CODE (index) == TYPE_CODE_ENUM)
- {
- const int n_enums = TYPE_NFIELDS (index);
-
- low = TYPE_FIELD_BITPOS (index, 0);
- high = TYPE_FIELD_BITPOS (index, n_enums - 1);
- }
- else
- return 0;
-
- /* Abort if the lower bound is greater than the higher bound, except
- when low = high + 1. This is a very common idiom used in Ada when
- defining empty ranges (for instance "range 1 .. 0"). */
- if (low > high + 1)
+ res = get_discrete_bounds (index, &low, &high);
+ if (res == -1)
return 0;
if (low_bound)
@@ -1126,7 +1109,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
unsigned int rep1;
/* Number of repetitions we have detected so far. */
unsigned int reps;
- long low_bound_index = 0;
+ LONGEST low_bound_index = 0;
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
@@ -1141,7 +1124,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
len = TYPE_LENGTH (type) / eltlen;
else
{
- long low, hi;
+ LONGEST low, hi;
if (get_array_bounds (type, &low, &hi))
len = hi - low + 1;
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 9b8004e..070d796 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -109,8 +109,8 @@ extern void get_raw_print_options (struct value_print_options *opts);
extern void get_formatted_print_options (struct value_print_options *opts,
char format);
-extern int get_array_bounds (struct type *type, long *low_bound,
- long *high_bound);
+extern int get_array_bounds (struct type *type, LONGEST *low_bound,
+ LONGEST *high_bound);
extern void maybe_print_array_index (struct type *index_type, LONGEST index,
struct ui_file *stream,