[19/61] Minor tui_reg_next / tui_reg_prev cleanup

Message ID 20190704170311.15982-20-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey July 4, 2019, 5:02 p.m. UTC
  This changes tui_reg_next and tui_reg_prev so that they don't need to
reference the TUI_DATA_WIN globals.

2019-07-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_reg_next, tui_reg_prev): Add "current_group"
	parameter.  Don't reference globals.
	(tui_reg_command): Update.
---
 gdb/ChangeLog      |  6 ++++++
 gdb/tui/tui-regs.c | 21 +++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)
  

Patch

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 931787ae4b5..31b252e2aa8 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -468,14 +468,13 @@  tui_display_register (struct tui_data_item_window *data)
    register window is not currently being displayed.  */
 
 static struct reggroup *
-tui_reg_next (struct gdbarch *gdbarch)
+tui_reg_next (struct reggroup *current_group, struct gdbarch *gdbarch)
 {
   struct reggroup *group = NULL;
 
-  if (TUI_DATA_WIN != NULL)
+  if (current_group != NULL)
     {
-      group = TUI_DATA_WIN->current_group;
-      group = reggroup_next (gdbarch, group);
+      group = reggroup_next (gdbarch, current_group);
       if (group == NULL)
         group = reggroup_next (gdbarch, NULL);
     }
@@ -487,14 +486,13 @@  tui_reg_next (struct gdbarch *gdbarch)
    register window is not currently being displayed.  */
 
 static struct reggroup *
-tui_reg_prev (struct gdbarch *gdbarch)
+tui_reg_prev (struct reggroup *current_group, struct gdbarch *gdbarch)
 {
   struct reggroup *group = NULL;
 
-  if (TUI_DATA_WIN != NULL)
+  if (current_group != NULL)
     {
-      group = TUI_DATA_WIN->current_group;
-      group = reggroup_prev (gdbarch, group);
+      group = reggroup_prev (gdbarch, current_group);
       if (group == NULL)
 	group = reggroup_prev (gdbarch, NULL);
     }
@@ -524,10 +522,13 @@  tui_reg_command (const char *args, int from_tty)
       if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->is_visible)
 	tui_set_layout_by_name (DATA_NAME);
 
+      struct reggroup *current_group = NULL;
+      if (TUI_DATA_WIN != NULL)
+	current_group = TUI_DATA_WIN->current_group;
       if (strncmp (args, "next", len) == 0)
-	match = tui_reg_next (gdbarch);
+	match = tui_reg_next (current_group, gdbarch);
       else if (strncmp (args, "prev", len) == 0)
-	match = tui_reg_prev (gdbarch);
+	match = tui_reg_prev (current_group, gdbarch);
 
       /* This loop matches on the initial part of a register group
 	 name.  If this initial part in ARGS matches only one register