From: "Maciej W. Rozycki" <macro@wdc.com>
To: Simon Marchi <simark@simark.ca>
Cc: Pedro Alves <palves@redhat.com>,
gdb-patches@sourceware.org, Jim Wilson <jimw@sifive.com>
Subject: Re: [PATCH v2 2/4] Unregister the last inferior from the event loop
Date: Wed, 22 Jan 2020 17:35:00 -0000 [thread overview]
Message-ID: <alpine.LFD.2.21.2001211848240.15714@redsun52.ssa.fujisawa.hgst.com> (raw)
In-Reply-To: <323e416c-f0a9-ec14-c279-508c0245a479@simark.ca>
On Tue, 21 Jan 2020, Simon Marchi wrote:
> > I have therefore gone reading through the code again and what I can see
> > is that in the async mode the `ready' (readiness) flag is never cleared:
> > see `infrun_async' and `remote_target::async', which are the only places
> > to call `clear_async_event_handler' and then only when the async mode is
> > being disabled.
>
> The ready flag is also cleared in `check_async_event_handlers`, just before
> invoking the callback. So I was thinking, why would the callback get called
> repeatedly if the ready flag is cleared just before it gets called, and
> there's nothing setting it back to true. The answer is probably that the
> busy loop is within that callback, as seen below?
Indeed it was cleared in `check_async_event_handlers' and then set again
via `mark_infrun_async_event_handler' in `prepare_to_wait' called from
`handle_inferior_event'.
> > On the other hand waiting for an inferior event does get disabled in
> > `handle_inferior_event' regardless of the readiness flag, by calling
> > `stop_waiting', for certain events, but not for TARGET_WAITKIND_IGNORE.
> > Instead for that event `prepare_to_wait' is called, which makes sense to
> > me because such an event does not indicate whether waiting should or
> > should not be disabled, and with an asynchronous target you can normally
> > (i.e. if not indicated by a specific event received otherwise, e.g.
> > TARGET_WAITKIND_EXITED) expect a further event to be received anytime.
> >
> > Does this clarify the problematic scenario to you?
>
> Ok, so if I understand, the infinite loop is this one, inside
> wait_for_inferior?
>
> while (1)
> {
> ...
>
> /* Now figure out what to do with the result of the result. */
> handle_inferior_event (ecs);
>
> if (!ecs->wait_some_more)
> break;
> }
Nope, it was in `start_event_loop':
while (1)
{
...
result = gdb_do_one_event ();
...
if (result < 0)
break;
}
calling `check_async_event_handlers',
`infrun_async_inferior_event_handler', `inferior_event_handler' and
ultimately `fetch_inferior_event':
/* Now figure out what to do with the result of the result. */
handle_inferior_event (ecs);
if (!ecs->wait_some_more)
...
> After the remote target has been unpushed, the remaining target is probably
> just the "exec file" target, which does not provide a ::wait implementation,
> and therefore inherits default_target_wait:
>
> ptid_t
> default_target_wait (struct target_ops *ops,
> ptid_t ptid, struct target_waitstatus *status,
> int options)
> {
> status->kind = TARGET_WAITKIND_IGNORE;
> return minus_one_ptid;
> }
And it was `dummy_target::wait' indeed invoking `default_target_wait'.
> And because that returns TARGET_WAITKIND_IGNORE, which results in
> ecs->wait_some_more getting set by handle_inferior_event/prepare_to_wait,
> it results in the infinite loop in wait_for_inferior.
Right.
> Does that look accurate?
Almost, except that code in question has since been heavily refactored
and the call to `target_wait' does not happen anymore. Now I need to
bisect the tree, find the offending commit and figure out whether it has
actually provided an alternative fix for the issue I have observed or just
papered it over by chance somehow.
Thanks for your input, I wish it happened earlier, before the code has
been rearranged, sigh...
Maciej
next prev parent reply other threads:[~2020-01-22 17:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 20:51 [PATCH v2 0/4] GDB fixes for the remote end having gone astray Maciej W. Rozycki
2019-11-06 20:51 ` [PATCH v2 1/4] Remove stale breakpoint step-over information Maciej W. Rozycki
2020-01-21 5:41 ` Simon Marchi
2020-02-19 11:26 ` Luis Machado
2019-11-06 20:52 ` [PATCH v2 2/4] Unregister the last inferior from the event loop Maciej W. Rozycki
2020-01-21 5:47 ` Simon Marchi
2020-01-21 11:21 ` Maciej W. Rozycki
2020-01-21 17:34 ` Simon Marchi
2020-01-22 17:35 ` Maciej W. Rozycki [this message]
2020-01-23 1:19 ` Maciej W. Rozycki
2020-01-23 5:39 ` Maciej W. Rozycki
2020-01-23 16:59 ` Simon Marchi
2019-11-06 20:52 ` [PATCH v2 4/4] Unregister the inferior from the event loop if failed to resume Maciej W. Rozycki
2020-02-19 13:40 ` Luis Machado
2019-11-06 20:52 ` [PATCH v2 3/4] Remove breakpoint step-over information " Maciej W. Rozycki
2020-01-21 8:29 ` Simon Marchi
2020-02-19 13:30 ` Luis Machado
2019-11-18 12:38 ` [PING][PATCH v2 0/4] GDB fixes for the remote end having gone astray Maciej W. Rozycki
2019-11-26 15:49 ` [PING^2][PATCH " Maciej W. Rozycki
2019-12-02 14:50 ` [PING^3][PATCH " Maciej W. Rozycki
2019-12-05 20:59 ` Palmer Dabbelt via gdb-patches
2019-12-05 21:21 ` Maciej W. Rozycki
2019-12-09 21:29 ` [PING^4][PATCH " Maciej W. Rozycki
2019-12-17 0:06 ` [PING^5][PATCH " Maciej W. Rozycki
2020-01-06 15:40 ` [PING^6][PATCH " Maciej W. Rozycki
2020-01-13 20:46 ` [PING^7][PATCH " Maciej W. Rozycki
2020-01-21 4:21 ` [PING^8][PATCH " Maciej W. Rozycki
2020-02-10 9:01 ` [PING^10][PATCH " Maciej W. Rozycki
2020-02-17 14:07 ` [PATCH " Maciej W. Rozycki
2020-02-18 10:38 ` Luis Machado
2020-02-19 21:11 ` 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=alpine.LFD.2.21.2001211848240.15714@redsun52.ssa.fujisawa.hgst.com \
--to=macro@wdc.com \
--cc=gdb-patches@sourceware.org \
--cc=jimw@sifive.com \
--cc=palves@redhat.com \
--cc=simark@simark.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