[gdb/testsuite] Don't leak tuiterm.exp spawn override
authorTom de Vries <tdevries@suse.de>
Fri, 12 Jun 2020 11:29:43 +0000 (13:29 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 12 Jun 2020 11:29:43 +0000 (13:29 +0200)
commit8c74a764f2cf5ea5e6997e35ba0f755fe2c09889
treec845c9044ec75facfa8df2e9e7c5cc331ef7fe93
parent26783bce15adc0316f9167a216519cebcf1ccac3
[gdb/testsuite] Don't leak tuiterm.exp spawn override

In lib/tuiterm.exp the builtin spawn is overridden by a tui-specific version.

After running the first test-case that imports tuiterm.exp, the override
remains active, so it can cause trouble in subsequent test-cases, even if they
do not import tuiterm.exp.  See f.i. commit c8d4f6dfd9 "[gdb/testsuite] Fix
spawn in tuiterm.exp".

Fix this by:
- adding a variable gdb_finish_hooks which is a list of procs to run during
  gdb_finish
- adding a proc tuiterm_env that is used in test-cases instead of
  "load_lib tuiterm.exp".
- letting tuiterm_env:
  - install the tui-specific spawn version, and
  - use the gdb_finish_hooks to schedule restoring the builtin spawn
    version.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-06-12  Tom de Vries  <tdevries@suse.de>

* lib/tuiterm.exp (spawn): Rename to ...
(tui_spawn): ... this.
(toplevel): Move rename of spawn ...
(gdb_init_tuiterm): ... here.  New proc.
(gdb_finish_tuiterm): New proc.
* lib/gdb.exp (gdb_finish_hooks): New global var.
(gdb_finish): Handle gdb_finish_hooks.
(tuiterm_env): New proc.
* gdb.python/tui-window.exp: Replace load_lib tuiterm.exp with
tuiterm_env.
* gdb.tui/basic.exp: Same.
* gdb.tui/corefile-run.exp: Same.
* gdb.tui/empty.exp: Same.
* gdb.tui/list-before.exp: Same.
* gdb.tui/list.exp: Same.
* gdb.tui/main.exp: Same.
* gdb.tui/new-layout.exp: Same.
* gdb.tui/regs.exp: Same.
* gdb.tui/resize.exp: Same.
* gdb.tui/tui-layout-asm-short-prog.exp: Same.
* gdb.tui/tui-layout-asm.exp: Same.
* gdb.tui/tui-missing-src.exp: Same.
* gdb.tui/winheight.exp: Same.
17 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/tui-window.exp
gdb/testsuite/gdb.tui/basic.exp
gdb/testsuite/gdb.tui/corefile-run.exp
gdb/testsuite/gdb.tui/empty.exp
gdb/testsuite/gdb.tui/list-before.exp
gdb/testsuite/gdb.tui/list.exp
gdb/testsuite/gdb.tui/main.exp
gdb/testsuite/gdb.tui/new-layout.exp
gdb/testsuite/gdb.tui/regs.exp
gdb/testsuite/gdb.tui/resize.exp
gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
gdb/testsuite/gdb.tui/tui-layout-asm.exp
gdb/testsuite/gdb.tui/tui-missing-src.exp
gdb/testsuite/gdb.tui/winheight.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/tuiterm.exp