From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=undo.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=undo.io Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-313e742a787so356692f8f.1 for ; Thu, 29 Jun 2023 02:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=undo.io; s=google2; t=1688031490; x=1690623490; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JMr+O7C9VrNpkjM52mrcgjlnwBmepQe9sj/QbdshfSs=; b=cDgKLndqDmR46yFlYNctggqxVzCbVP7DLbMgTFblQ/GKbdf9WEmVyGNTylqdNf7MA5 y1lIJc2K7h7oWrtl2mVlS0JgTF53mylzGF24CTnGrUT+lgybqt3n/JPPBKXBGdAd7RfZ FFsHRpkS9yx3Gq1DakyjNbagfarefjCoSc4rsI+Ew6Ivs+NNVODCw0kzaNchAX5s95x3 +MrOwgtzPzFhk4GIKWWQp97iEsDU6/FGMPzM4yJ/YyMTuqldT1U8WP4g/b/TW3XvV2RJ bncban/FiXh/Ql4jpom73T8ri4oEqWrDiqAyZLAWYyLy80kSXQwdkk1eclq81Ec2i3ii h9fQ== 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) From: Magne Hov 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 List-Id: 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