From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=lancelotsix.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lancelotsix.com 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) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=lancelotsix.com; s=2021; t=1688029314; bh=qIwlxbAFVCoZaydmEp2cutrOh5/cvgrc78FHoMfmt3U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Uuks3g+RkIpbBwMaWUbYg9hue822voO/S60QWNTTRgXcU9Is8s0FGn/VHv9FqpR7W K0cZfseNtAGr6cwT938QAxpOmJSys09xiw+x6NzQmIEwMDKfJWBn4YGB+BRj8J/wGb BwYq+E2EMComiL76LY03/3pZ73yp5tLcjJ2QojNrccfZOnXtNlLlOYDrDVXROfA4Zx X8ucfpdwCqmfAmQweYqHttXbi6GBLDbScAny7dUNMZV1V+zEvRiXBdKJM9bsMuR+/r yL2JmCkbrbTyivdXmIX4HdiXsUvdZ+ZnGufvQ0aw67AS3LKSO+7yQ4jpyoTRO7gAH0 K3amd9RK1tl6g== Date: Thu, 29 Jun 2023 10:01:48 +0100 From: Lancelot SIX 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 List-Id: 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 >