all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Claus Fischer <claus.fischer@clausfischer.com>
Cc: 30044@debbugs.gnu.org
Subject: bug#30044: Emacs: Gud-mode: Debugging with gud: Window switching problem
Date: Wed, 10 Jan 2018 20:58:51 -0500	[thread overview]
Message-ID: <87fu7dp350.fsf@users.sourceforge.net> (raw)
In-Reply-To: <20180110111945.fugo7cknqysarnny@clausfischer.com> (Claus Fischer's message of "Wed, 10 Jan 2018 12:19:45 +0100")

Claus Fischer <claus.fischer@clausfischer.com> writes:

> If that is so, the solution for me would be simple: let gud not
> remember the window, but let it search for the window with buffer
> name *gud...* and switch to that one. I have only one such buffer.

That is basically what we have already, relevant code excerpts below.
When gdb prints that a breakpoint is hit, Emacs runs the process filter
which gud-mode sets up, `gud-filter'.  It uses `get-buffer-window' to
find the corresponding window and switches to it while calling
`gud-display-frame'.  And then `gud-display-line' shows the source
buffer in any window but the current one (i.e., the one showing the gdb
interaction).

So to fix this, we would need to follow along this code path and see
where things go wrong.  This will be pretty much impossible without a
reliable way of triggering the problem, as suggested in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520647#10

    (defun gud-filter (proc string)
      ...
                (with-current-buffer (process-buffer proc)
                    (setq process-window
                          (and gud-last-frame
                               (>= (point) (process-mark proc))
                               (get-buffer-window (current-buffer)))))
      ...
                ;; Put the arrow on the source line.
                ;; This must be outside of the save-excursion
                ;; in case the source file is our current buffer.
                (if process-window
                    (with-selected-window process-window
                      (gud-display-frame))

    (defun gud-display-frame ()
      ...
        (gud-display-line (car gud-last-frame) (cdr gud-last-frame))

    ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
    ;; and that its line LINE is visible.
    ;; Put the overlay-arrow on the line LINE in that buffer.
    ;; Most of the trickiness in here comes from wanting to preserve the current
    ;; region-restriction if that's possible.  We use an explicit display-buffer
    ;; to get around the fact that this is called inside a save-excursion.

    (defun gud-display-line (true-file line)
      (let* ((last-nonmenu-event t)  ; Prevent use of dialog box for questions.
             (buffer
              (with-current-buffer gud-comint-buffer
                (gud-find-file true-file)))
             (window (and buffer
                          (or (get-buffer-window buffer)
                              (display-buffer buffer '(nil (inhibit-same-window . t))))))
      ...






  reply	other threads:[~2018-01-11  1:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 12:33 bug#30044: Emacs: Gud-mode: Debugging with gud: Window switching problem Claus Fischer
2018-01-09 18:44 ` Eli Zaretskii
2018-01-09 20:58   ` Claus Fischer
2018-01-10  3:28     ` Eli Zaretskii
2018-01-10  3:39 ` Noam Postavsky
2018-01-10 11:19   ` Claus Fischer
2018-01-11  1:58     ` Noam Postavsky [this message]
2018-01-11 13:24       ` Claus Fischer
2018-01-12  1:24         ` Noam Postavsky
2018-05-20 23:52 ` Noam Postavsky

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=87fu7dp350.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=30044@debbugs.gnu.org \
    --cc=claus.fischer@clausfischer.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.