aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-06-12 13:29:43 +0200
committerTom de Vries <tdevries@suse.de>2020-06-12 13:29:43 +0200
commit8c74a764f2cf5ea5e6997e35ba0f755fe2c09889 (patch)
treec845c9044ec75facfa8df2e9e7c5cc331ef7fe93 /gdb/testsuite
parent26783bce15adc0316f9167a216519cebcf1ccac3 (diff)
downloadgdb-8c74a764f2cf5ea5e6997e35ba0f755fe2c09889.zip
gdb-8c74a764f2cf5ea5e6997e35ba0f755fe2c09889.tar.gz
gdb-8c74a764f2cf5ea5e6997e35ba0f755fe2c09889.tar.bz2
[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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog26
-rw-r--r--gdb/testsuite/gdb.python/tui-window.exp2
-rw-r--r--gdb/testsuite/gdb.tui/basic.exp2
-rw-r--r--gdb/testsuite/gdb.tui/corefile-run.exp2
-rw-r--r--gdb/testsuite/gdb.tui/empty.exp2
-rw-r--r--gdb/testsuite/gdb.tui/list-before.exp2
-rw-r--r--gdb/testsuite/gdb.tui/list.exp2
-rw-r--r--gdb/testsuite/gdb.tui/main.exp2
-rw-r--r--gdb/testsuite/gdb.tui/new-layout.exp2
-rw-r--r--gdb/testsuite/gdb.tui/regs.exp2
-rw-r--r--gdb/testsuite/gdb.tui/resize.exp2
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp2
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm.exp2
-rw-r--r--gdb/testsuite/gdb.tui/tui-missing-src.exp2
-rw-r--r--gdb/testsuite/gdb.tui/winheight.exp2
-rw-r--r--gdb/testsuite/lib/gdb.exp23
-rw-r--r--gdb/testsuite/lib/tuiterm.exp17
17 files changed, 78 insertions, 16 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ff834b7..ef36759 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,31 @@
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.
+
+2020-06-12 Tom de Vries <tdevries@suse.de>
+
PR testsuite/26110
* lib/gdb.exp (gdb_init): Revert dejagnu's override of ::unknown.
(gdb_finish): Reinstall dejagnu's override of ::unknown.
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index 1a4feeb..503823a 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -16,7 +16,7 @@
# Test a TUI window implemented in Python.
load_lib gdb-python.exp
-load_lib tuiterm.exp
+tuiterm_env
# This test doesn't care about the inferior.
standard_testfile py-arch.c
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 34e6038..3e013a9 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -15,7 +15,7 @@
# Basic TUI tests.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/corefile-run.exp b/gdb/testsuite/gdb.tui/corefile-run.exp
index 440142f..1878770 100644
--- a/gdb/testsuite/gdb.tui/corefile-run.exp
+++ b/gdb/testsuite/gdb.tui/corefile-run.exp
@@ -18,7 +18,7 @@
#
# Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/empty.exp b/gdb/testsuite/gdb.tui/empty.exp
index e5d0228..89f49d6 100644
--- a/gdb/testsuite/gdb.tui/empty.exp
+++ b/gdb/testsuite/gdb.tui/empty.exp
@@ -15,7 +15,7 @@
# Test TUI resizing with empty windows.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile
diff --git a/gdb/testsuite/gdb.tui/list-before.exp b/gdb/testsuite/gdb.tui/list-before.exp
index d2f3ef4..9c5eb56 100644
--- a/gdb/testsuite/gdb.tui/list-before.exp
+++ b/gdb/testsuite/gdb.tui/list-before.exp
@@ -15,7 +15,7 @@
# Ensure that "list" before starting the TUI will affect the view.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/list.exp b/gdb/testsuite/gdb.tui/list.exp
index 41cec12..b1e5949 100644
--- a/gdb/testsuite/gdb.tui/list.exp
+++ b/gdb/testsuite/gdb.tui/list.exp
@@ -15,7 +15,7 @@
# Ensure that "list" will switch to the source view.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/main.exp b/gdb/testsuite/gdb.tui/main.exp
index ae2393e..fd3c2cd 100644
--- a/gdb/testsuite/gdb.tui/main.exp
+++ b/gdb/testsuite/gdb.tui/main.exp
@@ -15,7 +15,7 @@
# Test that "file" shows "main".
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/new-layout.exp b/gdb/testsuite/gdb.tui/new-layout.exp
index b71de7d..3ea4dd4 100644
--- a/gdb/testsuite/gdb.tui/new-layout.exp
+++ b/gdb/testsuite/gdb.tui/new-layout.exp
@@ -15,7 +15,7 @@
# Test "tui new-layout".
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/regs.exp b/gdb/testsuite/gdb.tui/regs.exp
index e31a47d..a9296a7 100644
--- a/gdb/testsuite/gdb.tui/regs.exp
+++ b/gdb/testsuite/gdb.tui/regs.exp
@@ -15,7 +15,7 @@
# Simple test of TUI register window.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/resize.exp b/gdb/testsuite/gdb.tui/resize.exp
index 1b3f407..fd1b350 100644
--- a/gdb/testsuite/gdb.tui/resize.exp
+++ b/gdb/testsuite/gdb.tui/resize.exp
@@ -15,7 +15,7 @@
# Test TUI resizing.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
index 4aa1ba3..50cb61f 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
@@ -16,7 +16,7 @@
# Ensure that 'layout asm' can scroll away from the last line of a
# very short program using a page up sized scroll.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout-asm-short-prog.S
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm.exp b/gdb/testsuite/gdb.tui/tui-layout-asm.exp
index 257321f..44f7a3a 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm.exp
@@ -16,7 +16,7 @@
# Ensure that 'layout asm' before starting the inferior puts us in the
# asm layout and displays the disassembly for main.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp
index 2d9a851..6b5c7fa 100644
--- a/gdb/testsuite/gdb.tui/tui-missing-src.exp
+++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp
@@ -25,7 +25,7 @@
# layout must show the contents of f2.c.
# 7. Going back to main() shall result in no contents again.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile
diff --git a/gdb/testsuite/gdb.tui/winheight.exp b/gdb/testsuite/gdb.tui/winheight.exp
index 7a17c31..8ac55f8 100644
--- a/gdb/testsuite/gdb.tui/winheight.exp
+++ b/gdb/testsuite/gdb.tui/winheight.exp
@@ -15,7 +15,7 @@
# Test the "winheight" command.
-load_lib "tuiterm.exp"
+tuiterm_env
standard_testfile tui-layout.c
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 64e667c..e7fce6f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -25,6 +25,9 @@ if {$tool == ""} {
exit 2
}
+# List of procs to run in gdb_finish.
+set gdb_finish_hooks [list]
+
load_lib libgloss.exp
load_lib cache.exp
load_lib gdb-utils.exp
@@ -5241,6 +5244,12 @@ proc gdb_finish { } {
}
set banned_traced 0
}
+
+ global gdb_finish_hooks
+ foreach gdb_finish_hook $gdb_finish_hooks {
+ $gdb_finish_hook
+ }
+ set gdb_finish_hooks [list]
}
global debug_format
@@ -7259,5 +7268,19 @@ proc with_override { name override body } {
return $result
}
+# Setup tuiterm.exp environment. To be used in test-cases instead of
+# "load_lib tuiterm.exp". Calls initialization function and schedules
+# finalization function.
+proc tuiterm_env { } {
+ load_lib tuiterm.exp
+
+ # Do initialization.
+ tuiterm_env_init
+
+ # Schedule finalization.
+ global gdb_finish_hooks
+ lappend gdb_finish_hooks tuiterm_env_finish
+}
+
# Always load compatibility stuff.
load_lib future.exp
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 8c9f97a..44cbc79 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -19,8 +19,7 @@
# array; but dejagnu doesn't export this globally. So, we have to
# wrap spawn with our own function, so that we can capture this value.
# The value is later used in calls to stty.
-rename spawn builtin_spawn
-proc spawn {args} {
+proc tuiterm_spawn { args } {
set result [uplevel builtin_spawn $args]
global gdb_spawn_name
upvar spawn_out spawn_out
@@ -32,6 +31,20 @@ proc spawn {args} {
return $result
}
+# Initialize tuiterm.exp environment.
+proc tuiterm_env_init { } {
+ # Override spawn with tui_spawn.
+ rename spawn builtin_spawn
+ rename tuiterm_spawn spawn
+}
+
+# Finalize tuiterm.exp environment.
+proc tuiterm_env_finish { } {
+ # Restore spawn.
+ rename spawn tuiterm_spawn
+ rename builtin_spawn spawn
+}
+
namespace eval Term {
variable _rows
variable _cols