public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 8/9] Implement gdb.execute_mi
Date: Tue, 04 Apr 2023 22:08:40 +0300	[thread overview]
Message-ID: <83bkk3tqh3.fsf@gnu.org> (raw)
In-Reply-To: <20230404-dap-loaded-sources-v1-8-75c796bd644b@adacore.com> (message from Tom Tromey via Gdb-patches on Tue, 04 Apr 2023 11:08:56 -0600)

> Date: Tue, 04 Apr 2023 11:08:56 -0600
> From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
> 
> This adds a new Python function, gdb.execute_mi, that can be used to
> invoke an MI command but get the output as a Python object, rather
> than a string.  This is done by implementing a new ui_out subclass
> that builds a Python object.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11688
> ---
>  gdb/Makefile.in                         |   1 +
>  gdb/NEWS                                |   3 +
>  gdb/doc/python.texi                     |  29 ++++
>  gdb/mi/mi-cmds.h                        |   5 +
>  gdb/mi/mi-main.c                        |  15 ++
>  gdb/python/py-mi.c                      | 298 ++++++++++++++++++++++++++++++++
>  gdb/python/python-internal.h            |   3 +
>  gdb/python/python.c                     |   5 +
>  gdb/testsuite/gdb.python/py-exec-mi.exp |  32 ++++
>  gdb/testsuite/gdb.python/py-mi-cmd.py   |  18 ++
>  10 files changed, 409 insertions(+)

Thanks.

> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -152,6 +152,9 @@ info main
>       (program-counter) values, and can be used as the frame-id when
>       calling gdb.PendingFrame.create_unwind_info.
>  
> +  ** New function gdb.execute_mi(COMMAND, [ARG]...), that invokes a
> +     GDB/MI command and returns the output as a Python dictionary.

This part is OK.

> +Conversely, it is possible to execute @sc{GDB/MI} commands from
                                         ^^^^^^^^^^^
In print, @sc produces "small caps" only for lower-case letters, so
the above should use @sc{gdb/mi} (here and elsewhere).

> +Invoke a @sc{GDB/MI} command.  @var{command} is the name of the
> +command, a string.  (Note that the leading @samp{-} should be omitted
> +here.)

Why is it a good idea to omit the leading dash?

And what does it mean for command switches, which start with two
dashes?

> +This function returns a Python dictionary whose contents reflect the
> +corresponding @sc{GDB/MI} command's output.  Refer to the
> +documentation for these commands for details.  Lists are represented
> +as Python lists, and tuples are represented as Python dictionaries.

Is this description enough to understand what will be returned?  What
about error messages, for example -- how are those returned?

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

  reply	other threads:[~2023-04-04 19:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 17:08 [PATCH 0/9] Implement the DAP "loadedSources" request Tom Tromey
2023-04-04 17:08 ` [PATCH 1/9] Use field_signed from Python MI commands Tom Tromey
2023-04-04 17:08 ` [PATCH 2/9] Use member initializers in mi_parse Tom Tromey
2023-04-04 17:08 ` [PATCH 3/9] Use accessor for mi_parse::args Tom Tromey
2023-04-04 17:08 ` [PATCH 4/9] Change mi_parse_argv to a method Tom Tromey
2023-04-04 17:08 ` [PATCH 5/9] Introduce "static constructor" for mi_parse Tom Tromey
2023-04-04 17:08 ` [PATCH 6/9] Introduce mi_parse helper methods Tom Tromey
2023-04-04 17:08 ` [PATCH 7/9] Add second mi_parse constructor Tom Tromey
2023-04-04 17:08 ` [PATCH 8/9] Implement gdb.execute_mi Tom Tromey
2023-04-04 19:08   ` Eli Zaretskii [this message]
2023-05-18 17:57     ` Tom Tromey
2023-05-18 18:31       ` Eli Zaretskii
2023-05-18 20:15         ` Tom Tromey
2023-05-18 20:34           ` Matt Rice
2023-05-19 15:57             ` Tom Tromey
2023-04-04 17:08 ` [PATCH 9/9] Implement DAP loadedSources request Tom Tromey
2023-04-10 23:43 ` [PATCH 0/9] Implement the DAP "loadedSources" request Matt Rice

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=83bkk3tqh3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --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).