Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs 23.1.1 with gdb - forcing source windows

Tags:

emacs

gdb

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?

like image 335
Yung Avatar asked Aug 13 '10 00:08

Yung


1 Answers

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
    ))
like image 115
Tobias Avatar answered Sep 21 '22 15:09

Tobias