diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-07-06 18:51:10 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-07-06 18:51:10 +0000 |
commit | 047427a8a8eee010a107b3ed55798f73aa9bcd92 (patch) | |
tree | a9672d4dc205b8dbdd903b5aa9f448aca56d343f /gdb | |
parent | ac8c974e4fc01aa939e29bf9e20dc4e074eefbc8 (diff) | |
download | gdb-047427a8a8eee010a107b3ed55798f73aa9bcd92.zip gdb-047427a8a8eee010a107b3ed55798f73aa9bcd92.tar.gz gdb-047427a8a8eee010a107b3ed55798f73aa9bcd92.tar.bz2 |
gdb/testsuite/
* lib/gdbserver-support.exp (gdbserver_start): Loop spawning
gdbserver increasing $portnum if "Can't bind address" has been seen.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdbserver-support.exp | 51 |
2 files changed, 37 insertions, 19 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8f3bbaf..c118286 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-07-06 Jan Kratochvil <jan.kratochvil@redhat.com> + + * lib/gdbserver-support.exp (gdbserver_start): Loop spawning + gdbserver increasing $portnum if "Can't bind address" has been seen. + 2009-07-05 Pedro Alves <pedro@codesourcery.com> * gdb.base/ending-run.exp: Add "step out of main" pattern for diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index f755d26..861406c 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -209,26 +209,39 @@ proc gdbserver_start { options arguments } { set gdbserver [find_gdbserver] - # Export the host:port pair. - set gdbport $debughost$portnum - - # Fire off the debug agent. - set gdbserver_command "$gdbserver" - if { $options != "" } { - append gdbserver_command " $options" - } - append gdbserver_command " :$portnum" - if { $arguments != "" } { - append gdbserver_command " $arguments" - } - - set server_spawn_id [remote_spawn target $gdbserver_command] + # Loop till we find a free port. + while 1 { + # Export the host:port pair. + set gdbport $debughost$portnum + + # Fire off the debug agent. + set gdbserver_command "$gdbserver" + if { $options != "" } { + append gdbserver_command " $options" + } + append gdbserver_command " :$portnum" + if { $arguments != "" } { + append gdbserver_command " $arguments" + } - # Wait for the server to open its TCP socket, so that GDB can connect. - expect { - -i $server_spawn_id - -notransfer - -re "Listening on" { } + 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 |