diff options
author | Joel Brobecker <brobecker@gnat.com> | 2010-11-03 23:20:13 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2010-11-03 23:20:13 +0000 |
commit | 75be741bdf0c664773f0cb0668a401887ee7706d (patch) | |
tree | 58a66d5ee9d6037bd5bc743e16ec91681c045e85 | |
parent | ee7f4c692b90f6db605fb5f322f522bcb2927218 (diff) | |
download | gdb-75be741bdf0c664773f0cb0668a401887ee7706d.zip gdb-75be741bdf0c664773f0cb0668a401887ee7706d.tar.gz gdb-75be741bdf0c664773f0cb0668a401887ee7706d.tar.bz2 |
[Ada] fix warning when printing empty array
This patch should fix the following regression:
(gdb) print my_table
-$1 = ()
-(gdb) PASS: gdb.ada/null_array.exp: print my_table
+$1 = (warning: unable to get bounds of array, assuming null array
+)
+(gdb) FAIL: gdb.ada/null_array.exp: print my_table
The problem was introduced by a change in val_print_array_elements
which removed a check for the case where the array's high bound
is smaller than the array's low bound (empty array).
This change restores the check and forces the len to zero in that case.
Looking at the patch that caused the regression, I suspect that we may
have other parts that might have been broken (non-zero array low bound?).
gdb/ChangeLog:
* valprint.c (val_print_array_elements): Put back handling of
empty arrays.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/valprint.c | 12 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 719582b..221868b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-11-03 Joel Brobecker <brobecker@adacore.com> + + * valprint.c (val_print_array_elements): Put back handling of + empty arrays. + 2010-11-03 Ken Werner <ken.werner@de.ibm.com> * dwarf2read.c (read_array_type): Read the DW_AT_byte_size from the diff --git a/gdb/valprint.c b/gdb/valprint.c index dba528b..ddb16e4 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1118,7 +1118,17 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr, index_type = TYPE_INDEX_TYPE (type); if (get_array_bounds (type, &low_bound, &high_bound)) - len = high_bound - low_bound + 1; + { + /* The array length should normally be HIGH_BOUND - LOW_BOUND + 1. + But we have to be a little extra careful, because some languages + such as Ada allow LOW_BOUND to be greater than HIGH_BOUND for + empty arrays. In that situation, the array length is just zero, + not negative! */ + if (low_bound > high_bound) + len = 0; + else + len = high_bound - low_bound + 1; + } else { warning (_("unable to get bounds of array, assuming null array")); |