]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/testsuite: capture GDB tty name in default_gdb_spawn
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 10 Jun 2021 18:30:33 +0000 (14:30 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 10 Jun 2021 18:30:35 +0000 (14:30 -0400)
commit9edb1e0191e582d28848684f259fd97a24c24701
tree7b01066bcf1362df92ca3a561e7ac1a997c89d20
parent6179e5f1d8d54e10a128e4de9c96ecda79e788bf
gdb/testsuite: capture GDB tty name in default_gdb_spawn

The TUI test gdb.tui/empty.exp fails with the native-extended-gdbserver
board, and takes a very long time to run due to numerous timeouts.  The
symptom, when looking at the logs, is that the TUI windows that we
expect to be resized are not resized.  Digging down, I found that GDB
didn't receive any SIGWINCH that should have resulted from
Term::resize's stty calls.

The reason for this is:

- The native-extended-gdbserver overrides gdb_start to first start GDB,
  then start GDBserver with --multi, then connect GDB to GDBserver.
  This means that two TCL "spawn"s are done, one for GDB and one for
  GDBserver.

- The TUI test framework  wants to know GDB's TTY name, so it can pass
  it to stty, to fake terminal resizes.  To do so, it overrides the
  spawn built-in proc to capture the tty name from the internals of the
  built-in proc.  It saves the TTY name to the gdb_spawn_name global
  variable.

- Because the native-extended-gdbserver boards starts both GDB and
  GDBserver, the final value of gdb_spawn_name is the name of
  GDBserver's TTY.

- When the TUI test framework attempts to resize GDB's terminal, it in
  fact resizes GDBserver's terminal.  So obviously, GDB doesn't get the
  SIGWINCH, and we don't get the expected TUI redraw.

Fix that by moving the hack to lib/gdb.exp, overriding the builtin spawn
all the time.  The override saves the TTY name in the
last_spawn_tty_name global.  The default_gdb_spawn proc then saves it in
the gdb_tty_name global.  This way, we specifically capture GDB's TTY
name in gdb_tty_name, not the TTY name of other spawned processes.

Remove tuiterm_env_init and tuiterm_env_finish, since they are now
empty.  In turn, the gdb_finish_hooks mechanism is now unused, remove it
as well.  It would be easy to add them back if needed.

gdb/ChangeLog:

* lib/gdb.exp (default_gdb_exit): Unset gdb_tty_name.
(spawn_capture_tty_name): New, override builtin spawn.
(default_gdb_spawn): Capture GDB's TTY name.
* lib/tuiterm.exp (tuiterm_spawn): Remove.
(tuiterm_env_init, tuiterm_env_finish): Remove spawn override.
(Term) <resize>: Use new variable name.
(tuiterm_env_init, tuiterm_env_finish): Remove.
(tuiterm_env): Don't call tuiterm_env_init and register
tuiterm_env_finish in gdb_finish_hooks.
(gdb_finish_hooks): Remove.
(gdb_finish): Don't call finish hooks.

Change-Id: Ia5ab74184a52a996416022308f8d0cc523355a78
gdb/ChangeLog
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/tuiterm.exp