remote packet sent after Ravenscar inferior exited
authorJoel Brobecker <brobecker@gnat.com>
Wed, 24 Oct 2012 18:19:50 +0000 (18:19 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Wed, 24 Oct 2012 18:19:50 +0000 (18:19 +0000)
When debugging a program using the Ravenscar profile, the debugger
sometimes tries to send the following packet to the remote after
the inferior exited.

     (gdb) c
     Continuing.
     [...]
     Sending packet: $vCont;c:1#13...Ack
     Packet received: W00
     Sending packet: $Hg1#e0...putpkt: write failed: Broken pipe.

As the inferior exited, the remote has already disconnected, and thus
the operation fails.

The reason why GDB sends the package is because the ravenscar-thread
module tries to updates the list of threads.  But this doesn't make
sense, since the program has exited.  This patch fixes it.

gdb/ChangeLog:

        * ravenscar-thread.c (ravenscar_wait): Only update the list
        of threads and inferior_ptid if the inferior is still alive.

gdb/ChangeLog
gdb/ravenscar-thread.c

index a4dd74e135ccbf0ebb106f497a6e68fc766b760f..be3bb1c2aa52ac0b4820f2d53079f34876c0aa22 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-24  Joel Brobecker  <brobecker@adacore.com>
+
+       * ravenscar-thread.c (ravenscar_wait): Only update the list
+       of threads and inferior_ptid if the inferior is still alive.
+
 2012-10-24  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (is_known_support_routine): Use lbasename when
index 385438175a271e0ba833a78ed9f21c7330686038..0c475cbd2d1a160fbfd00a3c5907465f484f327e 100644 (file)
@@ -204,8 +204,19 @@ ravenscar_wait (struct target_ops *ops, ptid_t ptid,
 
   inferior_ptid = base_ptid;
   beneath->to_wait (beneath, base_ptid, status, 0);
-  ravenscar_find_new_threads (ops);
-  ravenscar_update_inferior_ptid ();
+  /* Find any new threads that might have been created, and update
+     inferior_ptid to the active thread.
+
+     Only do it if the program is still alive, though.  Otherwise,
+     this causes problems when debugging through the remote protocol,
+     because we might try switching threads (and thus sending packets)
+     after the remote has disconnected.  */
+  if (status->kind != TARGET_WAITKIND_EXITED
+      && status->kind != TARGET_WAITKIND_SIGNALLED)
+    {
+      ravenscar_find_new_threads (ops);
+      ravenscar_update_inferior_ptid ();
+    }
   return inferior_ptid;
 }
 
This page took 0.042446 seconds and 4 git commands to generate.