mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
gdb/testsuite: avoid reading files through the remote protocol in gdb.server/*.exp
When I run some tests in gdb.server (fox example gdb.server/ext-attach.exp) on Ubuntu 20.04 with separate debug info for glibc installed, they often time out. This is because GDB reads the debug info through the remote protocol which is particularly slow: attach 316937 Attaching to program: /home/smarchi/build/binutils-gdb-all-targets/gdb/testsuite/outputs/gdb.server/ext-attach/ext-attach, process 316937 Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading /lib64/ld-linux-x86-64.so.2 from remote target... Reading symbols from target:/lib/x86_64-linux-gnu/libc.so.6... Reading /lib/x86_64-linux-gnu/libc-2.31.so from remote target... Reading /lib/x86_64-linux-gnu/.debug/libc-2.31.so from remote target... Reading /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so from remote target... FAIL: gdb.server/ext-attach.exp: attach to remote program 1 (timeout) This is avoided in gdbserver boards by adding "set sysroot" to GDBFLAGS (see boards/local-board.exp), which makes GDB read files from the local filesystem. But gdb.server tests spawn GDBserver directly, so are ran even when using the default unix board, where the "set sysroot" isn't used. Modify these tests to append "set sysroot" to the GDBFLAGS, a bit like lib/local-board.exp does. One special case is gdb.server/sysroot.exp, whose intent is to test different "set sysroot" values. For this one, increase the timeout when testing the "target:" sysroot. gdb/testsuite/ChangeLog: * gdb.server/abspath.exp: Append "set sysroot" to GDBFLAGS. * gdb.server/connect-without-multi-process.exp: Likewise. * gdb.server/exit-multiple-threads.exp: Likewise. * gdb.server/ext-attach.exp: Likewise. * gdb.server/ext-restart.exp: Likewise. * gdb.server/ext-run.exp: Likewise. * gdb.server/ext-wrapper.exp: Likewise. * gdb.server/multi-ui-errors.exp: Likewise. * gdb.server/no-thread-db.exp: Likewise. * gdb.server/reconnect-ctrl-c.exp: Likewise. * gdb.server/run-without-local-binary.exp: Likewise. * gdb.server/server-kill.exp: Likewise. * gdb.server/server-run.exp: Likewise. * gdb.server/solib-list.exp: Likewise. * gdb.server/stop-reply-no-thread.exp: Likewise. * gdb.server/wrapper.exp: Likewise. * gdb.server/sysroot.exp: Increase timeout when testing the target: sysroot. Change-Id: I7451bcc737f90e2cd0b977e9f09da3710774b0bf
This commit is contained in:

committed by
Simon Marchi

parent
d8387cc8b6
commit
8dc558a072
@ -1,3 +1,24 @@
|
||||
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
* gdb.server/abspath.exp: Append "set sysroot" to GDBFLAGS.
|
||||
* gdb.server/connect-without-multi-process.exp: Likewise.
|
||||
* gdb.server/exit-multiple-threads.exp: Likewise.
|
||||
* gdb.server/ext-attach.exp: Likewise.
|
||||
* gdb.server/ext-restart.exp: Likewise.
|
||||
* gdb.server/ext-run.exp: Likewise.
|
||||
* gdb.server/ext-wrapper.exp: Likewise.
|
||||
* gdb.server/multi-ui-errors.exp: Likewise.
|
||||
* gdb.server/no-thread-db.exp: Likewise.
|
||||
* gdb.server/reconnect-ctrl-c.exp: Likewise.
|
||||
* gdb.server/run-without-local-binary.exp: Likewise.
|
||||
* gdb.server/server-kill.exp: Likewise.
|
||||
* gdb.server/server-run.exp: Likewise.
|
||||
* gdb.server/solib-list.exp: Likewise.
|
||||
* gdb.server/stop-reply-no-thread.exp: Likewise.
|
||||
* gdb.server/wrapper.exp: Likewise.
|
||||
* gdb.server/sysroot.exp: Increase timeout when testing the
|
||||
target: sysroot.
|
||||
|
||||
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
* gdb.server/server-run.exp: Use clean_restart.
|
||||
|
@ -33,8 +33,17 @@ if { [is_remote target] } {
|
||||
return 0
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol (the `is_remote target` check is
|
||||
# already done above).
|
||||
if { ![is_remote host] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -31,9 +31,17 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
|
||||
# Test spawning gdbserver with a program, connect to it and run to
|
||||
# main, with both multiprocess extensions on and off.
|
||||
proc do_test {multiprocess} {
|
||||
global binfile
|
||||
global binfile GDBFLAGS
|
||||
|
||||
clean_restart $binfile
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart $binfile
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -39,7 +39,17 @@ standard_testfile
|
||||
# Places a breakpoint in function 'breakpt' and then continues to the
|
||||
# breakpoint, at which point it runs 'info threads'.
|
||||
proc prepare_for_test { executable disable_multi_process } {
|
||||
clean_restart ${executable}
|
||||
global GDBFLAGS
|
||||
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart ${executable}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -30,8 +30,16 @@ if {![can_spawn_for_attach]} {
|
||||
return 0
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -25,8 +25,16 @@ if { [skip_gdbserver_tests] } {
|
||||
return 0
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -32,7 +32,15 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
|
||||
# gdb_skip_xml_test must be called while gdb is not running.
|
||||
set do_xml_test [expr ![gdb_skip_xml_test]]
|
||||
|
||||
clean_restart $binfile
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart $binfile
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -27,8 +27,16 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
|
||||
return -1
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -28,8 +28,16 @@ if {[skip_gdbserver_tests]} {
|
||||
return 0
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -33,7 +33,15 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
|
||||
return -1
|
||||
}
|
||||
|
||||
clean_restart ${testfile}
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart ${testfile}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -30,8 +30,17 @@ if [target_info exists gdb,nointerrupts] {
|
||||
}
|
||||
|
||||
standard_testfile
|
||||
if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
|
||||
return -1
|
||||
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
@ -31,6 +31,13 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
|
||||
# remote/21852.
|
||||
save_vars { GDBFLAGS } {
|
||||
set GDBFLAGS ""
|
||||
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "-ex \"set sysroot\""
|
||||
}
|
||||
|
||||
gdb_exit
|
||||
gdb_start
|
||||
|
||||
|
@ -36,8 +36,17 @@ if { [build_executable "failed to prepare" ${testfile}] } {
|
||||
proc prepare {} {
|
||||
global binfile gdb_prompt srcfile decimal
|
||||
global server_pid
|
||||
global GDBFLAGS
|
||||
|
||||
clean_restart $binfile
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart $binfile
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -29,7 +29,15 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
|
||||
return -1
|
||||
}
|
||||
|
||||
clean_restart $binfile
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart $binfile
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -42,7 +42,16 @@ set interp_system [section_get ${binfile} .interp]
|
||||
verbose -log "system interpreter is: $interp_system"
|
||||
|
||||
foreach nonstop { 0 1 } { with_test_prefix "non-stop $nonstop" {
|
||||
clean_restart
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart
|
||||
}
|
||||
|
||||
gdb_load_shlib ${binlibfile}
|
||||
|
||||
set remote_binfile [gdb_remote_download target $binfile]
|
||||
|
@ -34,9 +34,17 @@ if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } {
|
||||
|
||||
# Run the tests with different features of GDBserver disabled.
|
||||
proc run_test { disable_feature target_nonstop } {
|
||||
global binfile gdb_prompt decimal
|
||||
global binfile gdb_prompt decimal GDBFLAGS
|
||||
|
||||
clean_restart ${binfile}
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
clean_restart ${binfile}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
|
@ -40,39 +40,45 @@ foreach_with_prefix sysroot { "local" "remote" } {
|
||||
if { $sysroot == "local" } {
|
||||
set sysroot_command "/"
|
||||
set reading_symbols "Reading symbols from $binfile..."
|
||||
set timeout_factor 1
|
||||
} else {
|
||||
set sysroot_command "target:"
|
||||
set reading_symbols "Reading $binfile from remote target..."
|
||||
set timeout_factor 5
|
||||
}
|
||||
|
||||
# Restart GDB.
|
||||
clean_restart
|
||||
# Reading debug info from the remote target can take a bit of time, so
|
||||
# increase the timeout in that case.
|
||||
with_timeout_factor $timeout_factor {
|
||||
# Restart GDB.
|
||||
clean_restart
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
gdb_test "disconnect" ".*"
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
# extended-remote board, therefore already connected.
|
||||
gdb_test "disconnect" ".*"
|
||||
|
||||
# Start GDBserver.
|
||||
set res [gdbserver_start "" $binfile]
|
||||
set gdbserver_protocol [lindex $res 0]
|
||||
set gdbserver_gdbport [lindex $res 1]
|
||||
# Start GDBserver.
|
||||
set res [gdbserver_start "" $binfile]
|
||||
set gdbserver_protocol [lindex $res 0]
|
||||
set gdbserver_gdbport [lindex $res 1]
|
||||
|
||||
# Set the sysroot.
|
||||
gdb_test_no_output "set sysroot $sysroot_command"
|
||||
# Set the sysroot.
|
||||
gdb_test_no_output "set sysroot $sysroot_command"
|
||||
|
||||
# Connect to gdbserver, making sure GDB reads in the binary correctly.
|
||||
set test "connect to remote and read binary"
|
||||
if {[gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport $reading_symbols] == 0} {
|
||||
pass $test
|
||||
} else {
|
||||
fail $test
|
||||
# Connect to gdbserver, making sure GDB reads in the binary correctly.
|
||||
set test "connect to remote and read binary"
|
||||
if {[gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport $reading_symbols] == 0} {
|
||||
pass $test
|
||||
} else {
|
||||
fail $test
|
||||
}
|
||||
|
||||
gdb_breakpoint main
|
||||
gdb_test "continue" "Breakpoint $decimal.* main.*" "continue to main"
|
||||
|
||||
# Test that we can stop inside a library.
|
||||
gdb_breakpoint printf
|
||||
gdb_test "continue" "Breakpoint $decimal.* (__)?printf .*" \
|
||||
"continue to printf"
|
||||
}
|
||||
|
||||
gdb_breakpoint main
|
||||
gdb_test "continue" "Breakpoint $decimal.* main.*" "continue to main"
|
||||
|
||||
# Test that we can stop inside a library.
|
||||
gdb_breakpoint printf
|
||||
gdb_test "continue" "Breakpoint $decimal.* (__)?printf .*" \
|
||||
"continue to printf"
|
||||
}
|
||||
|
@ -31,8 +31,16 @@ if { [istarget *-*-mingw*]
|
||||
return -1
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
save_vars { GDBFLAGS } {
|
||||
# If GDB and GDBserver are both running locally, set the sysroot to avoid
|
||||
# reading files via the remote protocol.
|
||||
if { ![is_remote host] && ![is_remote target] } {
|
||||
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
|
||||
}
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure we're disconnected, in case we're testing with an
|
||||
|
Reference in New Issue
Block a user