From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IXyIBxtRnWR1CBEAWB0awg (envelope-from ) for ; Thu, 29 Jun 2023 05:38:35 -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=uf/hoH+/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 10EF91E0BB; Thu, 29 Jun 2023 05:38:35 -0400 (EDT) Received: from sourceware.org (ip-8-43-85-97.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 EB6BC1E00F for ; Thu, 29 Jun 2023 05:38:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB5633858C41 for ; Thu, 29 Jun 2023 09:38:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB5633858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688031511; bh=JMr+O7C9VrNpkjM52mrcgjlnwBmepQe9sj/QbdshfSs=; h=To:Cc:Subject:In-Reply-To:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=uf/hoH+/3cKlerjLD1b1N0zw7ZNe8/SP3tuyilDVhLSz0rLFadcWPzvSJ2RJ7f7CK xB3QPegKfzWfbFMfLQ2kTJ48Pjbuu4nj1HWNxm0k9O5oU6PWZtncD7hiOi8hffnsPg /62R6vMB0TnLVXGu6Wohqiqr7fZU2R1Cin+tqvAE= Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id E2F373858D35 for ; Thu, 29 Jun 2023 09:38:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2F373858D35 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-313e742a787so356692f8f.1 for ; Thu, 29 Jun 2023 02:38:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688031490; x=1690623490; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JMr+O7C9VrNpkjM52mrcgjlnwBmepQe9sj/QbdshfSs=; b=MC7P2CexMNujuoelAuA5zwGccnqdH02cZMy+0QBz/Am22yiekD02mFBaFUIVD6B5OH W6Squ1BRPEUqrq7Y12gqD/MSo0BlGAKr3/yNJUKg23k1XMQANUcB3UazjXdmZ42n7zD/ PJKqI0EFzvOg2tiMmOngMW/OUV9xHAqfDMPDMqjYj8UFiNmeqFnHmNNAXrJ7EPhwxjlR Q1Fu9vSiByUfYmHaFcoyLa+Vb/2FogA9Y9JEr0IQsm21Ji18inLNO+iNOgIjbH1FmbO/ vFv+7E6kjzRAi+t1MhK5ClcrSpuSedCBgdSZ1ELz+YqeJ/15ELz8vYrTbV4f6XMV6R2b 7O/Q== X-Gm-Message-State: AC+VfDxNsHt8IRpgieuq4d0jWd5+EWFJJb1vWORsfhd5R6uf9h5GYx5X 5jJgyI8+3HqhmeN80Lngl7LReOAFjRStyDtD/VVhbtsY34eOmSBeIGIPTA5X7k+aVtLeCAy3d4i hOIZCmgTICGknJz3SyGLV/gwlk8AN1nFCyTYwhZPQZF03668Z5ZXeWjhWc0k6I/2EyIpUYkM= X-Google-Smtp-Source: ACHHUZ6NHvDcukkOm5Z30iLluhWKotd30qDU+uKp2rE8E69C3WigeT+kEC/H+9nCXiwL3tmgAmaXfA== X-Received: by 2002:adf:cf0d:0:b0:313:ed10:7f52 with SMTP id o13-20020adfcf0d000000b00313ed107f52mr4301227wrj.18.1688031490552; Thu, 29 Jun 2023 02:38:10 -0700 (PDT) Received: from sbrinz-thinkpad ([185.219.110.245]) by smtp.gmail.com with ESMTPSA id g6-20020a5d6986000000b003047dc162f7sm15427182wru.67.2023.06.29.02.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 02:38:10 -0700 (PDT) To: Lancelot SIX Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] gdb: keep record of thread numbers for reverse execution targets In-Reply-To: <20230629090022.cwk46lvhhnpharnf@octopus> References: <20230629083651.3145268-1-mhov@undo.io> <20230629083651.3145268-2-mhov@undo.io> <20230629090022.cwk46lvhhnpharnf@octopus> Date: Thu, 29 Jun 2023 10:38:09 +0100 Message-ID: <5s5y764ni6.fsf@undo.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Magne Hov via Gdb-patches Reply-To: Magne Hov Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Thu, Jun 29 2023, Lancelot SIX wrote: Thanks for the comments, I'll address these along with any other comments t= hat come in. > 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_, pt= id_t ptid_) >> { >> gdb_assert (inf_ !=3D NULL); >>=20=20 >> - this->global_num =3D ++highest_thread_num; >> - this->per_inf_num =3D ++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 =3D inf_->ptid_thread_num_map.find (ptid_); >> + if (pair !=3D inf_->ptid_thread_num_map.end ()) >> + { >> + this->global_num =3D pair->second.first; >> + this->per_inf_num =3D pair->second.second; >> + } >> + else { > > The '{' should be on the next line. > >> + this->global_num =3D ++highest_thread_num; >> + this->per_inf_num =3D ++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=E2=80=AFthink inserting to = the map > can be done unconditionally here. Ah yes, I forgot to remove this condition after some refactoring =E2=80=94 = thanks! > > Best, > Lancelot. > >> + inf_->ptid_thread_num_map[ptid_] =3D std::make_pair (this->global_nu= m, >> + this->per_inf_num); >> + } >> + } >> + else >> + { >> + this->global_num =3D ++highest_thread_num; >> + this->per_inf_num =3D ++inf_->highest_thread_num; >> + } >>=20=20 >> /* Nothing to follow yet. */ >> this->pending_follow.set_spurious (); >> --=20 >> 2.25.1 >>=20 --=20 Magne Hov | Software Engineer | Direct: +44 7395 395 648 | mhov@undo.io Undo | Record. Replay. Resolve