mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
4ec7020176
A few months ago semicolons after "return" were removed throughout the testsuite. However, as I pointed out in review, they're unnecessary not just after "return", but pretty much after any tcl command. ';' is the command separator, and you only need it if there's another command on the same line afterwards. This patch was written by running: $ find . -name "*.exp" | xargs grep -l ";\s*$" | xargs sed -i 's/\([^#][^\s*;]*\)\s*;\s*$/\1/' and then undoing changes to comments, and lib/future.exp. Tested on x86_64 Fedora 17. gdb/testsuite/ 2013-06-07 Pedro Alves <palves@redhat.com> * boards/native-extended-gdbserver.exp: Remove semicolon. * config/arm-ice.exp: Likewise. * config/bfin.exp: Likewise. * config/cygmon.exp: Likewise. * config/h8300.exp: Likewise. * config/monitor.exp: Likewise. * config/sid.exp: Likewise. * config/sim.exp: Likewise. * config/slite.exp: Likewise. * config/vx.exp: Likewise. * gdb.arch/i386-bp_permanent.exp: Likewise. * gdb.asm/asm-source.exp: Likewise. * gdb.base/args.exp: Likewise. * gdb.base/attach-pie-misread.exp: Likewise. * gdb.base/auxv.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/bitfields2.exp: Likewise. * gdb.base/bitfields.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/break-interp.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/call-sc.exp: Likewise. * gdb.base/commands.exp: Likewise. * gdb.base/corefile.exp: Likewise. * gdb.base/dbx.exp: Likewise. * gdb.base/ending-run.exp: Likewise. * gdb.base/exprs.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/huge.exp: Likewise. * gdb.base/list.exp: Likewise. * gdb.base/memattr.exp: Likewise. * gdb.base/overlays.exp: Likewise. * gdb.base/printcmds.exp: Likewise. * gdb.base/recurse.exp: Likewise. * gdb.base/remotetimeout.exp: Likewise. * gdb.base/reread.exp: Likewise. * gdb.base/savedregs.exp: Likewise. * gdb.base/scope.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/setshow.exp: Likewise. * gdb.base/setvar.exp: Likewise. * gdb.base/sigaltstack.exp: Likewise. * gdb.base/siginfo-addr.exp: Likewise. * gdb.base/siginfo.exp: Likewise. * gdb.base/siginfo-obj.exp: Likewise. * gdb.base/sigrepeat.exp: Likewise. * gdb.base/sigstep.exp: Likewise. * gdb.base/structs.exp: Likewise. * gdb.base/testenv.exp: Likewise. * gdb.base/twice.exp: Likewise. * gdb.base/valgrind-db-attach.exp: Likewise. * gdb.base/valgrind-infcall.exp: Likewise. * gdb.base/varargs.exp: Likewise. * gdb.base/watchpoint.exp: Likewise. * gdb.cp/gdb1355.exp: Likewise. * gdb.cp/misc.exp: Likewise. * gdb.disasm/hppa.exp: Likewise. * gdb.disasm/t01_mov.exp: Likewise. * gdb.disasm/t02_mova.exp: Likewise. * gdb.disasm/t03_add.exp: Likewise. * gdb.disasm/t04_sub.exp: Likewise. * gdb.disasm/t05_cmp.exp: Likewise. * gdb.disasm/t06_ari2.exp: Likewise. * gdb.disasm/t07_ari3.exp: Likewise. * gdb.disasm/t08_or.exp: Likewise. * gdb.disasm/t09_xor.exp: Likewise. * gdb.disasm/t10_and.exp: Likewise. * gdb.disasm/t11_logs.exp: Likewise. * gdb.disasm/t12_bit.exp: Likewise. * gdb.disasm/t13_otr.exp: Likewise. * gdb.gdb/selftest.exp: Likewise. * gdb.hp/gdb.base-hp/callfwmall.exp: Likewise. * gdb.mi/mi-reverse.exp: Likewise. * gdb.pascal/floats.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.threads/attach-into-signal.exp: Likewise. * gdb.threads/pthreads.exp: Likewise. * gdb.threads/thread_events.exp: Likewise. * gdb.threads/watchthreads.exp: Likewise. * gdb.trace/actions-changed.exp: Likewise. * gdb.trace/actions.exp: Likewise. * gdb.trace/ax.exp: Likewise. * gdb.trace/backtrace.exp: Likewise. * gdb.trace/change-loc.exp: Likewise. * gdb.trace/deltrace.exp: Likewise. * gdb.trace/disconnected-tracing.exp: Likewise. * gdb.trace/ftrace.exp: Likewise. * gdb.trace/infotrace.exp: Likewise. * gdb.trace/passc-dyn.exp: Likewise. * gdb.trace/passcount.exp: Likewise. * gdb.trace/pending.exp: Likewise. * gdb.trace/qtro.exp: Likewise. * gdb.trace/range-stepping.exp: Likewise. * gdb.trace/report.exp: Likewise. * gdb.trace/save-trace.exp: Likewise. * gdb.trace/status-stop.exp: Likewise. * gdb.trace/strace.exp: Likewise. * gdb.trace/tfile.exp: Likewise. * gdb.trace/tfind.exp: Likewise. * gdb.trace/trace-break.exp: Likewise. * gdb.trace/tracecmd.exp: Likewise. * gdb.trace/trace-mt.exp: Likewise. * gdb.trace/tspeed.exp: Likewise. * gdb.trace/tsv.exp: Likewise. * gdb.trace/while-stepping.exp: Likewise. * lib/gdb.exp: Likewise. * lib/gdbserver-support.exp: Likewise. * lib/java.exp: Likewise. * lib/mi-support.exp: Likewise. * lib/pascal.exp: Likewise. * lib/prompt.exp: Likewise. * lib/trace-support.exp: Likewise.
409 lines
12 KiB
Plaintext
409 lines
12 KiB
Plaintext
# Copyright 2000-2013 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/>.
|
||
|
||
# This file is based on config/gdbserver.exp, which was written by
|
||
# Michael Snyder (msnyder@redhat.com).
|
||
|
||
#
|
||
# To be addressed or set in your baseboard config file:
|
||
#
|
||
# set_board_info gdb_protocol "remote"
|
||
# Unles you have a gdbserver that uses a different protocol...
|
||
# After GDB starts you should check global $gdbserver_protocol instead as
|
||
# the testfile may force a specific different target protocol itself.
|
||
#
|
||
# set_board_info gdb_server_prog
|
||
# This will be the path to the gdbserver program you want to test.
|
||
# Defaults to "gdbserver".
|
||
#
|
||
# set_board_info sockethost
|
||
# The name of the host computer whose socket is being used.
|
||
# Defaults to "localhost". Note: old gdbserver requires
|
||
# that you define this, but libremote/gdbserver does not.
|
||
#
|
||
# set_board_info gdb,socketport
|
||
# Port id to use for socket connection. If not set explicitly,
|
||
# it will start at "2345" and increment for each use.
|
||
# After GDB starts you should check global $gdbserver_gdbport for the
|
||
# real port used. It is not useful if $gdbserver_reconnect_p was not set.
|
||
#
|
||
|
||
#
|
||
# gdb_target_cmd
|
||
# Send gdb the "target" command
|
||
#
|
||
proc gdb_target_cmd { targetname serialport } {
|
||
global gdb_prompt
|
||
|
||
set serialport_re [string_to_regexp $serialport]
|
||
for {set i 1} {$i <= 3} {incr i} {
|
||
send_gdb "target $targetname $serialport\n"
|
||
gdb_expect 60 {
|
||
-re "A program is being debugged already.*ill it.*y or n. $" {
|
||
send_gdb "y\n"
|
||
exp_continue
|
||
}
|
||
-re "unknown host.*$gdb_prompt" {
|
||
verbose "Couldn't look up $serialport"
|
||
}
|
||
-re "Couldn't establish connection to remote.*$gdb_prompt $" {
|
||
verbose "Connection failed"
|
||
}
|
||
-re "Remote MIPS debugging.*$gdb_prompt" {
|
||
verbose "Set target to $targetname"
|
||
return 0
|
||
}
|
||
-re "Remote debugging using .*$serialport_re.*$gdb_prompt $" {
|
||
verbose "Set target to $targetname"
|
||
return 0
|
||
}
|
||
-re "Remote debugging using stdio.*$gdb_prompt $" {
|
||
verbose "Set target to $targetname"
|
||
return 0
|
||
}
|
||
-re "Remote target $targetname connected to.*$gdb_prompt $" {
|
||
verbose "Set target to $targetname"
|
||
return 0
|
||
}
|
||
-re "Connected to.*$gdb_prompt $" {
|
||
verbose "Set target to $targetname"
|
||
return 0
|
||
}
|
||
-re "Ending remote.*$gdb_prompt $" { }
|
||
-re "Connection refused.*$gdb_prompt $" {
|
||
verbose "Connection refused by remote target. Pausing, and trying again."
|
||
sleep 30
|
||
continue
|
||
}
|
||
-re "Timeout reading from remote system.*$gdb_prompt $" {
|
||
verbose "Got timeout error from gdb."
|
||
}
|
||
-notransfer -re "Remote debugging using .*\r\n> $" {
|
||
# We got an unexpected prompt while creating the target.
|
||
# Leave it there for the test to diagnose.
|
||
return 1
|
||
}
|
||
timeout {
|
||
send_gdb ""
|
||
break
|
||
}
|
||
}
|
||
}
|
||
return 1
|
||
}
|
||
|
||
|
||
global portnum
|
||
set portnum "2345"
|
||
|
||
# Locate the gdbserver binary. Returns "" if gdbserver could not be found.
|
||
|
||
proc find_gdbserver { } {
|
||
global GDB
|
||
global GDBSERVER
|
||
|
||
if [info exists GDBSERVER] {
|
||
return ${GDBSERVER}
|
||
}
|
||
|
||
if [target_info exists gdb_server_prog] {
|
||
return [target_info gdb_server_prog]
|
||
}
|
||
|
||
set gdbserver "${GDB}server"
|
||
if { [file isdirectory $gdbserver] } {
|
||
append gdbserver "/gdbserver"
|
||
}
|
||
|
||
if { [file executable $gdbserver] } {
|
||
return $gdbserver
|
||
}
|
||
|
||
return ""
|
||
}
|
||
|
||
# Return non-zero if we should skip gdbserver-specific tests.
|
||
|
||
proc skip_gdbserver_tests { } {
|
||
if { [find_gdbserver] == "" } {
|
||
return 1
|
||
}
|
||
|
||
return 0
|
||
}
|
||
|
||
# Download the currently loaded program to the target if necessary.
|
||
# Return the target system filename.
|
||
# NOTE: This was named "gdbserver_download", but that collides with the
|
||
# dejagnu "download" API function when using load_generic_config "gdbserver".
|
||
|
||
proc gdbserver_download_current_prog { } {
|
||
global gdbserver_host_exec
|
||
global gdbserver_host_mtime
|
||
global gdbserver_server_exec
|
||
global last_loaded_file
|
||
|
||
set host_exec $last_loaded_file
|
||
|
||
# If we already downloaded a file to the target, see if we can reuse it.
|
||
set reuse 0
|
||
if { [info exists gdbserver_server_exec] } {
|
||
set reuse 1
|
||
|
||
# If the file has changed, we can not.
|
||
if { $host_exec != $gdbserver_host_exec } {
|
||
set reuse 0
|
||
}
|
||
|
||
# If the mtime has changed, we can not.
|
||
if { [file mtime $host_exec] != $gdbserver_host_mtime } {
|
||
set reuse 0
|
||
}
|
||
}
|
||
|
||
if { $reuse == 0 } {
|
||
set gdbserver_host_exec $host_exec
|
||
set gdbserver_host_mtime [file mtime $host_exec]
|
||
if [is_remote target] {
|
||
set gdbserver_server_exec [gdb_download $host_exec]
|
||
} else {
|
||
set gdbserver_server_exec $host_exec
|
||
}
|
||
}
|
||
|
||
return $gdbserver_server_exec
|
||
}
|
||
|
||
# Default routine to compute the argument to "target remote".
|
||
|
||
proc gdbserver_default_get_remote_address { host port } {
|
||
return "$host$port"
|
||
}
|
||
|
||
# Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS.
|
||
# The port will be filled in between them automatically.
|
||
#
|
||
# Returns the target protocol and socket to connect to.
|
||
|
||
proc gdbserver_start { options arguments } {
|
||
global portnum
|
||
|
||
# Port id -- either specified in baseboard file, or managed here.
|
||
if [target_info exists gdb,socketport] {
|
||
set portnum [target_info gdb,socketport]
|
||
} else {
|
||
# Bump the port number to avoid conflicts with hung ports.
|
||
incr portnum
|
||
}
|
||
|
||
# Extract the local and remote host ids from the target board struct.
|
||
if [target_info exists sockethost] {
|
||
set debughost [target_info sockethost]
|
||
} else {
|
||
set debughost "localhost:"
|
||
}
|
||
|
||
# Some boards use a different value for the port that is passed to
|
||
# gdbserver and the port that is passed to the "target remote" command.
|
||
# One example is the stdio gdbserver support.
|
||
if [target_info exists gdb,get_remote_address] {
|
||
set get_remote_address [target_info gdb,get_remote_address]
|
||
} else {
|
||
set get_remote_address gdbserver_default_get_remote_address
|
||
}
|
||
|
||
# Extract the protocol
|
||
if [target_info exists gdb_protocol] {
|
||
set protocol [target_info gdb_protocol]
|
||
} else {
|
||
set protocol "remote"
|
||
}
|
||
|
||
set gdbserver [find_gdbserver]
|
||
|
||
# Loop till we find a free port.
|
||
while 1 {
|
||
# Fire off the debug agent.
|
||
set gdbserver_command "$gdbserver"
|
||
|
||
# If gdbserver_reconnect will be called $gdbserver_reconnect_p must be
|
||
# set to true already during gdbserver_start.
|
||
global gdbserver_reconnect_p
|
||
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
|
||
# GDB client could accidentally connect to a stale server.
|
||
# append gdbserver_command " --debug --once"
|
||
append gdbserver_command " --once"
|
||
}
|
||
|
||
if { $options != "" } {
|
||
append gdbserver_command " $options"
|
||
}
|
||
if { $portnum != "" } {
|
||
append gdbserver_command " :$portnum"
|
||
}
|
||
if { $arguments != "" } {
|
||
append gdbserver_command " $arguments"
|
||
}
|
||
|
||
set server_spawn_id [remote_spawn target $gdbserver_command]
|
||
|
||
# Wait for the server to open its TCP socket, so that GDB can connect.
|
||
expect {
|
||
-i $server_spawn_id
|
||
-notransfer
|
||
-re "Listening on" { }
|
||
-re "Can't bind address: Address already in use\\.\r\n" {
|
||
verbose -log "Port $portnum is already in use."
|
||
if ![target_info exists gdb,socketport] {
|
||
# Bump the port number to avoid the conflict.
|
||
wait -i $expect_out(spawn_id)
|
||
incr portnum
|
||
continue
|
||
}
|
||
}
|
||
}
|
||
break
|
||
}
|
||
|
||
# We can't just call close, because if gdbserver is local then that means
|
||
# that it will get a SIGHUP. Doing it this way could also allow us to
|
||
# get at the inferior's input or output if necessary, and means that we
|
||
# don't need to redirect output.
|
||
expect_background {
|
||
-i $server_spawn_id
|
||
full_buffer { }
|
||
eof {
|
||
# The spawn ID is already closed now (but not yet waited for).
|
||
wait -i $expect_out(spawn_id)
|
||
}
|
||
}
|
||
|
||
return [list $protocol [$get_remote_address $debughost $portnum]]
|
||
}
|
||
|
||
# Start a gdbserver process running SERVER_EXEC, and connect GDB
|
||
# to it. CHILD_ARGS are passed to the inferior.
|
||
#
|
||
# Returns the target protocol and socket to connect to.
|
||
|
||
proc gdbserver_spawn { child_args } {
|
||
set target_exec [gdbserver_download_current_prog]
|
||
|
||
# Fire off the debug agent. This flavour of gdbserver takes as
|
||
# arguments the port information, the name of the executable file to
|
||
# be debugged, and any arguments.
|
||
set arguments "$target_exec"
|
||
if { $child_args != "" } {
|
||
append arguments " $child_args"
|
||
}
|
||
return [gdbserver_start "" $arguments]
|
||
}
|
||
|
||
# Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
|
||
# to it. Return 0 on success, or non-zero on failure.
|
||
|
||
proc gdbserver_run { child_args } {
|
||
global gdbserver_protocol
|
||
global gdbserver_gdbport
|
||
|
||
# Kill anything running before we try to start gdbserver, in case
|
||
# we are sharing a serial connection.
|
||
global gdb_prompt
|
||
send_gdb "kill\n"
|
||
gdb_expect 120 {
|
||
-re "Kill the program being debugged. .y or n. $" {
|
||
send_gdb "y\n"
|
||
verbose "\t\tKilling previous program being debugged"
|
||
exp_continue
|
||
}
|
||
-re "$gdb_prompt $" {
|
||
# OK.
|
||
}
|
||
}
|
||
|
||
set res [gdbserver_spawn $child_args]
|
||
set gdbserver_protocol [lindex $res 0]
|
||
set gdbserver_gdbport [lindex $res 1]
|
||
|
||
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
||
}
|
||
|
||
# Reconnect to the previous gdbserver session.
|
||
|
||
proc gdbserver_reconnect { } {
|
||
global gdbserver_protocol
|
||
global gdbserver_gdbport
|
||
|
||
global gdbserver_reconnect_p
|
||
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
|
||
error "gdbserver_reconnect_p is not set before gdbserver_reconnect"
|
||
return 0
|
||
}
|
||
|
||
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
||
}
|
||
|
||
# Start and connect to a gdbserver in extended mode. Note this frobs
|
||
# $gdbserver_protocol, so should be used only from a board that
|
||
# usually connects in target remote mode.
|
||
proc gdbserver_start_extended { } {
|
||
global gdbserver_protocol
|
||
global gdbserver_gdbport
|
||
global use_gdb_stub
|
||
|
||
set res [gdbserver_start "--multi" ""]
|
||
set gdbserver_protocol [lindex $res 0]
|
||
if { [string first "extended-" $gdbserver_protocol] != 0} {
|
||
set gdbserver_protocol "extended-$gdbserver_protocol"
|
||
}
|
||
set gdbserver_gdbport [lindex $res 1]
|
||
|
||
# Even if the board file is testing with target remote, our caller
|
||
# wants to test against gdbserver in extended-remote mode. Make sure to
|
||
# disable stub-like techniques.
|
||
set use_gdb_stub 0
|
||
|
||
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
||
}
|
||
|
||
# Start and connect to a gdbserver in extended/multi mode. Unlike
|
||
# gdbserver_start_extended, this does not frob $gdbserver_protocol.
|
||
|
||
proc gdbserver_start_multi { } {
|
||
global gdbserver_protocol
|
||
global gdbserver_gdbport
|
||
|
||
set res [gdbserver_start "--multi" ""]
|
||
set gdbserver_protocol [lindex $res 0]
|
||
set gdbserver_gdbport [lindex $res 1]
|
||
|
||
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
||
}
|
||
|
||
# Start a gdbserver process in multi/extended mode, and have GDB
|
||
# connect to it (MI version). Return 0 on success, or non-zero on
|
||
# failure.
|
||
|
||
proc mi_gdbserver_start_multi { } {
|
||
global gdbserver_protocol
|
||
global gdbserver_gdbport
|
||
|
||
set res [gdbserver_start "--multi" ""]
|
||
set gdbserver_protocol [lindex $res 0]
|
||
set gdbserver_gdbport [lindex $res 1]
|
||
|
||
return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
||
}
|