summaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index bc524bd86cc..20ac6336cd2 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -171,8 +171,13 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
elttype = check_typedef (unresolved_elttype);
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
{
+ LONGEST low_bound, high_bound;
+
+ if (!get_array_bounds (type, &low_bound, &high_bound))
+ error (_("Could not determine the array high bound"));
+
eltlen = TYPE_LENGTH (elttype);
- len = TYPE_LENGTH (type) / eltlen;
+ len = high_bound - low_bound + 1;
if (options->prettyprint_arrays)
{
print_spaces_filtered (2 + 2 * recurse, stream);