]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Don't start gdb in gdb.base/gstack.exp
authorTom de Vries <tdevries@suse.de>
Tue, 18 Feb 2025 07:47:33 +0000 (08:47 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 18 Feb 2025 07:47:33 +0000 (08:47 +0100)
In test-case gdb.base/gstack.exp we start a gdb implicitly using
prepare_for_testing.

The gdb is not really used, but its spawn_id (available in variable
gdb_spawn_id) is used in a gdb_test_multiple, which is used to interact with
the gstack process.

Usually, a running gdb is cleaned up at test-case exit in gdb_finish, which
calls gdb_exit, which by default calls gdb_default_exit, which does
'send_gdb "quit\n"'.

However, this sends a quit to the host process expect is currently talking to,
defined by board_info(host,fileid), and after spawning gstack that's gstack, not
gdb.

Fix this by:
- using build_executable instead of prepare_for_testing to not spawn an unused
  gdb, and
- changing the gdb_test_multiple into a gdb_expect, eliminating the implicit use
  of gdb_spawn_id.

Tested on x86_64-linux.

Reviewed-By: Keith Seitz <keiths@redhat.com>
PR testsuite/32709
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32709

gdb/testsuite/gdb.base/gstack.exp

index f603f2b4ea3e998dc986d73b484bb1d5207ed900..8df36b1b3bcb4910dcb7e6009c0f44dfdb9db611 100644 (file)
@@ -18,7 +18,7 @@ require can_spawn_for_attach
 
 standard_testfile
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] == -1} {
+if {[build_executable "failed to prepare" $testfile $srcfile {debug}] == -1} {
     return -1
 }
 
@@ -62,7 +62,7 @@ if { ![gdb_assert { ![expr {$res < 0 || $res == ""}] } $test] } {
 set test "got backtrace"
 set saw_backtrace false
 set no_awk false
-gdb_test_multiple "" $test {
+gdb_expect {
     -i "$res" -re "#0 +(0x\[0-9a-f\]+ in )?main \(\).*\r\nGSTACK-END\r\n\$" {
        set saw_backtrace true
        pass $test