From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9aPGG9FmcWFnTQAAWB0awg (envelope-from ) for ; Thu, 21 Oct 2021 09:10:41 -0400 Received: by simark.ca (Postfix, from userid 112) id 61C3B1F0BD; Thu, 21 Oct 2021 09:10:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7CA211ECEB for ; Thu, 21 Oct 2021 09:10:39 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F00543857C7B for ; Thu, 21 Oct 2021 13:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F00543857C7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1634821839; bh=4wNktc4lu2jKbyxXM0U4YO6TRarFzz3/nI7qa/uw1gU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=G3GmGpwlNr7eUz2cUWUSfZHXsLC2j3kZrgTi8r4l7E467Y8/PIBhRAna9qZXWTL6J 0OYWN44gwUtZnYX3zTKm9LBI+z+fkx8+Sp1aovRFPlYoc0YML81hoQ74obfqW5feOm /8sU++NAyPbSQIWYOF51NWri6sApUQQeYoIxtYy4= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 9A3553858025 for ; Thu, 21 Oct 2021 13:09:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A3553858025 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CD7B8218BB; Thu, 21 Oct 2021 13:09:10 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B6FE613BA5; Thu, 21 Oct 2021 13:09:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xamZK3ZmcWHMGQAAMHmgww (envelope-from ); Thu, 21 Oct 2021 13:09:10 +0000 Date: Thu, 21 Oct 2021 15:09:09 +0200 To: gdb-patches@sourceware.org Subject: [RFC][gdb/tui] Add tui auto-refresh-screen on/off Message-ID: <20211021130908.GA22710@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, As reported in PR28482, the tui screen may become garbled. A common workaround is to do ^L (or equivalently, issue the refresh command). There are two drawbacks to this workaround: - you need to known it in order to be able to use it. A new user that doesn't know about the workaround may well take having a garbled screen as an indication of software maturity, and decide to not invest further. - the workaround is so frequently used that people have started to try to automate the workaround outside gdb [1]. Introduce a new tui on/off variable auto-refresh-screen that automatically issues the refresh command when displaying the prompt, which fixes the problem observed in PR28482. It may be possible that this needs to be done at more locations. A drawback of automating the refresh is that it may cause (more) flickering (I haven't observed that, but I imagine it could). This is mentioned in the help text. The default setting is on. Build on x86_64-linux, tested with all .exp test-cases that contain tuiterm_env. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28482 [1] https://stackoverflow.com/questions/38803783/how-to-automatically-refresh-gdb-in-tui-mode Any comments? Thanks, - Tom [gdb/tui] Add tui auto-refresh-screen on/off --- gdb/tui/tui-hooks.c | 2 ++ gdb/tui/tui-win.c | 31 +++++++++++++++++++++++++++++++ gdb/tui/tui-win.h | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 52519aecf17..359efa39901 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -185,6 +185,8 @@ tui_before_prompt (const char *current_gdb_prompt) tui_refresh_frame_and_register_information (); from_stack = false; from_source_symtab = false; + if (auto_refresh_screen) + tui_refresh_all_win (); } /* Observer for the normal_stop notification. */ diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index a51e7b9f6da..987cecbc7f6 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -975,6 +975,25 @@ parse_scrolling_args (const char *arg, } } +bool auto_refresh_screen = true; + +/* Callback for "set tui auto-refresh-screen". */ + +static void +tui_set_auto_refresh_screen (const char *ignore, int from_tty, + struct cmd_list_element *c) +{ +} + +/* Callback for "show tui auto-refresh-screen". */ + +static void +tui_show_auto_refresh_screen (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + printf_filtered (_("TUI auto-refresh-screen is %s.\n"), value); +} + /* Function to initialize gdb commands, for tui window manipulation. */ @@ -1114,6 +1133,18 @@ the line numbers and uses less horizontal space."), tui_set_compact_source, tui_show_compact_source, &tui_setlist, &tui_showlist); + add_setshow_boolean_cmd ("auto-refresh-screen", class_tui, + &auto_refresh_screen, _("\ +Enable/disable TUI auto-refresh-screen."), _("\ +Show whether TUI auto-refresh-screen is enabled/disabled."), _("\ +In some cases, the TUI screen may become garbled, which can be fixed\n\ +by doing ^L or issuing the refresh command. This variable controls\n\ +whether the TUI screen is refreshed automatically. This may cause\n\ +more flickering. Defaults to on."), + tui_set_auto_refresh_screen, + tui_show_auto_refresh_screen, + &tui_setlist, &tui_showlist); + tui_border_style.changed.attach (tui_rehighlight_all, "tui-win"); tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win"); } diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index e9da9b98477..9bac6ec16a3 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -51,4 +51,8 @@ struct cmd_list_element **tui_get_cmd_list (void); /* Whether compact source display should be used. */ extern bool compact_source; +/* Whether tui should automatically refresh the screen to reduce screen + garbling. */ +extern bool auto_refresh_screen; + #endif /* TUI_TUI_WIN_H */