Fix gdbserver/MI testing regression
authorPedro Alves <palves@redhat.com>
Thu, 30 Jun 2016 10:55:22 +0000 (11:55 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 30 Jun 2016 10:59:19 +0000 (11:59 +0100)
Commit 51f77c3704a6 ("Add testing infrastruture bits for running with
MI on a separate UI") broke MI testing with native-gdbserver:

 $ make check RUNTESTFLAGS="--target_board=native-gdbserver mi-var-child.exp"
 ...
 Running .../src/binutils-gdb/gdb/testsuite/gdb.mi/mi-var-child.exp ...
 can't unset "inferior_spawn_id": no such variable
     while executing
 "unset inferior_spawn_id"
     (procedure "close_gdbserver" line 20)
     invoked from within
 "close_gdbserver"
 ...

When testing with gdbserver, gdb_exit is overridden with a special
version that calls close_gdbserver, which clears inferior_spawn_id.
The problem is that the commit mentioned above made
gdb_exit/mi_gdb_exit clear inferior_spawn_id too, and clearing a
non-existing variable is a tcl error.

Since gdb_exit/mi_gdb_exit always clears inferior_spawn_id now, the
fix is simply to stop clearing it in close_gdbserver.

gdb/testsuite/
2016-06-30  Pedro Alves  <palves@redhat.com>

* lib/gdbserver-support.exp (close_gdbserver, gdb_exit): Don't
unset inferior_spawn_id.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdbserver-support.exp

index ab0d9e67d6e94d12ea24213b6d3855e31ade0eb5..1362f09a6a1808c6b757de3093eae53811b27004 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-30  Pedro Alves  <palves@redhat.com>
+
+       * lib/gdbserver-support.exp (close_gdbserver, gdb_exit): Don't
+       unset inferior_spawn_id.
+
 2016-06-30  Pedro Alves  <palves@redhat.com>
 
        * lib/mi-support.exp (default_mi_gdb_start): Declare global
index 951afe5afbc1cbb27c6c8968b8f633dd55c8c64b..b792b2331fffbfcf71f1b4be4859f0f3cc6a6eb1 100644 (file)
@@ -324,7 +324,7 @@ proc gdbserver_spawn { child_args } {
 # Close the GDBserver connection.
 
 proc close_gdbserver {} {
-    global server_spawn_id inferior_spawn_id
+    global server_spawn_id
 
     # 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
@@ -340,7 +340,6 @@ proc close_gdbserver {} {
     catch "close -i $server_spawn_id"
     catch "wait -i $server_spawn_id"
     unset server_spawn_id
-    unset inferior_spawn_id
 }
 
 # Hook into GDB exit, and close GDBserver.
@@ -349,7 +348,7 @@ if { [info procs gdbserver_gdb_exit] == "" } {
     rename gdb_exit gdbserver_orig_gdb_exit
 }
 proc gdb_exit {} {
-    global gdb_spawn_id server_spawn_id inferior_spawn_id
+    global gdb_spawn_id server_spawn_id
     global gdb_prompt
     global gdbserver_reconnect_p
 
@@ -376,7 +375,6 @@ proc gdb_exit {} {
                -i "$server_spawn_id" eof {
                    wait -i $expect_out(spawn_id)
                    unset server_spawn_id
-                   unset inferior_spawn_id
                }
            }
        }