From 24f3aded1d42f515527e2de7e8e9e26f0b77c932 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 20 Dec 2022 15:01:29 +0000 Subject: gdb/testsuite/tui: more testing of the 'focus' command I noticed that we didn't have many tests of the tui 'focus' command, so I started adding some. This exposed a bug in GDB; we are able to focus windows that should not be focusable, e.g. the 'status' window. This is harmless until we then do 'focus next' or 'focus prev', along this code path we assert that the currently focused window is focusable, which obviously, is not always true, so GDB fails with an assertion error. The fix is simple; add a check to the tui_set_focus_command function to ensure that the selected window is focusable. If it is not then an error is thrown. The new tests I've added cover this case. --- gdb/tui/tui-win.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gdb/tui') diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 5837200..9c08889 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -723,6 +723,9 @@ tui_set_focus_command (const char *arg, int from_tty) if (!win_info->is_visible ()) error (_("Window \"%s\" is not visible"), arg); + if (!win_info->can_focus ()) + error (_("Window \"%s\" cannot be focused"), arg); + tui_set_win_focus_to (win_info); gdb_printf (_("Focus set to %s window.\n"), tui_win_with_focus ()->name ()); -- cgit v1.1