From: "Kévin Le Gouguec" <legouguec@adacore.com>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] Implement the notStopped DAP response
Date: Wed, 08 Nov 2023 09:23:51 +0100 [thread overview]
Message-ID: <878r78bqlk.fsf@adacore.com> (raw)
In-Reply-To: <20231107-dap-not-stopped-v1-3-3d91c935255d@adacore.com> (Tom Tromey's message of "Tue, 07 Nov 2023 11:29:31 -0700")
Tom Tromey <tromey@adacore.com> writes:
> @@ -21,8 +21,17 @@ from .startup import exec_and_log, in_gdb_thread, log
> from .modules import is_module, make_module
>
>
> +# True when the inferior is thought to be running, False otherwise.
> +# This may be accessed from any thread, which can be racy. However,
> +# this unimportant because this global is only used for the
> +# 'notStopped' response, which itself is inherently racy.
> +inferior_running = False
> +
> +
Out of curiosity, could `inferior_thread ()->state` have helped here?
(Exposing it as a gdb.Inferior method perhaps?)
Not necessarily with the "racy" part; thinking more of the "keep a
single source of truth" part (i.e. dispense with relying on event
notifications).
> +# A helper decorator that checks whether the inferior is running.
> +def _check_not_running(func):
> + @functools.wraps(func)
> + def check(*args, **kwargs):
> + # Import this as late as possible. FIXME.
> + from .events import inferior_running
> +
> + if inferior_running:
> + raise Exception("notStopped")
> + return func(*args, **kwargs)
> +
> + return check
Assuming this is what the FIXME is about (apologies if not): an
alternative could be doing a bare `import .events`, then lookup
`.events.inferior_running` in check(). Or defining an accessor function
in .events and importing that instead of this global.
> @@ -178,6 +199,11 @@ def request(name: str, *, response: bool = True, server: bool = False):
>
> If SERVER is True, the function will be invoked in the DAP thread.
> When SERVER is True, RESPONSE may not be False.
> +
> + If MUST_BE_STOPPED is True (the default), then the request will
> + fail with the 'notStopped' reason if it is processed while the
> + inferior is running. When MUST_BE_STOPPED is False, the request
> + will proceed regardless of the inferior's state.
> """
>
> # Validate the parameters.
(Feeling like EXPECT_STOPPED might better convey that parameter's role
as a precondition, rather than as a "call to action" for request(); tiny
nit though, the doc clarifies the intent anyway)
next prev parent reply other threads:[~2023-11-08 8:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 18:29 [PATCH 0/3] Implement the DAP notStopped response Tom Tromey
2023-11-07 18:29 ` [PATCH 1/3] Automatically run (most) DAP requests in gdb thread Tom Tromey
2023-11-13 12:59 ` Alexandra Petlanova Hajkova
2023-11-07 18:29 ` [PATCH 2/3] Remove ExecutionInvoker Tom Tromey
2023-11-13 13:57 ` Alexandra Petlanova Hajkova
2023-11-07 18:29 ` [PATCH 3/3] Implement the notStopped DAP response Tom Tromey
2023-11-08 8:23 ` Kévin Le Gouguec [this message]
2023-11-10 14:52 ` Tom Tromey
2023-11-10 15:14 ` Kévin Le Gouguec
2023-11-10 15:18 ` Tom Tromey
2023-11-10 15:08 ` 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=878r78bqlk.fsf@adacore.com \
--to=legouguec@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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).