public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC][gdb/tui] Add tui auto-refresh-screen on/off
Date: Thu, 21 Oct 2021 15:09:09 +0200	[thread overview]
Message-ID: <20211021130908.GA22710@delia.home> (raw)

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 */

             reply	other threads:[~2021-10-21 13:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 13:09 Tom de Vries [this message]
2021-10-22  6:47 ` [PATCH][gdb/tui] " Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021130908.GA22710@delia.home \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).