public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC][gdb/tui] Add tui auto-refresh-screen on/off
@ 2021-10-21 13:09 Tom de Vries
  2021-10-22  6:47 ` [PATCH][gdb/tui] " Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-10-21 13:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-22  6:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 13:09 [RFC][gdb/tui] Add tui auto-refresh-screen on/off Tom de Vries
2021-10-22  6:47 ` [PATCH][gdb/tui] " Tom de Vries

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).