From: Magne Hov <mhov@undo.io>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: keep record of thread numbers for reverse execution targets
Date: Thu, 29 Jun 2023 10:38:09 +0100 [thread overview]
Message-ID: <5s5y764ni6.fsf@undo.io> (raw)
In-Reply-To: <20230629090022.cwk46lvhhnpharnf@octopus>
On Thu, Jun 29 2023, Lancelot SIX wrote:
Thanks for the comments, I'll address these along with any other comments that 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_, 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.
Ah yes, I forgot to remove this condition after some refactoring — thanks!
>
> 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
>>
--
Magne Hov | Software Engineer | Direct: +44 7395 395 648 | mhov@undo.io
Undo | Record. Replay. Resolve
next prev parent reply other threads:[~2023-06-29 9:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-29 8:36 [PATCH 0/2] Improve handling " Magne Hov
2023-06-29 8:36 ` [PATCH 1/2] gdb: keep record " Magne Hov
2023-06-29 9:01 ` Lancelot SIX
2023-06-29 9:38 ` Magne Hov [this message]
2023-06-29 8:36 ` [PATCH 2/2] gdb: retain thread-specific breakpoints in " Magne Hov
2023-07-07 16:24 ` [PATCH v2 0/2] Improve handling of thread numbers for " Magne Hov
2023-07-07 16:24 ` [PATCH v2 1/2] gdb: keep record " Magne Hov
2023-07-13 12:21 ` Bruno Larsen
2023-09-19 16:33 ` Tom Tromey
2023-09-20 16:42 ` Pedro Alves
2023-09-20 17:00 ` Magne Hov
2023-09-20 17:13 ` Pedro Alves
2023-07-07 16:24 ` [PATCH v2 2/2] gdb: retain thread-specific breakpoints in " Magne Hov
2023-07-13 12:22 ` Bruno Larsen
2023-08-18 14:27 ` [PING][PATCH v2 0/2] Improve handling of thread numbers for " Magne Hov
2023-09-18 11:38 ` Magne Hov
2023-09-19 16:34 ` [PATCH " Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5s5y764ni6.fsf@undo.io \
--to=mhov@undo.io \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).