From patchwork Sat Dec 13 08:53:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 126500 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id F13474BA2E2D for ; Sat, 13 Dec 2025 08:54:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F13474BA2E2D Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=egFU69aC X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id B42FD4BA2E1C for ; Sat, 13 Dec 2025 08:53:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B42FD4BA2E1C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B42FD4BA2E1C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765616024; cv=none; b=U648PCm6H0DlGUGtPBwcjIh1LbChOLWwgCBhWbobxWzbfs2JAZtYJXSB/GkR/9q6snknjJFkH0WF3buyKYtEie4tcfcCjWXhxhavPYiqnRiSfZbWAV2h8ZohQdY/4U0oRR5kMsvOLGoyo8F/RK4q3l2RYJkcEG9JKK9stekDOm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765616024; c=relaxed/simple; bh=RAYgCMOXQWcNm8pnBeA5Py0oMpp/LS/yr2y6XvrFXSo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lTdKrlHk1P6VvRZXL9PTEsmL1WKOKSaxSGPTeJtTIjg4hKCKQuDawqtzUSuxt0mB5QYu06dXf3UujQeF3BJ5r/akCiu8Kojo9+9OeGzBeUn+VdzKtVbHE9KwPCP1u5vGkYJtWFajKGGgw8asvcdCgmKFOsyiv2mjQg3O6Hj24Rk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B42FD4BA2E1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765616024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FqWGpgpoIwBDGL/IcWpYTffp5wB0HWF3YLoOrfai2pc=; b=egFU69aCZx4j0w0ezkg1ikJhuJk/2Yc+U5SiJUXNbvvFiyXv4dHLZ6uPRJmhuAtF0fAqYE IjXvoakkJvMvObLmdS5JMTDkLINKs1E+UVNv6nFTvXTI48W3jUZv20og/Ng0CIIt/we1MF lLEZHa9X/mXhvhmNywXZyT55LGfiLiA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-T073j0z7P1iffBJgxNHJPQ-1; Sat, 13 Dec 2025 03:53:43 -0500 X-MC-Unique: T073j0z7P1iffBJgxNHJPQ-1 X-Mimecast-MFC-AGG-ID: T073j0z7P1iffBJgxNHJPQ_1765616022 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-47775585257so14058515e9.1 for ; Sat, 13 Dec 2025 00:53:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765616021; x=1766220821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FqWGpgpoIwBDGL/IcWpYTffp5wB0HWF3YLoOrfai2pc=; b=mXmMod2K/XO3ExMh5WtPOE8hc3WfKYT5gDKT3p4vsAnz36zS5PMWO+4xBE1a0Gqpc7 673MC9z+bqCjQrNpSh56OkmgTvzuOyn2yqmf2+jobyFtKEx/ol5z4vJ1as+Wmxs9o8Y6 SpfiduNaL+gIgK1tElC4av0SrTWZVcS4dyf5FamAhGWLcH4FMh/Ov40+rfc+eDq0YP52 af+nO/Jj1cI9gUjv/MbMlYxfvzq1CqkAJGXMTfXpGdUIihX68b6JjLSWAbuABGCxekpr MyvYQe5lq+O0iI9DLfLOVs6agmE+09bMDHXiZJMN3FTbClj8Msa1LtBZixQwJYFjS345 MD5Q== X-Gm-Message-State: AOJu0Yzz2afc015hj8anTDAge99Yi4S4lysL1bDHMj8zG2sBkRxK02BI Dg5ABlf7c0jWW+nkUuwI9RdBWtZ48SknMhUkuoqKvKuPvwZAgaNdNzjsmqjKwzGvu+cFs4vVLBR 5+gozzwViG2fdYLDOoaCOvAJvQwW6DEV0M7fM+b2VAhSY18Atlx2yapMPoYW0skDkb1PHfnxb3E ui36i2mRhLs6anJM7jHTBUtSJK54ipVH6RlxdE/A+xhL8d5zg= X-Gm-Gg: AY/fxX6H/o/q4zAPLYZ+5NPdjZ5C8rNEcOYN7wLToNmjfrxSmPtRFrvMj7vYUw6rbKw 4muF9aiq3MzS/QR81mmos7Hd2S4pANCTnetPwDI3D+sWhfdN3H/cTA3Hn7OFfKLVFFo+V8VdLbH Co0FfcexkURaTqYs4DpGRp9yfc9YuBv9GJab0kbknuGzoFJWn0DwCvcxxhBGBkMa6rDGvSEZ8uV kUtPwkxI9xFfJA8Daxctm3FqIIbFLg3sU5UH0WdFkaYVKURDq+SuPN4EXS3vd+FYmO8k3IB+RQ9 OAngJlDLUpTSdmOPztG+ZBergb4Vs4Uv8avV7F1x4htM9bZPdNirnagN/vgh/pvvBbnZOrKwHLK +jgnF X-Received: by 2002:a05:600c:4449:b0:47a:81b7:9a20 with SMTP id 5b1f17b1804b1-47a8f8c03e4mr43888045e9.9.1765616021414; Sat, 13 Dec 2025 00:53:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTEygzmdrJvBJMAldYwNG8CdSmAx29frTvMiNUO/aexuk5rk5gUG73MJAyIOyCdQWNvQ/4Ng== X-Received: by 2002:a05:600c:4449:b0:47a:81b7:9a20 with SMTP id 5b1f17b1804b1-47a8f8c03e4mr43887825e9.9.1765616020897; Sat, 13 Dec 2025 00:53:40 -0800 (PST) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42ff626b591sm3852571f8f.15.2025.12.13.00.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Dec 2025 00:53:40 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 GDB 17 1/2] gdb: rename scoped_gdb_tty_state, and make it non-copyable Date: Sat, 13 Dec 2025 08:53:33 +0000 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: <562d1cc3615faad72139c6974a4e76b292285f77.1765556713.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9EN4NakmDR6Q_zhYqem_1oT0zNocTySmCVPWQY3fen8_1765616022 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org The scoped_gdb_tty_state class seems misnamed. For save/restore type classes the pattern in GDB is usually scoped_restore_, so lets rename this to scoped_restore_tty_state. I dropped the 'gdb' part of the name as the underlying functions being called are serial_get_tty_state and serial_set_tty_state, so the new name matches (I think) what's actually being called. I've also made the class non-copyable like other scoped_restore_ classes. There should be no user visible changes after this commit. --- gdb/cli/cli-cmds.c | 2 +- gdb/inflow.c | 4 ++-- gdb/terminal.h | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index cf5571c5419..0f048d4fc27 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -950,7 +950,7 @@ shell_escape (const char *arg, int from_tty) static void shell_command (const char *arg, int from_tty) { - scoped_gdb_ttystate save_restore_gdb_ttystate; + scoped_restore_tty_state save_restore_gdb_ttystate; restore_initial_gdb_ttystate (); shell_escape (arg, from_tty); diff --git a/gdb/inflow.c b/gdb/inflow.c index ccab019158a..518b2dcf4e0 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -57,14 +57,14 @@ static struct serial *stdin_serial; /* See terminal.h. */ -scoped_gdb_ttystate::scoped_gdb_ttystate () +scoped_restore_tty_state::scoped_restore_tty_state () { m_ttystate = serial_get_tty_state (stdin_serial); } /* See terminal.h. */ -scoped_gdb_ttystate::~scoped_gdb_ttystate () +scoped_restore_tty_state::~scoped_restore_tty_state () { serial_set_tty_state (stdin_serial, m_ttystate); } diff --git a/gdb/terminal.h b/gdb/terminal.h index 87a1aee37fb..225554a60c3 100644 --- a/gdb/terminal.h +++ b/gdb/terminal.h @@ -49,12 +49,15 @@ extern void set_initial_gdb_ttystate (void); extern void restore_initial_gdb_ttystate (void); /* An RAII-based object that saves the tty state, and then restores it again - when this object is destroyed. */ -class scoped_gdb_ttystate + when this object is destroyed. */ +class scoped_restore_tty_state { public: - scoped_gdb_ttystate (); - ~scoped_gdb_ttystate (); + scoped_restore_tty_state (); + ~scoped_restore_tty_state (); + + DISABLE_COPY_AND_ASSIGN (scoped_restore_tty_state); + private: serial_ttystate m_ttystate; }; From patchwork Sat Dec 13 08:53:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 126501 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id BAF2E4BA2E22 for ; Sat, 13 Dec 2025 08:55:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAF2E4BA2E22 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cT9gy9dX X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 167FE4BA2E1D for ; Sat, 13 Dec 2025 08:53:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 167FE4BA2E1D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 167FE4BA2E1D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765616026; cv=none; b=Wb8yzzy6Utnxs/K6l+7Z4oMOYmimFWqFcCZE8QZZJfKhqZ9jUa1WbrPw1PnhJeHgWQGkS3aA1pXxHaAhsWsHdADrLKF25Ewo3YcsW0urhdC1zEh+p51GMPv8ahKdm69Yj+ZeYURCk3HS79i9iC3Ry2I/pqQus4o38r6aHiDQ+GI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765616026; c=relaxed/simple; bh=XL1cFPX+b5egK5Q+oVPwlCInX+EJmQq6Pj9HFPZliEw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LPBqVfq/ru0z2lw/dFCIIjPN3SHmrGYv5GYZJ0FwkpcefJjjFL1SuhJTcOciX8vlY1cOLw5uKErrWtAij0LU9cASnL2C0zTFDZf0jlgk28nuqhoKg5zbXFxsuvYeyVpecCp+Mqx/y+9m7YxQhpKHgBB6Qm4OgiMawhGu2JOwq/Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 167FE4BA2E1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765616025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y6B2LWMl5/HDOW8BYlwbbs0JXGPHb3pyw63XRZOkQ0w=; b=cT9gy9dXJ4Y8ahbpCD7IwYGpBN49a/R2AQid/MlT8eJjOgONavvpmGb0HNfxTo5433MV+Q 3TFeg+j8UpPpUGBGP4ajpjr3igN1HEnDnM0PGT4r/N2agv3bEcGY/ZdYfnMFQj0Z6EwoIY IdmFA/0/bobbNPWTnCRque/xVvhJKw8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-bzoBOAExNpamXeo1gd81pw-1; Sat, 13 Dec 2025 03:53:44 -0500 X-MC-Unique: bzoBOAExNpamXeo1gd81pw-1 X-Mimecast-MFC-AGG-ID: bzoBOAExNpamXeo1gd81pw_1765616023 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4779b3749a8so14720055e9.1 for ; Sat, 13 Dec 2025 00:53:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765616023; x=1766220823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5fZxgExDU9Vw9QGlSlN1VetYhf+17NjpQ4ARnGSmle0=; b=S6WIBuwHqNZuRPoz+4JKtZErHVYL455eojlDPDFF3PiqOV23Ma6jC+EfNCQTSC46pR vYTzC+0oBGxQfgN4G3WThy0ng7qCj6cTtNnnD3Sb/ad/jQsiq31UnIDZbTFAdgyVzXU4 SAoDirTOREA/9RgODkjZnrBf0CttYVFwYZ++HN5kT+7d5pIitoQH2555cHNQ/4UOv0K9 5qvjFmf9W42U4ZmCBVstMGeAcH246Bx/PhWhHo9VsMDJ3TPbQlgVZB2VWA2EFKb7DUO6 oPajmuJitSLJmgtSgWG1vmHnWRbzc637E+RAR/EzSqTfTlaGwBukXFgI4pbeOO9EbKtk Yf4Q== X-Gm-Message-State: AOJu0YzeBEefOfX5WHCO4rfqfWHa6RFb79L8OsQLhutNc1AmGYwEejDE WTlg1bnLGzAk1OT46VR023/Y1bAgqFwqrxJ557/9DZeJ2XhKWFR1LWePVXm4GyAemXFfffTh82Z YVnHiH2SnTGuxxZHHZiXqn8RKSZiPWHdLmg3UOHqV8e6cb0IuEGnr6hYkM2WU431OGOq+nmUZIx a9x8qrRSimk6ZrDkMaWXAaXCPTazyh4TKeJ6iR8CsfNcrWbnM= X-Gm-Gg: AY/fxX5v6POwQhutu6CfBiaJSsZDCX32vnSclIjmH2orhGljgybnJbdKOm8s5JMaGsT YTWQs0GPrZ2wfF/pVSpi0dEh6x6pxHDNKm0vFhvtOS9O/DuAd1ZHWAz9H0wvDpXN8aecV0oqSn7 XNu6sXuvhfQOE/ad6jfySYVfKJGdcERg5KUMykztfy6htfLR5Rwp9nMXK+UW4cwJfzwWZi/9sgs 7eSowYwtP77qB3yXjhto3UCoNyqYJpAOqxnXGwkyMK0FXsJfERFdbAdramAMVdpBhMNfn7znEkP nxGG/KDIITzvoCKFuKuZH8vr1wAKkDeTS7RoWGj9jQ4vtBbvNK6fCHUESgzYjNTUsT4k+YUe7BJ xw1Uq X-Received: by 2002:a05:600c:a086:b0:471:1774:3003 with SMTP id 5b1f17b1804b1-47a8f90fefamr50034015e9.29.1765616022753; Sat, 13 Dec 2025 00:53:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+MyTrP1Xcl5IAS4WOec4XYXqR378d+uS/0mohiuctvDLhlNPViKSsV2dp7r+UVLIiLT3XEA== X-Received: by 2002:a05:600c:a086:b0:471:1774:3003 with SMTP id 5b1f17b1804b1-47a8f90fefamr50033805e9.29.1765616022305; Sat, 13 Dec 2025 00:53:42 -0800 (PST) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a8f4a3e9fsm74489275e9.6.2025.12.13.00.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Dec 2025 00:53:41 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 GDB 17 2/2] gdb: fix crash from 'shell' when GDB has no terminal Date: Sat, 13 Dec 2025 08:53:34 +0000 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: <562d1cc3615faad72139c6974a4e76b292285f77.1765556713.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6lzzTwrRER9hPnPMOy3hSeB0vlo_wR0VAZhAhnOosBc_1765616023 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org Bug PR gdb/33716 identifies a problem where GDB will crash when using the 'shell' command if GDB is not attached to a terminal. E.g.: $ gdb -nw -nh -q -batch -ex 'shell echo hello' . + +# Run GDB in batch mode, with stdin attached to a non-pty. Use the +# 'shell' command from the GDB command line. Check that GDB doesn't +# crash. This checks for bug PR gdb/33716. + +# Remote boards override the 'remote_spawn' mechanism, and don't +# support the 'readonly' argument that this test relies on. Just +# running this test on local hosts should be fine. +require {!is_remote host} + +gdb_exit + +save_vars { GDBFLAGS } { + append GDBFLAGS " -batch -ex \"shell echo first\" -ex \"shell echo second\"