From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 95nYFx7P5WnzYysAWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 03:00:46 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eiemfvU+; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=aRsJeYLn; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ziK7+aNl; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vV+zFIOw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 337431E0BA; Mon, 20 Apr 2026 03:00:46 -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 484C31E067 for ; Mon, 20 Apr 2026 03:00:40 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 70CAA4A98F00 for ; Mon, 20 Apr 2026 07:00:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70CAA4A98F00 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eiemfvU+; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=aRsJeYLn; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ziK7+aNl; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vV+zFIOw Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id B47714BA23E3 for ; Mon, 20 Apr 2026 07:00:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B47714BA23E3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B47714BA23E3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776668411; cv=none; b=av0ArebqOpR9MSnqx5efHYDG4+SP5q9LPuhhBW1RHwMaIsY58NWSqe4WmDtYKkspjiFhZ7EB/clliVIwWuaFsbVPEhcGArJOUxJ6ZzvCRKyVgZoRIIM90UPzX96tHaNrQwLJMZfwRuQOscm/iND/fsN7KHq29oo1rq9pCfPV67o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776668411; c=relaxed/simple; bh=EgW+6ldPuoDRFlfaqsxhm1l4AMDeslJbT2X9bV5ZV5Q=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=mhYaa4eGpIxeUR3sSoGveBjV7OjAP1f9ZkwvX97/fClpZWINyDBHuFEvZdrP8Uk6Qbje5LW9WyaoI0/I82DOkK/SXXeHTz/DJ012NVwBzrLtp29kDP8ty7BSjSxbWpeF3Hgo1rhkvyPqHCPJm/ae/QMXM5TlIdZxr+efR56cHZ0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B47714BA23E3 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0E2766A7CF for ; Mon, 20 Apr 2026 07:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776668410; h=from:from:reply-to: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=zpNkJgXq/bdtXQCF0//ldBofJ/zjNkbZBjnqAhWh7As=; b=eiemfvU+IHKiOwRcmh6JbRZByLDQNA+5Rkl+BPop6ZLX7cdkwEt83+cReSzvMmafWuyIUX V2dFlxwASxYaRVUWbs7OxSfIa9ph8yV9A0MtYMBNxut+QqbSJSIrOSJDZQ0XNnqkZ2mdwa ff/u/jsqMIQfnGEoXmxCqapH09v4hho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776668410; h=from:from:reply-to: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=zpNkJgXq/bdtXQCF0//ldBofJ/zjNkbZBjnqAhWh7As=; b=aRsJeYLnuvrT4PD7KY7BAwOOnf+D0jDQGbhp0VMW1M92VcbeJkXUvYxjomO96LxJnPhhdW gwkbQYadGZs2mLAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776668409; h=from:from:reply-to: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=zpNkJgXq/bdtXQCF0//ldBofJ/zjNkbZBjnqAhWh7As=; b=ziK7+aNlVxfaFH+nU9NuJRmtnck3p16cZ6rvsV0QeS0rOIzaS/C/ivoA8KeQGkqHXrElUf UhT6kaYCnkZIVy+DqRdA1jWu7/e4BWp2/h8X4gz5WKm4FmXZ6I6iDcoFrGE771jjpkz4XB /8c3phsHGOEP4kDXFZBz2BSX8tgZICQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776668409; h=from:from:reply-to: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=zpNkJgXq/bdtXQCF0//ldBofJ/zjNkbZBjnqAhWh7As=; b=vV+zFIOw6x/4RJYRkGwdHobKNsViNm7pP2jsXXUeEtrxT+IdofJa2VfTXmImOeriAKkoG2 YKDktY0Wi3zlJ1DA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F36BE593AE for ; Mon, 20 Apr 2026 07:00:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id g3QuOvjO5WnwOAAAD6G6ig (envelope-from ) for ; Mon, 20 Apr 2026 07:00:08 +0000 Message-ID: <0b632c21-d3ff-437a-9eb0-9685655a06c3@suse.de> Date: Mon, 20 Apr 2026 09:00:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PING] [PATCH] [gdb/tui] Handle tui disable in new ui From: Tom de Vries To: gdb-patches@sourceware.org References: <20260403094046.2876515-1-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20260403094046.2876515-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:mid,sourceware.org:url,gnu.org:url,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid] 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 On 4/3/26 11:40 AM, Tom de Vries wrote: > 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 > ❌️ 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 > ❌️ 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 > = make_scoped_restore (¤t_ui, main_ui); > ... > but with just that change, when doing "tui enable" in the new UI we do get a > TUI layout in the main UI, but no gdb prompt. The prompt does appear after 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. > Ping. Thanks, - Tom > Tested on x86_64-linux. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34035 > --- > 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 == 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" \ > + "interpreter 'tui' cannot be used with a new UI" \ > + {new-ui tui $new_ui_tty_name} > + > + # Set up a new console UI. > + gdb_test "new-ui console $new_ui_tty_name" \ > + "New UI allocated" \ > + {new-ui cli $new_ui_tty_name} > +} > + > +with_test_prefix new-ui { > + with_spawn_id $new_ui_spawn_id { > + # Check that we cannot enable TUI in the new UI. > + gdb_test "tui enable" $re_cannot_enable_disable_tui > + } > +} > + > +with_test_prefix main-ui { > + if {![Term::enter_tui]} { > + unsupported "TUI not supported" > + return > + } > +} > + > +with_test_prefix new-ui { > + with_spawn_id $new_ui_spawn_id { > + # Check that we cannot disable TUI in the new UI. > + # Regression test for PR34035. Without the fix, this test will timeout, > + # because no prompt will appear. > + gdb_test "tui disable" $re_cannot_enable_disable_tui > + > + gdb_test "print 1" \ > + [quotemeta {$@DECIMAL = 1}] \ > + "Check that UI is responsive" > + } > + > + # Try out some TUI commands. We don't check for the effect in the main > + # UI, we just check that the main UI is still responsive at the end. > + with_spawn_id $new_ui_spawn_id { > + gdb_test "info win" [quotemeta "@...(has focus)@..."] > + > + gdb_test "focus cmd" \ > + [string_to_regexp "Focus set to cmd window."] > + > + # This command leaves a blinking cursor at the end of the status line. > + gdb_test_no_output "layout asm" > + > + gdb_test "winheight asm +1" > + gdb_test_no_output "tui refresh" > + } > +} > + > +with_test_prefix main-ui { > + gdb_assert {[Term::command "print 1"]} \ > + "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 ""; > } > > +/* Error out if the toplevel interpreter is not the TUI interpreter. */ > + > +static void > +require_tui_interpreter () > +{ > + const char *interp = top_level_interpreter ()->name (); > + if (!streq (interp, INTERP_TUI)) > + error (_("Cannot enable or disable the TUI when the interpreter is '%s'"), > + 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; > > /* If the top level interpreter is not the console/tui (e.g., > MI), enabling curses will certainly lose. */ > - interp = top_level_interpreter ()->name (); > - if (!streq (interp, INTERP_TUI)) > - error (_("Cannot enable the TUI when the interpreter is '%s'"), interp); > + require_tui_interpreter (); > > /* Don't try to setup curses (and print funny control > characters) if we're not outputting to a terminal. */ > @@ -556,6 +564,8 @@ tui_disable (void) > if (!tui_active) > return; > > + require_tui_interpreter (); > + > /* Restore initial readline keymap. */ > rl_set_keymap (tui_readline_standard_keymap); > > > base-commit: 5ae26f34ef5ac863203d63fffc968d63e823172f