aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/testsuite/gdb.tui/regs.exp26
-rw-r--r--gdb/tui/tui-regs.c34
2 files changed, 40 insertions, 20 deletions
diff --git a/gdb/testsuite/gdb.tui/regs.exp b/gdb/testsuite/gdb.tui/regs.exp
index 2f3482f..4f34ced 100644
--- a/gdb/testsuite/gdb.tui/regs.exp
+++ b/gdb/testsuite/gdb.tui/regs.exp
@@ -44,3 +44,29 @@ Term::check_box "source box in regs layout" 0 7 80 8
set text [Term::get_line 1]
# Just check for any register window content at all.
Term::check_contents "any register contents" "\\|.*\[^ \].*\\|"
+
+
+# Check that we can successfully cause the register window to appear
+# using the 'tui reg next' and 'tui reg prev' commands.
+foreach_with_prefix cmd { next prev } {
+ Term::clean_restart 24 80 $testfile
+
+ if {![runto_main]} {
+ perror "test suppressed"
+ return
+ }
+
+ if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+ }
+
+ Term::command "tui reg ${cmd}"
+ Term::check_box "register box" 0 0 80 8
+ Term::check_box "source box in regs layout" 0 7 80 8
+ Term::check_region_contents "check register group title" \
+ 0 0 80 1 "Register group: "
+ set contents [Term::get_region 0 15 80 8 "\r\n"]
+ gdb_assert {![regexp -- "unknown register group '${cmd}'" $contents]} \
+ "check register group is known"
+}
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 75ffa9b..b968947 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -515,38 +515,32 @@ tui_data_item_window::rerender (WINDOW *handle, int field_width)
}
/* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap
- around behaviour. Returns the next register group, or NULL if the
- register window is not currently being displayed. */
+ around behaviour. Will never return nullptr. If CURRENT_GROUP is
+ nullptr (e.g. if the tui register window has only just been displayed
+ and has no current group selected), then the first register group will
+ be returned. */
static const reggroup *
tui_reg_next (const reggroup *current_group, struct gdbarch *gdbarch)
{
- const reggroup *group = NULL;
-
- if (current_group != NULL)
- {
- group = reggroup_next (gdbarch, current_group);
- if (group == NULL)
- group = reggroup_next (gdbarch, NULL);
- }
+ const reggroup *group = reggroup_next (gdbarch, current_group);
+ if (group == NULL)
+ group = reggroup_next (gdbarch, NULL);
return group;
}
/* Helper for "tui reg prev", wraps a call to REGGROUP_PREV, but adds wrap
- around behaviour. Returns the previous register group, or NULL if the
- register window is not currently being displayed. */
+ around behaviour. Will never return nullptr. If CURRENT_GROUP is
+ nullptr (e.g. if the tui register window has only just been displayed
+ and has no current group selected), then the last register group will
+ be returned. */
static const reggroup *
tui_reg_prev (const reggroup *current_group, struct gdbarch *gdbarch)
{
- const reggroup *group = NULL;
-
- if (current_group != NULL)
- {
- group = reggroup_prev (gdbarch, current_group);
- if (group == NULL)
- group = reggroup_prev (gdbarch, NULL);
- }
+ const reggroup *group = reggroup_prev (gdbarch, current_group);
+ if (group == NULL)
+ group = reggroup_prev (gdbarch, NULL);
return group;
}