From: Eli Zaretskii <eliz@gnu.org>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 62697@debbugs.gnu.org, gustaf.waldemarson@gmail.com
Subject: bug#62697: gdb-mi.el: Change target-async to mi-async
Date: Fri, 07 Apr 2023 09:26:06 +0300 [thread overview]
Message-ID: <83h6tsp5s1.fsf@gnu.org> (raw)
In-Reply-To: <79ec3700-02ab-7574-1411-dfef0ec5eb7f@gmail.com> (message from Jim Porter on Thu, 6 Apr 2023 18:26:48 -0700)
> Date: Thu, 6 Apr 2023 18:26:48 -0700
> Cc: 62697@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
>
> On 4/6/2023 6:32 AM, Eli Zaretskii wrote:
> > We could either (1) ask GDB about its version, or (2) filter out the
> > annoying message so it isn't shown to the users; we'd then have to
> > revisit this if/when GDB actually drops the command, if it ever does.
> >
> > Alternative (1) is AFAIR problematic because the initialization of a
> > GDB session under Emacs is entirely asynchronous, so sending a command
> > and waiting for its response before sending the rest is not easy. So
> > I tend to the second alternative.
>
> I don't know much about gdb-mi.el's internals, but taking a quick look
> at the code, 'gdb-input' takes a callback, so something like the
> following pseudocode would probably do the trick?
The problem is not with the callback, the problem is with _when_ the
callback is called. gdb-mi doesn't wait for each gdb-input call to
complete and its callback called before calling the next gdb-input.
In practice, we send a dozen gdb-input commands before the response
for the first one is received and its callback called. You can
clearly see that if you enable gdb-enable-debug and look at the log it
collects.
So sending a command via gdb-input, then conditioning another command
on it is not trivial, since the callback could be called much later.
> (gdb-input "-gdb-version"
> (lambda ()
> (if (gdb-should-use-mi-async) ; Check the version output.
> (gdb-input "-gdb-set mi-async on" #'ignore)
> (gdb-input "-gdb-set target-async on" #'ignore))
> (gdb-input "-list-target-features" #'gdb-check-target-async)))
>
> The existing 'gdb-check-target-async' already chains GDB-MI commands
> like this, so I imagine the above will Just Work.
It "will work", but what if the other commands sent via the other
gdb-input calls during initialization depend, or change the GDB
behavior depending, on whether mi-async was or wasn't already sent?
Or are you saying that mi-async can be sent anywhere during the
initialization sequence, including after it finishes? The GDB manual
says:
The frontend may specify a preference for asynchronous execution
using the '-gdb-set mi-async 1' command, which should be emitted
before either running the executable or attaching to the target.
If GDB is invoked with, e.g., "gdb -p PID", then we need to send this
command up front, before GDB attaches.
And there could be other issues with that proposal. Which is why I
said that alternative was "problematic". Filtering out the annoying
message is much safer, IMO.
next prev parent reply other threads:[~2023-04-07 6:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 12:48 bug#62697: gdb-mi.el: Change target-async to mi-async Gustaf Waldemarson
2023-04-06 13:32 ` Eli Zaretskii
2023-04-07 1:26 ` Jim Porter
2023-04-07 6:26 ` Eli Zaretskii [this message]
2023-04-07 7:25 ` Jim Porter
2023-04-07 10:29 ` Eli Zaretskii
2023-04-07 10:36 ` Gustaf Waldemarson
2023-04-07 10:53 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83h6tsp5s1.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=62697@debbugs.gnu.org \
--cc=gustaf.waldemarson@gmail.com \
--cc=jporterbugs@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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).