aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-09-15 08:59:09 -0600
committerTom Tromey <tromey@adacore.com>2023-10-02 12:37:25 -0600
commit8f11ec2d3c57f3fb41f968e19bec3d4d58359171 (patch)
treefc65c2d4fdeb6a30a64cf370bf31051d35946418 /gdb/ada-valprint.c
parenta97875a518ef5f334e9bd4f1f0426e0eadf387ea (diff)
downloadgdb-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.c8
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;