From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sUqKIApy2GqeGgEAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 04:04:26 -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=1UQlODRo; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=w3XI08aj; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fMffaivq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=0VLCNEJM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7F3B41E090; Wed, 21 Oct 2026 04:04:26 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 18ECD1E047 for ; Wed, 21 Oct 2026 04:04:25 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CC314BA23DC for ; Wed, 21 Oct 2026 08:04:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CC314BA23DC 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=1UQlODRo; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=w3XI08aj; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fMffaivq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=0VLCNEJM Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 0E36F4BA2E16 for ; Wed, 21 Oct 2026 08:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E36F4BA2E16 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 0E36F4BA2E16 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792569692; cv=none; b=D5n8NNuZPpWnFKu1gbweM/k8OlnjbDBIzBAeNpaL1CS1+JuRoyxtXWiyFPkGjvanhI4i/Q32xVphcKnmWGQVfyDiepzYndexbZBtLaUa2DVYAo37EeRSzg+Ffm6zFRJdOnxasFfYbnJYgc/sZUwCly+l0y+FK44f/gM/61T8Fzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792569692; c=relaxed/simple; bh=2XimT8qJZyzQ1pqxw9qJD8fIy40wJmhfZjB18MLBhe0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=k2W4RHNgGgxRUJ7lCS2rYd1WFe2k8yteUAHlhTOWr3A+QFAoZwaBPvlpw/0mq4ozXVI2lAMpowjsGWH9cSulqhZChO1QVXz+m51ncRbZaTCkoaUPJD2f76o5oMQJ+7t4pYTCp+Q6ZavCHPGDUCoUzloLQPomSftdIynC1YhyTWw= ARC-Authentication-Results: i=1; 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=1UQlODRo; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=w3XI08aj; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fMffaivq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=0VLCNEJM DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E36F4BA2E16 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 7430C1F7CE for ; Wed, 21 Oct 2026 08:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792569689; 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=AdmyxVqbhmCdZJlPSZxVDqqXcG6BMARvFjVASvYQEHo=; b=1UQlODRo0ccqJzpnQK68s8hl0aBA+tj8YcbUGuNdwpMOfs1acSYqoV8SDNVoHRvI82btFH WKnCiL45qqpZY4GHpSyg8iTHPbYQJscqJedxpvQyLkIOmgPkdbDwyUhPsq4oHBlRkHU5By 1QH7sFujJ9YNIOIBqrBizsubM7KFpAY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792569689; 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=AdmyxVqbhmCdZJlPSZxVDqqXcG6BMARvFjVASvYQEHo=; b=w3XI08aj2h0Q3nCCzBBkj0sqjEPjIF56CxvxKoi8OVyQyLtBfzi0QZmXQX9A3MgYuL+Bpa 8EGS1t3T2U8k0GCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=fMffaivq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0VLCNEJM DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792569684; 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=AdmyxVqbhmCdZJlPSZxVDqqXcG6BMARvFjVASvYQEHo=; b=fMffaivqfOkNR5KENibPfU8lvd9ReDAlUDO/BB4krEr2X0C1u/t7ETto/HOICYH49/h7jA oBp+VD7r5GkFMqdPEZlLgClSeXLhglICFM3Rty7Z7bbRN5sqY/SsIw5VZyFJwwN4EvSrD9 I2U51/jvQnGJ1wvyFO9bOV1VmWA31qc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792569684; 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=AdmyxVqbhmCdZJlPSZxVDqqXcG6BMARvFjVASvYQEHo=; b=0VLCNEJMEoIybu84OHSljNUHfQ9jHR7LZdP61pUiw9wg81IqO5vbVu7fYbyWCK71BGuZvY HqleMr5WGXRUxfBA== 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 EF9A21351E for ; Wed, 21 Oct 2026 08:01:20 +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 ZNGOHVBx2GpjNwAAD6G6ig:T4 (envelope-from ) for ; Wed, 21 Oct 2026 08:01:20 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/4] [gdb/tui] Switch to main UI before disabling TUI Date: Wed, 21 Oct 2026 10:01:19 +0200 Message-ID: <20261021080120.349861-4-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261021080120.349861-1-tdevries@suse.de> References: <20261021080120.349861-1-tdevries@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, gdb.tui:url] X-Rspamd-Queue-Id: 7430C1F7CE X-Rspamd-Server: rspamd2.dmz-prg2.suse.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~public-inbox=simark.ca@sourceware.org Test-case gdb.tui/new-ui.exp has a setup where the main UI is in TUI mode, and a new UI is in CLI mode. When doing "maint internal-error" in the new UI, we'd expect something like: ... ❌ Command aborted. (gdb) ... but instead we get: ... (gdb) maint internal-error Cannot enable or disable the TUI when the interpreter is 'console' (gdb) ... Fix this by temporarily switching to the main UI before doing tui_disable in internal_vproblem, similar to what is done in undo_terminal_modifications_before_exit. Likewise in handle_fatal_signal and tui_exit. I've updated test-case gdb.tui/new-ui to handle the new behavior. Thanks to previous commit "Add logging_file::fd", the backtrace now ends up in the new UI instead of in the main UI. The output for the command to check that TUI is no longer active looks odd in the sense that a newline is missing: ... 21 info win 22 (gdb) info winThe TUI is not active. 23 (gdb) ... so I've made a note of that in the test-case, but glitches like this are not unexpected, given that we've only recently started testing this type of setup. --- gdb/event-top.c | 8 +++++++- gdb/testsuite/gdb.tui/new-ui.exp | 12 +++++++++++- gdb/tui/tui-interp.c | 4 ++++ gdb/utils.c | 8 +++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 0fb6eafec57..eedf75331ba 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -971,7 +971,13 @@ init_str_handle_fatal_signal () handle_fatal_signal (int sig) { #ifdef TUI - tui_disable (); + { + /* Switch to the main UI, otherwise TUI won't be disabled. */ + scoped_restore restore_current_ui + = make_scoped_restore (¤t_ui, main_ui); + + tui_disable (); + } #endif #ifdef GDB_PRINT_INTERNAL_BACKTRACE diff --git a/gdb/testsuite/gdb.tui/new-ui.exp b/gdb/testsuite/gdb.tui/new-ui.exp index 3063868334b..5c2066e785f 100644 --- a/gdb/testsuite/gdb.tui/new-ui.exp +++ b/gdb/testsuite/gdb.tui/new-ui.exp @@ -113,7 +113,7 @@ with_test_prefix new-ui { send_gdb "$cmd\n" set re \ [multi_line \ - $re_cannot_enable_disable_tui \ + [string_to_regexp "Command aborted."] \ "$gdb_prompt $"] gdb_expect { -re $re { @@ -131,3 +131,13 @@ with_test_prefix new-ui { } } } + +with_test_prefix main-ui { + # Currently there's a missing newline after running this command: + # (gdb) info winThe TUI is not active. + # (gdb) + send_gdb "info win\n" + set re_no_tui [string_to_regexp "The TUI is not active."] + gdb_assert {[Term::wait_for $re_no_tui]} "TUI disabled" + Term::dump_screen +} diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index e171ae6263e..5d1305a8fec 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -55,6 +55,10 @@ class tui_interp final : public cli_interp_base static void tui_exit (void) { + /* Switch to the main UI, otherwise TUI won't be disabled. */ + scoped_restore restore_current_ui + = make_scoped_restore (¤t_ui, main_ui); + /* Disable the tui. Curses mode is left leaving the screen in a clean state (see endwin()). */ tui_disable (); diff --git a/gdb/utils.c b/gdb/utils.c index 5deecdbba94..1ec7454a606 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -389,7 +389,13 @@ internal_vproblem (struct internal_problem *problem, } #ifdef TUI - tui_disable (); + { + /* Switch to the main UI, otherwise TUI won't be disabled. */ + scoped_restore restore_current_ui + = make_scoped_restore (¤t_ui, main_ui); + + tui_disable (); + } #endif /* Create a string containing the full error/warning message. Need -- 2.51.0