[2/3,gdb/tui] Add tui_get_cmd_set/show_list

Message ID 20230527182809.20569-3-tdevries@suse.de
State New
Headers
Series Add setting for default focus window |

Commit Message

Tom de Vries May 27, 2023, 6:28 p.m. UTC
  Add new functions:
- tui_get_cmd_set_list, and
- tui_get_cmd_show_list,
similar to tui_get_cmd_list that allow introducing "set/show tui" commands in
files other than tui/tui-win.c.

No functional changes.  No users in this patch.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 50 ++++++++++++++++++++++++++++++++++++++++-------
 gdb/tui/tui-win.h |  6 ++++++
 2 files changed, 49 insertions(+), 7 deletions(-)
  

Comments

Alexandra Petlanova Hajkova May 30, 2023, 1:41 p.m. UTC | #1
On Sat, May 27, 2023 at 8:28 PM Tom de Vries via Gdb-patches <
gdb-patches@sourceware.org> wrote:

> Add new functions:
> - tui_get_cmd_set_list, and
> - tui_get_cmd_show_list,
> similar to tui_get_cmd_list that allow introducing "set/show tui" commands
> in
> files other than tui/tui-win.c.
>
> No functional changes.  No users in this patch.
>
> Tested on x86_64-linux.
> ---
>
I can confirm this change causes no regressions on ppc64le with Fedora
Rawhide.

>
>
  

Patch

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 7abd1e225b9..c187f7c33ad 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -336,6 +336,47 @@  tui_get_cmd_list (void)
   return &tuilist;
 }
 
+/* The "tui set" command list. */
+
+static struct cmd_list_element *tui_setlist;
+
+/* The "tui show" command list. */
+
+static struct cmd_list_element *tui_showlist;
+
+/* Initialize the tui_setlist and tui_showlist variables. */
+
+static void
+init_tui_set_show_lists ()
+{
+  if (tui_setlist != nullptr)
+    return;
+
+  add_setshow_prefix_cmd ("tui", class_tui,
+			  _("TUI configuration variables."),
+			  _("TUI configuration variables."),
+			  &tui_setlist, &tui_showlist,
+			  &setlist, &showlist);
+}
+
+/* See tui-win.h.  */
+
+struct cmd_list_element **
+tui_get_cmd_set_list ()
+{
+  init_tui_set_show_lists ();
+  return &tui_setlist;
+}
+
+/* See tui-win.h.  */
+
+struct cmd_list_element **
+tui_get_cmd_show_list ()
+{
+  init_tui_set_show_lists ();
+  return &tui_showlist;
+}
+
 /* The set_func hook of "set tui ..." commands that affect the window
    borders on the TUI display.  */
 
@@ -1127,16 +1168,11 @@  void _initialize_tui_win ();
 void
 _initialize_tui_win ()
 {
-  static struct cmd_list_element *tui_setlist;
-  static struct cmd_list_element *tui_showlist;
+  /* Initialize tui_setlist and tui_showlist.  */
+  init_tui_set_show_lists ();
 
   /* Define the classes of commands.
      They will appear in the help list in the reverse of this order.  */
-  add_setshow_prefix_cmd ("tui", class_tui,
-			  _("TUI configuration variables."),
-			  _("TUI configuration variables."),
-			  &tui_setlist, &tui_showlist,
-			  &setlist, &showlist);
 
   cmd_list_element *refresh_cmd
     = add_cmd ("refresh", class_tui, tui_refresh_all_command,
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..4de938fa280 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -48,6 +48,12 @@  extern void tui_update_gdb_sizes (void);
 /* Create or get the TUI command list.  */
 struct cmd_list_element **tui_get_cmd_list (void);
 
+/* Create or get the TUI set command list.  */
+extern struct cmd_list_element **tui_get_cmd_set_list ();
+
+/* Create or get the TUI show command list.  */
+extern struct cmd_list_element **tui_get_cmd_show_list ();
+
 /* Whether compact source display should be used.  */
 extern bool compact_source;