Fix {mi-tracepoint-changed, mi-tsv-changed}.exp with native-extended-gdbserver
authorPedro Alves <palves@redhat.com>
Thu, 16 Apr 2015 11:23:26 +0000 (12:23 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 16 Apr 2015 13:36:52 +0000 (14:36 +0100)
Fixes:

 -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

These tests do something like this:

 #0 - start gdb/gdbserver normally
 #1 - setup some things in the debug session
 #2 - disconnect from gdbserver
 #3 - restart gdb
 #4 - reconnect to gdbserver

The problem is that the native-extended-gdbserver board always spawns
a new gdbserver instance in #3 (and has gdb connect to that).  So when
the test gets to #4, it connects to that new instance instead of the
old one:

 (gdb) spawn ../gdbserver/gdbserver --multi :2354
 Listening on port 2354
 target extended-remote localhost:2354
 Remote debugging using localhost:2354
 ...
 spawn ../gdbserver/gdbserver --multi :2355
 Listening on port 2355
 47-target-select extended-remote localhost:2355
 =tsv-created,name="trace_timestamp",initial="0"\n
 47^connected
 (gdb)
 ...
 47-target-select extended-remote localhost:2355
 47^connected
 (gdb)
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv1 created
 FAIL: gdb.trace/mi-tsv-changed.exp: upload: tsv2 created

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

* boards/native-extended-gdbserver.exp (mi_gdb_start): Don't start
a new gdbserver if gdbserver_reconnect_p is set.

gdb/testsuite/ChangeLog
gdb/testsuite/boards/native-extended-gdbserver.exp

index 77393253baf59137303b3b78cebcf9617b8b1220..2000dbed2c7993b4424cc33b4a83bb6184dd9337 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-16  Pedro Alves  <palves@redhat.com>
+
+       * boards/native-extended-gdbserver.exp (mi_gdb_start): Don't start
+       a new gdbserver if gdbserver_reconnect_p is set.
+
 2015-04-16  Pedro Alves  <palves@redhat.com>
 
        * lib/gdbserver-support.exp (gdb_exit): If gdbserver_reconnect_p
index 8d299ef3f639672cefa28b4e84cdc1f39eb51ed8..744e044e58a36a13107c1b98d7a99c434e33d129 100644 (file)
@@ -64,14 +64,19 @@ if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
     rename mi_gdb_start extended_gdbserver_mi_gdb_start
 }
 proc mi_gdb_start { args } {
+    global gdbserver_reconnect_p
+
     # Spawn GDB.
     set res [extended_gdbserver_mi_gdb_start $args]
     if { $res } {
        return $res
     }
 
-    # And then GDBserver, ready for extended-remote mode.
-    mi_gdbserver_start_multi
+    # And then spawn GDBserver and connect to it in extended-remote
+    # mode, unless the test wants to explicitly test reconnection.
+    if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
+       mi_gdbserver_start_multi
+    }
     return 0
 }