(require 'gud)
-(defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
-(defvar gdb-previous-address nil)
+(defvar gdb-frame-address "main" "Initialisation for Assembler buffer.")
+(defvar gdb-previous-frame-address nil)
(defvar gdb-memory-address "main")
(defvar gdb-previous-frame nil)
-(defvar gdb-current-frame nil)
-(defvar gdb-current-stack-level nil)
+(defvar gdb-selected-frame nil)
+(defvar gdb-frame-number nil)
(defvar gdb-current-language nil)
(defvar gdb-var-list nil "List of variables in watch window.")
(defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
+(defvar gdb-main-file nil "Source file from which program execution begins.")
(defvar gdb-buffer-type nil)
(defvar gdb-overlay-arrow-position nil)
(defvar gdb-server-prefix nil)
(defvar gdb-flush-pending-output nil)
-(defvar gdb-location-list nil "List of directories for source files.")
+(defvar gdb-location-alist nil
+ "Alist of breakpoint numbers and full filenames.")
(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.")
(defvar gdb-buffer-type nil
"One of the symbols bound in `gdb-buffer-rules'.")
:group 'gud
:version "22.1")
+(defcustom gdb-cpp-define-alist-program "gcc -E -dM -"
+ "Shell command for generating a list of defined macros in a source file.
+This list is used to display the #define directive associated
+with an identifier as a tooltip. It works in a debug session with
+GDB, when gud-tooltip-mode is t.
+
+Set `gdb-cpp-define-alist-flags' for any include paths or
+predefined macros."
+ :type 'string
+ :group 'gud
+ :version "22.1")
+
+(defcustom gdb-cpp-define-alist-flags ""
+ "Preprocessor flags for `gdb-cpp-define-alist-program'."
+ :type 'string
+ :group 'gud
+ :version "22.1")
+
+(defcustom gdb-show-main nil
+ "Non-nil means display source file containing the main routine at startup.
+Also display the main routine in the disassembly buffer if present."
+ :type 'boolean
+ :group 'gud
+ :version "22.1")
+
+(defvar gdb-define-alist nil "Alist of #define directives for GUD tooltips.")
+
+(defun gdb-create-define-alist ()
+ "Create an alist of #define directives for GUD tooltips."
+ (let* ((file (buffer-file-name))
+ (output
+ (with-output-to-string
+ (with-current-buffer standard-output
+ (call-process shell-file-name
+ (if (file-exists-p file) file nil)
+ (list t nil) nil "-c"
+ (concat gdb-cpp-define-alist-program " "
+ gdb-cpp-define-alist-flags)))))
+ (define-list (split-string output "\n" t))
+ (name))
+ (setq gdb-define-alist nil)
+ (dolist (define define-list)
+ (setq name (nth 1 (split-string define "[( ]")))
+ (push (cons name define) gdb-define-alist))))
+
+(defun gdb-tooltip-print ()
+ (tooltip-show
+ (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
+ (let ((string (buffer-string)))
+ ;; remove newline for gud-tooltip-echo-area
+ (substring string 0 (- (length string) 1))))
+ (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
+;; unexpected starting annotation (phase error).
+(defun gdb-tooltip-print-1 (expr)
+ (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
+ (goto-char (point-min))
+ (if (search-forward "expands to: " nil t)
+ (unless (looking-at "\\S+.*(.*).*")
+ (gdb-enqueue-input
+ (list (concat gdb-server-prefix "print " expr "\n")
+ 'gdb-tooltip-print))))))
+
(defun gdb-set-gud-minor-mode (buffer)
"Set gud-minor-mode from find-file if appropriate."
(goto-char (point-min))
(defun gdb-set-gud-minor-mode-1 (buffer)
(goto-char (point-min))
- (if (and (search-forward "Located in " nil t)
- (looking-at "\\S-*")
- (string-equal (buffer-file-name buffer)
- (match-string 0)))
- (with-current-buffer buffer
- (set (make-local-variable 'gud-minor-mode) 'gdba)
- (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))))
+ (when (and (search-forward "Located in " nil t)
+ (looking-at "\\S-+")
+ (string-equal (buffer-file-name buffer)
+ (match-string 0)))
+ (with-current-buffer buffer
+ (set (make-local-variable 'gud-minor-mode) 'gdba)
+ (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
+ (when gud-tooltip-mode
+ (make-local-variable 'gdb-define-alist)
+ (gdb-create-define-alist)
+ (add-hook 'after-save-hook 'gdb-create-define-alist nil t)))))
(defun gdb-set-gud-minor-mode-existing-buffers ()
(dolist (buffer (buffer-list))
(set (make-local-variable 'gud-minor-mode) 'gdba)
(set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
;;
- (gud-def gud-break (if (not (string-equal mode-name "Machine"))
+ (gud-def gud-break (if (not (string-match "Machine" mode-name))
(gud-call "break %f:%l" arg)
(save-excursion
(beginning-of-line)
(gud-call "break *%a" arg)))
"\C-b" "Set breakpoint at current line or address.")
;;
- (gud-def gud-remove (if (not (string-equal mode-name "Machine"))
+ (gud-def gud-remove (if (not (string-match "Machine" mode-name))
(gud-call "clear %f:%l" arg)
(save-excursion
(beginning-of-line)
(gud-call "clear *%a" arg)))
"\C-d" "Remove breakpoint at current line or address.")
;;
- (gud-def gud-until (if (not (string-equal mode-name "Machine"))
+ (gud-def gud-until (if (not (string-match "Machine" mode-name))
(gud-call "until %f:%l" arg)
(save-excursion
(beginning-of-line)
'gdb-mouse-set-clear-breakpoint)
(define-key gud-minor-mode-map [left-margin mouse-3]
'gdb-mouse-toggle-breakpoint)
+; Currently only works in margin.
; (define-key gud-minor-mode-map [left-fringe mouse-3]
; 'gdb-mouse-toggle-breakpoint)
(setq comint-input-sender 'gdb-send)
;;
;; (re-)initialize
- (setq gdb-current-address "main")
- (setq gdb-previous-address nil)
- (setq gdb-memory-address "main")
- (setq gdb-previous-frame nil)
- (setq gdb-current-frame nil)
- (setq gdb-current-stack-level nil)
- (setq gdb-var-list nil)
- (setq gdb-var-changed nil)
- (setq gdb-first-prompt nil)
- (setq gdb-prompting nil)
- (setq gdb-input-queue nil)
- (setq gdb-current-item nil)
- (setq gdb-pending-triggers nil)
- (setq gdb-output-sink 'user)
- (setq gdb-server-prefix "server ")
- (setq gdb-flush-pending-output nil)
- (setq gdb-location-list nil)
- (setq gdb-find-file-unhook nil)
+ (setq gdb-frame-address (if gdb-show-main "main" nil))
+ (setq gdb-previous-frame-address nil
+ gdb-memory-address "main"
+ gdb-previous-frame nil
+ gdb-selected-frame nil
+ gdb-current-language nil
+ gdb-frame-number nil
+ gdb-var-list nil
+ gdb-var-changed nil
+ gdb-first-prompt nil
+ gdb-prompting nil
+ gdb-input-queue nil
+ gdb-current-item nil
+ gdb-pending-triggers nil
+ gdb-output-sink 'user
+ gdb-server-prefix "server "
+ 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)
;;
(run-hooks 'gdba-mode-hook))
(defcustom gdb-use-colon-colon-notation nil
- "If non-nil use FUN::VAR format to display variables in the speedbar." ;
+ "If non-nil use FUN::VAR format to display variables in the speedbar."
:type 'boolean
:group 'gud
:version "22.1")
(require 'tooltip)
(let ((expr (tooltip-identifier-from-point (point))))
(if (and (string-equal gdb-current-language "c")
- gdb-use-colon-colon-notation gdb-current-frame)
- (setq expr (concat gdb-current-frame "::" expr)))
+ gdb-use-colon-colon-notation gdb-selected-frame)
+ (setq expr (concat gdb-selected-frame "::" expr)))
(catch 'already-watched
(dolist (var gdb-var-list)
(if (string-equal expr (car var)) (throw 'already-watched nil)))
(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)
(let ((varnum (match-string 1)))
(gdb-enqueue-input
(list
- (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
+ (if (with-current-buffer gud-comint-buffer
+ (eq gud-minor-mode 'gdba))
(concat "server interpreter mi \"-var-evaluate-expression "
varnum "\"\n")
(concat "-var-evaluate-expression " varnum "\n"))
(list
(if (with-current-buffer gud-comint-buffer
(eq gud-minor-mode 'gdba))
- (concat "server interpreter mi \"-var-assign " varnum " " value "\"\n")
+ (concat "server interpreter mi \"-var-assign "
+ varnum " " value "\"\n")
(concat "-var-assign " varnum " " value "\n"))
'ignore))))
(gdb-get-target-string)
"*"))
+(defun gdb-display-inferior-io-buffer ()
+ "Display IO of inferior in a separate window."
+ (interactive)
+ (if gdb-use-inferior-io-buffer
+ (gdb-display-buffer
+ (gdb-get-create-buffer 'gdb-inferior-io))))
+
+(defun gdb-frame-inferior-io-buffer ()
+ "Display IO of inferior in a new frame."
+ (interactive)
+ (if gdb-use-inferior-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)))))
+
(defvar gdb-inferior-io-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt)
(define-key map "\C-c\C-z" 'gdb-inferior-io-stop)
(define-key map "\C-c\C-\\" 'gdb-inferior-io-quit)
(define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
+ (define-key map "\C-d" 'gdb-inferior-io-eof)
map))
(define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
(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
("post-prompt" gdb-post-prompt)
("source" gdb-source)
("starting" gdb-starting)
- ("exited" gdb-stopping)
- ("signalled" gdb-stopping)
+ ("exited" gdb-exited)
+ ("signalled" gdb-exited)
("signal" gdb-stopping)
("breakpoint" gdb-stopping)
("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()
(setq gdb-prompting t))
(defconst gdb-source-spec-regexp
- "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
+ "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:0x0*\\([a-f0-9]*\\)")
;; Do not use this except as an annotation handler.
(defun gdb-source (args)
(setq gud-last-frame
(cons
(match-string 1 args)
- (string-to-int (match-string 2 args))))
- (setq gdb-current-address (match-string 3 args))
+ (string-to-number (match-string 2 args))))
+ (setq gdb-frame-address (match-string 3 args))
;; cover for auto-display output which comes *before*
;; stopped annotation
(if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
"An annotation handler for `starting'.
This says that I/O for the subprocess is now the program being debugged,
not GDB."
+ (setq gdb-active-process t)
(let ((sink gdb-output-sink))
(cond
((eq sink 'user)
(error "Unexpected `starting' annotation")))))
(defun gdb-stopping (ignored)
- "An annotation handler for `exited' and other annotations.
+ "An annotation handler for `breakpoint' and other annotations.
They say that I/O for the subprocess is now GDB, not the program
being debugged."
(if gdb-use-inferior-io-buffer
(gdb-resync)
(error "Unexpected stopping annotation"))))))
+(defun gdb-exited (ignored)
+ "An annotation handler for `exited' and `signalled'.
+They say that I/O for the subprocess is now GDB, not the program
+being debugged and that the program is no longer running. This
+function is used to change the focus of GUD tooltips to #define
+directives."
+ (setq gdb-active-process nil)
+ (gdb-stopping ignored))
+
(defun gdb-frame-begin (ignored)
(let ((sink gdb-output-sink))
(cond
(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-current-frame)
- (gdb-invalidate-frames)
- (gdb-invalidate-breakpoints)
- (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)
(match-beginning 0))))
;;
;; Everything after, we save, to combine with later input.
- (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0))))
+ (setq gud-marker-acc (substring gud-marker-acc
+ (match-beginning 0))))
;;
;; In case we know the gud-marker-acc contains no partial annotations:
(progn
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))
;; annotation rule binding of whatever gdb sends to tell us this command
;; might have changed it's output.
;;
-;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
+;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
;; input in the input queue (see comment about ``gdb communications'' above).
(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)))
-(defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command
- output-handler-name custom-defun)
+(defmacro def-gdb-auto-updated-buffer (buffer-key
+ trigger-name gdb-command
+ output-handler-name custom-defun)
`(progn
(def-gdb-auto-update-trigger ,trigger-name
;; The demand predicate:
"\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))
(defface breakpoint-enabled
- ;; On ttys, we don't inherit from the `fringe' face because that
- ;; doesn't seem to do the right thing in some cases (?), whereas
- ;; it's required on non-tty displays to get the background right.
- '((((type tty))
- :weight bold
- :foreground "red")
- (t
- :weight bold
+ '((t
:foreground "red"
- :inherit fringe))
+ :weight bold))
"Face for enabled breakpoint icon in fringe."
:group 'gud)
;; compatibility alias for old name
(defface breakpoint-disabled
;; We use different values of grey for different background types,
;; so that on low-color displays it will end up as something visible
- ;; if it has to be approximated. On ttys, we don't inherit from the
- ;; `fringe' face because that doesn't seem to do the right thing in
- ;; some cases (?), whereas it's required on non-tty displays to get
- ;; the background right.
- '((((type tty) (background dark))
- :foreground "grey60")
- (((type tty) (background light))
- :foreground "grey40")
- (((background dark))
- :foreground "grey60"
- :inherit fringe)
- (((background light))
- :foreground "grey40"
- :inherit fringe))
+ ;; if it has to be approximated.
+ '((((background dark)) :foreground "grey60")
+ (((background light)) :foreground "grey40"))
"Face for disabled breakpoint icon in fringe."
:group 'gud)
;; compatibility alias for old name
(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))
(looking-at "\\(\\S-+\\):\\([0-9]+\\)")
(let ((line (match-string 2)) (buffer-read-only nil)
(file (match-string 1)))
- (add-text-properties (point-at-bol) (point-at-eol)
+ (add-text-properties (line-beginning-position)
+ (line-end-position)
'(mouse-face highlight
help-echo "mouse-2, RET: visit breakpoint"))
(unless (file-exists-p file)
- (setq file (cdr (assoc bptno gdb-location-list))))
- (unless (string-equal file "File not found")
- (if file
- (with-current-buffer (find-file-noselect file)
- (set (make-local-variable 'gud-minor-mode)
- 'gdba)
- (set (make-local-variable 'tool-bar-map)
- gud-tool-bar-map)
- ;; only want one breakpoint icon at each location
- (save-excursion
- (goto-line (string-to-number line))
- (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
- (gdb-enqueue-input
- (list (concat "list "
- (match-string-no-properties 1) ":1\n")
- 'ignore))
- (gdb-enqueue-input
- (list "info source\n"
- `(lambda () (gdb-get-location
- ,bptno ,line ,flag)))))))))))
+ (setq file (cdr (assoc bptno gdb-location-alist))))
+ (if (and file
+ (not (string-equal file "File not found")))
+ (with-current-buffer (find-file-noselect file)
+ (set (make-local-variable 'gud-minor-mode)
+ 'gdba)
+ (set (make-local-variable 'tool-bar-map)
+ gud-tool-bar-map)
+ ;; only want one breakpoint icon at each
+ ;; location
+ (save-excursion
+ (goto-line (string-to-number line))
+ (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
+ (gdb-enqueue-input
+ (list
+ (concat "list "
+ (match-string-no-properties 1) ":1\n")
+ 'ignore))
+ (gdb-enqueue-input
+ (list "info source\n"
+ `(lambda () (gdb-get-location
+ ,bptno ,line ,flag))))))))))
(end-of-line)))))
(if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
(defvar gdb-breakpoints-mode-map
(let ((map (make-sparse-keymap))
(menu (make-sparse-keymap "Breakpoints")))
- (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
- (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
+ (define-key menu [quit] '("Quit" . kill-this-buffer))
(define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
-
+ (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
+ (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
(suppress-keymap map)
(define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
(define-key map " " 'gdb-toggle-breakpoint)
(define-key map "q" 'kill-this-buffer)
(define-key map "\r" 'gdb-goto-breakpoint)
(define-key map [mouse-2] 'gdb-goto-breakpoint)
+ (define-key map [follow-link] 'mouse-face)
map))
(defun gdb-breakpoints-mode ()
(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)))
(save-selected-window
- (let* ((buf (find-file-noselect (if (file-exists-p file)
- file
- (cdr (assoc bptno gdb-location-list)))))
+ (let* ((buf (find-file-noselect
+ (if (file-exists-p file) file
+ (cdr (assoc bptno gdb-location-alist)))))
(window (display-buffer buf)))
(with-current-buffer buf
(goto-line (string-to-number line))
(let ((buffer-read-only nil))
(goto-char (point-min))
(while (< (point) (point-max))
- (add-text-properties (point-at-bol) (point-at-eol)
+ (add-text-properties (line-beginning-position) (line-end-position)
'(mouse-face highlight
help-echo "mouse-2, RET: Select frame"))
(beginning-of-line)
(when (and (looking-at "^#\\([0-9]+\\)")
- (equal (match-string 1) gdb-current-stack-level))
- (put-text-property (point-at-bol) (point-at-eol)
+ (equal (match-string 1) gdb-frame-number))
+ (put-text-property (line-beginning-position) (line-end-position)
'face '(:inverse-video t)))
(forward-line 1))))))
(define-key map "q" 'kill-this-buffer)
(define-key map "\r" 'gdb-frames-select)
(define-key map [mouse-2] 'gdb-frames-select)
+ (define-key map [follow-link] 'mouse-face)
map))
(defun gdb-frames-mode ()
(interactive (list last-input-event))
(if event (mouse-set-point event))
(gdb-enqueue-input
- (list (concat gdb-server-prefix "frame " (gdb-get-frame-number) "\n") 'ignore))
+ (list (concat gdb-server-prefix "frame "
+ (gdb-get-frame-number) "\n") 'ignore))
(gud-display-frame))
\f
(let ((buffer-read-only nil))
(goto-char (point-min))
(while (< (point) (point-max))
- (add-text-properties (point-at-bol) (point-at-eol)
+ (add-text-properties (line-beginning-position) (line-end-position)
'(mouse-face highlight
help-echo "mouse-2, RET: select thread"))
(forward-line 1)))))
;; Registers buffer.
;;
+(defcustom gdb-all-registers nil
+ "Non-nil means include floating-point registers."
+ :type 'boolean
+ :group 'gud
+ :version "22.1")
+
(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
- (concat gdb-server-prefix "info registers\n")
+ (concat
+ gdb-server-prefix "info " (if gdb-all-registers "all-") "registers\n")
gdb-info-registers-handler
gdb-info-registers-custom)
(defvar gdb-registers-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
+ (define-key map " " 'toggle-gdb-all-registers)
(define-key map "q" 'kill-this-buffer)
map))
\\{gdb-registers-mode-map}"
(kill-all-local-variables)
(setq major-mode 'gdb-registers-mode)
- (setq mode-name "Registers")
+ (setq mode-name "Registers:")
(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
(special-display-frame-alist gdb-frame-parameters))
(display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
+(defun toggle-gdb-all-registers ()
+ "Toggle the display of floating-point registers."
+ (interactive)
+ (if gdb-all-registers
+ (progn
+ (setq gdb-all-registers nil)
+ (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
+ (setq mode-name "Registers:")))
+ (setq gdb-all-registers t)
+ (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
+ (setq mode-name "Registers:All")))
+ (gdb-invalidate-registers))
+\f
+
;; Memory buffer.
;;
(defcustom gdb-memory-repeat-count 32
gdb-read-memory-handler
gdb-read-memory-custom)
-(defun gdb-read-memory-custom ())
+(defun gdb-read-memory-custom ()
+ (save-excursion
+ (goto-char (point-min))
+ (if (looking-at "0x[[:xdigit:]]+")
+ (setq gdb-memory-address (match-string 0)))))
(defvar gdb-memory-mode-map
(let ((map (make-sparse-keymap)))
(save-selected-window
(select-window (posn-window (event-start event)))
(let* ((arg (read-from-minibuffer "Repeat count: "))
- (count (string-to-int arg)))
- (if (< count 0)
- (error "Non-negative numbers only")
+ (count (string-to-number arg)))
+ (if (<= count 0)
+ (error "Positive numbers only")
(customize-set-variable 'gdb-memory-repeat-count count)
(gdb-invalidate-memory)))))
(setq header-line-format
'(:eval
(concat
- "Read address: "
+ "Read address["
+ (propertize
+ "-"
+ 'face font-lock-warning-face
+ 'help-echo "mouse-1: Decrement address"
+ 'mouse-face 'mode-line-highlight
+ 'local-map
+ (gdb-make-header-line-mouse-map
+ 'mouse-1
+ #'(lambda () (interactive)
+ (let ((gdb-memory-address
+ ;; let GDB do the arithmetic
+ (concat
+ gdb-memory-address " - "
+ (number-to-string
+ (* gdb-memory-repeat-count
+ (cond ((string= gdb-memory-unit "b") 1)
+ ((string= gdb-memory-unit "h") 2)
+ ((string= gdb-memory-unit "w") 4)
+ ((string= gdb-memory-unit "g") 8)))))))
+ (gdb-invalidate-memory)))))
+ "|"
+ (propertize "+"
+ 'face font-lock-warning-face
+ 'help-echo "mouse-1: Increment address"
+ 'mouse-face 'mode-line-highlight
+ 'local-map (gdb-make-header-line-mouse-map
+ 'mouse-1
+ #'(lambda () (interactive)
+ (let ((gdb-memory-address nil))
+ (gdb-invalidate-memory)))))
+ "]: "
(propertize gdb-memory-address
'face font-lock-warning-face
- 'help-echo (purecopy "mouse-1: Set memory address")
- 'local-map (purecopy (gdb-make-header-line-mouse-map
- 'mouse-1
- #'gdb-memory-set-address)))
+ 'help-echo "mouse-1: Set memory address"
+ 'mouse-face 'mode-line-highlight
+ 'local-map (gdb-make-header-line-mouse-map
+ 'mouse-1
+ #'gdb-memory-set-address))
" Repeat Count: "
(propertize (number-to-string gdb-memory-repeat-count)
'face font-lock-warning-face
- 'help-echo (purecopy "mouse-1: Set repeat count")
- 'local-map (purecopy (gdb-make-header-line-mouse-map
- 'mouse-1
- #'gdb-memory-set-repeat-count)))
+ 'help-echo "mouse-1: Set repeat count"
+ 'mouse-face 'mode-line-highlight
+ 'local-map (gdb-make-header-line-mouse-map
+ 'mouse-1
+ #'gdb-memory-set-repeat-count))
" Display Format: "
(propertize gdb-memory-format
'face font-lock-warning-face
- 'help-echo (purecopy "mouse-3: Select display format")
+ 'help-echo "mouse-3: Select display format"
+ 'mouse-face 'mode-line-highlight
'local-map gdb-memory-format-keymap)
" Unit Size: "
(propertize gdb-memory-unit
'face font-lock-warning-face
- 'help-echo (purecopy "mouse-3: Select unit size")
+ 'help-echo "mouse-3: Select unit size"
+ 'mouse-face 'mode-line-highlight
'local-map gdb-memory-unit-keymap))))
(run-mode-hooks 'gdb-memory-mode-hook)
'gdb-invalidate-memory)
(let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
(with-current-buffer buf
(goto-char (point-min))
- (while (re-search-forward "^ .*\n" nil t)
+ (while (re-search-forward "^[ }].*\n" nil t)
(replace-match "" nil nil))
(goto-char (point-min))
- (while (re-search-forward "{[-0-9, {}\]*\n" nil t)
- (replace-match "(array);\n" nil nil))
+ (while (re-search-forward "{\\(.*=.*\n\\|\n\\)" nil t)
+ (replace-match "(structure);\n" nil nil))
(goto-char (point-min))
- (while (re-search-forward "{.*=.*\n" nil t)
- (replace-match "(structure);\n" nil nil))))
+ (while (re-search-forward "\\s-*{.*\n" nil t)
+ (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 ()
\\{gdb-locals-mode-map}"
(kill-all-local-variables)
(setq major-mode 'gdb-locals-mode)
- (setq mode-name (concat "Locals:" gdb-current-frame))
+ (setq mode-name (concat "Locals:" gdb-selected-frame))
(setq buffer-read-only t)
(use-local-map gdb-locals-mode-map)
(run-mode-hooks 'gdb-locals-mode-hook)
(let ((answer (get-buffer-window buf 0))
(must-split nil))
(if answer
- (display-buffer buf) ;Raise the frame if necessary.
+ (display-buffer buf nil 0) ;Raise the frame if necessary.
;; The buffer is not yet displayed.
(pop-to-buffer gud-comint-buffer) ;Select the right frame.
(let ((window (get-lru-window)))
- (if window
+ (if (and window
+ (not (eq window (get-buffer-window gud-comint-buffer))))
(progn
(set-window-buffer window buf)
(setq answer window))
(let ((menu (make-sparse-keymap "GDB-Windows")))
(define-key gud-menu-map [displays]
- `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba)))
+ `(menu-item "GDB-Windows" ,menu
+ :visible (memq gud-minor-mode '(gdbmi gdba))))
(define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
(define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
(define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
- (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
+ (define-key menu [disassembly]
+ '("Disassembly" . gdb-display-assembler-buffer))
(define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
+ (define-key menu [inferior]
+ '(menu-item "Inferior IO" gdb-display-inferior-io-buffer
+ :enable gdb-use-inferior-io-buffer))
(define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
(define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
- (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
+ (define-key menu [breakpoints]
+ '("Breakpoints" . gdb-display-breakpoints-buffer)))
(let ((menu (make-sparse-keymap "GDB-Frames")))
(define-key gud-menu-map [frames]
- `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
+ `(menu-item "GDB-Frames" ,menu
+ :visible (memq gud-minor-mode '(gdbmi gdba))))
(define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
(define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
(define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
- (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
+ (define-key menu [disassembly] '("Disassembiy" . gdb-frame-assembler-buffer))
(define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
+ (define-key menu [inferior]
+ '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer
+ :enable gdb-use-inferior-io-buffer))
(define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
(define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
- (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)))
+ (define-key menu [breakpoints]
+ '("Breakpoints" . gdb-frame-breakpoints-buffer)))
(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]
- '("Restore Window Layout" . gdb-restore-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."))
(define-key menu [gdb-many-windows]
- (menu-bar-make-toggle gdb-many-windows gdb-many-windows
- "Display Other Windows" "Many windows %s"
- "Toggle display of locals, stack and breakpoint information")))
+ '(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
+ (kill-buffer (gdb-inferior-io-name))))
(defun gdb-frame-gdb-buffer ()
"Display GUD buffer in a new frame."
(gdb-display-buffer
(gdb-get-create-buffer 'gdba)))
-(defvar gdb-main-file nil "Source file from which program execution begins.")
-
-(defcustom gdb-show-main nil
- "Nil means don't display source file containing the main routine."
- :type 'boolean
- :group 'gud
- :version "22.1")
-
(defun gdb-set-window-buffer (name)
(set-window-buffer (selected-window) (get-buffer name))
(set-window-dedicated-p (selected-window) t))
(when gdb-use-inferior-io-buffer
(split-window-horizontally)
(other-window 1)
- (gdb-set-window-buffer (gdb-inferior-io-name)))
+ (gdb-set-window-buffer
+ (gdb-get-create-buffer 'gdb-inferior-io)))
(other-window 1)
(gdb-set-window-buffer (gdb-stack-buffer-name))
(split-window-horizontally)
(gdb-remove-breakpoint-icons (point-min) (point-max) t)
(setq gud-minor-mode nil)
(kill-local-variable 'tool-bar-map)
- (setq gud-running nil))))))
+ (kill-local-variable 'gdb-define-alist))))))
(when (markerp gdb-overlay-arrow-position)
(move-marker gdb-overlay-arrow-position nil)
(setq gdb-overlay-arrow-position nil))
(setq overlay-arrow-variable-list
- (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list)))
+ (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list))
+ (setq gud-running nil)
+ (setq gdb-active-process nil)
+ (remove-hook 'after-save-hook 'gdb-create-define-alist t))
(defun gdb-source-info ()
"Find the source file where the program starts and displays it with related
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)
+ (setq gdb-macro-info t))
(if gdb-many-windows
(gdb-setup-windows)
(gdb-get-create-buffer 'gdb-breakpoints-buffer)
(goto-char (point-min))
(catch 'file-not-found
(if (search-forward "Located in " nil t)
- (if (looking-at "\\S-*")
- (push (cons bptno (match-string 0)) gdb-location-list))
+ (when (looking-at "\\S-+")
+ (delete (cons bptno "File not found") gdb-location-alist)
+ (push (cons bptno (match-string 0)) gdb-location-alist))
(gdb-resync)
- (push (cons bptno "File not found") gdb-location-list)
- (message-box "Cannot find source file for breakpoint location.\n\
-Add directory to search path for source files using the GDB command, dir.")
+ (unless (assoc bptno gdb-location-alist)
+ (push (cons bptno "File not found") gdb-location-alist)
+ (message-box "Cannot find source file for breakpoint location.\n\
+Add directory to search path for source files using the GDB command, dir."))
(throw 'file-not-found nil))
(with-current-buffer
(find-file-noselect (match-string 0))
(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
(unless buffer
(setq buffer (current-buffer)))
(dolist (overlay (overlays-in start end))
- (when (overlay-get overlay 'put-break)
+ (when (overlay-get overlay 'put-break)
(delete-overlay overlay))))
(defun gdb-put-breakpoint-icon (enabled bptno)
- (let ((start (progn (beginning-of-line) (- (point) 1)))
- (end (progn (end-of-line) (+ (point) 1)))
+ (let ((start (- (line-beginning-position) 1))
+ (end (+ (line-end-position) 1))
(putstring (if enabled "B" "b")))
(add-text-properties
0 1 '(help-echo "mouse-1: set/clear bkpt, mouse-3: enable/disable bkpt")
(def-gdb-auto-updated-buffer gdb-assembler-buffer
gdb-invalidate-assembler
- (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
+ (concat gdb-server-prefix "disassemble "
+ (if (member gdb-frame-address '(nil "main")) nil "0x")
+ gdb-frame-address "\n")
gdb-assembler-handler
gdb-assembler-custom)
(let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
(pos 1) (address) (flag) (bptno))
(with-current-buffer buffer
- (if (not (equal gdb-current-address "main"))
- (progn
- (goto-char (point-min))
- (if (re-search-forward gdb-current-address nil t)
- (progn
- (setq pos (point))
- (beginning-of-line)
- (or gdb-overlay-arrow-position
- (setq gdb-overlay-arrow-position (make-marker)))
- (set-marker gdb-overlay-arrow-position
- (point) (current-buffer))))))
- ;; remove all breakpoint-icons in assembler buffer before updating.
- (gdb-remove-breakpoint-icons (point-min) (point-max)))
+ (save-excursion
+ (if (not (equal gdb-frame-address "main"))
+ (progn
+ (goto-char (point-min))
+ (if (and gdb-frame-address
+ (re-search-forward gdb-frame-address nil t))
+ (progn
+ (setq pos (point))
+ (beginning-of-line)
+ (or gdb-overlay-arrow-position
+ (setq gdb-overlay-arrow-position (make-marker)))
+ (set-marker gdb-overlay-arrow-position
+ (point) (current-buffer))))))
+ ;; remove all breakpoint-icons in assembler buffer before updating.
+ (gdb-remove-breakpoint-icons (point-min) (point-max))))
(with-current-buffer (gdb-get-buffer 'gdb-breakpoints-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-+0x\\(\\S-+\\)")
+ "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x0*\\(\\S-+\\)")
(setq bptno (match-string 1))
(setq flag (char-after (match-beginning 2)))
(setq address (match-string 3))
- ;; remove leading 0s from output of info break.
- (if (string-match "^0+\\(.*\\)" address)
- (setq address (match-string 1 address)))
(with-current-buffer buffer
+ (save-excursion
(goto-char (point-min))
(if (re-search-forward address nil t)
- (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))))
- (if (not (equal gdb-current-address "main"))
+ (gdb-put-breakpoint-icon (eq flag ?y) bptno))))))))
+ (if (not (equal gdb-frame-address "main"))
(set-window-point (get-buffer-window buffer 0) pos))))
(defvar gdb-assembler-mode-map
\\{gdb-assembler-mode-map}"
(kill-all-local-variables)
(setq major-mode 'gdb-assembler-mode)
- (setq mode-name "Machine")
+ (setq mode-name (concat "Machine:" gdb-selected-frame))
(setq gdb-overlay-arrow-position nil)
(add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
- (put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>")
(setq fringes-outside-margins t)
(setq buffer-read-only t)
(use-local-map gdb-assembler-mode-map)
(defun gdb-assembler-buffer-name ()
(with-current-buffer gud-comint-buffer
- (concat "*Machine Code " (gdb-get-target-string) "*")))
+ (concat "*Disassembly of " (gdb-get-target-string) "*")))
(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))))
-;; modified because if gdb-current-address has changed value a new command
+;; modified because if gdb-frame-address has changed value a new command
;; must be enqueued to update the buffer with the new output
(defun gdb-invalidate-assembler (&optional ignored)
(if (gdb-get-buffer 'gdb-assembler-buffer)
(progn
- (unless (string-equal gdb-current-frame gdb-previous-frame)
+ (unless (and gdb-selected-frame
+ (string-equal gdb-selected-frame gdb-previous-frame))
(if (or (not (member 'gdb-invalidate-assembler
gdb-pending-triggers))
- (not (string-equal gdb-current-address
- gdb-previous-address)))
+ (not (string-equal gdb-frame-address
+ gdb-previous-frame-address)))
(progn
- ;; take previous disassemble command off the queue
+ ;; take previous disassemble command, if any, off the queue
(with-current-buffer gud-comint-buffer
(let ((queue gdb-input-queue))
(dolist (item queue)
(setq gdb-input-queue
(delete item gdb-input-queue))))))
(gdb-enqueue-input
- (list (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
+ (list
+ (concat gdb-server-prefix "disassemble "
+ (if (member gdb-frame-address '(nil "main")) nil "0x")
+ gdb-frame-address "\n")
'gdb-assembler-handler))
(push 'gdb-invalidate-assembler gdb-pending-triggers)
- (setq gdb-previous-address gdb-current-address)
- (setq gdb-previous-frame gdb-current-frame)))))))
+ (setq gdb-previous-frame-address gdb-frame-address)
+ (setq gdb-previous-frame gdb-selected-frame)))))))
-(defun gdb-get-current-frame ()
- (if (not (member 'gdb-get-current-frame gdb-pending-triggers))
+(defun gdb-get-selected-frame ()
+ (if (not (member 'gdb-get-selected-frame gdb-pending-triggers))
(progn
(gdb-enqueue-input
(list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
- (push 'gdb-get-current-frame
+ (push 'gdb-get-selected-frame
gdb-pending-triggers))))
(defun gdb-frame-handler ()
(setq gdb-pending-triggers
- (delq 'gdb-get-current-frame gdb-pending-triggers))
+ (delq 'gdb-get-selected-frame gdb-pending-triggers))
(with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
(goto-char (point-min))
- (if (looking-at "Stack level \\([0-9]+\\)")
- (setq gdb-current-stack-level (match-string 1)))
- (forward-line)
- (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
+ (if (re-search-forward "Stack level \\([0-9]+\\)" nil t)
+ (setq gdb-frame-number (match-string 1)))
+ (goto-char (point-min))
+ (if (re-search-forward
+ ".*=\\s-+0x0*\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? " nil t)
(progn
- (setq gdb-current-frame (match-string 2))
+ (setq gdb-selected-frame (match-string 2))
(if (gdb-get-buffer 'gdb-locals-buffer)
(with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
- (setq mode-name (concat "Locals:" gdb-current-frame))))
- (let ((address (match-string 1)))
- ;; remove leading 0s from output of info frame command.
- (if (string-match "^0+\\(.*\\)" address)
- (setq gdb-current-address
- (concat "0x" (match-string 1 address)))
- (setq gdb-current-address (concat "0x" address))))
- (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t))
- ;;update with new frame for machine code if necessary
- (gdb-invalidate-assembler)))))
+ (setq mode-name (concat "Locals:" gdb-selected-frame))))
+ (if (gdb-get-buffer 'gdb-assembler-buffer)
+ (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer)
+ (setq mode-name (concat "Machine:" gdb-selected-frame))))
+ (setq gdb-frame-address (match-string 1))))
+ (goto-char (point-min))
(if (re-search-forward " source language \\(\\S-*\\)\." nil t)
(setq gdb-current-language (match-string 1))))
+ (gdb-invalidate-assembler))
(provide 'gdb-ui)