(defvar gdb-find-file-unhook nil)
(defvar gdb-active-process nil "GUD tooltips display variable values when t, \
and #define directives otherwise.")
+(defvar gdb-error "Non-nil when GDB is reporting an error.")
(defvar gdb-macro-info nil
"Non-nil if GDB knows that the inferior includes preprocessor macro info.")
(let ((string (buffer-string)))
;; remove newline for gud-tooltip-echo-area
(substring string 0 (- (length string) 1))))
- gud-tooltip-echo-area))
+ (or gud-tooltip-echo-area tooltip-use-echo-area)))
;; If expr is a macro for a function don't print because of possible dangerous
;; side-effects. Also printing a function within a tooltip generates an
(defun gdb-set-gud-minor-mode-1 (buffer)
(goto-char (point-min))
(when (and (search-forward "Located in " nil t)
- (looking-at "\\S-*")
+ (looking-at "\\S-+")
(string-equal (buffer-file-name buffer)
(match-string 0)))
(with-current-buffer buffer
gdb-flush-pending-output nil
gdb-location-alist nil
gdb-find-file-unhook nil
+ gdb-error nil
gdb-macro-info nil)
;;
(setq gdb-buffer-type 'gdba)
(setq gdb-var-changed t)))
(if (re-search-forward "Undefined command" nil t)
(message-box "Watching expressions requires gdb 6.0 onwards")
- (message "No symbol %s in current context." expr)))))
+ (message "No symbol \"%s\" in current context." expr)))))
(defun gdb-var-evaluate-expression-handler (varnum changed)
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(defun gdb-send (proc string)
"A comint send filter for gdb.
This filter may simply queue input for a later time."
+ (with-current-buffer gud-comint-buffer
+ (remove-text-properties (point-min) (point-max) '(face)))
(let ((item (concat string "\n")))
(if gud-running
(progn
("watchpoint" gdb-stopping)
("frame-begin" gdb-frame-begin)
("stopped" gdb-stopped)
+ ("error-begin" gdb-error)
+ ("error" gdb-error)
) "An assoc mapping annotation tags to functions which process them.")
(defun gdb-resync()
(gdb-resync)
(error "Unexpected stopped annotation")))))
+(defun gdb-error (ignored)
+ (setq gdb-error (not gdb-error)))
+
(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."
(unless gdb-pending-triggers
- (gdb-get-selected-frame)
- (gdb-invalidate-frames)
- (gdb-invalidate-breakpoints)
- ;; Do this through gdb-get-selected-frame -> gdb-frame-handler
- ;; so gdb-frame-address is updated.
- ;; (gdb-invalidate-assembler)
- (gdb-invalidate-registers)
- (gdb-invalidate-memory)
- (gdb-invalidate-locals)
- (gdb-invalidate-threads)
- (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
- ;; FIXME: with GDB-6 on Darwin, this might very well work.
- ;; only needed/used with speedbar/watch expressions
- (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
- (setq gdb-var-changed t) ; force update
- (dolist (var gdb-var-list)
- (setcar (nthcdr 5 var) nil))
- (gdb-var-update))))
+ (gdb-get-selected-frame)
+ (gdb-invalidate-frames)
+ (gdb-invalidate-breakpoints)
+ ;; Do this through gdb-get-selected-frame -> gdb-frame-handler
+ ;; so gdb-frame-address is updated.
+ ;; (gdb-invalidate-assembler)
+ (gdb-invalidate-registers)
+ (gdb-invalidate-memory)
+ (gdb-invalidate-locals)
+ (gdb-invalidate-threads)
+ (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
+ ;; FIXME: with GDB-6 on Darwin, this might very well work.
+ ;; only needed/used with speedbar/watch expressions
+ (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
+ (setq gdb-var-changed t) ; force update
+ (dolist (var gdb-var-list)
+ (setcar (nthcdr 5 var) nil))
+ (gdb-var-update))))
(let ((sink gdb-output-sink))
(cond
((eq sink 'user) t)
output)))
(defun gdb-concat-output (so-far new)
+ (if gdb-error
+ (put-text-property 0 (length new) 'face font-lock-warning-face new))
(let ((sink gdb-output-sink))
(cond
((eq sink 'user) (concat so-far new))
(let ((buf (gdb-get-buffer ',buf-key)))
(and buf
(with-current-buffer buf
- (let ((p (point))
+ (let ((p (window-point (get-buffer-window buf 0)))
(buffer-read-only nil))
(erase-buffer)
(insert-buffer-substring (gdb-get-create-buffer
'gdb-partial-output-buffer))
- (goto-char p)))))
+ (set-window-point (get-buffer-window buf 0) p)))))
;; put customisation here
(,custom-defun)))
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
- (if (looking-at "[^\t].*breakpoint")
+ (if (looking-at "[^\t].*?breakpoint")
(progn
(looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
(setq bptno (match-string 1))
(save-excursion
(beginning-of-line 1)
(if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
- (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
+ (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)\\s-+")
(looking-at
- "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
+ "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
(gdb-enqueue-input
(list
(concat gdb-server-prefix
(interactive)
(beginning-of-line 1)
(if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
- (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
+ (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)")
(looking-at
- "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
+ "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
(gdb-enqueue-input
(list
(concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))
(save-excursion
(beginning-of-line 1)
(if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
- (looking-at "\\([0-9]+\\) .* in .* at\\s-+\\(\\S-*\\):\\([0-9]+\\)")
+ (looking-at "\\([0-9]+\\) .+ in .+ at\\s-+\\(\\S-+\\):\\([0-9]+\\)")
(looking-at
- "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\
-\\(\\S-*\\):\\([0-9]+\\)"))
+ "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+.\\s-+\\S-+\\s-+\
+\\(\\S-+\\):\\([0-9]+\\)"))
(let ((bptno (match-string 1))
(file (match-string 2))
(line (match-string 3)))
(setq buffer-read-only t)
(use-local-map gdb-registers-mode-map)
(run-mode-hooks 'gdb-registers-mode-hook)
- 'gdb-invalidate-registers)
+ (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
+ 'gdb-invalidate-registers
+ 'gdbmi-invalidate-registers))
(defun gdb-registers-buffer-name ()
(with-current-buffer gud-comint-buffer
(replace-match " (array);\n" nil nil))))
(let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
(and buf (with-current-buffer buf
- (let ((p (point))
+ (let ((p (window-point (get-buffer-window buf 0)))
(buffer-read-only nil))
- (delete-region (point-min) (point-max))
+ (erase-buffer)
(insert-buffer-substring (gdb-get-create-buffer
'gdb-partial-output-buffer))
- (goto-char p)))))
+ (set-window-point (get-buffer-window buf 0) p)))))
(run-hooks 'gdb-info-locals-hook))
(defun gdb-info-locals-custom ()
(let ((menu (make-sparse-keymap "GDB-UI")))
(define-key gud-menu-map [ui]
`(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
- (define-key menu [gdb-restore-windows]
- '(menu-item "Restore Window Layout" gdb-restore-windows
- :help "Restore standard layout for debug session."))
- (define-key menu [gdb-many-windows]
- '(menu-item "Display Other Windows" gdb-many-windows
- :help "Toggle display of locals, stack and breakpoint information"
- :button (:toggle . gdb-many-windows)))
(define-key menu [gdb-use-inferior-io]
(menu-bar-make-toggle toggle-gdb-use-inferior-io-buffer
gdb-use-inferior-io-buffer
"Separate inferior IO" "Use separate IO %s"
- "Toggle separate IO for inferior.")))
+ "Toggle separate IO for inferior."))
+ (define-key menu [gdb-many-windows]
+ '(menu-item "Display Other Windows" gdb-many-windows
+ :help "Toggle display of locals, stack and breakpoint information"
+ :button (:toggle . gdb-many-windows)))
+ (define-key menu [gdb-restore-windows]
+ '(menu-item "Restore Window Layout" gdb-restore-windows
+ :help "Restore standard layout for debug session.")))
(defadvice toggle-gdb-use-inferior-io-buffer (after gdb-kill-io-buffer activate)
(unless gdb-use-inferior-io-buffer
buffers."
(goto-char (point-min))
(if (and (search-forward "Located in " nil t)
- (looking-at "\\S-*"))
+ (looking-at "\\S-+"))
(setq gdb-main-file (match-string 0)))
(goto-char (point-min))
(if (search-forward "Includes preprocessor macro info." nil t)
(goto-char (point-min))
(catch 'file-not-found
(if (search-forward "Located in " nil t)
- (when (looking-at "\\S-*")
+ (when (looking-at "\\S-+")
(delete (cons bptno "File not found") gdb-location-alist)
(push (cons bptno (match-string 0)) gdb-location-alist))
(gdb-resync)
(add-hook 'find-file-hook 'gdb-find-file-hook)
(defun gdb-find-file-hook ()
+"Set up buffer for debugging if file is part of the source code
+of the current session."
(if (and (not gdb-find-file-unhook)
;; in case gud or gdb-ui is just loaded
gud-comint-buffer
(goto-char (point-min))
(while (< (point) (- (point-max) 1))
(forward-line 1)
- (if (looking-at "[^\t].*breakpoint")
+ (if (looking-at "[^\t].*?breakpoint")
(progn
(looking-at
"\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x0*\\(\\S-+\\)")
(defun gdb-display-assembler-buffer ()
"Display disassembly view."
(interactive)
+ (setq gdb-previous-frame nil)
(gdb-display-buffer
(gdb-get-create-buffer 'gdb-assembler-buffer)))
(defun gdb-frame-assembler-buffer ()
"Display disassembly view in a new frame."
(interactive)
+ (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))))