(gdb-set-buffer-rules 'gdba 'error)
;;
-;; partial-output buffers
-;;
-;; These accumulate output from a command executed on
+;; Partial-output buffer : This accumulates output from a command executed on
;; behalf of emacs (rather than the user).
;;
-
(gdb-set-buffer-rules 'gdb-partial-output-buffer
'gdb-partial-output-name)
;;update with new frame for machine code if necessary
(gdb-invalidate-assembler))
-(defun gdb-prompt (ignored)
- "An annotation handler for `prompt'.
-This sends the next command (if any) to gdb."
- (let ((sink (gdb-get-output-sink)))
- (cond
- ((eq sink 'user) t)
- ((eq sink 'post-emacs)
- (gdb-set-output-sink 'user))
- (t
- (gdb-set-output-sink 'user)
- (error "Phase error in gdb-prompt (got %s)" sink))))
- (let ((highest (gdb-dequeue-input)))
- (if highest
- (gdb-send-item highest)
- (let ((lowest (gdb-dequeue-idle-input)))
- (if lowest
- (gdb-send-item lowest)
- (progn
- (gdb-set-prompting t)
- (gud-display-frame)))))))
-
-(defun gdb-subprompt (ignored)
- "An annotation handler for non-top-level prompts."
- (let ((highest (gdb-dequeue-input)))
- (if highest
- (gdb-send-item highest)
- (gdb-set-prompting t))))
-
(defun gdb-send-item (item)
(gdb-set-current-item item)
(if (stringp item)
(gdb-set-output-sink 'user)
(error "Output sink phase error 1")))))
+(defun gdb-prompt (ignored)
+ "An annotation handler for `prompt'.
+This sends the next command (if any) to gdb."
+ (let ((sink (gdb-get-output-sink)))
+ (cond
+ ((eq sink 'user) t)
+ ((eq sink 'post-emacs)
+ (gdb-set-output-sink 'user))
+ (t
+ (gdb-set-output-sink 'user)
+ (error "Phase error in gdb-prompt (got %s)" sink))))
+ (let ((highest (gdb-dequeue-input)))
+ (if highest
+ (gdb-send-item highest)
+ (let ((lowest (gdb-dequeue-idle-input)))
+ (if lowest
+ (gdb-send-item lowest)
+ (progn
+ (gdb-set-prompting t)
+ (gud-display-frame)))))))
+
+(defun gdb-subprompt (ignored)
+ "An annotation handler for non-top-level prompts."
+ (let ((highest (gdb-dequeue-input)))
+ (if highest
+ (gdb-send-item highest)
+ (gdb-set-prompting t))))
+
(defun gdb-starting (ignored)
"An annotation handler for `starting'. This says that I/O for the
subprocess is now the program being debugged, not GDB."
(gdb-set-output-sink 'user))
(t (error "Unexpected stopping annotation")))))
-(defun gdb-stopped (ignored)
- "An annotation handler for `stopped'. It is just like gdb-stopping, except
-that if we already set the output sink to 'user in gdb-stopping, that is fine."
- (setq gud-running nil)
+(defun gdb-frame-begin (ignored)
(let ((sink (gdb-get-output-sink)))
(cond
((eq sink 'inferior)
(gdb-set-output-sink 'user))
((eq sink 'user) t)
- (t (error "Unexpected stopped annotation")))))
+ ((eq sink 'emacs) t)
+ (t (error "Unexpected frame-begin annotation (%S)" sink)))))
-(defun gdb-frame-begin (ignored)
+(defun gdb-stopped (ignored)
+ "An annotation handler for `stopped'. It is just like gdb-stopping, except
+that if we already set the output sink to 'user in gdb-stopping, that is fine."
+ (setq gud-running nil)
(let ((sink (gdb-get-output-sink)))
(cond
((eq sink 'inferior)
(gdb-set-output-sink 'user))
((eq sink 'user) t)
- ((eq sink 'emacs) t)
- (t (error "Unexpected frame-begin annotation (%S)" sink)))))
+ (t (error "Unexpected stopped annotation")))))
(defun gdb-post-prompt (ignored)
"An annotation handler for `post-prompt'. This begins the collection of
output from the current command if that happens to be appropriate."
(if (not (gdb-get-pending-triggers))
(progn
+ (gdb-get-current-frame)
(gdb-invalidate-registers ignored)
(gdb-invalidate-locals ignored)
(gdb-invalidate-display ignored)))
(gdb-expressions-mode)
(setq gdb-dive-display-number number)))
(set-buffer (get-buffer-create gdb-expression-buffer-name))
+ (gdb-expressions-mode)
(if (and (display-graphic-p) (not gdb-dive))
(catch 'frame-exists
(dolist (frame (frame-list))
(if (string-equal (frame-parameter frame 'name)
gdb-expression-buffer-name)
(throw 'frame-exists nil)))
- (gdb-expressions-mode)
(make-frame '((height . 20) (width . 40)
(tool-bar-lines . nil)
(menu-bar-lines . nil)
- (minibuffer . nil)))))))
+ (minibuffer . nil))))
+ (gdb-display-buffer (get-buffer gdb-expression-buffer-name)))))
(set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
(setq gdb-dive nil))
\f
;;
-;; Breakpoint buffers
-;;
-;; These display the output of `info breakpoints'.
+;; Breakpoint buffer : This displays the output of `info breakpoints'.
;;
-
(gdb-set-buffer-rules 'gdb-breakpoints-buffer
'gdb-breakpoints-buffer-name
'gdb-breakpoints-mode)
(let ((flag)(address))
;; remove all breakpoint-icons in source buffers but not assembler buffer
- (let ((buffers (buffer-list)))
+ (dolist (buffer (buffer-list))
(save-excursion
- (while buffers
- (set-buffer (car buffers))
- (if (and (eq gud-minor-mode 'gdba)
- (not (string-match "^\*" (buffer-name))))
- (if (display-graphic-p)
- (remove-images (point-min) (point-max))
- (remove-strings (point-min) (point-max))))
- (setq buffers (cdr buffers)))))
-
+ (set-buffer buffer)
+ (if (and (eq gud-minor-mode 'gdba)
+ (not (string-match "^\*" (buffer-name))))
+ (if (display-graphic-p)
+ (remove-images (point-min) (point-max))
+ (remove-strings (point-min) (point-max))))))
(save-excursion
(set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))
(save-excursion
(goto-line (string-to-number line))))))
\f
;;
-;; Frames buffers. These display a perpetually correct bactracktrace
+;; Frames buffer. This displays a perpetually correct bactracktrace
;; (from the command `where').
;;
-;; Alas, if your stack is deep, they are costly.
+;; Alas, if your stack is deep, it is costly.
;;
-
(gdb-set-buffer-rules 'gdb-stack-buffer
'gdb-stack-buffer-name
'gdb-frames-mode)
(set-buffer (gdb-get-buffer 'gdb-stack-buffer))
(let ((buffer-read-only nil))
(goto-char (point-min))
- (looking-at "\\S-*\\s-*\\(\\S-*\\)")
- (setq gdb-current-frame (match-string 1))
(while (< (point) (point-max))
(put-text-property (progn (beginning-of-line) (point))
(progn (end-of-line) (point))
\f
;;
-;; Registers buffers
+;; Registers buffer.
;;
+(gdb-set-buffer-rules 'gdb-registers-buffer
+ 'gdb-registers-buffer-name
+ 'gdb-registers-mode)
(def-gdb-auto-updated-buffer gdb-registers-buffer
gdb-invalidate-registers
(defun gdb-info-registers-custom ())
-(gdb-set-buffer-rules 'gdb-registers-buffer
- 'gdb-registers-buffer-name
- 'gdb-registers-mode)
-
(defvar gdb-registers-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(interactive)
(switch-to-buffer-other-frame
(gdb-get-create-buffer 'gdb-registers-buffer)))
-
+\f
;;
-;; Locals buffers
+;; Locals buffer.
;;
+(gdb-set-buffer-rules 'gdb-locals-buffer
+ 'gdb-locals-buffer-name
+ 'gdb-locals-mode)
(def-gdb-auto-updated-buffer gdb-locals-buffer
gdb-invalidate-locals
(defun gdb-info-locals-custom ()
nil)
-(gdb-set-buffer-rules 'gdb-locals-buffer
- 'gdb-locals-buffer-name
- 'gdb-locals-mode)
-
(defvar gdb-locals-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(interactive)
(switch-to-buffer-other-frame
(gdb-get-create-buffer 'gdb-locals-buffer)))
+\f
;;
-;; Display expression buffers (just allow one to start with)
+;; Display expression buffer.
;;
(gdb-set-buffer-rules 'gdb-display-buffer
'gdb-display-buffer-name
Use this command to exit a debugging session cleanly and reset
things like the toolbar and margin in the source buffers."
(interactive)
- (let ((buffers (buffer-list)))
+ (dolist (buffer (buffer-list))
(save-excursion
- (while buffers
- (set-buffer (car buffers))
- (if (eq gud-minor-mode 'gdba)
- (if (string-match "^\*" (buffer-name))
- (kill-buffer nil)
- (if (display-graphic-p)
- (remove-images (point-min) (point-max))
- (remove-strings (point-min) (point-max)))
- (setq left-margin-width 0)
- (setq gud-minor-mode nil)
- (kill-local-variable 'tool-bar-map)
- (setq gud-running nil)
- (if (get-buffer-window (current-buffer))
- (set-window-margins (get-buffer-window
- (current-buffer))
- left-margin-width
- right-margin-width))))
- (setq buffers (cdr buffers)))))
+ (set-buffer buffer)
+ (if (eq gud-minor-mode 'gdba)
+ (if (string-match "^\*" (buffer-name))
+ (kill-buffer nil)
+ (if (display-graphic-p)
+ (remove-images (point-min) (point-max))
+ (remove-strings (point-min) (point-max)))
+ (setq left-margin-width 0)
+ (setq gud-minor-mode nil)
+ (kill-local-variable 'tool-bar-map)
+ (setq gud-running nil)
+ (if (get-buffer-window (current-buffer))
+ (set-window-margins (get-buffer-window
+ (current-buffer))
+ left-margin-width
+ right-margin-width))))))
(if (eq (selected-window) (minibuffer-window))
(other-window 1))
(delete-other-windows))
(split-window)
(other-window 1)
(switch-to-buffer (gud-find-file gdb-main-file))
- (setq gdb-source-window (get-buffer-window (current-buffer))))
- (other-window 1)))
+ (setq gdb-source-window (get-buffer-window (current-buffer)))
+ (other-window 1))))
;;from put-image
(defun put-string (putstring pos &optional string area)
'ignore))
(kill-buffer nil)
(delete-frame))
-
+\f
;;
-;; Assembler buffer
+;; Assembler buffer.
;;
+(gdb-set-buffer-rules 'gdb-assembler-buffer
+ 'gdb-assembler-buffer-name
+ 'gdb-assembler-mode)
(def-gdb-auto-updated-buffer gdb-assembler-buffer
gdb-invalidate-assembler
(if gdb-current-address
(set-window-point (get-buffer-window buffer) gdb-arrow-position))))
-(gdb-set-buffer-rules 'gdb-assembler-buffer
- 'gdb-assembler-buffer-name
- 'gdb-assembler-mode)
-
(defvar gdb-assembler-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(gdb-get-pending-triggers)))
(setq gdb-prev-main-or-pc gdb-main-or-pc))))
+(defun gdb-get-current-frame ()
+ (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers)))
+ (progn
+ (gdb-enqueue-idle-input
+ (list (concat "server frame\n") 'gdb-frame-handler))
+ (gdb-set-pending-triggers
+ (cons 'gdb-get-current-frame
+ (gdb-get-pending-triggers))))))
+
+(defun gdb-frame-handler ()
+ (gdb-set-pending-triggers
+ (delq 'gdb-get-current-frame (gdb-get-pending-triggers)))
+ (save-excursion
+ (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer))
+ (goto-char (point-min))
+ (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")
+ (setq gdb-current-frame (match-string 1)))))
+
(provide 'gdb-ui)
;;; gdb-ui.el ends here