public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Johan Sternerup <johan.sternerup@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Handle DAP "stepOut" request in outermost frame
Date: Fri, 26 Apr 2024 20:32:13 +0200	[thread overview]
Message-ID: <CAKnZ_a0FJARgibGmF+ZWoHw0gY=L6gagUbRvmyowy_fta7=1Ow@mail.gmail.com> (raw)
In-Reply-To: <87frv9gvxk.fsf@tromey.com>

On Thu, Apr 25, 2024 at 8:05 PM Tom Tromey <tom@tromey.com> wrote:
>
> Tom> Maybe one way forward would be a new helper function to be run on the
> Tom> gdb thread, that incorporates the new check.
>
> Another way might be to revisit this idea, documented in a comment in
> next.py:
>
> # This is a server-side request because it is funny: it wants to
> # 'continue' but also return a result, which precludes using
> # response=False.  Using 'continue &' would mostly work ok, but this
> # yields races when a stop occurs before the response is sent back to
> # the client.
>
> That is, solve the stop event race by deferring such events, and then
> have all stepping commands add "&" for background execution.  Then they
> could all be ordinary requests (on the gdb thread with response), and
> any exceptions thrown early by the commands would affect the response.
>
> Tom

Thanks for your swift reply and comments.

I think your suggestion to use background execution makes a lot of sense.
I'm not sure I've understood the details though. For all the stepping commands
we would have a request with response=True and in_dap_thread=False, i.e. we
would pass our stepping command with a '&' to the gdb thread while
waiting for the
response in the dap thread. So then the dap thread would be blocked in
send_gdb_with_response().
Eventually the gdb thread would process the request and I guess
immediately return
any error or success. Only after the step request has been made can a
stop event be
triggered and since the gdb thread is busy handling the request the
_on_stop shouldn't be
allowed to run right? Then the stopped event will also always reach
the dap thread after
the dap thread received the response. Are there maybe several gdb
threads or are gdb
events/commands not processed in an event loop? Maybe the background command
is executed in a real asynchronous way so that I also need a two-step
procedure in the
gdb thread, one for the request and another one for the answer. Then I
could understand
the race.
As you can understand I'm not (yet) that familiar with the code base
so need some further
guidance to pull this off.

  reply	other threads:[~2024-04-26 18:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 17:20 Johan Sternerup
2024-04-25 17:52 ` Tom Tromey
2024-04-25 18:05   ` Tom Tromey
2024-04-26 18:32     ` Johan Sternerup [this message]
2024-04-26 20:28       ` Tom Tromey
2024-04-27  8:24         ` Johan Sternerup

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='CAKnZ_a0FJARgibGmF+ZWoHw0gY=L6gagUbRvmyowy_fta7=1Ow@mail.gmail.com' \
    --to=johan.sternerup@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).