When using gdb -i=mi to debug a program, I typically split the window into two buffers vertically. But every time my program prints something gud automatically replaces my source code buffer with I/O buffer and pops up a new "frame" that contains my source code, and what's worse is that it creates a "dedicated window" that I can't switch back to source code. This behavior is obviously very very annoying, it should for example, open a new frame for the I/O buffer instead. How can I achieve that or just simply turn off auto replacing buffer for gud? (gud-gdb doesn't seem to have such behaviors but it doesn't show where breakpoints are)
The automatic pop-up of the i/o buffer can be disabled by setting
t. In your
.emacs file, add:
;; Prevent gdb from popping i/o window to the foreground on every output op (setq-default gdb-display-io-nopopup t)
I learned this from ajp's answer here.
A partial answer is to disable gud from making the windows "dedicated", so you can change their buffer. From https://www.emacswiki.org/emacs/GDB-MI:
;; Force gdb-mi to not dedicate any windows (advice-add 'gdb-display-buffer :around (lambda (orig-fun &rest r) (let ((window (apply orig-fun r))) (set-window-dedicated-p window nil) window))) (advice-add 'gdb-set-window-buffer :around (lambda (orig-fun name &optional ignore-dedicated window) (funcall orig-fun name ignore-dedicated window) (set-window-dedicated-p window nil)))