mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-12 12:16:04 +08:00
8dc558a072
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
147 lines
4.9 KiB
Plaintext
147 lines
4.9 KiB
Plaintext
# This testcase is part of GDB, the GNU debugger.
|
|
#
|
|
# Copyright 2020-2021 Free Software Foundation, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Test that GDB can handle receiving the W and X packets for a target
|
|
# with multiple threads, but only a single inferior.
|
|
#
|
|
# Specifically, check GDB handles this case where multi-process
|
|
# extensions are turned off. At one point this was causing GDB to
|
|
# give a warning when the exit arrived that the remote needed to
|
|
# include a thread-id, which was not correct.
|
|
|
|
load_lib gdbserver-support.exp
|
|
|
|
if { [skip_gdbserver_tests] } {
|
|
verbose "skipping gdbserver tests"
|
|
return -1
|
|
}
|
|
|
|
standard_testfile
|
|
|
|
# Start up GDB and GDBserver debugging EXECUTABLE. When
|
|
# DISABLE_MULTI_PROCESS is true then disable GDB's remote
|
|
# multi-process support, otherwise, leave it enabled.
|
|
#
|
|
# 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 } {
|
|
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.
|
|
gdb_test "disconnect" ".*"
|
|
|
|
# Disable XML-based thread listing, and possible the multi-process
|
|
# extensions.
|
|
gdb_test_no_output "set remote threads-packet off"
|
|
if { $disable_multi_process } {
|
|
gdb_test_no_output "set remote multiprocess-feature-packet off"
|
|
}
|
|
|
|
# Start gdbserver and connect.
|
|
set res [gdbserver_start "" $executable]
|
|
set gdbserver_protocol [lindex $res 0]
|
|
set gdbserver_gdbport [lindex $res 1]
|
|
set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
|
if ![gdb_assert {$res == 0} "connect"] {
|
|
return
|
|
}
|
|
|
|
# Run until we hit the breakpt function, then list all threads.
|
|
gdb_breakpoint "breakpt"
|
|
gdb_continue_to_breakpoint "breakpt"
|
|
gdb_test "info threads" ".*"
|
|
}
|
|
|
|
# Run the tests where the inferior exits normally (the W packet) while
|
|
# we have multiple-threads. EXECUTABLE is the binary under test, and
|
|
# DISABLE_MULTI_PROCESS indicates if we should disable GDB's remote
|
|
# multi-process support.
|
|
proc run_exit_test { executable disable_multi_process } {
|
|
global decimal
|
|
|
|
prepare_for_test ${executable} ${disable_multi_process}
|
|
|
|
# Finally, continue until the process exits, ensure we don't see
|
|
# any warnings between "Continuing." and the final process has
|
|
# exited message.
|
|
if { $disable_multi_process } {
|
|
set process_pattern "Remote target"
|
|
} else {
|
|
set process_pattern "process $decimal"
|
|
}
|
|
gdb_test "continue" \
|
|
[multi_line \
|
|
"Continuing\\." \
|
|
"\\\[Inferior $decimal \\\(${process_pattern}\\\) exited normally\\\]" ] \
|
|
"continue until process exits"
|
|
}
|
|
|
|
# Run the tests where the inferior exits with a signal (the X packet)
|
|
# while we have multiple-threads. EXECUTABLE is the binary under
|
|
# test, and DISABLE_MULTI_PROCESS indicates if we should disable GDB's
|
|
# remote multi-process support.
|
|
proc run_signal_test { executable disable_multi_process } {
|
|
global decimal gdb_prompt
|
|
|
|
prepare_for_test ${executable} ${disable_multi_process}
|
|
|
|
set inf_pid [get_valueof "/d" "global_pid" "unknown"]
|
|
gdb_assert ![string eq ${inf_pid} "unknown"] "read the pid"
|
|
|
|
# This sets the inferior running again, with all threads going
|
|
# into a long delay loop.
|
|
send_gdb "continue\n"
|
|
|
|
# Send the inferior a signal to kill it.
|
|
sleep 1
|
|
remote_exec target "kill -9 ${inf_pid}"
|
|
|
|
# Process the output from GDB.
|
|
gdb_test_multiple "" "inferior exited with signal" {
|
|
-re "Continuing\\.\r\n\r\nProgram terminated with signal SIGKILL, Killed.\r\nThe program no longer exists.\r\n$gdb_prompt $" {
|
|
pass $gdb_test_name
|
|
}
|
|
}
|
|
}
|
|
|
|
# Run all of the tests.
|
|
foreach_with_prefix test { exit signal } {
|
|
set def "DO_[string toupper $test]_TEST"
|
|
set func "run_${test}_test"
|
|
|
|
set executable "$binfile-${test}"
|
|
if [prepare_for_testing "failed to prepare" $executable $srcfile \
|
|
[list debug pthreads additional_flags=-D${def}]] {
|
|
return -1
|
|
}
|
|
|
|
foreach_with_prefix multi_process { 0 1 } {
|
|
$func ${executable} ${multi_process}
|
|
}
|
|
}
|