我已經在emacs中定製了gdb窗口。在調試過程中,新的源代碼在不同的窗口中打開。我只想在一個窗口中看到源代碼。我GDB定製是:[emacs] [gdb自定義]如何在一個窗口中顯示源緩衝區?
; _____________________________________________________________________________________
; | | |
; | BREAKPOINTS | |
; |__________________________________________| |
; | | |
; | STACK | |
; |__________________________________________| |
; | | |
; | | |
; | LOCALS | |
; | | SOURCE CODE |
; |__________________________________________| |
; | | |
; | | |
; | | |
; | | |
; | | |
; | | |
; | GDB | |
; | |__________________________________________|
; | | |
; | | |
; | | I/O |
; | | |
; |__________________________________________|__________________________________________|
(require 'gud)
; invoke
(global-set-key [f8] 'gdb)
; GDB layout
(defadvice gdb-setup-windows (after activate)
(gdb-setup-my-windows)
)
(defun gdb-setup-my-windows()
(set-window-dedicated-p (selected-window) nil)
(switch-to-buffer gud-comint-buffer)
(delete-other-windows)
(let
((win0 (selected-window)) ; breakpoints
(win1 (split-window-horizontally
(floor (* 0.5 (window-width))))) ; source + i/o
(win2 (split-window-vertically
(floor (* 0.5 (window-body-height))))) ; gdb
(win3 (split-window-vertically
(floor (* 0.5 (window-body-height))))) ; locals
(win4 (split-window-vertically
(floor (* 0.6 (window-body-height))))) ; stack
)
(select-window win1)
; configurating right window
(let
((winSrc (selected-window)) ; source
(winIO (split-window-vertically (floor (* 0.9 (window-body-height))))) ; I/O
)
(set-window-buffer winIO (gdb-get-buffer-create 'gdb-inferior-io))
(set-window-buffer
winSrc
(if gud-last-last-frame
(gud-find-file (car gud-last-last-frame))
(if gdb-main-file
(gud-find-file gdb-main-file)
(list-buffers-noselect))))
(setq gdb-source-window winSrc)
(set-window-dedicated-p winIO t)
)
(set-window-buffer win0 (gdb-get-buffer-create 'gdb-breakpoints-buffer))
(set-window-buffer win3 (gdb-get-buffer-create 'gdb-locals-buffer))
(set-window-buffer win4 (gdb-get-buffer-create 'gdb-stack-buffer))
(select-window win2)
)
)
; GDB variables
(setq gdb-many-windows t)
(setq gdb-show-main t)
(setq gdb-show-changed-values t)
(setq gdb-use-colon-colon-notation t)
(setq gdb-use-separate-io-buffer nil)
(setq gdb-delete-out-of-scope t)
(setq gdb-speedbar-auto-raise t)
主屏幕是: gdb screen after start
但是,當我開始調試,然後下一個源文件在另一個窗口打開。見例如波紋管: New source code in gdb window
應用再現的例子是:
main.cpp中
#include "classB.h"
int main()
{
B *b = 0;
b = new B();
return 0;
}
classA.h
#ifndef CLASS_A_H
#define CLASS_A_H
class A
{
public:
A();
};
#endif
classA.cpp
#include "classA.h"
#include <iostream>
A::A()
{
std::cout << "Constructor A" << std::endl;
}
classB.h
#ifndef CLASS_B_H
#define CLASS_B_H
#include "classA.h"
class B : public A
{
public:
B();
};
#endif
classB.cpp
#include "classB.h"
#include <iostream>
B::B() : A()
{
std::cout << "Constructor B" << std::endl;
}
生成文件
SOURCES=main.cpp classA.cpp classB.cpp
TARGET=test
CXX_FLAGS=-g
.PHONY: all
all: $(TARGET)
$(TARGET): $(SOURCES)
$(CXX) $(CXX_FLAGS) $^ -o [email protected]
.PHONY: clean
clean:
rm -vf $(TARGET)
步驟重現:
運行的emacs
的Mx的gdb
GDB -i = MI測試
在GDB命令窗口運行:啓動
運行:下一步
運行:步
我的環境是:Ubuntu14.04,GDB - 7.7.1,emacs的 - 25.1.1。
我試着用set-window-dedicated-p。但這不是我的問題的解決方案。 我是新的emacs,請幫助我,我的配置有什麼問題?
對不起話題,但你用什麼主題'linum'和緩衝區分隔符? –
我建議從標題中刪除[標籤],因爲SO已經將標籤作爲問題的一部分。 –
@ChakravarthyRaghunandan,我正在使用idea-darkula-theme。 –