unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gustaf Waldemarson <gustaf.waldemarson@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Jim Porter <jporterbugs@gmail.com>, 62697@debbugs.gnu.org
Subject: bug#62697: gdb-mi.el: Change target-async to mi-async
Date: Fri, 7 Apr 2023 12:36:31 +0200	[thread overview]
Message-ID: <CABehr5ebYh38RD2a5A6uR64QEYe9HsPbXrf65r7sssSo-z0a3A@mail.gmail.com> (raw)
In-Reply-To: <83bkk0ouhx.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5030 bytes --]

Filtering the message is probably easy, but as Jim pointed out, it will
probably
have unintended consequences later on. Besides, extracting the version could
enable a lot of different things down the line.

I had actually started on a "check-gdb-version-string", but was never able
to
get it to work. In fact, revisiting that code now makes we wonder if any of
these
"handlers" are actually working as intended.

From what I can see, the handlers scan the current buffer (which one is
that anyways?)
to determine whether to do some operations. However, adding some prints to
these handlers reveal that they seem to always be empty:

(defun gdb-non-stop-handler ()
  (goto-char (point-min))
  (print (buffer-substring-no-properties (point-min) (point-max)))
  (if (re-search-forward "No symbol" nil t)
      (progn
(message
         "This version of GDB doesn't support non-stop mode.  Turning it
off.")
(setq gdb-non-stop nil)
(setq gdb-supports-non-stop nil))
    (setq gdb-supports-non-stop t)
    (gdb-input "-gdb-set mi-async on" 'ignore)
    (gdb-input "-list-target-features" 'gdb-check-mi-async)))

(defun gdb-version-handler ()
  "Set the version of gdb currently being used."
  (message "Searching for GDB version...")
  (goto-char (point-min))
  (print (buffer-substring-no-properties (point-min) (point-max)))
  (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
    (goto-char (point-min))
    (print (buffer-substring-no-properties (point-min) (point-max)))
    (when (re-search-forward "GNU gdb (GDB) \\(.+\\)" nil t)
      (message
       "Attempting to retrieve GDB version: %s" (match-string 1))
      (setq gdb-version (match-string 1)))))

I also tried to change the buffer in the `gdb-version-handler`, but that
didn't
actually change anything. Am I making some wrong assumption here? To me
at least, it does not make sense that these are empty.

Best regards,
Gustaf

Den fre 7 apr. 2023 kl 12:29 skrev Eli Zaretskii <eliz@gnu.org>:

> > Date: Fri, 7 Apr 2023 00:25:03 -0700
> > Cc: 62697@debbugs.gnu.org, gustaf.waldemarson@gmail.com
> > From: Jim Porter <jporterbugs@gmail.com>
> >
> > On 4/6/2023 11:26 PM, Eli Zaretskii wrote:
> > >
> > >    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.
> >
> > Maybe I'm just misunderstanding something, but it looks like "-gdb-set
> > target-async 1" is already sent from a callback: specifically, the one
> > for "-gdb-set non-stop 1". Is this code already violating GDB's rules?
>
> I don't know.
>
> > Would adding another layer of callback make it any worse?
>
> I don't know.
>
> > Maybe so, but if we're worried about the latter, then couldn't we do
> > something like:
>
> I don't know!  It will take someone who knows a lot more than I do
> about both GDB/MI and gdb-mi.el to tell, and the changes need to be
> tested with many different versions of GDB.  Feel free to do that and
> see if those changes are benign, and then we can install them.
> Failing that, given that we don't have an active enough maintainer of
> gdb-mi.el on board, I feel that suppressing the annoying message is a
> much more easy way out.
>
> > Assuming handlers are called in the same order as their inputs are sent,
>
> They are called in the order in which responses for inputs are
> received, not in the order these inputs are sent.  I don't think these
> are the same orders, at least they aren't guaranteed to be.  You can
> see this by yourself if you enable the gdb-mi debug mode (each
> response is tagged with the number of the corresponding input command,
> and those numbers are given to commands by gdb-mi.el in the order it
> sends the commands).
>
> > My main worry with just suppressing the warning is that presumably at
> > some point in the future, GDB will remove the old form entirely, and
> > then gdb-mi.el breaks.
>
> I'm not even sure this will be removed at all.  It certainly won't be
> removed soon, as they just recently started issuing a warning.  For
> example, the annotations feature of GDB, use by "M-x gud-gdb", is
> still being supported, although it became deprecated as soon as GDB/MI
> was added to GDB.
>
> > If we could get this code to use the new form when available, then
> > there's no need to worry about having to publish a hotfix for
> > gdb-mi.el on short notice.
>
> I agree.  But if adding that means dealing with tricky
> timing-dependent and version-dependent bugs, I prefer to use a less
> radical solution, even if it's less clean and less future-proof.
>
> Btw, as an easy alternative, we could add a defcustom whose value
> would be the minimum supported value of GDB.  Then users could set it
> to, say, 7.8.0, to force gdb-mi.el to use mi-async, and by that avoid
> the annoyance.  This could even go into Emacs 29.
>

[-- Attachment #2: Type: text/html, Size: 6414 bytes --]

  reply	other threads:[~2023-04-07 10:36 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
2023-04-07  7:25       ` Jim Porter
2023-04-07 10:29         ` Eli Zaretskii
2023-04-07 10:36           ` Gustaf Waldemarson [this message]
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=CABehr5ebYh38RD2a5A6uR64QEYe9HsPbXrf65r7sssSo-z0a3A@mail.gmail.com \
    --to=gustaf.waldemarson@gmail.com \
    --cc=62697@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --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).