[commit] gdbserver testing improvement

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] gdbserver testing improvement

Daniel Jacobowitz-2
This patch makes the testsuite kill any running gdbserver before it
attempts to start a new one, so that there are never two running at
once (unless an error occurs, of course).  This should make it easier
to reuse a single TCP port for multiple gdbservers, instead of eating
a huge range of ports.  I also used it to run gdbserver over a serial
connection, where I can only start one at a time.

Tested m68k-uclinux and x86_64-linux and committed.

--
Daniel Jacobowitz
CodeSourcery

2007-05-23  Daniel Jacobowitz  <[hidden email]>

        gdb/testsuite/
        * lib/gdbserver-support.exp (gdbserver_spawn): Only match full_buffer.
        (gdbserver_run): Kill any running gdbserver.
        * lib/mi-support.exp (mi_gdb_target_load): Likewise.

Index: gdb/testsuite/lib/gdbserver-support.exp
===================================================================
--- gdb/testsuite/lib/gdbserver-support.exp (revision 172026)
+++ gdb/testsuite/lib/gdbserver-support.exp (revision 172027)
@@ -221,7 +221,7 @@ proc gdbserver_spawn { child_args } {
     # don't need to redirect output.
     expect_background {
  -i $server_spawn_id
- -re "." { }
+ full_buffer { }
  eof {
     # The spawn ID is already closed now (but not yet waited for).
     wait -i $expect_out(spawn_id)
@@ -235,6 +235,21 @@ proc gdbserver_spawn { child_args } {
 # to it.  Return 0 on success, or non-zero on failure.
 
 proc gdbserver_run { child_args } {
+    # 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 protocol [lindex $res 0]
     set gdbport [lindex $res 1]
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
--- gdb/testsuite/lib/mi-support.exp (revision 172026)
+++ gdb/testsuite/lib/mi-support.exp (revision 172027)
@@ -453,6 +453,7 @@ proc mi_gdb_target_load { } {
     upvar timeout timeout
 
     if { [info procs gdbserver_gdb_load] != "" } {
+ mi_gdb_test "kill" ".*" ""
  set res [gdbserver_gdb_load]
  set protocol [lindex $res 0]
  set gdbport [lindex $res 1]