gdb/testsuite/tui: more testing of the 'focus' command
authorAndrew Burgess <aburgess@redhat.com>
Tue, 20 Dec 2022 15:01:29 +0000 (15:01 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 25 Jan 2023 10:50:57 +0000 (10:50 +0000)
commit24f3aded1d42f515527e2de7e8e9e26f0b77c932
tree9f12fba044ed7ffeee8af28261e72f1c0ecd46a1
parent3602634035f6a346ac043a7f01442a7290b9f588
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/testsuite/gdb.tui/tui-focus.c [new file with mode: 0644]
gdb/testsuite/gdb.tui/tui-focus.exp [new file with mode: 0644]
gdb/tui/tui-win.c