From: Pedro Alves Date: Sun, 13 Sep 2020 19:31:25 +0000 (+0100) Subject: Make default_mi_gdb_start/dbx_gdb_start use gdb_spawn X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f4b83cd51953fdf9626dc7a198b35505d1f5472;p=binutils-gdb.git Make default_mi_gdb_start/dbx_gdb_start use gdb_spawn If a board file wants to customize how gdb is launched, the obvious way is to have the board override gdb_spawn. However, that doesn't work for either gdb.mi/ testcases or gdb.base/dbx.exp, because default_mi_gdb_start and dbx_gdb_start don't use gdb_spawn currently. That is fixed by this patch. gdb/testsuite/ * gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn instead of spawning GDB with remote_spawn. * lib/mi-support.exp (default_mi_gdb_start): Adjust to use gdb_spawn instead of spawning GDB with remote_spawn. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0744c1e941d..397c6161324 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2020-09-13 Pedro Alves + + * gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn + instead of spawning GDB with remote_spawn. + * lib/mi-support.exp (default_mi_gdb_start): Adjust to use + gdb_spawn instead of spawning GDB with remote_spawn. + 2020-09-13 Pedro Alves * gdb.dwarf2/ada-linkage-name.c (main): Move to the bottom of the diff --git a/gdb/testsuite/gdb.base/dbx.exp b/gdb/testsuite/gdb.base/dbx.exp index 2a53f99a28d..5228f2e6c22 100644 --- a/gdb/testsuite/gdb.base/dbx.exp +++ b/gdb/testsuite/gdb.base/dbx.exp @@ -26,31 +26,33 @@ if {[build_executable $testfile.exp $testfile \ # start gdb -- start gdb running, default procedure # proc dbx_gdb_start { } { - global GDB - global INTERNAL_GDBFLAGS GDBFLAGS global prompt - global spawn_id global timeout - verbose "Spawning $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS" + global gdb_spawn_id - if { [which $GDB] == 0 } then { - perror "$GDB does not exist." - exit 1 + save_vars { GDBFLAGS } { + append GDBFLAGS " -dbx" + + set res [gdb_spawn] + if { $res != 0} { + return $res + } } set oldtimeout $timeout set timeout [expr "$timeout + 60"] - eval "spawn $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS" gdb_expect { -re ".*\r\n$gdb_prompt $" { verbose "GDB initialized." } -re "$prompt $" { perror "GDB never initialized." + unset gdb_spawn_id return -1 } timeout { perror "(timeout) GDB never initialized." + unset gdb_spawn_id return -1 } } diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 7c1dcd6f3fb..5c1fcca4d23 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -226,24 +226,19 @@ proc default_mi_gdb_start { args } { sid_start } - verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS" - if [info exists gdb_spawn_id] { return 0 } - if ![is_remote host] { - if { [which $GDB] == 0 } then { - perror "$GDB does not exist." - exit 1 + save_vars { GDBFLAGS } { + append GDBFLAGS " $MIFLAGS" + + set res [gdb_spawn] + if { $res != 0} { + return $res } } - set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host_info gdb_opts]"] - if { $res < 0 || $res == "" } { - perror "Spawning $GDB failed." - return 1 - } gdb_expect { -re "~\"GNU.*\r\n~\".*$mi_gdb_prompt$" { # We have a new format mi startup prompt. If we are @@ -252,6 +247,7 @@ proc default_mi_gdb_start { args } { if { $MIFLAGS == "-i=mi1" } { perror "(mi startup) Got unexpected new mi prompt." remote_close host + unset gdb_spawn_id return -1 } verbose "GDB initialized." @@ -263,6 +259,7 @@ proc default_mi_gdb_start { args } { if { $MIFLAGS != "-i=mi1" } { perror "(mi startup) Got unexpected old mi prompt." remote_close host + unset gdb_spawn_id return -1 } verbose "GDB initialized." @@ -270,22 +267,24 @@ proc default_mi_gdb_start { args } { -re ".*unrecognized option.*for a complete list of options." { untested "skip mi tests (not compiled with mi support)." remote_close host + unset gdb_spawn_id return -1 } -re ".*Interpreter `mi' unrecognized." { untested "skip mi tests (not compiled with mi support)." remote_close host + unset gdb_spawn_id return -1 } timeout { perror "(timeout) GDB never initialized after 10 seconds." remote_close host + unset gdb_spawn_id return -1 } } - set gdb_spawn_id $res - set gdb_main_spawn_id $res - set mi_spawn_id $res + set gdb_main_spawn_id $gdb_spawn_id + set mi_spawn_id $gdb_spawn_id # FIXME: mi output does not go through pagers, so these can be removed. # force the height to "unlimited", so no pagers get used