From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WXClMomV52kccDAAWB0awg (envelope-from ) for ; Tue, 21 Apr 2026 11:19:37 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Gee9z+9X; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CA6481E0C3; Tue, 21 Apr 2026 11:19:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_MSPIKE_H2,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 C36A71E067 for ; Tue, 21 Apr 2026 11:19:36 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 44A524BA23F9 for ; Tue, 21 Apr 2026 15:19:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44A524BA23F9 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=Gee9z+9X Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id CBDF24BA23F7 for ; Tue, 21 Apr 2026 15:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBDF24BA23F7 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 CBDF24BA23F7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776784749; cv=none; b=pd44q1+FJ68NvBfKC52+Ws+nx4+loN9t5uq0hAp8kXkn7qtbaB/bGSKHGmVHGg3I3okCc9N6wkK0e3ojSDgtY6niTo7CAwNGsuH2z1i0Tty9Ry4ggvi1zmNMNIQ7vCapzTPQbMgS+S7ncC5oSNv8mu1Hn1EYrPJsQzkcvS6beXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776784749; c=relaxed/simple; bh=hvN2eQMjnI6KlLthNERpcExUBORLMOLulMm40MnehdQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=I8uVmuPMBRGLnu8yaqeJRqHGFWqsW6SETAXjGpmLFYWSM423kg5oUcuNVtVCQgAHOPewhuuLlQWTfMMi005F2lCnqkIf484ZJqkSjFj6HfF1+fIAFy9JcUN4q75EWSiyt4qc9ucYUSGCTZHdMneyuomP3iMbhrI5yKYbqdso3OU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBDF24BA23F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776784748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YFtiNScwjoNo7+jxseHV+AgukTQOaDoMO/+8vTrbPj8=; b=Gee9z+9Xu9xCa/L+Ctl9PrGFThp/3/5k5AQWNTuaTj66YiSRjxdEPVXreJH73ff3UwwAdu YIV3Pwh+m2zWrwKc2qH5dEP2Ubko3N/OPCFQk0jQw947Yt/0T9Ob8eAMUXW72bxr9bJVtN 39lwqtgVdCJJp/oR4WcscxZXI+UlGlU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-_4NXFcKgNdOzmQPLidbpsA-1; Tue, 21 Apr 2026 11:19:07 -0400 X-MC-Unique: _4NXFcKgNdOzmQPLidbpsA-1 X-Mimecast-MFC-AGG-ID: _4NXFcKgNdOzmQPLidbpsA_1776784746 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-43ff0eb2b2aso1942375f8f.2 for ; Tue, 21 Apr 2026 08:19:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776784745; x=1777389545; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0YfZycysn5nNMHKy7BaGbfpODT32s/kDIXDNLmHiTXQ=; b=tMX6GD5CVVLT3o+kPcoV9NGb+ovxHbxzeqRUkbBehgaqsNgueSnH3Ya+EkFJs7kGD6 0W2wJpImAp+L/KWyg6RSWkfdHfoLy/TWwMmUkpVg8szdGr0sXkBYiQt3w0k4sUhnLhlE HE7rg8IvqEgIvSIUXcj6Z8kNFM09n6d8PDqfQ1ZSzp/FDzwbpUy+X/a44itOQcxRvOPM PMsYDopGSprMkjw9a2o7D2y5OYbXIWgOpzBT/qm5Nfb2LuuJFoFlKyZm41xS0UDhwxlc 4j5ag5ADiAXhqQeuxBDQaRrJ+V4aPHa+xPh+NES+TkFu8XBX/ijTN58r5losiJhMioh+ yItA== X-Forwarded-Encrypted: i=1; AFNElJ9C6ek4rF1al9JfaJ7Le+jSWnv8QghFg2E3atF5vWvrroSmZKcXsFsjCdic7tVJQbfynhZvAV6BGJRsqQ==@sourceware.org X-Gm-Message-State: AOJu0Yw6x01myPRRIwkF39QyxN+PV0DNJ3Bs5R1RcXBhR9Itd2l3f1JH M30oTV5DmEey8ClwEMvRKvwS4hCBtPLklol96efwQpya09tnkMY/zyMmMLHtNaRvDeF+aDveWs0 ASis1Tc/XQnyHYGm/eKBe+KSB+gc80PAyN/uWfIpW2HRRQSZruPWyeiETNkC82HWYHgxDaKc= X-Gm-Gg: AeBDietjhS5gvAyZs/NhSbVSlOO5koLXicFUCRxVivMyedUrYGv5Lmm51kJi9Ep0aQZ V1iHLg/8qxLckqlfu8ijBtP6WeiLLa2GyDny3LN8Lq8/XKGg8BYxFVVePXmsauUb78FP4T4dS2i TJBdCsQMIYpeeZiVb7jiplOKvDI+m1zEQrEvjX7uH7jWqbt0zW8rJmXXXFMIWkO1wajJg7ARi5r n39zuRWvq3a/2Nu9pIXdgMPvUTUMagXGCKXZJ3Bc1ljJ7Xt1EhKoVCoO19gMkHLV4x+kvejSod0 wSEAwP6m1RAH/8cJeNx6nkzvy1ByRPkBDW1nTkLyPpmFLk270sNu2PIzy27doVFHMEBS/EOSuSX dBrx3N4dv9ifY6mb7HkaSIXmtBa8= X-Received: by 2002:a05:6000:420a:b0:43c:4810:dc4a with SMTP id ffacd0b85a97d-43fe3e14f81mr28954112f8f.38.1776784744977; Tue, 21 Apr 2026 08:19:04 -0700 (PDT) X-Received: by 2002:a05:6000:420a:b0:43c:4810:dc4a with SMTP id ffacd0b85a97d-43fe3e14f81mr28954062f8f.38.1776784744283; Tue, 21 Apr 2026 08:19:04 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4cb1176sm39470640f8f.3.2026.04.21.08.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 08:19:03 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/tui] Handle tui disable in new ui In-Reply-To: <20260403094046.2876515-1-tdevries@suse.de> References: <20260403094046.2876515-1-tdevries@suse.de> Date: Tue, 21 Apr 2026 16:19:02 +0100 Message-ID: <877bq02vfd.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oFrT2US2a_uJzsLDHJN3SKRaO0dAWQQg_ERSk9h4McM_1776784746 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 Tom de Vries writes: > I tried out the following scenario. > > First, I start a terminal to get a tty [1]. > ... > $ gnome-terminal -- bash -c "tty; sleep 999999999" & > ... > > Then I start gdb, and start a new UI in the tty: > ... > $ gdb > (gdb) new-ui console /dev/pts/3 > New UI allocated > (gdb) > ... > > Now I have two terminals, each with a gdb prompt. > > I try in the new UI to enable TUI: > ... > (gdb) tui enable > =E2=9D=8C=EF=B8=8F Cannot enable the TUI when the interpreter is 'console= ' > (gdb) > ... > but that is not allowed. > > So instead, I enable TUI in the main UI. So far so good. > > Now I disable TUI in the new UI. That leaves the new UI in this state: > ... > (gdb) tui disable > > ... > So, no gdb prompt. > > The main UI does leave TUI, AFAICT. > > If I do "print 1" in the new UI, I get the result in the main UI, = which > is not supposed to happen. > > Fix this by instead throwing an error if we try to disable TUI in the new= UI: > ... > (gdb) tui disable > =E2=9D=8C=EF=B8=8F Cannot enable or disablethe TUI when the interpreter = is 'console' > (gdb) > ... > > We could try to fix this instead by allowing tui enable/disable from the = new > UI, using: > ... > scoped_restore restore_interpreter > =3D make_scoped_restore (¤t_ui, main_ui); > ... > but with just that change, when doing "tui enable" in the new UI we do ge= t a > TUI layout in the main UI, but no gdb prompt. The prompt does appear aft= er a > new keystroke in the main UI though. > > A few more TUI commands (for instance "layout asm") have the same problem= : > - they work when entered in the new UI, > - they have an effect in the main UI, but > - they don't show a prompt in the main UI. > > I left that problem as is, and exercised some TUI commands in a new UI in= the > test-case. > > Tested on x86_64-linux. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D34035 LGTM. Approved-By: Andrew Burgess Thanks, Andrew > --- > gdb/testsuite/gdb.tui/new-ui.exp | 93 ++++++++++++++++++++++++++++++++ > gdb/tui/tui.c | 18 +++++-- > 2 files changed, 107 insertions(+), 4 deletions(-) > create mode 100644 gdb/testsuite/gdb.tui/new-ui.exp > > diff --git a/gdb/testsuite/gdb.tui/new-ui.exp b/gdb/testsuite/gdb.tui/new= -ui.exp > new file mode 100644 > index 00000000000..8fe3567077a > --- /dev/null > +++ b/gdb/testsuite/gdb.tui/new-ui.exp > @@ -0,0 +1,93 @@ > +# 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 TUI in combination with a new UI. > + > +tuiterm_env > + > +# Creating a pty is done on build, and we use it with gdb on host, so we= need > +# build =3D=3D host, in other words, local host. > +require {!is_remote host} > + > +# Create a pty. > +spawn -pty > +set new_ui_spawn_id $spawn_id > +set new_ui_tty_name $spawn_out(slave,name) > + > +set re_cannot_enable_disable_tui \ > + "Cannot enable or disable the TUI when the interpreter is 'console'" > + > +with_test_prefix main-ui { > + Term::clean_restart 24 80 > + > + # Check that we cannot setup a new tui UI. Also checked in > + # gdb.base/new-ui.exp. > + gdb_test "new-ui tui $new_ui_tty_name" \ > +=09"interpreter 'tui' cannot be used with a new UI" \ > +=09{new-ui tui $new_ui_tty_name} > + > + # Set up a new console UI. > + gdb_test "new-ui console $new_ui_tty_name" \ > +=09"New UI allocated" \ > +=09{new-ui cli $new_ui_tty_name} > +} > + > +with_test_prefix new-ui { > + with_spawn_id $new_ui_spawn_id { > +=09# Check that we cannot enable TUI in the new UI. > +=09gdb_test "tui enable" $re_cannot_enable_disable_tui > + } > +} > + > +with_test_prefix main-ui { > + if {![Term::enter_tui]} { > +=09unsupported "TUI not supported" > +=09return > + } > +} > + > +with_test_prefix new-ui { > + with_spawn_id $new_ui_spawn_id { > +=09# Check that we cannot disable TUI in the new UI. > +=09# Regression test for PR34035. Without the fix, this test will timeo= ut, > +=09# because no prompt will appear. > +=09gdb_test "tui disable" $re_cannot_enable_disable_tui > + > +=09gdb_test "print 1" \ > +=09 [quotemeta {$@DECIMAL =3D 1}] \ > +=09 "Check that UI is responsive" > + } > + > + # Try out some TUI commands. We don't check for the effect in the m= ain > + # UI, we just check that the main UI is still responsive at the end. > + with_spawn_id $new_ui_spawn_id { > +=09gdb_test "info win" [quotemeta "@...(has focus)@..."] > + > +=09gdb_test "focus cmd" \ > +=09 [string_to_regexp "Focus set to cmd window."] > + > +=09# This command leaves a blinking cursor at the end of the status line= . > +=09gdb_test_no_output "layout asm" > + > +=09gdb_test "winheight asm +1" > +=09gdb_test_no_output "tui refresh" > + } > +} > + > +with_test_prefix main-ui { > + gdb_assert {[Term::command "print 1"]} \ > +=09"Check that UI is responsive" > + Term::dump_screen > +} > diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c > index 9cf21f390c8..5e39eef71c6 100644 > --- a/gdb/tui/tui.c > +++ b/gdb/tui/tui.c > @@ -394,6 +394,17 @@ gdb_getenv_term (void) > return ""; > } > =20 > +/* Error out if the toplevel interpreter is not the TUI interpreter. */ > + > +static void > +require_tui_interpreter () > +{ > + const char *interp =3D top_level_interpreter ()->name (); > + if (!streq (interp, INTERP_TUI)) > + error (_("Cannot enable or disable the TUI when the interpreter is '= %s'"), > +=09 interp); > +} > + > /* Enter in the tui mode (curses). > When in normal mode, it installs the tui hooks in gdb, redirects > the gdb output, configures the readline to work in tui mode. > @@ -424,13 +435,10 @@ tui_enable (void) > #ifndef __MINGW32__ > const char *cap; > #endif > - const char *interp; > =20 > /* If the top level interpreter is not the console/tui (e.g., > =09 MI), enabling curses will certainly lose. */ > - interp =3D top_level_interpreter ()->name (); > - if (!streq (interp, INTERP_TUI)) > -=09error (_("Cannot enable the TUI when the interpreter is '%s'"), inter= p); > + require_tui_interpreter (); > =20 > /* Don't try to setup curses (and print funny control > =09 characters) if we're not outputting to a terminal. */ > @@ -556,6 +564,8 @@ tui_disable (void) > if (!tui_active) > return; > =20 > + require_tui_interpreter (); > + > /* Restore initial readline keymap. */ > rl_set_keymap (tui_readline_standard_keymap); > =20 > > base-commit: 5ae26f34ef5ac863203d63fffc968d63e823172f > --=20 > 2.51.0