comparison lisp/progmodes/gdb-ui.el @ 94273:4fad9433957b

(gdb-previous-frame-address): Rename... (gdb-previous-frame-pc-address): ...to this. (gdb-get-selected-frame): Use MI command -stack-info-frame instead of "info frame" with Gdb 6.4+. (gdb-stack-list-frames-regexp): New regexp. (gdb-frame-handler-1): Parse output of -stack-info-frame
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 23 Apr 2008 02:50:24 +0000
parents 37605d9673f1
children ca9efc5939fc
comparison
equal deleted inserted replaced
94272:d861bedec991 94273:4fad9433957b
108 (defvar speedbar-initial-expansion-list-name) 108 (defvar speedbar-initial-expansion-list-name)
109 109
110 (defvar gdb-pc-address nil "Initialization for Assembler buffer. 110 (defvar gdb-pc-address nil "Initialization for Assembler buffer.
111 Set to \"main\" at start if `gdb-show-main' is t.") 111 Set to \"main\" at start if `gdb-show-main' is t.")
112 (defvar gdb-frame-address nil "Identity of frame for watch expression.") 112 (defvar gdb-frame-address nil "Identity of frame for watch expression.")
113 (defvar gdb-previous-frame-address nil) 113 (defvar gdb-previous-frame-pc-address nil)
114 (defvar gdb-memory-address "main") 114 (defvar gdb-memory-address "main")
115 (defvar gdb-previous-frame nil) 115 (defvar gdb-previous-frame nil)
116 (defvar gdb-selected-frame nil) 116 (defvar gdb-selected-frame nil)
117 (defvar gdb-frame-number nil) 117 (defvar gdb-frame-number nil)
118 (defvar gdb-current-language nil) 118 (defvar gdb-current-language nil)
583 (define-key gud-minor-mode-map [left-margin C-mouse-3] 583 (define-key gud-minor-mode-map [left-margin C-mouse-3]
584 'gdb-mouse-jump) 584 'gdb-mouse-jump)
585 585
586 ;; (re-)initialize 586 ;; (re-)initialize
587 (setq gdb-pc-address (if gdb-show-main "main" nil)) 587 (setq gdb-pc-address (if gdb-show-main "main" nil))
588 (setq gdb-previous-frame-address nil 588 (setq gdb-previous-frame-pc-address nil
589 gdb-memory-address "main" 589 gdb-memory-address "main"
590 gdb-previous-frame nil 590 gdb-previous-frame nil
591 gdb-selected-frame nil 591 gdb-selected-frame nil
592 gdb-current-language nil 592 gdb-current-language nil
593 gdb-frame-number nil 593 gdb-frame-number nil
3540 (unless (and gdb-selected-frame 3540 (unless (and gdb-selected-frame
3541 (string-equal gdb-selected-frame gdb-previous-frame)) 3541 (string-equal gdb-selected-frame gdb-previous-frame))
3542 (if (or (not (member 'gdb-invalidate-assembler 3542 (if (or (not (member 'gdb-invalidate-assembler
3543 gdb-pending-triggers)) 3543 gdb-pending-triggers))
3544 (not (string-equal gdb-pc-address 3544 (not (string-equal gdb-pc-address
3545 gdb-previous-frame-address))) 3545 gdb-previous-frame-pc-address)))
3546 (progn 3546 (progn
3547 ;; take previous disassemble command, if any, off the queue 3547 ;; take previous disassemble command, if any, off the queue
3548 (with-current-buffer gud-comint-buffer 3548 (with-current-buffer gud-comint-buffer
3549 (let ((queue gdb-input-queue)) 3549 (let ((queue gdb-input-queue))
3550 (dolist (item queue) 3550 (dolist (item queue)
3556 (concat gdb-server-prefix "disassemble " 3556 (concat gdb-server-prefix "disassemble "
3557 (if (member gdb-pc-address '(nil "main")) nil "0x") 3557 (if (member gdb-pc-address '(nil "main")) nil "0x")
3558 gdb-pc-address "\n") 3558 gdb-pc-address "\n")
3559 'gdb-assembler-handler)) 3559 'gdb-assembler-handler))
3560 (push 'gdb-invalidate-assembler gdb-pending-triggers) 3560 (push 'gdb-invalidate-assembler gdb-pending-triggers)
3561 (setq gdb-previous-frame-address gdb-pc-address) 3561 (setq gdb-previous-frame-pc-address gdb-pc-address)
3562 (setq gdb-previous-frame gdb-selected-frame))))))) 3562 (setq gdb-previous-frame gdb-selected-frame)))))))
3563 3563
3564 (defun gdb-get-selected-frame () 3564 (defun gdb-get-selected-frame ()
3565 (if (not (member 'gdb-get-selected-frame gdb-pending-triggers)) 3565 (if (not (member 'gdb-get-selected-frame gdb-pending-triggers))
3566 (progn 3566 (progn
3567 (gdb-enqueue-input 3567 (if (string-equal gdb-version "pre-6.4")
3568 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler)) 3568 (gdb-enqueue-input
3569 (push 'gdb-get-selected-frame 3569 (list (concat gdb-server-prefix "info frame\n")
3570 gdb-pending-triggers)))) 3570 'gdb-frame-handler))
3571 (gdb-enqueue-input
3572 (list "server interpreter mi -stack-info-frame\n"
3573 'gdb-frame-handler-1)))
3574 (push 'gdb-get-selected-frame gdb-pending-triggers))))
3571 3575
3572 (defun gdb-frame-handler () 3576 (defun gdb-frame-handler ()
3573 (setq gdb-pending-triggers 3577 (setq gdb-pending-triggers
3574 (delq 'gdb-get-selected-frame gdb-pending-triggers)) 3578 (delq 'gdb-get-selected-frame gdb-pending-triggers))
3575 (goto-char (point-min)) 3579 (goto-char (point-min))
3628 (make-local-variable 'gdb-define-alist) 3632 (make-local-variable 'gdb-define-alist)
3629 (gdb-create-define-alist) 3633 (gdb-create-define-alist)
3630 (add-hook 'after-save-hook 'gdb-create-define-alist nil t))))) 3634 (add-hook 'after-save-hook 'gdb-create-define-alist nil t)))))
3631 (gdb-force-mode-line-update 3635 (gdb-force-mode-line-update
3632 (propertize "ready" 'face font-lock-variable-name-face))) 3636 (propertize "ready" 'face font-lock-variable-name-face)))
3637
3638 ;; Used for -stack-info-frame but could be used for -stack-list-frames too.
3639 (defconst gdb-stack-list-frames-regexp
3640 ".*?level=\"\\(.*?\\)\",.*?addr=\"\\(.*?\\)\",.*?func=\"\\(.*?\\)\",\
3641 \\(?:.*?file=\".*?\",.*?fullname=\"\\(.*?\\)\",.*?line=\"\\(.*?\\)\".*?}\\|\
3642 from=\"\\(.*?\\)\"\\)")
3643
3644 (defun gdb-frame-handler-1 ()
3645 (setq gdb-pending-triggers
3646 (delq 'gdb-get-selected-frame gdb-pending-triggers))
3647 (goto-char (point-min))
3648 (when (re-search-forward gdb-stack-list-frames-regexp nil t)
3649 (setq gdb-frame-number (match-string 1))
3650 (setq gdb-pc-address (match-string 2))
3651 (setq gdb-selected-frame (match-string 3))
3652 (if (gdb-get-buffer 'gdb-locals-buffer)
3653 (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
3654 (setq mode-name (concat "Locals:" gdb-selected-frame))))
3655 (if (gdb-get-buffer 'gdb-assembler-buffer)
3656 (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer)
3657 (setq mode-name (concat "Machine:" gdb-selected-frame)))))
3658 (gdb-invalidate-assembler))
3633 3659
3634 ; Uses "-var-list-children --all-values". Needs GDB 6.4 onwards. 3660 ; Uses "-var-list-children --all-values". Needs GDB 6.4 onwards.
3635 (defun gdb-var-list-children-1 (varnum) 3661 (defun gdb-var-list-children-1 (varnum)
3636 (gdb-enqueue-input 3662 (gdb-enqueue-input
3637 (list 3663 (list