]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix bug in previous remote unique_ptr change
authorPedro Alves <pedro@palves.net>
Wed, 20 Dec 2023 20:11:23 +0000 (20:11 +0000)
committerPedro Alves <pedro@palves.net>
Wed, 20 Dec 2023 20:24:15 +0000 (20:24 +0000)
By inspection, I noticed that the previous patch went too far, here:

 @@ -7705,7 +7713,8 @@ remote_target::discard_pending_stop_replies (struct inferior *inf)
    if (rs->remote_desc == NULL)
      return;

 -  reply = (struct stop_reply *) rns->pending_event[notif_client_stop.id];
 +  stop_reply_up reply
 +    = as_stop_reply_up (std::move (rns->pending_event[notif_client_stop.id]));

    /* Discard the in-flight notification.  */
    if (reply != NULL && reply->ptid.pid () == inf->pid)

That is always moving the stop reply from pending_event, when we only
really want to peek into it.  The code further below that even says:

  /* Discard the in-flight notification.  */
  if (reply != NULL && reply->ptid.pid () == inf->pid)
    {
      /* Leave the notification pending, since the server expects that
 we acknowledge it with vStopped.  But clear its contents, so
 that later on when we acknowledge it, we also discard it.  */

This commit reverts that hunk back, adjusted to use unique_ptr::get().

Change-Id: Ifc809d1a8225150a4656889f056d51267100ee24

gdb/remote.c

index f3823bb9c76a44c5e008dde48a91be57dc2c9fa6..dcc1a0d0639c6de41b450ed8ba6d15a73c6f7b9f 100644 (file)
@@ -7713,8 +7713,9 @@ remote_target::discard_pending_stop_replies (struct inferior *inf)
   if (rs->remote_desc == NULL)
     return;
 
-  stop_reply_up reply
-    = as_stop_reply_up (std::move (rns->pending_event[notif_client_stop.id]));
+  struct notif_event *notif_event
+    = rns->pending_event[notif_client_stop.id].get ();
+  auto *reply = static_cast<stop_reply *> (notif_event);
 
   /* Discard the in-flight notification.  */
   if (reply != NULL && reply->ptid.pid () == inf->pid)