From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Simon Marchi <simon.marchi@ericsson.com>,
gdb-patches@sourceware.org,
Antoine Tremblay <antoine.tremblay@ericsson.com>
Subject: Re: [PATCH master+7.12 v2 3/3] Add test for user context selection sync
Date: Wed, 21 Sep 2016 16:43:00 -0000 [thread overview]
Message-ID: <3daec8aa-b88a-e0a1-fe63-4574ef09fbbe@redhat.com> (raw)
In-Reply-To: <3b2d8c6c3f8cfb4c008162e6f1bad226@simark.ca>
On 09/16/2016 03:01 AM, Simon Marchi wrote:
> On 2016-09-14 15:31, Pedro Alves wrote:
>> Hi Simon,
>>
>> I didn't try to understand everything in detail, but overall
>> it looks very nice now. Thank you very much. A few comments below.
>
> Oops, while trying to rerun the full testsuite, I noticed that it leaves
> "-ex \"set non-stop 1\"" in the GDBFLAGS... that's not good. You can
> see it easily if you swap the order of the "all-stop" and "non-stop"
> variations. Can you spot why the save_vars isn't working as intended?
> When I use a temporary variable instead, it works as intended...
Did you ever figure this out?
>> Did you try using barriers and breakpoints? Several tests use that
>> to make sure threads are past a point.
>
> I tried, but the issue is that depending on the scheduling, the threads
> might still be in the pthread_barrier_wait function when you stop.
>
> Consider this pseudo-code:
>
> thread_function:
> barrier_wait
> infinite_loop # This is where I want the threads to be stopped.
>
> main_thread ():
> initialize_barrier with n = 3
> spawn_thread (thread_function)
> spawn_thread (thread_function)
> barrier_wait
> breakpoint
>
> Once the main thread hits the breakpoint, we have the assurance that the
> threads have started, but we don't know where they are. They might not
> have exited the barrier_wait function, or they might be in the infinite
> loop. Adding a sleep before the breakpoint in the main thread is the
> only way to be reasonnably sure (assuming 1 second is enough...) that
> both threads will have reached the infinite loop.
>
> Actually, it might work by putting thread-specific breakpoints on the
> single-line infinite loop, then doing two "continue". This way I think
> we would be guaranteed that the two threads stop exactly at that line.
> With a regular breakpoint it might not work, since a thread could hit
> the breakpoint twice while the other still hasn't reached it.
What I've done in the past is something very much like your breakpoints
idea. Though, instead of a thread-specific breakpoint, I used a normal
breakpoint + "set scheduler-locking on" to control which thread got to
the breakpoint. See multiple-step-overs.exp, for example.
Using a thread-specific breakpoint maybe makes that a little simpler,
worth a try.
>> Hmm, looks like this version of the test still runs forever.
>
> I don't think so, the main thread sets the quit flag which unblocks the
> threads. If you run the executable you'll see it exits in ~2 seconds.
Ah, OK.
>> gdb_test_multiple ?
>
> Like this?
>
> set test "interrupt thread $inf.2"
>
> send_gdb "interrupt\n"
> gdb_test_multiple "" $test {
> -re "Thread.*2.*stopped" {
> pass $test
> }
> }
No need for the separate send_gdb call:
set test "interrupt thread $inf.2"
gdb_test_multiple "interrupt" $test {
-re "Thread.*2.*stopped" {
pass $test
}
}
>>> + with_spawn_id $gdb_main_spawn_id {
>>> + # TODO: it doesn't work as of now.
>>> + # match_re_or_ensure_not_output "$cli_re\r\n"
>>> "-thread-select, event on cli"
>>> + }
>>
>> Is there a plan here?
>
> I think that will go in the same basket as the fact that any MI command
> with --thread currently changes the selected thread silently (without
> any =thread-selected event). Currently, --thread changes the thread tot
> he desired one, then when the mi_cmd_thread_select tries to change the
> thread, it thinks that it was already the current thread, so that an
> event isn't necessary. This should get fixed in the next iteration,
> when we split the concepts of user-selected-ptid and
> internally-selected-ptid. Specifying --thread won't mess with the
> user-selected-ptid, but if you do "-thread-select --thread 2 2", then
> mi_cmd_thread_select will change the user-selected-ptid, generating an
> event.
>
> It's not pretty to leave it like this in the test though. Should I
> create a bug right now and kfail it? Leave it commented out but put a
> better description?
There's no right or wrong answer, but since you've already written the
bits, I'd be inclined to file bug and kfail.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-09-21 16:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-14 17:46 [PATCH master+7.12 v2 0/3] Emit user selection change notifications on all UIs Simon Marchi
2016-09-14 17:46 ` [PATCH master+7.12 v2 1/3] Introduce cleanup to restore current_uiout Simon Marchi
2016-09-14 17:56 ` Pedro Alves
2016-09-15 3:24 ` Simon Marchi
2016-09-16 18:18 ` Pedro Alves
[not found] ` <0c9914b2-f012-3b59-f127-04e70a7f867a@ericsson.com>
2016-10-03 21:25 ` Simon Marchi
2016-09-14 18:11 ` Tom Tromey
2016-09-14 18:18 ` Simon Marchi
2016-09-14 18:32 ` Pedro Alves
2016-09-14 19:12 ` Tom Tromey
2016-09-15 3:17 ` Simon Marchi
2016-09-14 17:46 ` [PATCH master+7.12 v2 3/3] Add test for user context selection sync Simon Marchi
2016-09-14 19:31 ` Pedro Alves
2016-09-16 2:02 ` Simon Marchi
2016-09-21 16:43 ` Pedro Alves [this message]
2016-09-21 21:38 ` Simon Marchi
2016-09-22 1:56 ` Simon Marchi
2016-09-14 17:46 ` [PATCH master+7.12 v2 2/3] Emit inferior, thread and frame selection events to all UIs Simon Marchi
2016-09-14 18:30 ` Pedro Alves
2016-09-15 16:21 ` Simon Marchi
2016-09-16 18:26 ` Pedro Alves
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=3daec8aa-b88a-e0a1-fe63-4574ef09fbbe@redhat.com \
--to=palves@redhat.com \
--cc=antoine.tremblay@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
--cc=simon.marchi@polymtl.ca \
/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