aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-03-31 15:17:27 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-04-07 16:01:18 +0100
commit07c316ecaa2e47721b5e1281456e6b8b0d15c7ba (patch)
treed345f180246c27d027daf0b16fac14ca8c95c07b /gdb/tui
parent5783701b36f842b1a5057c02b62d67a0ad703834 (diff)
downloadgdb-07c316ecaa2e47721b5e1281456e6b8b0d15c7ba.zip
gdb-07c316ecaa2e47721b5e1281456e6b8b0d15c7ba.tar.gz
gdb-07c316ecaa2e47721b5e1281456e6b8b0d15c7ba.tar.bz2
gdb/tui: fix 'tui reg next/prev' command when data window is hidden
Start GDB like: $ gdb -q executable (gdb) start (gdb) layout src ... tui windows are now displayed ... (gdb) tui reg next At this point the data (register) window should be displayed, but will contain the message 'Register Values Unavailable', and at the console you'll see the message "unknown register group 'next'". The same happens with 'tui reg prev' (but the error message is slightly different). At this point you can continue to use 'tui reg next' and/or 'tui reg prev' and you'll keep getting the error message. The problem is that when the data (register) window is first displayed, it's current register group is nullptr. As a consequence tui_reg_next and tui_reg_prev (tui/tui-regs.c) will always just return nullptr, which triggers an error in tui_reg_command. In this commit I change tui_reg_next and tui_reg_prev so that they instead return the first and last register group respectively if the current register group is nullptr. So, after this, using 'tui reg next' will (in the above case) show the first register group, while 'tui reg prev' will display the last register group.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-regs.c34
1 files changed, 14 insertions, 20 deletions
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;
}