From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QIimDOy7RGrPxyAAWB0awg (envelope-from ) for ; Wed, 01 Jul 2026 03:04:12 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=OkL6cJci; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 245D81E070; Wed, 01 Jul 2026 03:04:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 857DB1E070 for ; Wed, 01 Jul 2026 03:04:10 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A11FB4BA23C7 for ; Wed, 1 Jul 2026 07:04:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A11FB4BA23C7 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=OkL6cJci Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 09E944BA2E12 for ; Wed, 1 Jul 2026 07:03:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09E944BA2E12 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 09E944BA2E12 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782889420; cv=none; b=noCZh62ftUX2xnRh7M0sD2tKaQSLgGiKLvDVt2y0GKdT7tD8261FUkPOXxZl8P92XqDumbpcnu4ZA8bfTUQOG9huXbTtt1pdFvzNbcN3TAvdj2pxnwh6wn0pEZdTW1ATBONbuAlocpZ+ABew6/dEpgg5bZp+X8teMRdQqaxxV9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782889420; c=relaxed/simple; bh=qzN1ww+nzsvWCKoO06LUPK/GD0j7hBunATOIBUBL5Y4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KxNDBKY/5RQlvKYxOLlAaAC7HSDjUmCVUMe4SwbY6Jd/NRXTE/uMNIIvqAHbepYzBm1rSJl0Ogjpqy59q/Daag0cSiFL0fYHvrxZktYigbMrGB7S6VlvOO+bc1CRoxjs3h1D+7E6R9HqnrFHQJSgETyD5n+ISAlgyDLRUciQzsQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=OkL6cJci DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09E944BA2E12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782889421; x=1814425421; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qzN1ww+nzsvWCKoO06LUPK/GD0j7hBunATOIBUBL5Y4=; b=OkL6cJci6M7m3EAo2GZFovRlDnzBGbLknuku5ISVY8oYMO1/7ivFwhIz gNrhA7n0ytA68VP84QGHJqdW9GEekLqoUIuRZtko2oElxOWJHMDmP7lLm URP60pwhL43TdF73WUYQkxzss4/VcCClePdiQMCkpfxTvARRMvtBETOmX r8A2aRAwvpdn4PQu9wRtnkS3OYnSsKYlh6Lgukb7vfmev7vw4stZk2AHi ZkHtQlf/QKGN2BmyJw0QsOl/CizMzttLMxOQfzXd80U0Z/O3dTbr1TlMH LyMEYu23NSBduvF/G/KzPje3kHeAU6XWVn5u7EQ0K7qb8/JotdTuzLJhf A==; X-CSE-ConnectionGUID: CLFCrDZERqeHb4A9QP5Exg== X-CSE-MsgGUID: bW6JQT8UQc+nNvYPa0+/vQ== X-IronPort-AV: E=McAfee;i="6800,10657,11833"; a="87525440" X-IronPort-AV: E=Sophos;i="6.24,235,1774335600"; d="scan'208";a="87525440" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 00:03:40 -0700 X-CSE-ConnectionGUID: SXC15TonQIGyZKVyHmi0hA== X-CSE-MsgGUID: Bv5cQXYgSWmGx783Q30Q4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,235,1774335600"; d="scan'208";a="252611506" Received: from dut1048pvc.igk.intel.com (HELO localhost) ([10.211.177.228]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 00:03:39 -0700 From: Stephan Rohr To: gdb-patches@sourceware.org Subject: [PATCH 1/1] gdb: disable pagination during inferior creation Date: Wed, 1 Jul 2026 07:03:24 +0000 Message-ID: <20260701070324.36461-2-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260701070324.36461-1-stephan.rohr@intel.com> References: <20260701070324.36461-1-stephan.rohr@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 From: "Rohr, Stephan" The '[New inferior ..]' and 'Added inferior' messages may cause pagination in certain use-cases. If the user inputs 'quit' when prompted for pagination, GDB throws a quit error. This aborts the inferior setup and may leave the inferior in an incomplete state, e.g., the inferior's pspace and aspace may be uninitialized. This triggers an assertion when switching to the inferior. Temporarily disable pagination when adding new inferiors. --- gdb/inferior.c | 7 ++ gdb/remote.c | 6 ++ .../gdb.base/add-inferior-paginate.exp | 67 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 gdb/testsuite/gdb.base/add-inferior-paginate.exp diff --git a/gdb/inferior.c b/gdb/inferior.c index 1481f46cdd1..6e346aee271 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -991,6 +991,13 @@ add_inferior_command (const char *args, int from_tty) scoped_restore_current_pspace_and_thread restore_pspace_thread; + /* Temporarily disable pagination. If the '[New inferior ..]' or + 'Added inferior ..' message cause pagination and the user quits, this + leaves the inferior not properly initialized, e.g., the inferior's + pspace and aspace could be left uninitialized. */ + scoped_restore save_pagination + = make_scoped_restore (&pagination_enabled, false); + for (unsigned int i = 0; i < opts.num_copies; ++i) { inferior *inf = add_inferior_with_spaces (); diff --git a/gdb/remote.c b/gdb/remote.c index f8c7383cb03..b169371c818 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3090,6 +3090,12 @@ remote_target::remote_add_inferior (bool fake_pid_p, int pid, int attached, if (attached == -1) attached = remote_query_attached (pid); + /* Temporarily disable pagination. If the '[New inferior ..] or other + messages from the notifiers cause pagination and the user quits, + this would leave the inferior not properly initialized. */ + scoped_restore save_pagination + = make_scoped_restore (&pagination_enabled, false); + if (gdbarch_has_global_solist (current_inferior ()->arch ())) { /* If the target shares code across all inferiors, then every diff --git a/gdb/testsuite/gdb.base/add-inferior-paginate.exp b/gdb/testsuite/gdb.base/add-inferior-paginate.exp new file mode 100644 index 00000000000..6dcb52db495 --- /dev/null +++ b/gdb/testsuite/gdb.base/add-inferior-paginate.exp @@ -0,0 +1,67 @@ +# Copyright 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test that "add-inferior" does not paginate while setting up a new +# inferior. If the '[New inferior ..]' message causes pagination and the +# user quits, this leaves the inferior in a half baked state, e.g., the +# inferior's program space is not initialized. + +standard_testfile advance.c + +if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { + return +} + +clean_restart + +# Avoid some confusing output from readline. +gdb_test_no_output "set editing off" + +# Tests that neither the '[New inferior ..]' nor the 'Added inferior' +# message cause pagination. +gdb_test_no_output "set height 1" +gdb_test_no_output "set width 10" + +gdb_test_multiple "add-inferior -exec $binfile" "add inferior" { + -re "\\\[New inferior 2\\\]" { + exp_continue + } + -re "Added inferior 2( on connection \[^\r\n\]*)?" { + exp_continue + } + -re "Reading symbols from \[^\r\n\]*$binfile\[^\r\n\]*" { + exp_continue + } + -re "$pagination_prompt$" { + # We unexpectedly hit the pagination prompt. Send 'quit' to + # trigger the assertion in the 'info inferiors' command. + send_gdb "q\n" + exp_continue + } + -re "Quit\r\n$gdb_prompt $" { + fail $gdb_test_name + } + -re "\r\n$gdb_prompt $" { + pass $gdb_test_name + } +} + +gdb_test_no_output "set height unlimited" +gdb_test_no_output "set width unlimited" + +# Test that the inferior is properly setup. Without temporarly disabling +# pagination, GDB hits an assertion here. +gdb_test "info inferiors" "\\s+2\[^\r\n\]*$binfile\[^\r\n\]*" \ + "info inferiors" -- 2.43.0 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928