Jay*_*rod 8 emacs gdb elisp gud
我在Emacs 24中使用GDB gdb-many-windows设置为t,通常在自己的框架中.我喜欢有一个单独的编辑框架.它看起来像这样(为我粗略的ASCII图表道歉):
+-------------+-------------+
| gdb | locals |
+-------------+-------------+
| source | I/O |
| | |
+-------------+-------------+
| stack | breakpoints |
+-------------+-------------+
Run Code Online (Sandbox Code Playgroud)
除了一个大问题之外,这很有效.每当gdb需要显示不同的源缓冲区时,例如,在上/下/步之后,它并不总是在"源"窗口中显示它.例如,如果我在不同帧的窗口中打开相同的缓冲区,它将提升该帧,同时将键盘焦点保持在gdb帧中.当帧相互覆盖时,这在单显示器设置上非常烦人.
我希望gdb始终使用gdb-many-windows设置中的源窗口来显示源,无论是否在其他地方显示相同的源缓冲区.我怎样才能做到这一点?
编辑:更详细的重现说明.我正在使用Emacs 24.2.1和GDB 7.5-ubuntu.我在Ubuntu 10.04和Linux Mint Nadia与Cinnamon上看到过这个问题.
(setq gdb-many-windows t)例如:
// foo.c
void bar(int);
void foo(int c) {
if (c > 0)
bar(c - 1);
}
int main(void) {
foo(100);
return 0;
}
// bar.c
void foo(int c);
void bar(int c) {
if (c > 0)
foo(c - 2);
}
// compile with gcc -g -O0 foo.c bar.c -o test
Run Code Online (Sandbox Code Playgroud)
M-x 5 2.在该框架中,使用启动gdb M-x gdb.如上图所示,该帧中应该有六个窗口.将gdb框架放在源框架的顶部.main并逐步调用foo和bar.当bar被调用时,主框架将在GDB架升起,因为bar.c已经可见有,但键盘焦点将停留在gdb的框架.我认为问题功能gdb-display-source-buffer在gud.el.gz中.我打算尝试重写这个defadvice,但我并不熟悉建议.如果我搞清楚了,我会在这里发一个答案.
我的是24.3 而且我无法重现这个版本的问题。看起来gud-display-line如下:
(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))))
(pos))
(when buffer
(with-current-buffer buffer
(unless (or (verify-visited-file-modtime buffer) gud-keep-buffer)
(if (yes-or-no-p
(format "File %s changed on disk. Reread from disk? "
(buffer-name)))
(revert-buffer t t)
(setq gud-keep-buffer t)))
(save-restriction
(widen)
(goto-char (point-min))
(forward-line (1- line))
(setq pos (point))
(or gud-overlay-arrow-position
(setq gud-overlay-arrow-position (make-marker)))
(set-marker gud-overlay-arrow-position (point) (current-buffer))
;; If they turned on hl-line, move the hl-line highlight to
;; the arrow's line.
(when (featurep 'hl-line)
(cond
(global-hl-line-mode
(global-hl-line-highlight))
((and hl-line-mode hl-line-sticky-flag)
(hl-line-highlight)))))
(cond ((or (< pos (point-min)) (> pos (point-max)))
(widen)
(goto-char pos))))
(when window
(set-window-point window gud-overlay-arrow-position)
(if (eq gud-minor-mode 'gdbmi)
(setq gdb-source-window window))))))
Run Code Online (Sandbox Code Playgroud)
设置window和你的完全不同。也许,上面的代码很有帮助,或者也许您应该升级到新的 gud/gdb 东西。