Subject: bug#30044: Emacs: Gud-mode: Debugging with gud: Window switching problem

From: Noam Postavsky <[email-masked]>
Date: Thu, 11 Jan 2018 20:24:42 -0500

Claus Fischer <[email-masked]> writes:

> Is it possible to take a gud.el, sprinkle it liberally with some debug
> output, e.g. into Emacs' message buffer or on the terminal, and let me
> load it and wait for the problem to re-occur?

> Does Emacs have some debugging or recording mode for such situations?

This should do it, hopefully it catches all the relevant info.  It will
be printed into a buffer named *trace-output*.

(dolist (fun '(gud-filter gud-display-frame gud-display-line display-buffer))
  (trace-function-background fun))

(defun bug-30044-trace-window-list (&rest _)
  (when (> trace-level 0)
    (trace-values (window-list)
                  (mapcar #'window-prev-buffers (window-list))
                  (mapcar #'window-next-buffers (window-list)))))
(advice-add 'gud-filter :before #'bug-30044-trace-window-list)

(defun bug-30044-trace-current-window (&rest _)
  (when (> trace-level 0)
    (trace-values (selected-window))))
(advice-add 'gud-display-line :before #'bug-30044-trace-current-window)