diff options
author | Per Bothner <per@bothner.com> | 1995-10-05 01:09:53 +0000 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 1995-10-05 01:09:53 +0000 |
commit | 706bfe5a1c25b80f2af9c48477035cfe73987ae4 (patch) | |
tree | ce4a369a9f5beaa3c7a7909bd4708aec8a3b2340 /gdb/ch-valprint.c | |
parent | c780e5dbafac580ef35286c4325ecf59015f12b1 (diff) | |
download | gdb-706bfe5a1c25b80f2af9c48477035cfe73987ae4.zip gdb-706bfe5a1c25b80f2af9c48477035cfe73987ae4.tar.gz gdb-706bfe5a1c25b80f2af9c48477035cfe73987ae4.tar.bz2 |
* gdbtypes.c (get_discrete_bounds): New function.
(force_to_range_type): Use get_discrete_bounds.
* gdbtypes.h (get_discrete_bounds): Add declaration.
* valarith.c (value_bit_index): Generalize to use get_discrete_bounds.
* ch-valprint.c (chill_val_print): Make (power)sets and bitstring
support use get_discrete_bounds and generally be more robust.
This fixes PR chill/8136.
Diffstat (limited to 'gdb/ch-valprint.c')
-rw-r--r-- | gdb/ch-valprint.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 795aca6..120d8ad 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -347,8 +347,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, } { struct type *range = elttype; - int low_bound = TYPE_LOW_BOUND (range); - int high_bound = TYPE_HIGH_BOUND (range); + LONGEST low_bound, high_bound; int i; int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING; int need_comma = 0; @@ -357,9 +356,23 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, fputs_filtered ("B'", stream); else fputs_filtered ("[", stream); + + i = get_discrete_bounds (range, &low_bound, &high_bound); + maybe_bad_bstring: + if (i < 0) + { + fputs_filtered ("<error value>", stream); + goto done; + } + for (i = low_bound; i <= high_bound; i++) { int element = value_bit_index (type, valaddr, i); + if (element < 0) + { + i = element; + goto maybe_bad_bstring; + } if (is_bitstring) fprintf_filtered (stream, "%d", element); else if (element) @@ -381,6 +394,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, } } } + done: if (is_bitstring) fputs_filtered ("'", stream); else |