GDBserver: Discard previous queued events when GDB disconnects.
authorPedro Alves <palves@redhat.com>
Wed, 8 Jan 2014 19:16:54 +0000 (19:16 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 8 Jan 2014 20:34:26 +0000 (20:34 +0000)
... not when a new GDB connection sends the status packet ('?').
Mainly just a cleanup/simplification, as GDB always sends '?' first.

Tested on x86_64 Fedora 17.

2014-01-08  Pedro Alves  <palves@redhat.com>

* server.c (handle_status): Don't discard previous queued stop
replies or thread's pending status here.
(main) <disconnection>: Do it here instead.

gdb/gdbserver/ChangeLog
gdb/gdbserver/server.c

index bf874a15ea477ab720455bc624d529b2ac29763f..adba6f6c73dadffa091f859be9ca337052fc93e1 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-08  Pedro Alves  <palves@redhat.com>
+
+       * server.c (handle_status): Don't discard previous queued stop
+       replies or thread's pending status here.
+       (main) <disconnection>: Do it here instead.
+
 2014-01-08  Pedro Alves  <palves@redhat.com>
 
        * gdbthread.h (struct thread_info) <status_pending_p>: New field.
index 5e8007511d219bc38f4899d6b187a3c39fcf495e..c9d9eec0d4e7444c70a1203fd7d77ae51b4868bf 100644 (file)
@@ -2635,9 +2635,6 @@ handle_status (char *own_buf)
   /* GDB is connected, don't forward events to the target anymore.  */
   for_each_inferior (&all_processes, gdb_reattached_process);
 
-  discard_queued_stop_replies (-1);
-  for_each_inferior (&all_threads, clear_pending_status_callback);
-
   /* In non-stop mode, we must send a stop reply for each stopped
      thread.  In all-stop mode, just send one for the first stopped
      thread we find.  */
@@ -3140,6 +3137,12 @@ main (int argc, char *argv[])
               "Remote side has terminated connection.  "
               "GDBserver will reopen the connection.\n");
 
+      /* Get rid of any pending statuses.  An eventual reconnection
+        (by the same GDB instance or another) will refresh all its
+        state from scratch.  */
+      discard_queued_stop_replies (-1);
+      for_each_inferior (&all_threads, clear_pending_status_callback);
+
       if (tracing)
        {
          if (disconnected_tracing)
This page took 0.032104 seconds and 4 git commands to generate.