From: Tom Tromey <tom@tromey.com>
To: Simon Farre via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: Re: [PATCH] gdb/DAP: Add customRequest
Date: Sun, 07 May 2023 15:19:26 -0600 [thread overview]
Message-ID: <871qjr6dr5.fsf@tromey.com> (raw)
In-Reply-To: <20230507094144.894866-1-simon.farre.cx@gmail.com> (Simon Farre via Gdb-patches's message of "Sun, 7 May 2023 11:41:44 +0200")
>>>>> "Simon" == Simon Farre via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> This patch introduces the customRequest, which allows for DA's (debug adapters)
Simon> that want to use the full extent of GDB's functionality by working a bit
Simon> like the extension of `gdb.Command`
Seems reasonable to me.
Simon> Unfortunately, there's nothing about such a request in the
Simon> DAP-spec, but I'd argue that's really irrelevant; the largest
Simon> code editor for debug adapter protocol implementers, has a notion
Simon> of it, though it's up to DA-implementers to make sure they
Simon> understand their own requests.
Makes sense.
Simon> Beyond this patch, documentation would be needed also, to document how
Simon> to create customRequests, like the one above. I'm hoping Eli can provide me with
Simon> some direction here.
There's a DAP node in the docs where I think it would make sense to
document the existence of the custom request. For implementing requests
themselves, I think a new node in python.texi would be appropriate.
>> @server.custom_request("foo")
>> def fooRequestHandler(argumentBaz):
>> # full Python interpreter access, full access to all of GDB, like we're @ the CLI
>> # say goodbye to MI! Yay! :P
>> return { "bar": gdb.execute("print foo", to_string=True), "someParam": argumentBaz }
Simon> +@request("customRequest")
Simon> +def custom_request_handler(**args):
Simon> + global _custom_requests
Simon> + cmd = args["command"]
Simon> + if _custom_requests.get(cmd) is not None:
Simon> + return _custom_requests[cmd](args["args"])
An issue here is that the DAP thread can't directly invoke code in gdb
-- basically the 'gdb' module is off-limits. This is why there are
decorators to assert that a given function is on the DAP thread or gdb
thread. This rule is in place because the core of gdb isn't
thread-safe.
Probably the fix is as simple as wrapping the call with
send_gdb_with_response, and having the custom_request decorator
use in_gdb_thread.
Tom
next prev parent reply other threads:[~2023-05-07 21:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 9:41 Simon Farre via Gdb-patches
2023-05-07 10:45 ` Matt Rice via Gdb-patches
2023-05-07 21:19 ` Tom Tromey [this message]
2023-05-10 9:40 ` Lancelot SIX via Gdb-patches
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=871qjr6dr5.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.farre.cx@gmail.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