From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eoyLHolPvWoTlB8AWB0awg (envelope-from ) for ; Wed, 30 Sep 2026 14:06:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=HPlQGOjV; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 65B231E051; Wed, 30 Sep 2026 14:06:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D70B51E01F for ; Wed, 30 Sep 2026 14:06:00 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0714B4BAE7F8 for ; Wed, 30 Sep 2026 18:06:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0714B4BAE7F8 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=HPlQGOjV Received: from mail-oo2-x2a.google.com (mail-oo2-x2a.google.com [IPv6:2607:f8b0:4864:31::2a]) by sourceware.org (Postfix) with ESMTPS id A85694BA2E0A for ; Wed, 30 Sep 2026 18:05:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A85694BA2E0A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A85694BA2E0A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:31::2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790791536; cv=none; b=tbQgSDyW1zEJykOzwEGcxrxut/kSxOvpo55vkO9Zso1M9Gv+AuBbNPgN/nIGGE9gMNKagOmUVza5vHPVPy50Kk4S6tf8fnFDEz3LKSqnamq/ckacN1hhQVOI7sX4FBfJiO9lUlTSaprhj1sW+hA5NOstiK1bV0bLJbRh9rnd2CM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790791536; c=relaxed/simple; bh=rdKR6WD55YJoyuxYrOq4OeNZisHVSh+ynI6nZWY1xQw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=licDatmk1oXYfVeUEpy4BKXebX5UEfC+K7ZbqwKFxVrvgcaBIoIvPazgwOQM9/7bzOWif+2gAUPnaBaxuDlQdxmRerEiBNUG05xBPnuMFF/WWlYMu39EtkpwytVPsEGbZXPmnv4IiAbTEzuf+7dVJ6zHEnIyc2K+aYP+fkzm1aY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=HPlQGOjV DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A85694BA2E0A Received: by mail-oo2-x2a.google.com with SMTP id 46e09a7af769-80a18990c76so3583956a34.2 for ; Wed, 30 Sep 2026 11:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1790791536; x=1791396336; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Jsjm925SZxuNueHadpQYdyMdRfUXya+ib6JULXGr6Mk=; b=HPlQGOjV1Is8CX92AASnW990+93OlOTjEUvY5muDLnWGtO5/ZOkp8UJRYKLjy7fdjY jRbtWpJjn6cF2/i9EqlVwGCOSIDdh4c89G80HgjNQnWnJhb7mA5+HQD0/L6US+APWwmg lHJXQzn2ZUXG1eVxltFcUrQmIva+3oOf+LtSoTDeIOatmrhuj5b1jPL8JtL+eOzrwr80 wNun5ZUQi3F8MOFYPq7Ixzd9MgGJyC+1Vy8ZtM/NT7CHvb34JxboP03ez3ZEP5f5yLpT hoxsrLQTuDVNcVAu3M6peoRe2WUjdpFOhjFI0MbowsDuWmJhY5axrm9MQpsjoytwAQOW +yfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790791536; x=1791396336; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Jsjm925SZxuNueHadpQYdyMdRfUXya+ib6JULXGr6Mk=; b=ycQo2PCIeZLXnqgzG9rAEDSh6zj31Fa0FhMaDZeIkaqNYJlkihYz6BM+URF4o4+Tfn UdaYDme/YfzdfTsqG4jWR+32fxDUt8Tfi3SU/bDU6t4AqISs48rZio9is6g83MQtf8sa wNUFEZWd8FtAStkR1+wzVUpfEqHsno9rq9wF//0SmFxHz5oqR4O+5r1ArvMeqM7A17yT y/WxqyCyj2jnZ6MlWNkV9xFMGLwHdhr8rAfgOSH8LBDTWE6pe05URyyNe0S2JRzcyX0U kMS61N9ywEd2NEGo94TtcKc9DUzZMFz+lfXrotw4oFdmnyqiXfo4/AUM86pQHptIy6xp p11A== X-Gm-Message-State: AFuF++nWInl48su/1fVdswtHBB3kDx4qkOkhff34hqSF7Yi0PGjKabme +qQYDoh4qZx+2XKVxEkAciX506YwYI9OWG+N8jsLfX0IEhmvazE124BxINjO+w0ifP7mO6z6PCf QX40fyQ== X-Gm-Gg: AYBFou1K9XMEZWK1P851g3bvp1oxNyGdAN0BmeAYRjZzAB1lwgBssNeeSv8DrqpPr7C E2k1dvVZmr1qvophCBdqfIQpqE9ndC8SBnhWw1DAJbhxDQw/bGB7AXHCF51KH1rPzCRjJ/L/l61 vcDaEOkKjC8p4DaTgQmKg0ggxu1WXS7GNwt05Xy5z/QR3F3yMbt5BF46wBRDCgdwXjEy+dTJNFu gSZssRZmXfr3nRjllvq6IdhmSH+HnPVv3VU+Cy2FP6nUeKuVu7Y9uE9Lnh4/Y99j6Uwvolkfk97 4wrv90rPxnG+RbIYiIGziZ+oeENPvaKjjUpC0ca5ZszAFn8N1atS7vl3zj1MAvG8FfO38G1OSTu vfRnSIzbpfPF8U20LmfA3UOF1odjdkmKZu1UschNer9QDuKbRSqIuYsVRGYNMwBJspu0e82dMN7 10V2uccwe92IxucrQTaCxu4V2zkvR0WWOtCRxObxgfoardXB4O7DUUtZDN7sZ1yiCEnbbEC/iGw lGPAzhzcMQ2mcLEggc= X-Received: by 2002:a05:6820:818f:b0:6d9:890f:e2b7 with SMTP id 006d021491bc7-6dcf1fa4df9mr1891441eaf.4.1790791535906; Wed, 30 Sep 2026 11:05:35 -0700 (PDT) Received: from bapiya (75-166-229-74.hlrn.qwest.net. [75.166.229.74]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-49ded1b53c0sm771223fac.8.2026.09.30.11.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 11:05:35 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2] Add QUIT to inner loop in value_print_array_elements Date: Wed, 30 Sep 2026 12:05:33 -0600 Message-ID: <20260930180533.3722413-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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. In v2 this also moves a QUIT in the string-printing code, pushing it into a more important loop. 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/char-print.c | 4 ++-- gdb/f-valprint.c | 5 +++++ gdb/valprint.c | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) 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/char-print.c b/gdb/char-print.c index f3425ac2cbc..ba1cec4ff9f 100644 --- a/gdb/char-print.c +++ b/gdb/char-print.c @@ -278,6 +278,8 @@ wchar_printer::count_next_character (wchar_iterator *iter, while (1) { + QUIT; + /* Get the next character. */ d.num_chars = iter->iterate (&d.result, &chars, &d.buf, &d.buflen); @@ -526,8 +528,6 @@ wchar_printer::print (struct ui_file *stream, const gdb_byte *string, { int r; - QUIT; - /* Grab the next character and repeat count. */ r = count_next_character (&iter, &converted_chars); 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: a122bb30358a3aabe314bcc918494e8b50c336fb -- 2.55.0