diff options
author | Tom Tromey <tom@tromey.com> | 2019-08-16 15:16:12 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-11-12 12:29:14 -0700 |
commit | 45e4216376f37e543fc80062025cab0c2d9faf35 (patch) | |
tree | f2c6f0623643aaf4293481443aaa97bc554b7b33 /gdb/tui | |
parent | ef8f595f73a6b42f745bc76a716f45079eae1075 (diff) | |
download | fsf-binutils-gdb-45e4216376f37e543fc80062025cab0c2d9faf35.zip fsf-binutils-gdb-45e4216376f37e543fc80062025cab0c2d9faf35.tar.gz fsf-binutils-gdb-45e4216376f37e543fc80062025cab0c2d9faf35.tar.bz2 |
Make TUI resizing tests more robust
As Sergio pointed out, the TUI resizing tests are flaky. Debugging
this showed three main problems.
1. expect's "stty" command processes its arguments one-by-one. So,
rather than requesting a single resize, it sends two separate resize
requests (one for rows and one for columns). This means gdb sees two
SIGWINCH signals and resizes the terminal twice.
I consider this a bug in expect, but I couldn't readily see how to
report a bug; and anyway the fix wouldn't propagate very quickly.
This patch works around this problem by explicitly doing two separate
resizes (so it will be robust if expect ever does change); and then by
waiting for each resize to complete before continuing.
2. gdb uses curses to drive the console rendering. Currently the test
suite looks for terminal text insertion sequences to decide when a
command has completed. However, it turns out that, sometimes, curses
can output things in non-obvious ways. I didn't debug into curses but
I guess this can happen due to output optimizations. No matter the
reason, sometimes the current approach of only tracking text
insertions is not enough to detect that gdb has finished rendering.
This patch fixes this problem by arranging to detect the termination
output after any curses command, not just insertion.
3. Detecting when a resize has completed is tricky. In fact, I could
not find a way to reliably do this.
This patch fixes this problem by adding a special maint
"tui-resize-message" setting to gdb. When this is enabled, gdb will
print a message after each SIGWINCH has been fully processed. The
test suite enables this mode and then waits for the message in order
to know when control can be returned to the calling test.
This patch also adds a timeout, to avoid the situation where the
terminal code fails to notice a change for some reason. This lets the
test at least try to continue.
gdb/ChangeLog
2019-11-12 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (resize_message): New global.
(show_tui_resize_message): New function.
(tui_async_resize_screen): Print message if requested.
(_initialize_tui_win): Add tui-resize-message setting.
* NEWS: Add entry for new commands.
gdb/doc/ChangeLog
2019-11-12 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document new command.
gdb/testsuite/ChangeLog
2019-11-12 Tom Tromey <tom@tromey.com>
* lib/tuiterm.exp (_accept): Add wait_for parameter. Check output
after any command. Expect prompt after WAIT_FOR is seen.
(enter_tui): Enable resize messages.
(command): Expect command in output.
(get_line): Avoid error when cursor appears to be off-screen.
(dump_screen): Include screen size in title.
(_do_resize): New proc, from "resize".
(resize): Rewrite. Do resize in two steps.
* gdb.tui/empty.exp (layouts): Fix entries.
(check_boxes): Remove xfail.
(check_text): Dump screen on failure.
Change-Id: I420e0259cb99b21adcd28f671b99161eefa7a51d
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-win.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 6df5ea2..feeee34 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -33,6 +33,7 @@ #include "top.h" #include "source.h" #include "event-loop.h" +#include "gdbcmd.h" #include "tui/tui.h" #include "tui/tui-io.h" @@ -340,6 +341,22 @@ tui_set_var_cmd (const char *null_args, tui_rehighlight_all (); } + + +/* True if TUI resizes should print a message. This is used by the + test suite. */ + +static bool resize_message; + +static void +show_tui_resize_message (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("TUI resize messaging is %s.\n"), value); +} + + + /* Generic window name completion function. Complete window name pointed to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special window names 'next' and 'prev' will also be considered as possible @@ -677,6 +694,13 @@ tui_async_resize_screen (gdb_client_data arg) tui_resize_all (); tui_refresh_all_win (); tui_update_gdb_sizes (); + if (resize_message) + { + static int count; + printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count, + tui_term_width (), tui_term_height ()); + ++count; + } tui_redisplay_readline (); } } @@ -1434,4 +1458,14 @@ Show the tab witdh, in characters, for the TUI."), _("\ This variable controls how many spaces are used to display a tab character."), tui_set_tab_width, tui_show_tab_width, &tui_setlist, &tui_showlist); + + add_setshow_boolean_cmd ("tui-resize-message", class_maintenance, + &resize_message, _("\ +Set TUI resize messaging."), _("\ +Show TUI resize messaging."), _("\ +When enabled GDB will print a message when the terminal is resized."), + nullptr, + show_tui_resize_message, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); } |