From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lLqxL5lInWQcBBEAWB0awg (envelope-from ) for ; Thu, 29 Jun 2023 05:02:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=oBnABOuI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B54B11E0BB; Thu, 29 Jun 2023 05:02:17 -0400 (EDT) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A1E041E00F for ; Thu, 29 Jun 2023 05:02:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E37FB3858D37 for ; Thu, 29 Jun 2023 09:02:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E37FB3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688029334; bh=Aj5vSSZXBd5DUgrnR/z9xibepBebMSqcEElIUY+QbD8=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=oBnABOuIC7k/hU2/eMHZ1c6rEq7Zsr5SUuiCvOIJ7pztHfgxCNk2/OGW+Pdc77ORT fXAl11F334GEZBiGfhq7ds5aSaEbW8Su1We105zTR8zADSdYX0hMPJLxJuj5FVa2cU XoK1PpS3fakivTxEa8zdbC6HIEf9XPcZ8D413fOI= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id E42A83858C1F for ; Thu, 29 Jun 2023 09:01:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E42A83858C1F Received: from octopus (unknown [IPv6:2a02:390:9086:0:b939:4017:af1c:9f4]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id B387C80E7A; Thu, 29 Jun 2023 09:01:54 +0000 (UTC) Date: Thu, 29 Jun 2023 10:01:48 +0100 To: Magne Hov Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] gdb: keep record of thread numbers for reverse execution targets Message-ID: <20230629090022.cwk46lvhhnpharnf@octopus> References: <20230629083651.3145268-1-mhov@undo.io> <20230629083651.3145268-2-mhov@undo.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230629083651.3145268-2-mhov@undo.io> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Thu, 29 Jun 2023 09:01:54 +0000 (UTC) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi Magne, I have some comments below. > diff --git a/gdb/inferior.h b/gdb/inferior.h > index caa8e4d494a..33eb857645e 100644 > --- a/gdb/inferior.h > +++ b/gdb/inferior.h > @@ -332,8 +341,33 @@ thread_info::thread_info (struct inferior *inf_, ptid_t ptid_) > { > gdb_assert (inf_ != NULL); > > - this->global_num = ++highest_thread_num; > - this->per_inf_num = ++inf_->highest_thread_num; > + /* Targets that support reverse execution may see the same thread be > + created multiple times so a historical record must be maintained > + and queried. For targets without reverse execution we don't look > + up historical thread numbers because it leaves us vulnerable to > + collisions between thread identifiers that have been recycled by > + the target operating system. */ > + if (target_can_execute_reverse ()) > + { > + auto pair = inf_->ptid_thread_num_map.find (ptid_); > + if (pair != inf_->ptid_thread_num_map.end ()) > + { > + this->global_num = pair->second.first; > + this->per_inf_num = pair->second.second; > + } > + else { The '{' should be on the next line. > + this->global_num = ++highest_thread_num; > + this->per_inf_num = ++inf_->highest_thread_num; > + if (target_can_execute_reverse ()) This code is already in a block guarded by target_can_execute_reverse (), so doing this check again seems redundant. I think inserting to the map can be done unconditionally here. Best, Lancelot. > + inf_->ptid_thread_num_map[ptid_] = std::make_pair (this->global_num, > + this->per_inf_num); > + } > + } > + else > + { > + this->global_num = ++highest_thread_num; > + this->per_inf_num = ++inf_->highest_thread_num; > + } > > /* Nothing to follow yet. */ > this->pending_follow.set_spurious (); > -- > 2.25.1 >