From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iZW+NwbeBmvwsDwAWB0awg (envelope-from ) for ; Wed, 25 Nov 2026 08:09:26 -0500 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=Upkhu8+Y; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DEEAF1E166; Wed, 25 Nov 2026 08:09:26 -0500 (EST) 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 EC7F61E09B for ; Wed, 25 Nov 2026 08:09:25 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30C5841625E6 for ; Wed, 25 Nov 2026 13:09:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30C5841625E6 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=Upkhu8+Y Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by sourceware.org (Postfix) with ESMTPS id AEE7840AFDC2 for ; Wed, 25 Nov 2026 13:08:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEE7840AFDC2 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 AEE7840AFDC2 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795612105; cv=none; b=TrzmKWiR4gRolCWPf9FxXvJltHzCkxO+E+sNxHmfWw6UCBTaVtl8xVDDwPtExLO0kBZxuROytBsqMHKE17GROU/RoyP47DFOh3Pglhcn2wSnTTqML137xPamJB5Z/CTB5+fbWTOx/gRt/wShVICm6tWs4GMmOgcdBaDE77Aw0lE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795612105; c=relaxed/simple; bh=Ph3DTqrEk23W5zQgLH6zufQJjLWCFjFif0U4Q9o+XKs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sfl8Jr5OFdWVHGxY46VNJyGIzy03rzmq6CURUHaYpYKAurMe/4TM3RU/rEj6LZy2CZrXR9t8R0IP6W4Ls4SdupBEOS5SLnctCAtypK7rvuce+M473e9ra1qV+e5FlDqofsbFdOYy2c5+UT411osgBC9rj3uKPdHevgMq2dRem4k= 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=Upkhu8+Y DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEE7840AFDC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795612105; x=1827148105; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Ph3DTqrEk23W5zQgLH6zufQJjLWCFjFif0U4Q9o+XKs=; b=Upkhu8+YRHdOQ2XsUcNrkMugR9DGI2HJhxDpNhXzxuaZTvC55tTS1dBc pBmUEQr1XbNs8HEHTR5QutfGJ9Agm5Ah16j9MA5w8jdCwosmgluDyREAk rfC36w+hbxb2KAHPGPIXA9/v/xuqt4CNG5Cw9soNh/4BEDLLYdXHlMCfs xi4eD6HIO3QRhaGinWLiz/f5YyOd7znkqoc2PVP0GyxBvuaFOHKFdjpQk rL+uNT3s9wyf+EHd5EG/vUf4846m2kWHdNs+GubEPUmWGhUIEwB99GrSl yabW5HRWHuRc3UMvOY1jecLmaFLh1yGCz3Pv8mpBGwy/rqnsa9xVs0LbN Q==; X-CSE-ConnectionGUID: O1H6nz/oQ1SLHlqthuKPSg== X-CSE-MsgGUID: lmO64TvESUWqF/HJFpjfzw== X-IronPort-AV: E=McAfee;i="6800,10657,11977"; a="4551029" X-IronPort-AV: E=Sophos;i="6.27,232,1787036400"; d="scan'208";a="4551029" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2026 05:08:25 -0800 X-CSE-ConnectionGUID: SY49ND8NTu6mMpC94BMApQ== X-CSE-MsgGUID: DrFV5yA6QE+pgaB9IKkMFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,232,1787036400"; d="scan'208";a="11736184" Received: from dut1048pvc.igk.intel.com (HELO localhost) ([10.211.177.228]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2026 05:08:24 -0800 From: Stephan Rohr To: gdb-patches@sourceware.org Subject: [PATCH v2 2/2] gdb: disable pagination while following a fork Date: Wed, 25 Nov 2026 13:08:02 +0000 Message-ID: <20261125130802.117043-3-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261125130802.117043-1-stephan.rohr@intel.com> References: <20261125130802.117043-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 With "set detach-on-fork off", continueing from a fork catchpoint follows the fork. Pagination is enabled. If the new inferior notification triggers pagination and the user answers "q", the new inferior is not fully set up. It is missing the target and threads: (gdb) set height 1 (gdb) set width 10 (gdb) continue Continuing. [New infer--Type for more, q to quit, c to continue without paging--q Quit (gdb) inferior 2 Inferior has no threads. Temporarily disable pagination in "follow_fork ()". --- gdb/infrun.c | 6 ++ .../gdb.base/fork-inferior-paginate.exp | 83 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 gdb/testsuite/gdb.base/fork-inferior-paginate.exp diff --git a/gdb/infrun.c b/gdb/infrun.c index dced78a3963..b8864aabd76 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -812,6 +812,12 @@ follow_fork () { INFRUN_SCOPED_DEBUG_ENTER_EXIT; + /* Temporarily disable pagination. Otherwise, the user could answer + 'q' at the pager prompt and abort following the fork, i.e., the new + inferior has no target and threads. */ + scoped_restore save_pagination + = make_scoped_restore (&pagination_enabled, false); + bool follow_child = (follow_fork_mode_string == follow_fork_mode_child); bool should_resume = true; diff --git a/gdb/testsuite/gdb.base/fork-inferior-paginate.exp b/gdb/testsuite/gdb.base/fork-inferior-paginate.exp new file mode 100644 index 00000000000..c394e5f8977 --- /dev/null +++ b/gdb/testsuite/gdb.base/fork-inferior-paginate.exp @@ -0,0 +1,83 @@ +# 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 there is no pagination if a new inferior is setup when following +# a fork. "Continue" may still paginate but should not leave GDB incompletely +# setup. + +require allow_fork_tests + +standard_testfile fork-print-inferior-events.c + +if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { + return +} + +set bp_line [gdb_get_line_number "return 0;"] + +proc test_paginate { follow_fork_mode } { + global gdb_prompt pagination_prompt + + with_test_prefix "follow-fork-mode=$follow_fork_mode" { + clean_restart $::testfile + + if {![runto_main]} { + return + } + + gdb_test_no_output "set detach-on-fork off" + gdb_test_no_output "set follow-fork-mode $follow_fork_mode" + gdb_test "catch fork" "Catchpoint $::decimal \\(fork\\)" + gdb_test "continue" \ + "Catchpoint $::decimal \\(forked process $::decimal\\).*" + gdb_breakpoint $::srcfile:$::bp_line + + # Avoid unexpected output from readline. + gdb_test_no_output "set editing off" + + # Following the fork shall not produce any pagination. "Continue" + # still may paginate, though. + set saw_fork_pagination 0 + with_set height 1 { + with_set width 10 { + gdb_test_multiple "continue" "no pagination in follow fork" { + -re "(New infer|Attachin)\[^\r\n\]*$pagination_prompt$" { + set saw_fork_pagination 1 + send_gdb "q\n" + exp_continue + } + -re "$pagination_prompt$" { + send_gdb "\n" + exp_continue + } + -re "\r\n$gdb_prompt $" { + gdb_assert { !$saw_fork_pagination } $gdb_test_name + } + } + } + } + + # Check inferior 2 is properly set up. + gdb_test "info inferiors" \ + "\r\n\\*?\\s+2\\s+process $::decimal\\s+$::decimal \\(\[^\r\n\]*" + gdb_test "inferior 2" \ + "\\\[Switching to thread 2\\.1 \[^\r\n\]*\\\].*" \ + "switch to inferior 2" + } +} + +foreach follow_fork_mode {parent child} { + test_paginate $follow_fork_mode +} -- 2.43.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.