Subject: Re: bug#62697: gdb-mi.el: Change target-async to mi-async

From: Jim Porter <[email-masked]>
Date: Thu, 6 Apr 2023 18:26:48 -0700

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?

   (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.