From: Pedro Alves <palves@redhat.com>
To: "André Pönitz" <apoenitz@t-online.de>
Cc: Joel Brobecker <brobecker@adacore.com>,
Eli Zaretskii <eliz@gnu.org>,
gdb-patches@sourceware.org
Subject: Re: [RFA 2/2][master only] gdb/windows-nat.c: Get rid of main_thread_id global
Date: Tue, 23 Apr 2019 11:42:00 -0000 [thread overview]
Message-ID: <9e51c3bc-9875-6465-5332-f92f54f6aa03@redhat.com> (raw)
In-Reply-To: <20190422214607.GA2372@klara.mpi.htwm.de>
On 4/22/19 10:46 PM, André Pönitz wrote:
> On Mon, Apr 22, 2019 at 06:28:55PM +0100, Pedro Alves wrote:
>> On 4/22/19 4:23 PM, André Pönitz wrote:
>>> On Mon, Apr 22, 2019 at 03:24:46PM +0100, Pedro Alves wrote:
>>>> I don't see the asymmetry (silent at creation, not silent at destruction)
>>>> in this particular case as surprising [...]
>>>
>>> It's not surprising, but it's inconsistent
>>> and causes extra work in
>>> cases one wants to mechanically examine such output.
>>
>> I'm curious about what extra work you're thinking of.
>
> As far as I understand it, any (non-MI) user wanting to keep track of
> running threads would need to find out which events are "not surprising"
> (for which version of GDB...) and mentally (or in code) "generate"
> the "missing" events. That's a kind of "work".
gdb on GNU/Linux already works like I'm suggesting, and has been doing it
for a few years, and I don't think I recall ever hearing complaints about it:
Simple single-threaded "hello world" program:
(gdb) r
Starting program: /home/pedro/brno/pedro/gdb/tests/main
[Inferior 1 (process 13298) exited normally]
(gdb)
Multi-threaded program that exits normally (gdb.threads/schedlock.exp testcase):
(gdb) r
Starting program: build/gdb/testsuite/outputs/gdb.threads/schedlock/schedlock
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff74b8700 (LWP 13984)] <<< extra thread
[Thread 0x7ffff74b8700 (LWP 13984) exited] <<< extra thread exits
[Inferior 1 (process 13980) exited normally]
(gdb)
Threaded program that has the leader thread exit with pthread_exit while
another thread keeps running (gdb.threads/leader-exit.exp testcase):
(gdb) r
Starting program: build/gdb/testsuite/outputs/gdb.threads/leader-exit/leader-exit
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff74b8700 (LWP 13230)] <<<< extra thread
[Thread 0x7ffff7fb6740 (LWP 13226) exited] <<<< leader thread exits (notice LWP == process ID)
[Inferior 1 (process 13226) exited normally]
(gdb)
Note there's some time between the leader exiting, and the process exiting.
If the output were changed like I was suggesting, we'd have something like this,
which I think would be much clearer:
(gdb) r
Starting program: build/gdb/testsuite/outputs/gdb.threads/schedlock/schedlock
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 1.2 (0x7ffff74b8700 (LWP 13984))]
[Thread 1.2 (0x7ffff74b8700 (LWP 13984)) exited]
[Inferior 1 (process 13980) exited normally]
(gdb)
And:
(gdb) r
Starting program: build/gdb/testsuite/outputs/gdb.threads/leader-exit/leader-exit
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 1.2 (0x7ffff74b8700 (LWP 13230))]
[Thread 1.1 (0x7ffff7fb6740 (LWP 13226)) exited]
[Inferior 1 (process 13226) exited normally]
(gdb)
We're going on a tangent, but maybe even say "Thread ... appeared" instead
of "New Thread", for better visual alignment, like:
(gdb) r
Starting program: build/gdb/testsuite/outputs/gdb.threads/schedlock/schedlock
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Thread 1.2 (0x7ffff74b8700 (LWP 13984)) appeared]
[Thread 1.2 (0x7ffff74b8700 (LWP 13984)) exited]
[Inferior 1 (process 13980) exited normally]
(gdb)
>
>> Can't think of anything significant.
>
> It's not significant, but less surprising to me personally, i.e.
> violating the principle of least astonishment.
>
>> But do note that this discussion does not affect MI.
>
> I understand that, and for thread related notifications MI is sufficient
> for my frontend purposes, but in general MI does not cover all functionality
> of CLI and already this discrepancy is a surprise to some degree. I'd
> rather see the differences go away over time, not to increase.
>
>> So what do you propose? My proposal kept these two ideas in mind:
>>
>> - be quiet wrt to threads with single-threaded programs.
>
> TBH, I don't see the necessity of this requirement. That would be two
> lines of noise per run.
I think I had originally proposed that when I switched gdb's model
to "always a thread", but got pushed back. And I do think the pushback made
sense, particularly when you consider remote debugging targets that don't even
have a concept of threads.
I kind of convinced myself by considering bare metal targets, but also considering
further "execution unit" levels/layers -- say gdb adds native support for fibers, and
the model is that the initial thread has an initial fiber too -- i.e., there's always
a fiber, like there's always a thread. Would we want to automatically announce the
initial fiber as soon as the process starts, even if the process doesn't make
use of fibers?
(gdb) r
Starting program: ...
[New Thread 1.1 ...]
[New Fiber 1.1 ...]
.....
[Fiber 1.1 ... exited]
[Thread 1.1 exited]
[Inferior 1 (process 13226) exited normally]
(gdb)
Or, would we rather be quiet about fibers until something creates a second one,
similarly to how we are quiet about threads until a second thread is created?
And fibers would be one kind of unit of execution. There may be others.
What to do then?
>
>> - inform the user the main thread exited while other threads stay running.
>
> Also here, I don't see enough gain in one suppressed line of output
> to compensate for the inconsistency, this time even with a CLI user hat on.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2019-04-23 11:42 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
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 [this message]
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 1/2][master+8.3] (Windows) fix thr != nullptr assert failure in delete_thread_1 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-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=9e51c3bc-9875-6465-5332-f92f54f6aa03@redhat.com \
--to=palves@redhat.com \
--cc=apoenitz@t-online.de \
--cc=brobecker@adacore.com \
--cc=eliz@gnu.org \
--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