"Non-nil if GDB knows that the inferior includes preprocessor macro info.")
(defvar gdb-buffer-fringe-width nil)
(defvar gdb-signalled nil)
+(defvar gdb-source-window nil)
(defvar gdb-buffer-type nil
"One of the symbols bound in `gdb-buffer-rules'.")
gdb-macro-info nil
gdb-buffer-fringe-width (car (window-fringes))
gdb-debug-ring nil
- gdb-signalled nil)
+ gdb-signalled nil
+ gdb-source-window nil)
(setq gdb-buffer-type 'gdba)
;; The usual gdb interaction buffer is given the type `gdba' and
;; is constructed specially.
;;
-;; Others are constructed by gdb-get-create-buffer and
+;; Others are constructed by gdb-get-buffer-create and
;; named according to the rules set forth in the gdb-buffer-rules-assoc
(defvar gdb-buffer-rules-assoc '())
(save-excursion
(gdb-look-for-tagged-buffer key (buffer-list))))
-(defun gdb-get-create-buffer (key)
+(defun gdb-get-buffer-create (key)
"Create a new gdb buffer of the type specified by KEY.
The key should be one of the cars in `gdb-buffer-rules-assoc'."
(or (gdb-get-buffer key)
(interactive)
(if gdb-use-separate-io-buffer
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-inferior-io))))
+ (gdb-get-buffer-create 'gdb-inferior-io))))
(defconst gdb-frame-parameters
'((height . 14) (width . 80)
(if gdb-use-separate-io-buffer
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))))
+ (display-buffer (gdb-get-buffer-create 'gdb-inferior-io)))))
(defvar gdb-inferior-io-mode-map
(let ((map (make-sparse-keymap)))
(setq gdb-output-sink 'user)
(let ((handler
(car (cdr gdb-current-item))))
- (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
(funcall handler))))
(t
(gdb-resync)
(gdb-get-selected-frame)
(gdb-invalidate-frames)
;; Regenerate breakpoints buffer in case it has been inadvertantly deleted.
- (gdb-get-create-buffer 'gdb-breakpoints-buffer)
+ (gdb-get-buffer-create 'gdb-breakpoints-buffer)
(gdb-invalidate-breakpoints)
;; Do this through gdb-get-selected-frame -> gdb-frame-handler
;; so gdb-frame-address is updated.
(gdb-resync)
(error "Phase error in gdb-post-prompt (got %s)" sink)))))
+;; GUD displays the selected GDB frame. This might might not be the current
+;; GDB frame (after up, down etc). If no GDB frame is visible but the last
+;; visited breakpoint is, use that window.
+(defun gdb-display-source-buffer (buffer)
+ (let* ((last-window (if gud-last-last-frame
+ (get-buffer-window
+ (gud-find-file (car gud-last-last-frame)))))
+ (source-window (or last-window
+ (if (and gdb-source-window
+ (window-live-p gdb-source-window))
+ gdb-source-window))))
+ (when source-window
+ (setq gdb-source-window source-window)
+ (set-window-buffer source-window buffer))
+ source-window))
+
(defun gud-gdba-marker-filter (string)
"A gud marker filter for gdb. Handle a burst of output from GDB."
(if gdb-flush-pending-output
(error "Bogon output sink %S" sink)))))
(defun gdb-append-to-partial-output (string)
- (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
(goto-char (point-max))
(insert string)))
(defun gdb-clear-partial-output ()
- (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
(erase-buffer)))
(defun gdb-append-to-inferior-io (string)
- (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
(goto-char (point-max))
(insert-before-markers string))
(if (not (string-equal string ""))
- (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))
+ (gdb-display-buffer (gdb-get-buffer-create 'gdb-inferior-io))))
(defun gdb-clear-inferior-io ()
- (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
(erase-buffer)))
\f
(and buf
(with-current-buffer buf
(let* ((window (get-buffer-window buf 0))
+ (start (window-start window))
(p (window-point window))
(buffer-read-only nil))
(erase-buffer)
- (insert-buffer-substring (gdb-get-create-buffer
+ (insert-buffer-substring (gdb-get-buffer-create
'gdb-partial-output-buffer))
+ (set-window-start window start)
(set-window-point window p)))))
;; put customisation here
(,custom-defun)))
"Display status of user-settable breakpoints."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
+ (gdb-get-buffer-create 'gdb-breakpoints-buffer)))
(defun gdb-frame-breakpoints-buffer ()
"Display status of user-settable breakpoints in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-breakpoints-buffer))))
(defvar gdb-breakpoints-mode-map
(let ((map (make-sparse-keymap))
"Display the breakpoint location specified at current line."
(interactive (list last-input-event))
(if event (posn-set-point (event-end event)))
- ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer.
- (let ((window (get-buffer-window gud-comint-buffer)))
- (if window (save-selected-window (select-window window))))
(save-excursion
(beginning-of-line 1)
(if (looking-at "\\([0-9]+\\) .+ in .+ at\\s-+\\(\\S-+\\):\\([0-9]+\\)")
(file (match-string 2))
(line (match-string 3)))
(save-selected-window
- (let* ((buf (find-file-noselect
+ (let* ((buffer (find-file-noselect
(if (file-exists-p file) file
(cdr (assoc bptno gdb-location-alist)))))
- (window (display-buffer buf)))
- (with-current-buffer buf
+ (window (unless (gdb-display-source-buffer buffer)
+ (display-buffer buffer))))
+ (setq gdb-source-window window)
+ (with-current-buffer buffer
(goto-line (string-to-number line))
(set-window-point window (point))))))
(error "No location specified."))))
"Display backtrace of current stack."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-stack-buffer)))
+ (gdb-get-buffer-create 'gdb-stack-buffer)))
(defun gdb-frame-stack-buffer ()
"Display backtrace of current stack in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-stack-buffer))))
(defvar gdb-frames-mode-map
(let ((map (make-sparse-keymap)))
"Display IDs of currently known threads."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-threads-buffer)))
+ (gdb-get-buffer-create 'gdb-threads-buffer)))
(defun gdb-frame-threads-buffer ()
"Display IDs of currently known threads in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-threads-buffer))))
(defvar gdb-threads-mode-map
(let ((map (make-sparse-keymap)))
"Display integer register contents."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-registers-buffer)))
+ (gdb-get-buffer-create 'gdb-registers-buffer)))
(defun gdb-frame-registers-buffer ()
"Display integer register contents in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-registers-buffer))))
(defun gdb-all-registers ()
"Toggle the display of floating-point registers (pre GDB 6.4 only)."
(if gdb-all-registers
(progn
(setq gdb-all-registers nil)
- (with-current-buffer (gdb-get-create-buffer 'gdb-registers-buffer)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-registers-buffer)
(setq mode-name "Registers")))
(setq gdb-all-registers t)
- (with-current-buffer (gdb-get-create-buffer 'gdb-registers-buffer)
+ (with-current-buffer (gdb-get-buffer-create 'gdb-registers-buffer)
(setq mode-name "Registers:All")))
(message (format "Display of floating-point registers %sabled"
(if gdb-all-registers "en" "dis")))
"Display memory contents."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-memory-buffer)))
+ (gdb-get-buffer-create 'gdb-memory-buffer)))
(defun gdb-frame-memory-buffer ()
"Display memory contents in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-memory-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-memory-buffer))))
\f
;; Locals buffer.
(and buf
(with-current-buffer buf
(let* ((window (get-buffer-window buf 0))
+ (start (window-start window))
(p (window-point window))
(buffer-read-only nil))
(erase-buffer)
- (insert-buffer-substring (gdb-get-create-buffer
+ (insert-buffer-substring (gdb-get-buffer-create
'gdb-partial-output-buffer))
- (set-window-point window p)))))
+ (set-window-start window start)
+ (set-window-point window p))
+)))
(run-hooks 'gdb-info-locals-hook))
(defvar gdb-locals-mode-map
"Display local variables of current stack and their values."
(interactive)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-locals-buffer)))
+ (gdb-get-buffer-create 'gdb-locals-buffer)))
(defun gdb-frame-locals-buffer ()
"Display local variables of current stack and their values in a new frame."
(interactive)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-locals-buffer))))
\f
;;;; Window management
(split-window-horizontally)
(other-window 1)
(gdb-set-window-buffer
- (gdb-get-create-buffer 'gdb-inferior-io)))
+ (gdb-get-buffer-create 'gdb-inferior-io)))
(other-window 1)
(gdb-set-window-buffer (gdb-stack-buffer-name))
(split-window-horizontally)
(setq gdb-macro-info t))
(if gdb-many-windows
(gdb-setup-windows)
- (gdb-get-create-buffer 'gdb-breakpoints-buffer)
+ (gdb-get-buffer-create 'gdb-breakpoints-buffer)
(if gdb-show-main
(let ((pop-up-windows t))
(display-buffer (gud-find-file gdb-main-file))))))
(interactive)
(setq gdb-previous-frame nil)
(gdb-display-buffer
- (gdb-get-create-buffer 'gdb-assembler-buffer)))
+ (gdb-get-buffer-create 'gdb-assembler-buffer)))
(defun gdb-frame-assembler-buffer ()
"Display disassembly view in a new frame."
(setq gdb-previous-frame nil)
(let ((special-display-regexps (append special-display-regexps '(".*")))
(special-display-frame-alist gdb-frame-parameters))
- (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
+ (display-buffer (gdb-get-buffer-create 'gdb-assembler-buffer))))
;; modified because if gdb-frame-address has changed value a new command
;; must be enqueued to update the buffer with the new output
(concat register-values register-string)))
(let ((buf (gdb-get-buffer 'gdb-registers-buffer)))
(with-current-buffer buf
- (let ((p (window-point (get-buffer-window buf 0)))
- (buffer-read-only nil))
+ (let* ((window (get-buffer-window buf 0))
+ (start (window-start window))
+ (p (window-point window))
+ (buffer-read-only nil))
(erase-buffer)
(insert register-values)
- (set-window-point (get-buffer-window buf 0) p))))))
+ (set-window-start window start)
+ (set-window-point window p))))))
(gdb-data-list-register-values-custom))
(defun gdb-data-list-register-values-custom ()
(let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
(and buf (with-current-buffer buf
(let* ((window (get-buffer-window buf 0))
+ (start (window-start window))
(p (window-point window))
(buffer-read-only nil))
(erase-buffer)
(insert
(concat name "\t" (nth 1 local)
"\t" (nth 2 local) "\n")))
+ (set-window-start window start)
(set-window-point window p)))))))
(defun gdb-get-register-names ()