* [PATCH 0/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp
@ 2026-09-27 4:57 Tom de Vries
2026-09-27 4:57 ` [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill Tom de Vries
2026-09-27 4:57 ` [PATCH 2/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
0 siblings, 2 replies; 4+ messages in thread
From: Tom de Vries @ 2026-09-27 4:57 UTC (permalink / raw)
To: gdb-patches
I noticed a cleanup was needed in gdb.multi/checkpoint-multi.exp.
While working on it, I realized the opportunity for some refactoring related
to the kill command.
The first patch contains the refactoring.
The second patch contains the cleanup.
Tested on x86_64-linux and aarch64-linux.
Tom de Vries (2):
[gdb/testsuite] Factor out gdb_test_kill
[gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp
gdb/testsuite/gdb.base/attach-wait-input.exp | 6 ++---
gdb/testsuite/gdb.base/attach.exp | 8 +++---
gdb/testsuite/gdb.base/break-interp.exp | 2 +-
gdb/testsuite/gdb.base/break.exp | 2 +-
gdb/testsuite/gdb.base/catch-fork-kill.exp | 3 +--
gdb/testsuite/gdb.base/checkpoint.exp | 6 ++---
.../detach-in-breakpoint-commands.exp | 2 +-
gdb/testsuite/gdb.base/hbreak2.exp | 3 +--
gdb/testsuite/gdb.base/hook-stop.exp | 2 +-
gdb/testsuite/gdb.base/info-program.exp | 3 +--
gdb/testsuite/gdb.base/kill-after-signal.exp | 6 +----
gdb/testsuite/gdb.base/run-after-attach.exp | 4 +--
.../run-control-while-bg-execution.exp | 2 +-
gdb/testsuite/gdb.base/sepdebug.exp | 2 +-
gdb/testsuite/gdb.base/traced-thread.exp | 2 +-
gdb/testsuite/gdb.base/valgrind-bt.exp | 2 +-
gdb/testsuite/gdb.cp/mb-templates.exp | 3 +--
gdb/testsuite/gdb.guile/scm-value.exp | 4 +--
gdb/testsuite/gdb.multi/checkpoint-multi.exp | 17 ++++++------
gdb/testsuite/gdb.multi/multi-attach.exp | 4 +--
.../gdb.multi/pending-bp-del-inferior.exp | 3 +--
.../gdb.multi/watchpoint-multi-exit.exp | 3 +--
gdb/testsuite/gdb.python/py-value.exp | 4 +--
gdb/testsuite/gdb.reverse/break-precsave.exp | 4 +--
.../gdb.reverse/consecutive-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/finish-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/i386-precsave.exp | 4 +--
.../gdb.reverse/machinestate-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/sigall-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/solib-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/step-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/until-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/watch-precsave.exp | 4 +--
gdb/testsuite/gdb.server/ext-attach.exp | 2 +-
gdb/testsuite/gdb.server/ext-restart.exp | 2 +-
gdb/testsuite/gdb.server/ext-run.exp | 2 +-
gdb/testsuite/gdb.server/ext-wrapper.exp | 2 +-
.../gdb.server/extended-remote-restart.exp | 6 ++---
.../attach-many-short-lived-threads.exp | 2 +-
.../infcall-from-bp-cond-simple.exp | 3 +--
gdb/testsuite/gdb.threads/kill.exp | 6 +----
.../gdb.threads/threads-after-exec.exp | 4 +--
gdb/testsuite/lib/gdb.exp | 26 +++++++++++++++++++
43 files changed, 92 insertions(+), 96 deletions(-)
base-commit: 196286d25ccc652dc086ae173d1cfa836bed0618
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill
2026-09-27 4:57 [PATCH 0/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
@ 2026-09-27 4:57 ` Tom de Vries
2026-09-28 11:01 ` Andrew Burgess
2026-09-27 4:57 ` [PATCH 2/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
1 sibling, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2026-09-27 4:57 UTC (permalink / raw)
To: gdb-patches
Replace all kill commands with "" or ".*" pattern and question/response:
...
gdb_test "kill" "" "kill program" \
"Kill the program being debugged.*y or n. $" \
"y"
...
with:
...
gdb_test "with confirm off -- kill" "" "kill program"
...
Factor out procs gdb_test_kill and inferior_killed_re and use for cases where
the output of the kill command is matched more precisely.
---
gdb/testsuite/gdb.base/attach-wait-input.exp | 6 ++---
gdb/testsuite/gdb.base/attach.exp | 8 +++---
gdb/testsuite/gdb.base/break-interp.exp | 2 +-
gdb/testsuite/gdb.base/break.exp | 2 +-
gdb/testsuite/gdb.base/catch-fork-kill.exp | 3 +--
gdb/testsuite/gdb.base/checkpoint.exp | 6 ++---
.../detach-in-breakpoint-commands.exp | 2 +-
gdb/testsuite/gdb.base/hbreak2.exp | 3 +--
gdb/testsuite/gdb.base/hook-stop.exp | 2 +-
gdb/testsuite/gdb.base/info-program.exp | 3 +--
gdb/testsuite/gdb.base/kill-after-signal.exp | 6 +----
gdb/testsuite/gdb.base/run-after-attach.exp | 4 +--
.../run-control-while-bg-execution.exp | 2 +-
gdb/testsuite/gdb.base/sepdebug.exp | 2 +-
gdb/testsuite/gdb.base/traced-thread.exp | 2 +-
gdb/testsuite/gdb.base/valgrind-bt.exp | 2 +-
gdb/testsuite/gdb.cp/mb-templates.exp | 3 +--
gdb/testsuite/gdb.guile/scm-value.exp | 4 +--
gdb/testsuite/gdb.multi/checkpoint-multi.exp | 11 +++-----
gdb/testsuite/gdb.multi/multi-attach.exp | 4 +--
.../gdb.multi/pending-bp-del-inferior.exp | 3 +--
.../gdb.multi/watchpoint-multi-exit.exp | 3 +--
gdb/testsuite/gdb.python/py-value.exp | 4 +--
gdb/testsuite/gdb.reverse/break-precsave.exp | 4 +--
.../gdb.reverse/consecutive-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/finish-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/i386-precsave.exp | 4 +--
.../gdb.reverse/machinestate-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/sigall-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/solib-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/step-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/until-precsave.exp | 4 +--
gdb/testsuite/gdb.reverse/watch-precsave.exp | 4 +--
gdb/testsuite/gdb.server/ext-attach.exp | 2 +-
gdb/testsuite/gdb.server/ext-restart.exp | 2 +-
gdb/testsuite/gdb.server/ext-run.exp | 2 +-
gdb/testsuite/gdb.server/ext-wrapper.exp | 2 +-
.../gdb.server/extended-remote-restart.exp | 6 ++---
.../attach-many-short-lived-threads.exp | 2 +-
.../infcall-from-bp-cond-simple.exp | 3 +--
gdb/testsuite/gdb.threads/kill.exp | 6 +----
.../gdb.threads/threads-after-exec.exp | 4 +--
gdb/testsuite/lib/gdb.exp | 26 +++++++++++++++++++
43 files changed, 86 insertions(+), 96 deletions(-)
diff --git a/gdb/testsuite/gdb.base/attach-wait-input.exp b/gdb/testsuite/gdb.base/attach-wait-input.exp
index 68979b3c9f9..70751daf910 100644
--- a/gdb/testsuite/gdb.base/attach-wait-input.exp
+++ b/gdb/testsuite/gdb.base/attach-wait-input.exp
@@ -102,11 +102,9 @@ proc test { editing } {
# As we've used attach, on quit, we'll detach from the
# program. Explicitly kill it in case we failed above.
- gdb_test "kill" \
+ gdb_test "with confirm off -- kill" \
"" \
- "after attach, exit" \
- "Kill the program being debugged.*y or n. $" \
- "y"
+ "after attach, exit"
}
}
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index e75dd662203..25fcf1c6ac5 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -186,7 +186,7 @@ proc_with_prefix do_attach_failure_tests {} {
gdb_test_no_output "set confirm off"
gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1"
- gdb_test "kill" "killed.*" "exit after attach failures"
+ gdb_test_kill "exit after attach failures"
# This can probably be replaced with a call to runto or runto_main once
# the kfail is removed.
@@ -372,11 +372,9 @@ proc_with_prefix do_attach_tests {} {
"attach when process' a.out not in cwd"
set test "after attach3, exit"
- gdb_test "kill" \
+ gdb_test "with confirm off -- kill" \
"" \
- "$test" \
- "Kill the program being debugged.*y or n. $" \
- "y"
+ "$test"
# Another "don't leave a process around"
kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 14094c72844..1a57b601fb5 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -463,7 +463,7 @@ proc test_ld {file ifmain trynosym displacement} {
}
# Try re-run if the new PIE displacement takes effect.
- gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
+ gdb_test "with confirm off -- kill" "" "kill"
reach $solib_bp "run" $displacement 2
gdb_test_no_output "set verbose off"
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 7ebce65bf4c..f578628a2c7 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -735,7 +735,7 @@ proc_with_prefix test_next_with_recursion {} {
global decimal
global binfile
- gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill program"
delete_breakpoints
gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
diff --git a/gdb/testsuite/gdb.base/catch-fork-kill.exp b/gdb/testsuite/gdb.base/catch-fork-kill.exp
index cd541e66247..c6ffb937ef0 100644
--- a/gdb/testsuite/gdb.base/catch-fork-kill.exp
+++ b/gdb/testsuite/gdb.base/catch-fork-kill.exp
@@ -84,8 +84,7 @@ proc do_test {fork_kind exit_kind} {
gdb_test "break grandparent_done" "Breakpoint .*"
gdb_test "continue" "hit Breakpoint .*, grandparent_done.*"
} elseif {$exit_kind == "kill"} {
- gdb_test "kill" "" "kill parent" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill parent"
} else {
perror "unreachable"
}
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 23686f8fcf0..9917628b22c 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -266,8 +266,7 @@ gdb_test "info checkpoints" " 1 .* 2 .* 3 .* 4 .* 5 .*" \
# Kill should now terminate all of them.
#
-gdb_test "kill" "" "kill all one" \
- "Kill the program being debugged.*y or n. $" "y"
+gdb_test "with confirm off -- kill" "" "kill all one"
#
# and confirm that all are gone
@@ -343,8 +342,7 @@ gdb_test_multiple "info checkpoints" $msg {
# OK, kill 'em all...
#
-gdb_test "kill" "" "kill all one with many checkpoints" \
- "Kill the program being debugged.*y or n. $" "y"
+gdb_test "with confirm off -- kill" "" "kill all one with many checkpoints"
#
# Finished: cleanup
diff --git a/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp b/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
index b0487b58436..db4c4d8f01a 100644
--- a/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
+++ b/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
@@ -49,5 +49,5 @@ gdb_test \
"kill in commands"
gdb_test "run" \
- [subst_vars {\[Inferior $decimal \([^\r\n]*\) killed\]}] \
+ [inferior_killed_re] \
"run - kill"
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index f090aeefee9..10dc8e07e63 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -440,8 +440,7 @@ proc test_next_with_recursion {} {
"Hardware assisted breakpoint $decimal at .*" \
"hardware break at factorial"
- gdb_test "kill" "" "kill program" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill program"
# Run until we call factorial with 6
diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp
index 27016db3c87..7a08216347d 100644
--- a/gdb/testsuite/gdb.base/hook-stop.exp
+++ b/gdb/testsuite/gdb.base/hook-stop.exp
@@ -87,7 +87,7 @@ proc hook_stop_kill {} {
set test "run hook-stop"
gdb_test_multiple "continue" "$test" {
- -re "Continuing.*\r\n\\\[Inferior $decimal \\(.*\\) killed\\\]\r\n${gdb_prompt} $" {
+ -re "Continuing.*\r\n[inferior_killed_re]\r\n${gdb_prompt} $" {
pass $test
}
}
diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp
index 3b6e7a2afb8..79ab8b89224 100644
--- a/gdb/testsuite/gdb.base/info-program.exp
+++ b/gdb/testsuite/gdb.base/info-program.exp
@@ -95,8 +95,7 @@ proc do_test { threads non-stop } {
}
}
- gdb_test "kill" "" "kill program" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill program"
gdb_test "info program" "The program being debugged is not being run." \
"info program, after kill"
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
index f55aa8b81f3..330faab3ce2 100644
--- a/gdb/testsuite/gdb.base/kill-after-signal.exp
+++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
@@ -65,8 +65,4 @@ gdb_test_multiple "stepi" $test {
}
}
-gdb_test_multiple "kill" "kill" {
- -re "Kill the program being debugged\\? \\(y or n\\) $" {
- gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
- }
-}
+gdb_test_kill "kill"
diff --git a/gdb/testsuite/gdb.base/run-after-attach.exp b/gdb/testsuite/gdb.base/run-after-attach.exp
index 256f2fbcdd1..a577b96649d 100644
--- a/gdb/testsuite/gdb.base/run-after-attach.exp
+++ b/gdb/testsuite/gdb.base/run-after-attach.exp
@@ -31,9 +31,7 @@ set test_pid [spawn_id_get_pid $test_spawn_id]
set test "attach to process"
gdb_test "attach $test_pid" "Attaching to program.*" $test
-set test "kill process"
-gdb_test "kill" "" $test \
- "Kill the program being debugged.*y or n. $" "y"
+gdb_test "with confirm off -- kill" "" "kill process"
set test "restart process"
gdb_test "start" "Starting program.*Temporary breakpoint .*" $test
diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
index 0bdf95256dd..91e66f0b988 100644
--- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
+++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
@@ -69,7 +69,7 @@ proc do_test { action1 action2 } {
gdb_test -no-prompt-anchor "continue &"
if { $action1 == "kill" } {
- gdb_test "kill" "Inferior 1 .* killed.*"
+ gdb_test_kill "kill" 1
} elseif { $action1 == "detach" } {
set child_pid [get_integer_valueof "mypid" -1]
if { $child_pid == -1 } {
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 1ada019ea43..faf072415db 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -483,7 +483,7 @@ proc test_next_with_recursion {} {
global decimal
global binfile
- gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill program"
delete_breakpoints
gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
diff --git a/gdb/testsuite/gdb.base/traced-thread.exp b/gdb/testsuite/gdb.base/traced-thread.exp
index 219e3f900ac..4ca589ff942 100644
--- a/gdb/testsuite/gdb.base/traced-thread.exp
+++ b/gdb/testsuite/gdb.base/traced-thread.exp
@@ -47,7 +47,7 @@ gdb_test "attach $child_pid" \
# Now kill the parent process, ending the trace.
gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1"
-gdb_test "kill" ".*" "kill the parent process"
+gdb_test "with confirm off -- kill" ".*" "kill the parent process"
# Kill the child process as well. Use the shell to avoid funny
# business with gdbserver testing.
diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp
index 2fd29e72508..29ba72a0261 100644
--- a/gdb/testsuite/gdb.base/valgrind-bt.exp
+++ b/gdb/testsuite/gdb.base/valgrind-bt.exp
@@ -62,6 +62,6 @@ gdb_test_no_output "set width 0"
gdb_test "bt" "#\[0-9 ]+main \\(.*\\) at .*${srcfile}.*"
# Explicitly kill the program so it doesn't dump core when we quit->detach.
-gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
+gdb_test "with confirm off -- kill" "" "kill program"
vgdb_stop
diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp
index a1d55d3246f..0e7d79ebfc1 100644
--- a/gdb/testsuite/gdb.cp/mb-templates.exp
+++ b/gdb/testsuite/gdb.cp/mb-templates.exp
@@ -52,8 +52,7 @@ gdb_test "continue" \
# Separately set the condition.
delete_breakpoints
-gdb_test "kill" "" "kill" \
- {Kill the program being debugged\? \(y or n\) } "y"
+gdb_test "with confirm off -- kill" "" "kill"
gdb_test "break $srcfile:$bp_location" \
"Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
index fab1c300042..3c467404e80 100644
--- a/gdb/testsuite/gdb.guile/scm-value.exp
+++ b/gdb/testsuite/gdb.guile/scm-value.exp
@@ -279,9 +279,7 @@ proc test_value_after_death {} {
"create PTR type"
# Kill the inferior and remove the symbols.
- gdb_test "kill" "" "kill the inferior" \
- "Kill the program being debugged. .y or n. $" \
- "y"
+ gdb_test "with confirm off -- kill" "" "kill the inferior"
gdb_test "file" "" "discard the symbols" \
"Discard symbol table from.*y or n. $" \
"y"
diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
index b847d06b5e0..ac9890682c1 100644
--- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -153,8 +153,7 @@ with_test_prefix "check detach on non-checkpointed inferior" {
with_test_prefix "check kill on non-checkpointed inferior" {
start_2_inferiors_checkpoint_on_inf_2
- gdb_test "kill" "" "kill non-checkpointed inferior" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill non-checkpointed inferior"
}
with_test_prefix "check restart 0 on non-checkpointed inferior" {
@@ -419,9 +418,7 @@ with_test_prefix "two inferiors with checkpoints" {
}
with_test_prefix "kill inferior 1" {
- gdb_test "kill" "\\\[Inferior 1 \\(process $::decimal\\) killed\\\]" \
- "kill inferior 1" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test_kill "kill inferior 1" 1 "process $decimal"
gdb_test "info checkpoints" \
[multi_line \
@@ -559,9 +556,7 @@ with_test_prefix "three inferiors with checkpoints" {
}
with_test_prefix "kill inferior 3" {
- gdb_test "kill" "\\\[Inferior 3 \\(process $::decimal\\) killed\\\]" \
- "kill inferior 3" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test_kill "kill inferior 3" 3 "process $decimal"
gdb_test "info checkpoints" \
[multi_line \
diff --git a/gdb/testsuite/gdb.multi/multi-attach.exp b/gdb/testsuite/gdb.multi/multi-attach.exp
index 03a30446129..c0e631a87d2 100644
--- a/gdb/testsuite/gdb.multi/multi-attach.exp
+++ b/gdb/testsuite/gdb.multi/multi-attach.exp
@@ -51,9 +51,9 @@ gdb_test "attach $testpid2" \
"attach to program 2"
gdb_test "backtrace" ".*main.*" "backtrace 2"
-gdb_test "kill" "" "kill inferior 2" "Kill the program being debugged. .y or n. " "y"
+gdb_test "with confirm off -- kill" "" "kill inferior 2"
gdb_test "inferior 1" ".*Switching to inferior 1.*"
-gdb_test "kill" "" "kill inferior 1" "Kill the program being debugged. .y or n. " "y"
+gdb_test "with confirm off -- kill" "" "kill inferior 1"
kill_wait_spawned_process $test_spawn_id1
kill_wait_spawned_process $test_spawn_id2
diff --git a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
index 26b1bc14830..84d967cca8c 100644
--- a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
+++ b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
@@ -67,8 +67,7 @@ proc test_setup {} {
# Assuming inferior 2 is already selected, kill the current inferior
# (inferior 2), select inferior 1, and then remove inferior 2.
proc kill_and_remove_inferior_2 {} {
- gdb_test "kill" "" "kill inferior 2" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill inferior 2"
gdb_test "inferior 1" "Switching to inferior 1 .*" \
"select inferior 1"
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
index 2283d5926aa..ddb511962ef 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
@@ -46,8 +46,7 @@ proc do_test {dispose} {
# Dispose of the inferior. This should get rid of this inferior's
# watchpoint locations.
if {$dispose == "kill"} {
- gdb_test "kill" "" "kill inferior 2" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill inferior 2"
} elseif {$dispose == "detach"} {
gdb_test "detach" ".*" "detach inferior 2"
} elseif {$dispose == "exit"} {
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index ff658465897..f99b46ee101 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -404,9 +404,7 @@ proc test_value_after_death {} {
"create PTR type" 1
# Kill the inferior and remove the symbols.
- gdb_test "kill" "" "kill the inferior" \
- "Kill the program being debugged. .y or n. $" \
- "y"
+ gdb_test "with confirm off -- kill" "" "kill the inferior"
gdb_test "file" "" "discard the symbols" \
"Discard symbol table from.*y or n. $" \
"y"
diff --git a/gdb/testsuite/gdb.reverse/break-precsave.exp b/gdb/testsuite/gdb.reverse/break-precsave.exp
index 994457d4439..6a977ce77c5 100644
--- a/gdb/testsuite/gdb.reverse/break-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/break-precsave.exp
@@ -50,8 +50,8 @@ proc precsave_tests {} {
"Saved core file $precsave with execution log\." \
"save process recfile"
- gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+ gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
index 9a9132d9a4f..ad271e3e13d 100644
--- a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
@@ -44,8 +44,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/finish-precsave.exp b/gdb/testsuite/gdb.reverse/finish-precsave.exp
index 00c7d8caa41..c5aa63ad94b 100644
--- a/gdb/testsuite/gdb.reverse/finish-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/finish-precsave.exp
@@ -45,8 +45,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/i386-precsave.exp b/gdb/testsuite/gdb.reverse/i386-precsave.exp
index 8f6ad2283c0..2b93ee432a0 100644
--- a/gdb/testsuite/gdb.reverse/i386-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/i386-precsave.exp
@@ -52,8 +52,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
index 8a11c6d24b9..f81ca0f08bb 100644
--- a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
@@ -68,8 +68,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
index 5ce7de0ea1f..25f03a102c0 100644
--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
@@ -268,8 +268,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp
index cad30320048..98c50a98e63 100644
--- a/gdb/testsuite/gdb.reverse/solib-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp
@@ -88,8 +88,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 76171343677..0fa45e82890 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -66,8 +66,8 @@ with_timeout_factor 10 {
"save process recfile"
}
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
clean_restart ${::testfile}
diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp
index 075a87dc2d8..d3df71f6953 100644
--- a/gdb/testsuite/gdb.reverse/until-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/until-precsave.exp
@@ -65,8 +65,8 @@ with_timeout_factor 10 {
"save process recfile"
}
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.reverse/watch-precsave.exp b/gdb/testsuite/gdb.reverse/watch-precsave.exp
index 474012f74c7..bc7bdb72f66 100644
--- a/gdb/testsuite/gdb.reverse/watch-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/watch-precsave.exp
@@ -43,8 +43,8 @@ gdb_test "record save $precsave" \
"Saved core file $precsave with execution log\." \
"save process recfile"
-gdb_test "kill" "" "kill process, prepare to debug log file" \
- "Kill the program being debugged\\? \\(y or n\\) " "y"
+gdb_test "with confirm off -- kill" "" \
+ "kill process, prepare to debug log file"
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
diff --git a/gdb/testsuite/gdb.server/ext-attach.exp b/gdb/testsuite/gdb.server/ext-attach.exp
index cb4c1277228..204e521216d 100644
--- a/gdb/testsuite/gdb.server/ext-attach.exp
+++ b/gdb/testsuite/gdb.server/ext-attach.exp
@@ -87,7 +87,7 @@ proc run_test { target_async target_non_stop to_disable } {
"attach to remote program 2"
gdb_test "backtrace" ".*main.*" "backtrace 2"
- gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
+ gdb_test "with confirm off -- kill" "" "kill"
gdb_test_no_output "monitor exit"
kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.server/ext-restart.exp b/gdb/testsuite/gdb.server/ext-restart.exp
index 031aaeb5db8..dd4bd710d89 100644
--- a/gdb/testsuite/gdb.server/ext-restart.exp
+++ b/gdb/testsuite/gdb.server/ext-restart.exp
@@ -69,6 +69,6 @@ with_test_prefix "restart" {
}
}
-gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
+gdb_test "with confirm off -- kill" "" "kill"
gdb_test_no_output "monitor exit"
diff --git a/gdb/testsuite/gdb.server/ext-run.exp b/gdb/testsuite/gdb.server/ext-run.exp
index 4fb2fe004f2..664b8c74bf0 100644
--- a/gdb/testsuite/gdb.server/ext-run.exp
+++ b/gdb/testsuite/gdb.server/ext-run.exp
@@ -145,7 +145,7 @@ proc do_test { clear_sysroot set_remote_exec fetch_exec_and_args } {
}
}
- gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
+ gdb_test "with confirm off -- kill" "" "kill"
gdb_load $::binfile
gdb_test "monitor help" "The following monitor commands.*" \
diff --git a/gdb/testsuite/gdb.server/ext-wrapper.exp b/gdb/testsuite/gdb.server/ext-wrapper.exp
index 757127b1548..0986bd9197a 100644
--- a/gdb/testsuite/gdb.server/ext-wrapper.exp
+++ b/gdb/testsuite/gdb.server/ext-wrapper.exp
@@ -74,6 +74,6 @@ with_test_prefix "restart" {
gdb_test "print d" "${::valnum_re} = ${hex} \"1\".*"
}
-gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
+gdb_test "with confirm off -- kill" "" "kill"
gdb_test_no_output "monitor exit"
diff --git a/gdb/testsuite/gdb.server/extended-remote-restart.exp b/gdb/testsuite/gdb.server/extended-remote-restart.exp
index a592dba79ed..df0202c5157 100644
--- a/gdb/testsuite/gdb.server/extended-remote-restart.exp
+++ b/gdb/testsuite/gdb.server/extended-remote-restart.exp
@@ -101,11 +101,9 @@ proc test_reload { do_kill_p follow_child_p } {
if { $do_kill_p } {
# (Optional) Kill one of the inferiors.
- gdb_test "kill" \
+ gdb_test "with confirm off -- kill" \
"" \
- "Kill inferior" \
- "Kill the program being debugged.*y or n. $" \
- "y"
+ "Kill inferior"
# Check the first inferior really did die.
gdb_test "info inferiors" \
diff --git a/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp b/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
index 6f51e607d77..a69034e961c 100644
--- a/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
+++ b/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
@@ -178,7 +178,7 @@ proc test {} {
gdb_test "detach" "Detaching from.*"
} else {
- gdb_test "kill" "" "kill process" "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill process"
}
gdb_test_no_output "set breakpoint always-inserted off"
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
index bce53c39196..a2843dd5765 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
@@ -133,8 +133,7 @@ proc_with_prefix run_kill_and_restart_test { target_async target_non_stop } {
gdb_continue_to_breakpoint "worker_func"
# Now kill the program being debugged.
- gdb_test "kill" "" "kill process" \
- "Kill the program being debugged.*y or n. $" "y"
+ gdb_test "with confirm off -- kill" "" "kill process"
# Check we can restart the inferior. At one point this would trigger an
# assertion.
diff --git a/gdb/testsuite/gdb.threads/kill.exp b/gdb/testsuite/gdb.threads/kill.exp
index 84ab6cd561c..de22e3e46f6 100644
--- a/gdb/testsuite/gdb.threads/kill.exp
+++ b/gdb/testsuite/gdb.threads/kill.exp
@@ -67,11 +67,7 @@ proc test {threaded} {
#
# the above would mean that the remote end crashed.
- gdb_test_multiple "kill" "kill" {
- -re "Kill the program being debugged\\? \\(y or n\\) $" {
- gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
- }
- }
+ gdb_test_kill "kill"
}
}
diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp
index fd8550d3e99..8cc50970009 100644
--- a/gdb/testsuite/gdb.threads/threads-after-exec.exp
+++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp
@@ -53,9 +53,7 @@ proc do_test { } {
# on native Linux as GDB did not dispose of the pre-exec LWP for
# the non-leader (and that LWP did not have a matching thread in
# the core thread list).
- gdb_test "with confirm off -- kill" \
- "\\\[Inferior 1 (.*) killed\\\]" \
- "kill inferior"
+ gdb_test_kill "kill inferior" 1
}
do_test
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9ade9a16818..07c0ca1bcf2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -365,6 +365,22 @@ set octal {(?:[0-7]+)}
set inferior_exited_re "(?:\\\[Inferior ${::decimal} \\(\[^\n\r\]*\\) exited)"
+# Match gdb output for the kill command. The match can be made more specific
+# using INFERIOR_RE and PROCESS_RE.
+proc inferior_killed_re {{inferior_re ""} {process_re ""}} {
+ if {$inferior_re == ""} {
+ set inferior_re $::decimal
+ }
+ if {$process_re == ""} {
+ # A target-specific string, like "process n", "process n, thread t" or
+ # "target remote". Because it's target-specific, match anything.
+ set process_re {[^\r\n]+}
+ }
+ return \
+ [subst_vars \
+ {\[Inferior (?:$inferior_re) \((?:$process_re)\) killed\]}]
+}
+
# A regular expression that matches the first word of a thread
# description after the thread number info 'info threads'
set tdlabel_re "(process|Thread|LWP)"
@@ -7869,6 +7885,16 @@ proc kill_wait_spawned_process { proc_spawn_id } {
clean_up_spawn_id target $proc_spawn_id
}
+# Kill the current inferior with MESSAGE. If INFERIOR_RE/PROCESS_RE is
+# non-empty, check that the killed inferior matches.
+
+proc gdb_test_kill {message {inferior_re ""} {process_re ""}} {
+ gdb_test \
+ "with confirm off -- kill" \
+ [inferior_killed_re $inferior_re $process_re] \
+ $message
+}
+
# Returns the process id corresponding to the given spawn id.
proc spawn_id_get_pid { spawn_id } {
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp
2026-09-27 4:57 [PATCH 0/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
2026-09-27 4:57 ` [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill Tom de Vries
@ 2026-09-27 4:57 ` Tom de Vries
1 sibling, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-09-27 4:57 UTC (permalink / raw)
To: gdb-patches
I noticed in gdb.multi/checkpoint-multi.exp that when an inferior is detached,
the process is not cleaned up.
Fix this by re-attaching and killing it.
---
gdb/testsuite/gdb.multi/checkpoint-multi.exp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
index ac9890682c1..4dcb579bf4a 100644
--- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
@@ -148,7 +148,13 @@ proc start_2_inferiors_checkpoint_on_inf_2_alt {} {
with_test_prefix "check detach on non-checkpointed inferior" {
start_2_inferiors_checkpoint_on_inf_2
+ set pid [get_inferior_pid]
gdb_test "detach" "Detaching from program.*$::exec1.*Inferior 1.*detached.*"
+ with_test_prefix cleanup {
+ gdb_test "inferior 1" "Switching to inferior 1 .*"
+ gdb_test "attach $pid" "Attaching to program: .*" "re-attach for kill"
+ gdb_test_kill "kill" 1
+ }
}
with_test_prefix "check kill on non-checkpointed inferior" {
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill
2026-09-27 4:57 ` [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill Tom de Vries
@ 2026-09-28 11:01 ` Andrew Burgess
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess @ 2026-09-28 11:01 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
Tom de Vries <tdevries@suse.de> writes:
> Replace all kill commands with "" or ".*" pattern and question/response:
> ...
> gdb_test "kill" "" "kill program" \
> "Kill the program being debugged.*y or n. $" \
> "y"
> ...
> with:
> ...
> gdb_test "with confirm off -- kill" "" "kill program"
> ...
I agree that in most cases matching the 'kill the program' message is
unnecessary, but have you left any tests for that question and response
mechanism?
It might be worth mentioning in this commit message where the official
test for this feature is.
I would expect to see at least tests for that feature in both single and
multi-threaded inferiors.
Alternatively, though I haven't tested this, I suspect your
gdb_test_kill proc could be used quite happily for the empty regexp
case, couldn't you just make use of that more widely, and have
gdb_test_kill handle the question and response, rather than using 'with
confirm off'. Then testing 'with confirm off' becomes the special case.
Thanks,
Andrew
>
> Factor out procs gdb_test_kill and inferior_killed_re and use for cases where
> the output of the kill command is matched more precisely.
> ---
> gdb/testsuite/gdb.base/attach-wait-input.exp | 6 ++---
> gdb/testsuite/gdb.base/attach.exp | 8 +++---
> gdb/testsuite/gdb.base/break-interp.exp | 2 +-
> gdb/testsuite/gdb.base/break.exp | 2 +-
> gdb/testsuite/gdb.base/catch-fork-kill.exp | 3 +--
> gdb/testsuite/gdb.base/checkpoint.exp | 6 ++---
> .../detach-in-breakpoint-commands.exp | 2 +-
> gdb/testsuite/gdb.base/hbreak2.exp | 3 +--
> gdb/testsuite/gdb.base/hook-stop.exp | 2 +-
> gdb/testsuite/gdb.base/info-program.exp | 3 +--
> gdb/testsuite/gdb.base/kill-after-signal.exp | 6 +----
> gdb/testsuite/gdb.base/run-after-attach.exp | 4 +--
> .../run-control-while-bg-execution.exp | 2 +-
> gdb/testsuite/gdb.base/sepdebug.exp | 2 +-
> gdb/testsuite/gdb.base/traced-thread.exp | 2 +-
> gdb/testsuite/gdb.base/valgrind-bt.exp | 2 +-
> gdb/testsuite/gdb.cp/mb-templates.exp | 3 +--
> gdb/testsuite/gdb.guile/scm-value.exp | 4 +--
> gdb/testsuite/gdb.multi/checkpoint-multi.exp | 11 +++-----
> gdb/testsuite/gdb.multi/multi-attach.exp | 4 +--
> .../gdb.multi/pending-bp-del-inferior.exp | 3 +--
> .../gdb.multi/watchpoint-multi-exit.exp | 3 +--
> gdb/testsuite/gdb.python/py-value.exp | 4 +--
> gdb/testsuite/gdb.reverse/break-precsave.exp | 4 +--
> .../gdb.reverse/consecutive-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/finish-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/i386-precsave.exp | 4 +--
> .../gdb.reverse/machinestate-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/sigall-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/solib-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/step-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/until-precsave.exp | 4 +--
> gdb/testsuite/gdb.reverse/watch-precsave.exp | 4 +--
> gdb/testsuite/gdb.server/ext-attach.exp | 2 +-
> gdb/testsuite/gdb.server/ext-restart.exp | 2 +-
> gdb/testsuite/gdb.server/ext-run.exp | 2 +-
> gdb/testsuite/gdb.server/ext-wrapper.exp | 2 +-
> .../gdb.server/extended-remote-restart.exp | 6 ++---
> .../attach-many-short-lived-threads.exp | 2 +-
> .../infcall-from-bp-cond-simple.exp | 3 +--
> gdb/testsuite/gdb.threads/kill.exp | 6 +----
> .../gdb.threads/threads-after-exec.exp | 4 +--
> gdb/testsuite/lib/gdb.exp | 26 +++++++++++++++++++
> 43 files changed, 86 insertions(+), 96 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/attach-wait-input.exp b/gdb/testsuite/gdb.base/attach-wait-input.exp
> index 68979b3c9f9..70751daf910 100644
> --- a/gdb/testsuite/gdb.base/attach-wait-input.exp
> +++ b/gdb/testsuite/gdb.base/attach-wait-input.exp
> @@ -102,11 +102,9 @@ proc test { editing } {
>
> # As we've used attach, on quit, we'll detach from the
> # program. Explicitly kill it in case we failed above.
> - gdb_test "kill" \
> + gdb_test "with confirm off -- kill" \
> "" \
> - "after attach, exit" \
> - "Kill the program being debugged.*y or n. $" \
> - "y"
> + "after attach, exit"
> }
> }
>
> diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
> index e75dd662203..25fcf1c6ac5 100644
> --- a/gdb/testsuite/gdb.base/attach.exp
> +++ b/gdb/testsuite/gdb.base/attach.exp
> @@ -186,7 +186,7 @@ proc_with_prefix do_attach_failure_tests {} {
> gdb_test_no_output "set confirm off"
> gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1"
>
> - gdb_test "kill" "killed.*" "exit after attach failures"
> + gdb_test_kill "exit after attach failures"
>
> # This can probably be replaced with a call to runto or runto_main once
> # the kfail is removed.
> @@ -372,11 +372,9 @@ proc_with_prefix do_attach_tests {} {
> "attach when process' a.out not in cwd"
>
> set test "after attach3, exit"
> - gdb_test "kill" \
> + gdb_test "with confirm off -- kill" \
> "" \
> - "$test" \
> - "Kill the program being debugged.*y or n. $" \
> - "y"
> + "$test"
>
> # Another "don't leave a process around"
> kill_wait_spawned_process $test_spawn_id
> diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
> index 14094c72844..1a57b601fb5 100644
> --- a/gdb/testsuite/gdb.base/break-interp.exp
> +++ b/gdb/testsuite/gdb.base/break-interp.exp
> @@ -463,7 +463,7 @@ proc test_ld {file ifmain trynosym displacement} {
> }
>
> # Try re-run if the new PIE displacement takes effect.
> - gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
> + gdb_test "with confirm off -- kill" "" "kill"
> reach $solib_bp "run" $displacement 2
> gdb_test_no_output "set verbose off"
>
> diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
> index 7ebce65bf4c..f578628a2c7 100644
> --- a/gdb/testsuite/gdb.base/break.exp
> +++ b/gdb/testsuite/gdb.base/break.exp
> @@ -735,7 +735,7 @@ proc_with_prefix test_next_with_recursion {} {
> global decimal
> global binfile
>
> - gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill program"
> delete_breakpoints
>
> gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
> diff --git a/gdb/testsuite/gdb.base/catch-fork-kill.exp b/gdb/testsuite/gdb.base/catch-fork-kill.exp
> index cd541e66247..c6ffb937ef0 100644
> --- a/gdb/testsuite/gdb.base/catch-fork-kill.exp
> +++ b/gdb/testsuite/gdb.base/catch-fork-kill.exp
> @@ -84,8 +84,7 @@ proc do_test {fork_kind exit_kind} {
> gdb_test "break grandparent_done" "Breakpoint .*"
> gdb_test "continue" "hit Breakpoint .*, grandparent_done.*"
> } elseif {$exit_kind == "kill"} {
> - gdb_test "kill" "" "kill parent" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill parent"
> } else {
> perror "unreachable"
> }
> diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
> index 23686f8fcf0..9917628b22c 100644
> --- a/gdb/testsuite/gdb.base/checkpoint.exp
> +++ b/gdb/testsuite/gdb.base/checkpoint.exp
> @@ -266,8 +266,7 @@ gdb_test "info checkpoints" " 1 .* 2 .* 3 .* 4 .* 5 .*" \
> # Kill should now terminate all of them.
> #
>
> -gdb_test "kill" "" "kill all one" \
> - "Kill the program being debugged.*y or n. $" "y"
> +gdb_test "with confirm off -- kill" "" "kill all one"
>
> #
> # and confirm that all are gone
> @@ -343,8 +342,7 @@ gdb_test_multiple "info checkpoints" $msg {
> # OK, kill 'em all...
> #
>
> -gdb_test "kill" "" "kill all one with many checkpoints" \
> - "Kill the program being debugged.*y or n. $" "y"
> +gdb_test "with confirm off -- kill" "" "kill all one with many checkpoints"
>
> #
> # Finished: cleanup
> diff --git a/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp b/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
> index b0487b58436..db4c4d8f01a 100644
> --- a/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
> +++ b/gdb/testsuite/gdb.base/detach-in-breakpoint-commands.exp
> @@ -49,5 +49,5 @@ gdb_test \
> "kill in commands"
>
> gdb_test "run" \
> - [subst_vars {\[Inferior $decimal \([^\r\n]*\) killed\]}] \
> + [inferior_killed_re] \
> "run - kill"
> diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
> index f090aeefee9..10dc8e07e63 100644
> --- a/gdb/testsuite/gdb.base/hbreak2.exp
> +++ b/gdb/testsuite/gdb.base/hbreak2.exp
> @@ -440,8 +440,7 @@ proc test_next_with_recursion {} {
> "Hardware assisted breakpoint $decimal at .*" \
> "hardware break at factorial"
>
> - gdb_test "kill" "" "kill program" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill program"
>
> # Run until we call factorial with 6
>
> diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp
> index 27016db3c87..7a08216347d 100644
> --- a/gdb/testsuite/gdb.base/hook-stop.exp
> +++ b/gdb/testsuite/gdb.base/hook-stop.exp
> @@ -87,7 +87,7 @@ proc hook_stop_kill {} {
>
> set test "run hook-stop"
> gdb_test_multiple "continue" "$test" {
> - -re "Continuing.*\r\n\\\[Inferior $decimal \\(.*\\) killed\\\]\r\n${gdb_prompt} $" {
> + -re "Continuing.*\r\n[inferior_killed_re]\r\n${gdb_prompt} $" {
> pass $test
> }
> }
> diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp
> index 3b6e7a2afb8..79ab8b89224 100644
> --- a/gdb/testsuite/gdb.base/info-program.exp
> +++ b/gdb/testsuite/gdb.base/info-program.exp
> @@ -95,8 +95,7 @@ proc do_test { threads non-stop } {
> }
> }
>
> - gdb_test "kill" "" "kill program" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill program"
>
> gdb_test "info program" "The program being debugged is not being run." \
> "info program, after kill"
> diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
> index f55aa8b81f3..330faab3ce2 100644
> --- a/gdb/testsuite/gdb.base/kill-after-signal.exp
> +++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
> @@ -65,8 +65,4 @@ gdb_test_multiple "stepi" $test {
> }
> }
>
> -gdb_test_multiple "kill" "kill" {
> - -re "Kill the program being debugged\\? \\(y or n\\) $" {
> - gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
> - }
> -}
> +gdb_test_kill "kill"
> diff --git a/gdb/testsuite/gdb.base/run-after-attach.exp b/gdb/testsuite/gdb.base/run-after-attach.exp
> index 256f2fbcdd1..a577b96649d 100644
> --- a/gdb/testsuite/gdb.base/run-after-attach.exp
> +++ b/gdb/testsuite/gdb.base/run-after-attach.exp
> @@ -31,9 +31,7 @@ set test_pid [spawn_id_get_pid $test_spawn_id]
> set test "attach to process"
> gdb_test "attach $test_pid" "Attaching to program.*" $test
>
> -set test "kill process"
> -gdb_test "kill" "" $test \
> - "Kill the program being debugged.*y or n. $" "y"
> +gdb_test "with confirm off -- kill" "" "kill process"
>
> set test "restart process"
> gdb_test "start" "Starting program.*Temporary breakpoint .*" $test
> diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
> index 0bdf95256dd..91e66f0b988 100644
> --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
> +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
> @@ -69,7 +69,7 @@ proc do_test { action1 action2 } {
> gdb_test -no-prompt-anchor "continue &"
>
> if { $action1 == "kill" } {
> - gdb_test "kill" "Inferior 1 .* killed.*"
> + gdb_test_kill "kill" 1
> } elseif { $action1 == "detach" } {
> set child_pid [get_integer_valueof "mypid" -1]
> if { $child_pid == -1 } {
> diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
> index 1ada019ea43..faf072415db 100644
> --- a/gdb/testsuite/gdb.base/sepdebug.exp
> +++ b/gdb/testsuite/gdb.base/sepdebug.exp
> @@ -483,7 +483,7 @@ proc test_next_with_recursion {} {
> global decimal
> global binfile
>
> - gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill program"
> delete_breakpoints
>
> gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
> diff --git a/gdb/testsuite/gdb.base/traced-thread.exp b/gdb/testsuite/gdb.base/traced-thread.exp
> index 219e3f900ac..4ca589ff942 100644
> --- a/gdb/testsuite/gdb.base/traced-thread.exp
> +++ b/gdb/testsuite/gdb.base/traced-thread.exp
> @@ -47,7 +47,7 @@ gdb_test "attach $child_pid" \
>
> # Now kill the parent process, ending the trace.
> gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1"
> -gdb_test "kill" ".*" "kill the parent process"
> +gdb_test "with confirm off -- kill" ".*" "kill the parent process"
>
> # Kill the child process as well. Use the shell to avoid funny
> # business with gdbserver testing.
> diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp
> index 2fd29e72508..29ba72a0261 100644
> --- a/gdb/testsuite/gdb.base/valgrind-bt.exp
> +++ b/gdb/testsuite/gdb.base/valgrind-bt.exp
> @@ -62,6 +62,6 @@ gdb_test_no_output "set width 0"
> gdb_test "bt" "#\[0-9 ]+main \\(.*\\) at .*${srcfile}.*"
>
> # Explicitly kill the program so it doesn't dump core when we quit->detach.
> -gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
> +gdb_test "with confirm off -- kill" "" "kill program"
>
> vgdb_stop
> diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp
> index a1d55d3246f..0e7d79ebfc1 100644
> --- a/gdb/testsuite/gdb.cp/mb-templates.exp
> +++ b/gdb/testsuite/gdb.cp/mb-templates.exp
> @@ -52,8 +52,7 @@ gdb_test "continue" \
> # Separately set the condition.
>
> delete_breakpoints
> -gdb_test "kill" "" "kill" \
> - {Kill the program being debugged\? \(y or n\) } "y"
> +gdb_test "with confirm off -- kill" "" "kill"
>
> gdb_test "break $srcfile:$bp_location" \
> "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
> diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
> index fab1c300042..3c467404e80 100644
> --- a/gdb/testsuite/gdb.guile/scm-value.exp
> +++ b/gdb/testsuite/gdb.guile/scm-value.exp
> @@ -279,9 +279,7 @@ proc test_value_after_death {} {
> "create PTR type"
>
> # Kill the inferior and remove the symbols.
> - gdb_test "kill" "" "kill the inferior" \
> - "Kill the program being debugged. .y or n. $" \
> - "y"
> + gdb_test "with confirm off -- kill" "" "kill the inferior"
> gdb_test "file" "" "discard the symbols" \
> "Discard symbol table from.*y or n. $" \
> "y"
> diff --git a/gdb/testsuite/gdb.multi/checkpoint-multi.exp b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
> index b847d06b5e0..ac9890682c1 100644
> --- a/gdb/testsuite/gdb.multi/checkpoint-multi.exp
> +++ b/gdb/testsuite/gdb.multi/checkpoint-multi.exp
> @@ -153,8 +153,7 @@ with_test_prefix "check detach on non-checkpointed inferior" {
>
> with_test_prefix "check kill on non-checkpointed inferior" {
> start_2_inferiors_checkpoint_on_inf_2
> - gdb_test "kill" "" "kill non-checkpointed inferior" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill non-checkpointed inferior"
> }
>
> with_test_prefix "check restart 0 on non-checkpointed inferior" {
> @@ -419,9 +418,7 @@ with_test_prefix "two inferiors with checkpoints" {
> }
>
> with_test_prefix "kill inferior 1" {
> - gdb_test "kill" "\\\[Inferior 1 \\(process $::decimal\\) killed\\\]" \
> - "kill inferior 1" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test_kill "kill inferior 1" 1 "process $decimal"
>
> gdb_test "info checkpoints" \
> [multi_line \
> @@ -559,9 +556,7 @@ with_test_prefix "three inferiors with checkpoints" {
> }
>
> with_test_prefix "kill inferior 3" {
> - gdb_test "kill" "\\\[Inferior 3 \\(process $::decimal\\) killed\\\]" \
> - "kill inferior 3" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test_kill "kill inferior 3" 3 "process $decimal"
>
> gdb_test "info checkpoints" \
> [multi_line \
> diff --git a/gdb/testsuite/gdb.multi/multi-attach.exp b/gdb/testsuite/gdb.multi/multi-attach.exp
> index 03a30446129..c0e631a87d2 100644
> --- a/gdb/testsuite/gdb.multi/multi-attach.exp
> +++ b/gdb/testsuite/gdb.multi/multi-attach.exp
> @@ -51,9 +51,9 @@ gdb_test "attach $testpid2" \
> "attach to program 2"
> gdb_test "backtrace" ".*main.*" "backtrace 2"
>
> -gdb_test "kill" "" "kill inferior 2" "Kill the program being debugged. .y or n. " "y"
> +gdb_test "with confirm off -- kill" "" "kill inferior 2"
> gdb_test "inferior 1" ".*Switching to inferior 1.*"
> -gdb_test "kill" "" "kill inferior 1" "Kill the program being debugged. .y or n. " "y"
> +gdb_test "with confirm off -- kill" "" "kill inferior 1"
>
> kill_wait_spawned_process $test_spawn_id1
> kill_wait_spawned_process $test_spawn_id2
> diff --git a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
> index 26b1bc14830..84d967cca8c 100644
> --- a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
> +++ b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
> @@ -67,8 +67,7 @@ proc test_setup {} {
> # Assuming inferior 2 is already selected, kill the current inferior
> # (inferior 2), select inferior 1, and then remove inferior 2.
> proc kill_and_remove_inferior_2 {} {
> - gdb_test "kill" "" "kill inferior 2" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill inferior 2"
>
> gdb_test "inferior 1" "Switching to inferior 1 .*" \
> "select inferior 1"
> diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
> index 2283d5926aa..ddb511962ef 100644
> --- a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
> +++ b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
> @@ -46,8 +46,7 @@ proc do_test {dispose} {
> # Dispose of the inferior. This should get rid of this inferior's
> # watchpoint locations.
> if {$dispose == "kill"} {
> - gdb_test "kill" "" "kill inferior 2" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill inferior 2"
> } elseif {$dispose == "detach"} {
> gdb_test "detach" ".*" "detach inferior 2"
> } elseif {$dispose == "exit"} {
> diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
> index ff658465897..f99b46ee101 100644
> --- a/gdb/testsuite/gdb.python/py-value.exp
> +++ b/gdb/testsuite/gdb.python/py-value.exp
> @@ -404,9 +404,7 @@ proc test_value_after_death {} {
> "create PTR type" 1
>
> # Kill the inferior and remove the symbols.
> - gdb_test "kill" "" "kill the inferior" \
> - "Kill the program being debugged. .y or n. $" \
> - "y"
> + gdb_test "with confirm off -- kill" "" "kill the inferior"
> gdb_test "file" "" "discard the symbols" \
> "Discard symbol table from.*y or n. $" \
> "y"
> diff --git a/gdb/testsuite/gdb.reverse/break-precsave.exp b/gdb/testsuite/gdb.reverse/break-precsave.exp
> index 994457d4439..6a977ce77c5 100644
> --- a/gdb/testsuite/gdb.reverse/break-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/break-precsave.exp
> @@ -50,8 +50,8 @@ proc precsave_tests {} {
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> - gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> + gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
> index 9a9132d9a4f..ad271e3e13d 100644
> --- a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
> @@ -44,8 +44,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/finish-precsave.exp b/gdb/testsuite/gdb.reverse/finish-precsave.exp
> index 00c7d8caa41..c5aa63ad94b 100644
> --- a/gdb/testsuite/gdb.reverse/finish-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/finish-precsave.exp
> @@ -45,8 +45,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/i386-precsave.exp b/gdb/testsuite/gdb.reverse/i386-precsave.exp
> index 8f6ad2283c0..2b93ee432a0 100644
> --- a/gdb/testsuite/gdb.reverse/i386-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/i386-precsave.exp
> @@ -52,8 +52,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
> index 8a11c6d24b9..f81ca0f08bb 100644
> --- a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
> @@ -68,8 +68,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
> index 5ce7de0ea1f..25f03a102c0 100644
> --- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
> @@ -268,8 +268,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp
> index cad30320048..98c50a98e63 100644
> --- a/gdb/testsuite/gdb.reverse/solib-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp
> @@ -88,8 +88,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
> index 76171343677..0fa45e82890 100644
> --- a/gdb/testsuite/gdb.reverse/step-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
> @@ -66,8 +66,8 @@ with_timeout_factor 10 {
> "save process recfile"
> }
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> clean_restart ${::testfile}
>
> diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp
> index 075a87dc2d8..d3df71f6953 100644
> --- a/gdb/testsuite/gdb.reverse/until-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/until-precsave.exp
> @@ -65,8 +65,8 @@ with_timeout_factor 10 {
> "save process recfile"
> }
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.reverse/watch-precsave.exp b/gdb/testsuite/gdb.reverse/watch-precsave.exp
> index 474012f74c7..bc7bdb72f66 100644
> --- a/gdb/testsuite/gdb.reverse/watch-precsave.exp
> +++ b/gdb/testsuite/gdb.reverse/watch-precsave.exp
> @@ -43,8 +43,8 @@ gdb_test "record save $precsave" \
> "Saved core file $precsave with execution log\." \
> "save process recfile"
>
> -gdb_test "kill" "" "kill process, prepare to debug log file" \
> - "Kill the program being debugged\\? \\(y or n\\) " "y"
> +gdb_test "with confirm off -- kill" "" \
> + "kill process, prepare to debug log file"
>
> gdb_test "record restore $precsave" \
> "Restored records from core file .*" \
> diff --git a/gdb/testsuite/gdb.server/ext-attach.exp b/gdb/testsuite/gdb.server/ext-attach.exp
> index cb4c1277228..204e521216d 100644
> --- a/gdb/testsuite/gdb.server/ext-attach.exp
> +++ b/gdb/testsuite/gdb.server/ext-attach.exp
> @@ -87,7 +87,7 @@ proc run_test { target_async target_non_stop to_disable } {
> "attach to remote program 2"
> gdb_test "backtrace" ".*main.*" "backtrace 2"
>
> - gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
> + gdb_test "with confirm off -- kill" "" "kill"
> gdb_test_no_output "monitor exit"
>
> kill_wait_spawned_process $test_spawn_id
> diff --git a/gdb/testsuite/gdb.server/ext-restart.exp b/gdb/testsuite/gdb.server/ext-restart.exp
> index 031aaeb5db8..dd4bd710d89 100644
> --- a/gdb/testsuite/gdb.server/ext-restart.exp
> +++ b/gdb/testsuite/gdb.server/ext-restart.exp
> @@ -69,6 +69,6 @@ with_test_prefix "restart" {
> }
> }
>
> -gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
> +gdb_test "with confirm off -- kill" "" "kill"
>
> gdb_test_no_output "monitor exit"
> diff --git a/gdb/testsuite/gdb.server/ext-run.exp b/gdb/testsuite/gdb.server/ext-run.exp
> index 4fb2fe004f2..664b8c74bf0 100644
> --- a/gdb/testsuite/gdb.server/ext-run.exp
> +++ b/gdb/testsuite/gdb.server/ext-run.exp
> @@ -145,7 +145,7 @@ proc do_test { clear_sysroot set_remote_exec fetch_exec_and_args } {
> }
> }
>
> - gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
> + gdb_test "with confirm off -- kill" "" "kill"
>
> gdb_load $::binfile
> gdb_test "monitor help" "The following monitor commands.*" \
> diff --git a/gdb/testsuite/gdb.server/ext-wrapper.exp b/gdb/testsuite/gdb.server/ext-wrapper.exp
> index 757127b1548..0986bd9197a 100644
> --- a/gdb/testsuite/gdb.server/ext-wrapper.exp
> +++ b/gdb/testsuite/gdb.server/ext-wrapper.exp
> @@ -74,6 +74,6 @@ with_test_prefix "restart" {
> gdb_test "print d" "${::valnum_re} = ${hex} \"1\".*"
> }
>
> -gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
> +gdb_test "with confirm off -- kill" "" "kill"
>
> gdb_test_no_output "monitor exit"
> diff --git a/gdb/testsuite/gdb.server/extended-remote-restart.exp b/gdb/testsuite/gdb.server/extended-remote-restart.exp
> index a592dba79ed..df0202c5157 100644
> --- a/gdb/testsuite/gdb.server/extended-remote-restart.exp
> +++ b/gdb/testsuite/gdb.server/extended-remote-restart.exp
> @@ -101,11 +101,9 @@ proc test_reload { do_kill_p follow_child_p } {
>
> if { $do_kill_p } {
> # (Optional) Kill one of the inferiors.
> - gdb_test "kill" \
> + gdb_test "with confirm off -- kill" \
> "" \
> - "Kill inferior" \
> - "Kill the program being debugged.*y or n. $" \
> - "y"
> + "Kill inferior"
>
> # Check the first inferior really did die.
> gdb_test "info inferiors" \
> diff --git a/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp b/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
> index 6f51e607d77..a69034e961c 100644
> --- a/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
> +++ b/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.exp
> @@ -178,7 +178,7 @@ proc test {} {
>
> gdb_test "detach" "Detaching from.*"
> } else {
> - gdb_test "kill" "" "kill process" "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill process"
> }
>
> gdb_test_no_output "set breakpoint always-inserted off"
> diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
> index bce53c39196..a2843dd5765 100644
> --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
> +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
> @@ -133,8 +133,7 @@ proc_with_prefix run_kill_and_restart_test { target_async target_non_stop } {
> gdb_continue_to_breakpoint "worker_func"
>
> # Now kill the program being debugged.
> - gdb_test "kill" "" "kill process" \
> - "Kill the program being debugged.*y or n. $" "y"
> + gdb_test "with confirm off -- kill" "" "kill process"
>
> # Check we can restart the inferior. At one point this would trigger an
> # assertion.
> diff --git a/gdb/testsuite/gdb.threads/kill.exp b/gdb/testsuite/gdb.threads/kill.exp
> index 84ab6cd561c..de22e3e46f6 100644
> --- a/gdb/testsuite/gdb.threads/kill.exp
> +++ b/gdb/testsuite/gdb.threads/kill.exp
> @@ -67,11 +67,7 @@ proc test {threaded} {
> #
> # the above would mean that the remote end crashed.
>
> - gdb_test_multiple "kill" "kill" {
> - -re "Kill the program being debugged\\? \\(y or n\\) $" {
> - gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
> - }
> - }
> + gdb_test_kill "kill"
> }
> }
>
> diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp
> index fd8550d3e99..8cc50970009 100644
> --- a/gdb/testsuite/gdb.threads/threads-after-exec.exp
> +++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp
> @@ -53,9 +53,7 @@ proc do_test { } {
> # on native Linux as GDB did not dispose of the pre-exec LWP for
> # the non-leader (and that LWP did not have a matching thread in
> # the core thread list).
> - gdb_test "with confirm off -- kill" \
> - "\\\[Inferior 1 (.*) killed\\\]" \
> - "kill inferior"
> + gdb_test_kill "kill inferior" 1
> }
>
> do_test
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 9ade9a16818..07c0ca1bcf2 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -365,6 +365,22 @@ set octal {(?:[0-7]+)}
>
> set inferior_exited_re "(?:\\\[Inferior ${::decimal} \\(\[^\n\r\]*\\) exited)"
>
> +# Match gdb output for the kill command. The match can be made more specific
> +# using INFERIOR_RE and PROCESS_RE.
> +proc inferior_killed_re {{inferior_re ""} {process_re ""}} {
> + if {$inferior_re == ""} {
> + set inferior_re $::decimal
> + }
> + if {$process_re == ""} {
> + # A target-specific string, like "process n", "process n, thread t" or
> + # "target remote". Because it's target-specific, match anything.
> + set process_re {[^\r\n]+}
> + }
> + return \
> + [subst_vars \
> + {\[Inferior (?:$inferior_re) \((?:$process_re)\) killed\]}]
> +}
> +
> # A regular expression that matches the first word of a thread
> # description after the thread number info 'info threads'
> set tdlabel_re "(process|Thread|LWP)"
> @@ -7869,6 +7885,16 @@ proc kill_wait_spawned_process { proc_spawn_id } {
> clean_up_spawn_id target $proc_spawn_id
> }
>
> +# Kill the current inferior with MESSAGE. If INFERIOR_RE/PROCESS_RE is
> +# non-empty, check that the killed inferior matches.
> +
> +proc gdb_test_kill {message {inferior_re ""} {process_re ""}} {
> + gdb_test \
> + "with confirm off -- kill" \
> + [inferior_killed_re $inferior_re $process_re] \
> + $message
> +}
> +
> # Returns the process id corresponding to the given spawn id.
>
> proc spawn_id_get_pid { spawn_id } {
> --
> 2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-28 11:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-27 4:57 [PATCH 0/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
2026-09-27 4:57 ` [PATCH 1/2] [gdb/testsuite] Factor out gdb_test_kill Tom de Vries
2026-09-28 11:01 ` Andrew Burgess
2026-09-27 4:57 ` [PATCH 2/2] [gdb/testsuite] Clean up in gdb.multi/checkpoint-multi.exp Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox