diff options
author | Tom Tromey <tromey@adacore.com> | 2023-09-15 08:59:09 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-10-02 12:37:25 -0600 |
commit | 8f11ec2d3c57f3fb41f968e19bec3d4d58359171 (patch) | |
tree | fc65c2d4fdeb6a30a64cf370bf31051d35946418 /gdb/ada-valprint.c | |
parent | a97875a518ef5f334e9bd4f1f0426e0eadf387ea (diff) | |
download | gdb-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.zip gdb-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.tar.gz gdb-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.tar.bz2 |
Clean up intermediate values in val_print_packed_array_elements
Following on Tom de Vries' work in the other array-printers, this
patch changes val_print_packed_array_elements to also avoid allocating
too many values when printing an Ada packed array.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r-- | gdb/ada-valprint.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index eaeca0f..b32f1e5 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -150,6 +150,11 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, while (i < len && things_printed < options->print_max) { + /* Both this outer loop and the inner loop that checks for + duplicates may allocate many values. To avoid using too much + memory, both spots release values as they work. */ + scoped_value_mark outer_free_values; + struct value *v0, *v1; int i0; @@ -180,6 +185,9 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, bitsize, elttype); while (1) { + /* Make sure to free any values in the inner loop. */ + scoped_value_mark free_values; + i += 1; if (i >= len) break; |