From patchwork Wed Dec 20 20:27:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 82607 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF62A38618AD for ; Wed, 20 Dec 2023 20:27:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by sourceware.org (Postfix) with ESMTPS id A946F3858CD1 for ; Wed, 20 Dec 2023 20:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A946F3858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A946F3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703104060; cv=none; b=ir9puMyi/ad50Mk+UbVVhgG1clyeZh1cF4yRSxXAflUi+p2Cpnt+B/BUGDk7dHeDCEkoFG2B1QdOTrfJ0sOs+DKRM0BgpJAal9HiibcD3b8QwvHhtkRbQrngekRZqZqKw6x4nrwzbrdNCAaJUuVDnI8+DZAFL6VTiKVWkDd4MUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703104060; c=relaxed/simple; bh=wA0YhBYpwzzUt+ZKEamjvgiXJGx2SihTBIbljp1u0X8=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=xc4AOrhBnyhfyWiL2EQjGx+fsAh6UqzJR9Q3izl6pbS0/Z41A5wdKJ7olDyLQqKutpaklPnDFjH0ZDbHqplPcSn0SvpF1AvYOc8kaYNwTuVXndgNhLZTDkICJV7nAn3B8r737mWvixGKzImmKqcp0SCn/YzcOfI61meb52R+4tc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40d22d3e751so7226715e9.1 for ; Wed, 20 Dec 2023 12:27:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703104057; x=1703708857; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8IUWsswla8n8rD/1BGo4F2axhQUHgP5lOuEogXmgOow=; b=IB5f/mwK+8E1NvRNQWFZD5OL7WYtTsby9AtV3tHw7oQ183+3zY3k+lwibY/of2/SuS vSm0JXysw2wK10xZSBSU5lk7qccGSq95nX0Sx2oqglyKQwWVcm9zOsKv0ansCqE0tUWy 58mHcJLk2YRe7KLT5SfCRHDIGvvzZvR6HcCFdHAyGCt4agEkCPjjrpvtv0bCCyqRr56U Uo6PHhASBNQppIY0CZmHy8xu3+ZnZgvjVUtXRzrUAVH75Bjdk1MDgWIzfyetr7Y05oPS uMYNGeLQ8lulIZrPd8d+QLkLGlrvZ/altr3jLRfNx5w77/cdERY9H9RzLWc84tghI1Hj mtgA== X-Gm-Message-State: AOJu0YzZ2TCd9OPfHBRnef8eWR4vVsZC02OP5WVuWMxN4USqMbi4JNeK hModJDfOhf4rKoxYVFyyXPjeZetqj38H4w== X-Google-Smtp-Source: AGHT+IEArPV7bhj2VsiBTqxheeM4zFjwYmTJOGQqjKP2xd1GMCNjWyR0CE43YURGxJGhpwdij6ROAw== X-Received: by 2002:a05:600c:4584:b0:40d:3a4a:63b6 with SMTP id r4-20020a05600c458400b0040d3a4a63b6mr107822wmo.104.1703104057186; Wed, 20 Dec 2023 12:27:37 -0800 (PST) Received: from ?IPV6:2001:8a0:f923:4f00:1791:acb8:e147:39c1? ([2001:8a0:f923:4f00:1791:acb8:e147:39c1]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c450e00b003fe1fe56202sm711000wmo.33.2023.12.20.12.27.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Dec 2023 12:27:36 -0800 (PST) Message-ID: <08f2de94-a450-4bd3-9c3f-2f3916a7cb02@palves.net> Date: Wed, 20 Dec 2023 20:27:35 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [pushed] Fix bug in previous remote unique_ptr change (Re: [PATCH 0/2] Use unique_ptr more in the remote target) Content-Language: en-US To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20231215181257.1196830-1-pedro@palves.net> <87msub703n.fsf@tromey.com> From: Pedro Alves In-Reply-To: <87msub703n.fsf@tromey.com> X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org On 2023-12-15 19:10, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> A couple cleanup patches improving the ownership tracking in the > Pedro> remote target. > > Thanks. These look good to me. > Approved-By: Tom Tromey Thanks. I pushed it, and then immediately afterwards, while looking at the patch again I noticed a problem... :-/ I've pushed this follow up patch as well. From aed77b16f17fc3ed9c952af632674dc25d0dfdb5 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 20 Dec 2023 20:11:23 +0000 Subject: [PATCH] Fix bug in previous remote unique_ptr change 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) base-commit: e21633812306a23d454e1a63fa57a5b689cddcbb diff --git a/gdb/remote.c b/gdb/remote.c index f3823bb9c76..dcc1a0d0639 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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 (notif_event); /* Discard the in-flight notification. */ if (reply != NULL && reply->ptid.pid () == inf->pid)