From: Simon Marchi <simon.marchi@polymtl.ca>
To: "Rohr, Stephan" <stephan.rohr@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdbserver/win32-low.cc: remove use of `all_threads`
Date: Mon, 2 Dec 2024 21:48:09 -0500 [thread overview]
Message-ID: <ca49893a-fbb0-4e27-a1ff-b1cbd0017abf@polymtl.ca> (raw)
In-Reply-To: <DS7PR11MB6247C64B7DA28BCB7091C8C993352@DS7PR11MB6247.namprd11.prod.outlook.com>
On 2024-12-02 15:48, Rohr, Stephan wrote:
> Hi Simon,
>
> thanks for fixing this. I missed to check the windows build when submitting the
> thread map patch for GDBserver. The fix itself looks ok, but I also cannot judge if
> GDBserver only supports a single process at a time. We could also use something
> like
>
> int num_threads = 0;
> for_each_process ([&num_threads] (process_info *process)
> {
> num_threads += process->thread_map ().size ();
> });
>
> if (num_threads == 0)
> return;
>
> to preserve the same behaviour as implemented now.
Even though it looks like preserving the same behaviour in surface, I
don't think it makes sense. Let's saywe did the work to make GDBserver
for Windows multi-process, what would this check become? My intuition
is that this would be changed to check the number of threads in the
process the thread being deleted belongs to, not the overall number of
threads. So adding that loop wouldn't go in the right direction. I
don't know the exact reason for this check to exist in the first place,
my guess is that we must always have at least one thread in the process
for things not to explode, and if this is indeed the last thread
existing, then an "exit process" event will likely follow.
However, the patch could probably be improved by not using
`current_process ()`. The caller of this function,
`get_child_debug_event ()`, would likely not have set the current
process to the right one. So it would perhaps be better to write the
function like this instead:
static void
child_delete_thread (DWORD pid, DWORD tid)
{
thread_info *thread = find_thread_ptid (ptid_t (pid, tid));
if (thread == NULL)
return;
/* If the last thread is exiting, just return. */
if (thread->process ()->thread_map ().size () == 1)
return;
delete_thread_info (thread);
}
Would that make sense?
Simon
next prev parent reply other threads:[~2024-12-03 2:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 19:47 Simon Marchi
2024-12-02 20:48 ` Rohr, Stephan
2024-12-03 2:48 ` Simon Marchi [this message]
2024-12-03 9:03 ` Rohr, Stephan
2024-12-03 15:54 ` Simon Marchi
2024-12-03 14:34 ` Hannes Domani
2024-12-03 15:58 ` Simon Marchi
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=ca49893a-fbb0-4e27-a1ff-b1cbd0017abf@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=stephan.rohr@intel.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