From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Add QUIT to inner loop in value_print_array_elements
Date: Tue, 22 Sep 2026 14:12:02 -0600 [thread overview]
Message-ID: <20260922201202.2189948-1-tromey@adacore.com> (raw)
When printing an array, some work is done to detect repeated elements.
This work is not interruptible, and it is somewhat slow (see
PR exp/32681).
This patch adds QUITs to the relevant spots.
I am not sure there is a way to write a non-racy test for this.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17613
---
gdb/ada-valprint.c | 2 ++
gdb/f-valprint.c | 5 +++++
gdb/valprint.c | 2 ++
3 files changed, 9 insertions(+)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index d66f9f84d52..020478bdf40 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -183,6 +183,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
bitsize, elttype);
while (1)
{
+ QUIT;
+
/* Make sure to free any values in the inner loop. */
scoped_value_mark free_values;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index d0b2030554f..2b54c8bf1c0 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -36,6 +36,7 @@
#include "cli/cli-style.h"
#include "gdbarch.h"
#include "f-array-walker.h"
+#include "event-top.h"
static void f77_get_dynamic_length_of_aggregate (struct type *);
@@ -188,6 +189,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
struct type *elt_type, LONGEST elt_off,
LONGEST index, bool last_p)
{
+ QUIT;
+
size_t dim_indx = m_dimension - 1;
struct type *elt_type_prev = m_elt_type_prev;
LONGEST elt_off_prev = m_elt_off_prev;
@@ -262,6 +265,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
LONGEST elt_off_prev = m_elt_off_prev;
bool repeated = false;
+ QUIT;
+
if (m_options.repeat_count_threshold < UINT_MAX
&& elt_type_prev != nullptr)
{
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 83a442dcef5..7e41943f66f 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2038,6 +2038,8 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
while (rep1 < len)
{
+ QUIT;
+
/* When printing large arrays this spot is called frequently, so
clean up temporary values asap to prevent allocating a large
amount of them. */
base-commit: 123e4a5eab2db300b44288dcc1a29c903f9622f9
--
2.55.0
next reply other threads:[~2026-09-22 20:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:12 Tom Tromey [this message]
2026-09-24 20:36 ` Guinevere Larsen
2026-09-26 0:26 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922201202.2189948-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox