Fix gdbserver_reconnect_p handling
authorPedro Alves <palves@redhat.com>
Thu, 16 Apr 2015 13:26:59 +0000 (14:26 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 16 Apr 2015 13:26:59 +0000 (14:26 +0100)
Commit 6423214f (testsuite: Don't use expect_background to reap
gdbserver) broke a couple tests that set gdbserver_reconnect_p and
restart gdb before reconnecting, because a gdb_exit (e.g., through
clean_restart) exits gdbserver unconditionally.

Fixes, with --target_board=native-gdbserver:

 -FAIL: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint created
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: tracepoint on marker is installed
 +PASS: gdb.trace/mi-tracepoint-changed.exp: reconnect: break-info 1

 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 -FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 +PASS: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

gdb/testsuite/
2015-04-16  Pedro Alves  <palves@redhat.com>

* lib/gdbserver-support.exp (gdb_exit): If gdbserver_reconnect_p
is set, don't exit gdbserver.

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

index 0f2d552b9160e9ac5c84515ab693c74fc6419a89..77393253baf59137303b3b78cebcf9617b8b1220 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-16  Pedro Alves  <palves@redhat.com>
+
+       * lib/gdbserver-support.exp (gdb_exit): If gdbserver_reconnect_p
+       is set, don't exit gdbserver.
+
 2015-04-16  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * gdb.arch/s390-vregs.S (change_vrs): Replace exrl by an
index b3140c2296ad1dbb671a5ec2d42611751c849f2e..6c3401c04dfe98f39b07e2bcc87346a4fd5487fa 100644 (file)
@@ -351,6 +351,14 @@ if { [info procs gdbserver_gdb_exit] == "" } {
 proc gdb_exit {} {
     global gdb_spawn_id server_spawn_id inferior_spawn_id
     global gdb_prompt
+    global gdbserver_reconnect_p
+
+    # Leave GDBserver running if we're exiting GDB in order to
+    # reconnect to the same instance of GDBserver again.
+    if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} {
+       gdbserver_orig_gdb_exit
+       return
+    }
 
     if {[info exists gdb_spawn_id] && [info exists server_spawn_id]} {
        # GDB may be terminated in an expected way or an unexpected way,