From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey 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-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 21 Oct 2021 13:09:13 -0000 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 */