From: Eli Zaretskii <eliz@gnu.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA 2/2][master only] gdb/windows-nat.c: Get rid of main_thread_id global
Date: Wed, 17 Apr 2019 18:29:00 -0000 [thread overview]
Message-ID: <83wojseb9c.fsf@gnu.org> (raw)
In-Reply-To: <20190417173842.GA14817@adacore.com> (message from Joel Brobecker on Wed, 17 Apr 2019 10:38:42 -0700)
> Date: Wed, 17 Apr 2019 10:38:42 -0700
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: gdb-patches@sourceware.org
>
> It happens completely randomly, and in all cases, the program itself
> has a main program which waits for all software threads to complete
> before itself terminating. Not sure what Windows is doing under
> the hood.
At program termination time, all kinds of irregularities could happen,
especially if the program doesn't exit by exiting 'main' -- because
AFAIK doing the latter causes CRT to explicitly shut down all the
other threads.
But there's little doubt in my mind that the thread whose ID is
reported by CREATE_PROCESS_DEBUG_EVENT is the main thread.
> If I understand you correctly, you want to preserve the global
> so we can avoid those notifications. In my opinion, doing that
> just for the purpose of filtering one notification is simply
> not worth the trouble of keeping a global around. Generally speaking,
> we tend to try to avoid globals as much as we can, as they are hard to
> track, and makes the code harder to understand and maintain.
> Modifying the logic to use the main_thread_id global instead of
> the kind of event is a step backwards, in my opinion.
If the only problem is having the global variable, we could mark the
main thread in some other way, that won't need the global.
But yes, I think not announcing the main thread is a nice feature, and
losing it due to the mess that happens at program exit (something to
which most users won't pay attention anyway) would be a pity. I'd
even agree to announcing the exit of the main thread, if we cannot
come up with a better solution, if that could allow us avoid its
announcement at program startup.
The use case I have in mind is debugging a single-threaded program.
It is jarring enough, when debugging such a program, to see GDB
announcing threads started by the OS. It would be nice if we could
avoid announcing the main thread.
Thanks.
next prev parent reply other threads:[~2019-04-17 18:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 22:33 Windows native GDB event handling enhancement Joel Brobecker
2019-04-16 22:33 ` [RFA 2/2][master only] gdb/windows-nat.c: Get rid of main_thread_id global Joel Brobecker
[not found] ` <83imvcg0ud.fsf@gnu.org>
2019-04-17 17:38 ` Joel Brobecker
2019-04-17 18:29 ` Eli Zaretskii [this message]
2019-04-17 22:17 ` Joel Brobecker
2019-04-18 12:52 ` Eli Zaretskii
2019-04-18 14:54 ` Joel Brobecker
2019-04-18 16:27 ` Pedro Alves
2019-04-19 20:43 ` Joel Brobecker
2019-04-22 14:24 ` Pedro Alves
2019-04-22 15:20 ` André Pönitz
2019-04-22 17:29 ` Pedro Alves
2019-04-22 21:42 ` André Pönitz
2019-04-23 5:54 ` Eli Zaretskii
2019-04-24 20:10 ` André Pönitz
2019-04-25 5:39 ` Eli Zaretskii
2019-04-23 11:42 ` Pedro Alves
2019-04-16 22:33 ` [RFA 1/2][master+8.3] (Windows) fix thr != nullptr assert failure in delete_thread_1 Joel Brobecker
2019-04-18 14:52 ` Pedro Alves
2019-04-18 15:04 ` Pedro Alves
2019-04-28 16:58 ` [v2] Windows native GDB event handling enhancement Joel Brobecker
2019-04-28 16:58 ` [RFA v2 2/2][master only] gdb/windows-nat.c: Get rid of main_thread_id global Joel Brobecker
2019-04-28 16:58 ` [RFA v2 1/2][master+8.3] (Windows) fix thr != nullptr assert failure in delete_thread_1 Joel Brobecker
2019-04-30 13:00 ` [v2] Windows native GDB event handling enhancement Pedro Alves
2019-04-30 21:04 ` pushed(master+8.3): " Joel Brobecker
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=83wojseb9c.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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