我在Emacs 24中使用GDB,gdb-many-
windows设置为t,通常在自己的框架中.我喜欢有一个单独的编辑框架.它看起来像这样(为我粗略的ASCII图表道歉):
+-------------+-------------+ | gdb | locals | +-------------+-------------+ | source | I/O | | | | +-------------+-------------+ | stack | breakpoints | +-------------+-------------+
除了一个大问题外,这种方法效果很好.每当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)
>使用至少两个文件编译C程序.
例如:
// 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
>让bar.c显示在主框架中.使用M-x 5打开一个新帧2.在该帧中,使用M-x gdb启动gdb.如上图所示,该帧中应该有六个窗口.将gdb框架放在源框架的顶部.
>在main中设置断点并逐步调用foo和bar.当调用bar时,主框架将在gdb框架上方抬起,因为bar.c已在那里可见,但键盘焦点将保留在gdb框架中.
我认为问题函数是gud.el.gz中的gdb-display-source-buffer.我打算尝试用defadvice来覆盖它,但我并不熟悉建议.如果我搞清楚,我会在这里发一个答案.
我有24.3.我无法重现这个版本的问题.
gud-display-line看起来如下:
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))))))
窗口设置与您的完全不同.也许,上面的代码是有用的,或者你应该升级到新的gud / gdb东西.