public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 8/9] Implement gdb.execute_mi
Date: Mon, 29 May 2023 11:54:17 -0400	[thread overview]
Message-ID: <3f4fa15a-29f0-f1bb-f824-fbe9d344c397@simark.ca> (raw)
In-Reply-To: <20230404-dap-loaded-sources-v2-8-93f229095e03@adacore.com>

On 5/18/23 16:18, Tom Tromey via Gdb-patches wrote:
> 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.

Hi Tom,

My patch here:

https://inbox.sourceware.org/gdb-patches/48eb5ee9-53e1-f1df-b424-d08342c7e857@simark.ca/T/#m94825956483bc1d340da33ad4712752d3326fecf

conflicts with this patch, so I am taking a closer look at
gdb.execute_mi.  I think some things are missing from the gdb.execute_mi
implementation, one way to expose some are to try:

  (gdb) python gdb.execute_mi('-gdb-exit')

First, I think that the new mi_execute_command function should install
the mi interpreter as the current interpreter (or the command
interpreter, I don't really understand the distinction) such as code
down mi_execute_command gets the mi_interp object when calling
current_interpreter.  There are not a lot of commands getting the
current interpreter, but -gdb-exit is one of them.  I tried fixing this
quickly, but it's not just a oneliner.  We need to ens

The other places that get the current interpreter are mostly in the
observers that output notifications.  So that got me wondering, what
should we do with any MI notification happening during the execution of
the MI command?  MI notifications are often suppressed during the
execution of MI commands, but I suspect that there might some legitimate
cases where notifications would go through.  I was wondering what to do
about them.  They are written directly to mi->raw_stdout, so they would
likely just appear on the terminal.  Should we just make them go to
/dev/null?  Should we accumulate them and return a list of notifications
as part of gdb.execute_mi's return value?  Should the caller of
gdb.execute_mi be able to provide a callback that gets called whenever
there is a notification?

The latter has the advantage that the Python code get notified
immediately when the notification is sent, rather than receiving them
all at once when the command's execution is complete.  For something
like -target-download, it might be interesting.  It also has the
advantage that it can be implemented later without breaking
gdb.execute_mi (just add an optional parameter).  Whereas the solution
of returning them as a list would require changing gdb.execute_mi now,
to avoid doing a breaking change later.

Simon

  parent reply	other threads:[~2023-05-29 15:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 20:18 [PATCH v2 0/9] Implement the DAP "loadedSources" request Tom Tromey
2023-05-18 20:18 ` [PATCH v2 1/9] Use field_signed from Python MI commands Tom Tromey
2023-05-18 20:18 ` [PATCH v2 2/9] Use member initializers in mi_parse Tom Tromey
2023-05-18 20:18 ` [PATCH v2 3/9] Use accessor for mi_parse::args Tom Tromey
2023-05-18 20:18 ` [PATCH v2 4/9] Change mi_parse_argv to a method Tom Tromey
2023-05-18 20:18 ` [PATCH v2 5/9] Introduce "static constructor" for mi_parse Tom Tromey
2023-08-11 11:02   ` Andrew Burgess
2023-08-11 13:10     ` Tom Tromey
2023-08-11 15:06       ` Andrew Burgess
2023-05-18 20:18 ` [PATCH v2 6/9] Introduce mi_parse helper methods Tom Tromey
2023-05-18 20:18 ` [PATCH v2 7/9] Add second mi_parse constructor Tom Tromey
2023-05-18 20:18 ` [PATCH v2 8/9] Implement gdb.execute_mi Tom Tromey
2023-05-19  5:37   ` Eli Zaretskii
2023-05-29 15:54   ` Simon Marchi [this message]
2023-06-02 19:19     ` Tom Tromey
2023-06-08 20:16     ` Tom Tromey
2023-05-18 20:18 ` [PATCH v2 9/9] Implement DAP loadedSources request Tom Tromey
2023-05-23 19:46 ` [PATCH v2 0/9] Implement the DAP "loadedSources" request 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=3f4fa15a-29f0-f1bb-f824-fbe9d344c397@simark.ca \
    --to=simark@simark.ca \
    --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).