6
votes

I'm using emacs 23.1.1 with gdb and gdb-many-windows.

My question is if it's possible to force gdb to always use the main source window for stepping through the code. What happens is that as I move through stack frames, if I happen to have the source file up in another emacs frames, emacs brings that frame to the foreground while leaving the gud frame in the background with keyboard focus.

What I'd like to do is to force emacs/gdb to use the primary source window for all tracing even if there is another frame with the same source file laying around somewhere.

Any ideas?

1
on debian with emacs 24.4.1, this still happens to me. FWIW, i found a bug report, but without (yet) any patch: lists.gnu.org/archive/html/bug-gnu-emacs/2014-06/msg00097.htmlpestophagous

1 Answers

3
votes

My emacs version is 24.3. So I am not really sure whether the following advice will solve your problem:

(defadvice gud-display-line (before one-source-window activate)
  "Always use the same window to show source code."
  (let ((buf (get-file-buffer true-file)))
    (when (and buf gdb-source-window)
      (set-window-buffer gdb-source-window buf))))

I found gud-display-line with the arg true-file in the old source there: http://www.mit.edu/~mkgray/stuff/ath/afs/oldfiles/project/silk/root/afs/athena.mit.edu/contrib/xemacs/OldFiles/share/xemacs-packages/lisp/debug/gdb.el

Furthermore, gdb-source-window can be found in a discussion about 23.1: https://groups.google.com/forum/#!topic/gnu.emacs.bug/KS6bhNeJ9rc

Therefore, it looks like the things I used should be available in 23.1.

To avoid splitting of the window you can try this one:

(defadvice gud-display-line (around one-source-window activate)
  "Always use the same window to show source code."
  (let ((buf (get-file-buffer true-file)))
    (when (and buf gdb-source-window)
      (set-window-buffer gdb-source-window buf)))
  (let (split-width-threshold split-width-threshold)
    ad-do-it
    ))