From: Jan Vrany <jan.vrany@labware.com>
To: Tom Tromey <tom@tromey.com>,
Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org>
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: Re: [PATCHv4] gdb/python/mi: create MI commands using python
Date: Fri, 25 Feb 2022 19:31:54 +0000 [thread overview]
Message-ID: <cfd8ed22b347f8d676b4c7e180ceb426a5b71054.camel@labware.com> (raw)
In-Reply-To: <87r17qn43c.fsf@tromey.com>
On Fri, 2022-02-25 at 12:22 -0700, Tom Tromey wrote:
> > > > > > "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> This v4 patch is identical to the version I posted here:
> Andrew>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_pipermail_gdb-2Dpatches_2022-2DFebruary_185821.html&d=DwIBAg&c=sPZ6DeHLiehUHQWKIrsNwWp3t7snrE-az24ztT0w7Jc&r=WpFFGgYa98Yp-c29WHTCwU1wAGFBvszA6a4RzgpMSqc&m=WKDSYr2J171tvbvDjhBen4GJ7U_Ub6ZV_q_Nyl7TQb8&s=Yz53CWD-zdMB2I_L-G0Xai7hGsPlRXGOkvDDoaMoy3c&e=
>
> Andrew> except I've rebased onto current master. I just wanted to make sure
> Andrew> it was clear what the latest version of this patch was.
>
> Thank you both for working on this.
>
> Andrew> When used within gdb the above command produced output like this:
> Andrew> (gdb)
> Andrew> -echo-args a b c
> Andrew> ^done,args=["a","b","c"]
> Andrew> (gdb)
>
> Not necessary for this patch but I wonder if there should also be a way
> to emit an async event from Python.
This is on my list already but I decided leave this for later patch.
I have not even started working on this as to not having too many balls
in the air.
>
> Andrew> I have required that the fields names used in mi result output must
> Andrew> follow C identifier restrictions (i.e. must match the regexp
> Andrew> "[a-zA-Z][a-zA-Z0-9_]*").
>
> I think '-' is also supported, e.g.:
>
> uiout->field_string ("thread-id", print_thread_id (thr));
>
> Andrew> +@defun MICommand.invoke (arguments)
> Andrew> +This method is called by @value{GDBN} when the new MI command is
> Andrew> +invoked.
> Andrew> +
> Andrew> +@var{arguments} is a list of strings. Note, that @code{--thread}
> Andrew> +and @code{--frame} arguments are handled by @value{GDBN} itself therefore
> Andrew> +they do not show up in @code{arguments}.
>
> I guess this is done because an option may or may not take a value?
> That kind of too bad since it would be nice if this could just be a
> dictionary.
>
> I suppose we could always also add an MI parsing helper, though Python
> also has tons of things for this as well.
>
> Andrew> +The strings used for @emph{VARIABLE} names in the @sc{GDB/MI} output
> Andrew> +must follow the following rules; the string must be at least one
> Andrew> +character long, the first character must be in the set
> Andrew> +@code{[a-zA-Z]}, while every subsequent character must be in the set
> Andrew> +@code{[a-zA-Z0-9_]}.
>
> This should be updated to include '-'.
>
> Andrew> +@smallexample
> Andrew> +class MIEcho(gdb.MICommand):
> Andrew> + """Echo arguments passed to the command."""
> Andrew> +
> Andrew> + def __init__(self, name, mode, toplevel = None):
> Andrew> + self._mode = mode
> Andrew> + super(MIEcho, self).__init__(name, toplevel)
>
> What is 'toplevel' here? It isn't documented for gdb.MICommand.
>
> Andrew> + /* Called when the MI command is invoked. */
> Andrew> + virtual void do_invoke(struct mi_parse *parse) const override;
>
> Andrew> + if (key_repr != nullptr)
> Andrew> + key_repr_string = python_string_to_target_string (key_repr.get ());
> Andrew> + if (key_repr_string == nullptr)
> Andrew> + gdbpy_handle_exception ();
> Andrew> +
> Andrew> + gdbpy_error (_("non-string object used as key: %s"),
> Andrew> + key_repr_string.get ());
>
> Someday I'd like gdb to solve the "denaturation" problem, where if
> Python code throw some exception, it's turned into a generic exception
> of some kind by gdb ... which if it is then caught again by Python, has
> transmuted into something else.
>
> Anyway this seems fine, just felt like I had to get that out.
>
> Andrew> + for (; *name != '\0'; ++name)
> Andrew> + if (!isalnum (*name) && *name != '_')
> Andrew> + return false;
>
> '-'
>
> Andrew> + else if (PyIter_Check (result))
> Andrew> + {
> Andrew> + gdbpy_ref<> item;
> Andrew> + ui_out_emit_list list_emitter (uiout, field_name);
> Andrew> + while (true)
> Andrew> + {
>
> Not for this patch but I wonder if emitting dictionaries via ui_out
> might make for nicer CLI commands sometimes.
>
> Andrew> + gdbpy_enter enter_py (get_current_arch (), current_language);
>
> Probably should just drop the parameters here.
>
> thanks,
> Tom
next prev parent reply other threads:[~2022-02-25 19:32 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 12:44 [PATCH 0/5] create GDB/MI " Jan Vrany
2022-01-17 12:44 ` [PATCH 1/5] gdb/mi: introduce new class mi_command_builtin Jan Vrany
2022-01-17 12:44 ` [PATCH 2/5] gdb/python: create GDB/MI commands using python Jan Vrany
2022-02-06 16:52 ` Lancelot SIX
2022-01-17 12:44 ` [PATCH 3/5] gdb/python: allow redefinition of python GDB/MI commands Jan Vrany
2022-02-06 17:13 ` Lancelot SIX
2022-02-06 20:33 ` Simon Marchi
2022-02-06 20:44 ` Jan Vrany
2022-02-06 20:46 ` Simon Marchi
2022-02-07 9:46 ` Lancelot SIX
2022-01-17 12:44 ` [PATCH 4/5] gdb/testsuite: add tests for python-defined MI commands Jan Vrany
2022-01-17 12:44 ` [PATCH 5/5] gdb/python: document GDB/MI commands in Python Jan Vrany
2022-01-17 13:15 ` Eli Zaretskii
2022-01-17 13:20 ` Eli Zaretskii
2022-01-18 12:34 ` Jan Vrany
2022-01-18 15:09 ` Eli Zaretskii
2022-01-18 13:55 ` [PATCH 0/5] create GDB/MI commands using python Andrew Burgess
2022-01-18 15:13 ` Jan Vrany
2022-01-21 15:22 ` Andrew Burgess
2022-01-24 12:59 ` Jan Vrany
2022-02-02 16:57 ` Andrew Burgess
2022-02-06 21:16 ` Simon Marchi
2022-02-07 15:56 ` [PATCHv2] gdb/python/mi: create MI " Andrew Burgess
2022-02-08 15:16 ` Simon Marchi
2022-02-09 12:25 ` [PATCHv3] " Andrew Burgess
2022-02-09 14:08 ` Simon Marchi
2022-02-10 18:26 ` Andrew Burgess
2022-02-13 14:27 ` Joel Brobecker
2022-02-13 21:46 ` Jan Vrany
2022-02-24 10:37 ` [PATCHv4] " Andrew Burgess
2022-02-25 19:22 ` Tom Tromey
2022-02-25 19:31 ` Jan Vrany [this message]
2022-02-28 16:48 ` [PATCHv5] " Andrew Burgess
2022-02-28 18:40 ` Tom Tromey
2022-03-13 4:47 ` Joel Brobecker
2022-03-14 14:13 ` Andrew Burgess
2022-03-16 8:10 ` Joel Brobecker
2022-03-16 12:29 ` Simon Marchi
2022-03-18 15:06 ` Simon Marchi
2022-03-18 16:12 ` Andrew Burgess
2022-03-18 19:57 ` Simon Marchi
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=cfd8ed22b347f8d676b4c7e180ceb426a5b71054.camel@labware.com \
--to=jan.vrany@labware.com \
--cc=aburgess@redhat.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).