From: Lancelot SIX <lsix@lancelotsix.com>
To: Simon Farre <simon.farre.cx@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/DAP: Add customRequest
Date: Wed, 10 May 2023 10:40:35 +0100 [thread overview]
Message-ID: <20230510094035.x7po26hd6c5dgsqt@octopus> (raw)
In-Reply-To: <20230507094144.894866-1-simon.farre.cx@gmail.com>
Hi Simon,
I have a couple of remarks below.
> +@request("customRequest")
> +def custom_request_handler(**args):
It looks like the args dict must contain the "command" and "args". I
would find it clearer if this was stated in the function definition like
so:
def custom_request_handler(*, command, args):
If args can contain more keys (which will be ignored by the
implementation), it could be:
def custom_request_handler(*, command, args, **kwargs):
> + global _custom_requests
> + cmd = args["command"]
> + if _custom_requests.get(cmd) is not None:
> + return _custom_requests[cmd](args["args"])
Just a nit, but the cmd lookup could be done just once:
cmd = _custom_requests.get(command)
if cmd is not None:
return cmd(args)
Also see Tom's comment regarding which thread you want this to execute
in. This part could become
return send_gdb_with_response(lambda: cmd(args))
> + else:
> + raise Exception(f"Unrecognized customRequest {cmd}")
I am not sure we guarantee python >= 3.6, so f-strings might not be
available. That being said, as python-3.6 istelf is not supported
anymore we could maybe just bump the required version.
Best,
Lancelot.
prev parent reply other threads:[~2023-05-10 9:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 9:41 Simon Farre
2023-05-07 10:45 ` Matt Rice
2023-05-07 21:19 ` Tom Tromey
2023-05-10 9:40 ` Lancelot SIX [this message]
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=20230510094035.x7po26hd6c5dgsqt@octopus \
--to=lsix@lancelotsix.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).