comparison lisp/progmodes/gdb-ui.el @ 96444:7830512d2616

(gdb-create-source-file-list): New option. (gdb-init-2): Use it. Don't run gdb-mode-hook again. (gdb-var-list-children-regexp, gdb-var-update-regexp) (gdb-info-breakpoints-custom, gdb-stack-list-frames-regexp) (gdb-var-list-children-regexp-1, gdb-var-update-regexp-1) (gdb-stack-list-locals-regexp): Future proof regexps better.
author Nick Roberts <nickrob@snap.net.nz>
date Tue, 01 Jul 2008 01:57:50 +0000
parents cc30416c6de7
children cd65c90908c4
comparison
equal deleted inserted replaced
96443:10b6d5ab8f11 96444:7830512d2616
364 "Preprocessor flags for `gdb-cpp-define-alist-program'." 364 "Preprocessor flags for `gdb-cpp-define-alist-program'."
365 :type 'string 365 :type 'string
366 :group 'gdb 366 :group 'gdb
367 :version "22.1") 367 :version "22.1")
368 368
369 (defcustom gdb-create-source-file-list t
370 "Non-nil means create a list of files from which the executable was built.
371 Set this to nil if the GUD buffer displays \"initializing...\" in the mode
372 line for a long time when starting, possibly because your executable was
373 built from a large number of files. This allows quicker initialization
374 but means that these files are not automatically enabled for debugging,
375 e.g., you won't be able to click in the fringe to set a breakpoint until
376 execution has already stopped there."
377 :type 'boolean
378 :group 'gdb
379 :version "23.1")
380
369 (defcustom gdb-show-main nil 381 (defcustom gdb-show-main nil
370 "Non-nil means display source file containing the main routine at startup. 382 "Non-nil means display source file containing the main routine at startup.
371 Also display the main routine in the disassembly buffer if present." 383 Also display the main routine in the disassembly buffer if present."
372 :type 'boolean 384 :type 'boolean
373 :group 'gdb 385 :group 'gdb
650 (gdb-enqueue-input (list "set new-console off\n" 'ignore))) 662 (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
651 (gdb-enqueue-input (list "set height 0\n" 'ignore)) 663 (gdb-enqueue-input (list "set height 0\n" 'ignore))
652 (gdb-enqueue-input (list "set width 0\n" 'ignore)) 664 (gdb-enqueue-input (list "set width 0\n" 'ignore))
653 665
654 (if (string-equal gdb-version "pre-6.4") 666 (if (string-equal gdb-version "pre-6.4")
655 (progn 667 (if gdb-create-source-file-list
656 (gdb-enqueue-input (list (concat gdb-server-prefix "info sources\n") 668 (gdb-enqueue-input (list (concat gdb-server-prefix "info sources\n")
657 'gdb-set-gud-minor-mode-existing-buffers)) 669 'gdb-set-gud-minor-mode-existing-buffers))
658 (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-1)) 670 (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-1))
659 (gdb-enqueue-input 671 (gdb-enqueue-input
660 (list "server interpreter mi -data-list-register-names\n" 672 (list "server interpreter mi -data-list-register-names\n"
661 'gdb-get-register-names)) 673 'gdb-get-register-names))
662 ; Needs GDB 6.2 onwards. 674 ; Needs GDB 6.2 onwards.
663 (gdb-enqueue-input 675 (if gdb-create-source-file-list
664 (list "server interpreter mi \"-file-list-exec-source-files\"\n" 676 (gdb-enqueue-input
665 'gdb-set-gud-minor-mode-existing-buffers-1)) 677 (list "server interpreter mi \"-file-list-exec-source-files\"\n"
678 'gdb-set-gud-minor-mode-existing-buffers-1)))
666 (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-2)) 679 (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-2))
667 680
668 ;; Find source file and compilation directory here. 681 ;; Find source file and compilation directory here.
669 ;; Works for C, C++, Fortran and Ada but not Java (GDB 6.4) 682 ;; Works for C, C++, Fortran and Ada but not Java (GDB 6.4)
670 (gdb-enqueue-input (list "server list\n" 'ignore)) 683 (gdb-enqueue-input (list "server list\n" 'ignore))
671 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) 684 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)))
672
673 (run-hooks 'gdb-mode-hook))
674 685
675 (defun gdb-get-version () 686 (defun gdb-get-version ()
676 (goto-char (point-min)) 687 (goto-char (point-min))
677 (if (re-search-forward "Undefined\\( mi\\)* command:" nil t) 688 (if (re-search-forward "Undefined\\( mi\\)* command:" nil t)
678 (setq gdb-version "pre-6.4") 689 (setq gdb-version "pre-6.4")
851 (gdb-enqueue-input 862 (gdb-enqueue-input
852 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n") 863 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n")
853 `(lambda () (gdb-var-list-children-handler ,varnum))))) 864 `(lambda () (gdb-var-list-children-handler ,varnum)))))
854 865
855 (defconst gdb-var-list-children-regexp 866 (defconst gdb-var-list-children-regexp
856 "child={.*?name=\"\\(.*?\\)\",.*?exp=\"\\(.*?\\)\",.*?\ 867 "child={.*?name=\"\\(.*?\\)\".*?,exp=\"\\(.*?\\)\".*?,\
857 numchild=\"\\(.*?\\)\"\\(}\\|,.*?\\(type=\"\\(.*?\\)\"\\)?.*?}\\)") 868 numchild=\"\\(.*?\\)\"\\(}\\|.*?,\\(type=\"\\(.*?\\)\"\\)?.*?}\\)")
858 869
859 (defun gdb-var-list-children-handler (varnum) 870 (defun gdb-var-list-children-handler (varnum)
860 (goto-char (point-min)) 871 (goto-char (point-min))
861 (let ((var-list nil)) 872 (let ((var-list nil))
862 (catch 'child-already-watched 873 (catch 'child-already-watched
889 (list "server interpreter mi \"-var-update *\"\n" 900 (list "server interpreter mi \"-var-update *\"\n"
890 'gdb-var-update-handler)) 901 'gdb-var-update-handler))
891 (push 'gdb-var-update gdb-pending-triggers))) 902 (push 'gdb-var-update gdb-pending-triggers)))
892 903
893 (defconst gdb-var-update-regexp 904 (defconst gdb-var-update-regexp
894 "{.*?name=\"\\(.*?\\)\",.*?in_scope=\"\\(.*?\\)\",.*?\ 905 "{.*?name=\"\\(.*?\\)\".*?,in_scope=\"\\(.*?\\)\".*?,\
895 type_changed=\".*?\".*?}") 906 type_changed=\".*?\".*?}")
896 907
897 (defun gdb-var-update-handler () 908 (defun gdb-var-update-handler ()
898 (dolist (var gdb-var-list) 909 (dolist (var gdb-var-list)
899 (setcar (nthcdr 5 var) nil)) 910 (setcar (nthcdr 5 var) nil))
1958 (when (re-search-forward " in \\(.*\\) at" el t) 1969 (when (re-search-forward " in \\(.*\\) at" el t)
1959 (add-text-properties 1970 (add-text-properties
1960 (match-beginning 1) (match-end 1) 1971 (match-beginning 1) (match-end 1)
1961 '(face font-lock-function-name-face))) 1972 '(face font-lock-function-name-face)))
1962 (if (re-search-forward 1973 (if (re-search-forward
1963 ".*\\s-+\\(\\S-+\\):\\([0-9]+\\)$" nil t) 1974 ".*\\s-+\\(\\S-+\\):\\([0-9]+\\)$" el t)
1964 (let ((line (match-string 2)) 1975 (let ((line (match-string 2))
1965 (file (match-string 1))) 1976 (file (match-string 1)))
1966 (add-text-properties bl el 1977 (add-text-properties bl el
1967 '(mouse-face highlight 1978 '(mouse-face highlight
1968 help-echo "mouse-2, RET: visit breakpoint")) 1979 help-echo "mouse-2, RET: visit breakpoint"))
3636 (gdb-force-mode-line-update 3647 (gdb-force-mode-line-update
3637 (propertize "ready" 'face font-lock-variable-name-face))) 3648 (propertize "ready" 'face font-lock-variable-name-face)))
3638 3649
3639 ;; Used for -stack-info-frame but could be used for -stack-list-frames too. 3650 ;; Used for -stack-info-frame but could be used for -stack-list-frames too.
3640 (defconst gdb-stack-list-frames-regexp 3651 (defconst gdb-stack-list-frames-regexp
3641 ".*?level=\"\\(.*?\\)\",.*?addr=\"\\(.*?\\)\",.*?func=\"\\(.*?\\)\",\ 3652 ".*?level=\"\\(.*?\\)\".*?,addr=\"\\(.*?\\)\".*?,func=\"\\(.*?\\)\",\
3642 \\(?:.*?file=\".*?\",.*?fullname=\"\\(.*?\\)\",.*?line=\"\\(.*?\\)\".*?}\\|\ 3653 \\(?:.*?file=\".*?\".*?,fullname=\"\\(.*?\\)\".*?,line=\"\\(.*?\\)\".*?}\\|\
3643 from=\"\\(.*?\\)\"\\)") 3654 from=\"\\(.*?\\)\"\\)")
3644 3655
3645 (defun gdb-frame-handler-1 () 3656 (defun gdb-frame-handler-1 ()
3646 (setq gdb-pending-triggers 3657 (setq gdb-pending-triggers
3647 (delq 'gdb-get-selected-frame gdb-pending-triggers)) 3658 (delq 'gdb-get-selected-frame gdb-pending-triggers))
3680 varnum "\\\"\"\n") 3691 varnum "\\\"\"\n")
3681 (concat "-var-list-children --all-values \"" varnum "\"\n")) 3692 (concat "-var-list-children --all-values \"" varnum "\"\n"))
3682 `(lambda () (gdb-var-list-children-handler-1 ,varnum))))) 3693 `(lambda () (gdb-var-list-children-handler-1 ,varnum)))))
3683 3694
3684 (defconst gdb-var-list-children-regexp-1 3695 (defconst gdb-var-list-children-regexp-1
3685 "child={.*?name=\"\\(.+?\\)\",.*?exp=\"\\(.+?\\)\",.*?\ 3696 "child={.*?name=\"\\(.+?\\)\".*?,exp=\"\\(.+?\\)\".*?,\
3686 numchild=\"\\(.+?\\)\",.*?value=\\(\".*?\"\\)\ 3697 numchild=\"\\(.+?\\)\".*?,value=\\(\".*?\"\\)\
3687 \\(}\\|,.*?\\(type=\"\\(.+?\\)\"\\)?.*?}\\)") 3698 \\(}\\|.*?,\\(type=\"\\(.+?\\)\"\\)?.*?}\\)")
3688 3699
3689 (defun gdb-var-list-children-handler-1 (varnum) 3700 (defun gdb-var-list-children-handler-1 (varnum)
3690 (goto-char (point-min)) 3701 (goto-char (point-min))
3691 (let ((var-list nil)) 3702 (let ((var-list nil))
3692 (catch 'child-already-watched 3703 (catch 'child-already-watched
3719 "-var-update --all-values *\n") 3730 "-var-update --all-values *\n")
3720 'gdb-var-update-handler-1)) 3731 'gdb-var-update-handler-1))
3721 (push 'gdb-var-update gdb-pending-triggers)))) 3732 (push 'gdb-var-update gdb-pending-triggers))))
3722 3733
3723 (defconst gdb-var-update-regexp-1 3734 (defconst gdb-var-update-regexp-1
3724 "{.*?name=\"\\(.*?\\)\",.*?\\(?:value=\\(\".*?\"\\),\\)?.*?\ 3735 "{.*?name=\"\\(.*?\\)\".*?,\\(?:value=\\(\".*?\"\\),\\)?.*?\
3725 in_scope=\"\\(.*?\\)\".*?}") 3736 in_scope=\"\\(.*?\\)\".*?}")
3726 3737
3727 (defun gdb-var-update-handler-1 () 3738 (defun gdb-var-update-handler-1 ()
3728 (dolist (var gdb-var-list) 3739 (dolist (var gdb-var-list)
3729 (setcar (nthcdr 5 var) nil)) 3740 (setcar (nthcdr 5 var) nil))
3759 "server interpreter mi \"-data-list-register-values x\"\n" 3770 "server interpreter mi \"-data-list-register-values x\"\n"
3760 "-data-list-register-values x\n") 3771 "-data-list-register-values x\n")
3761 gdb-data-list-register-values-handler) 3772 gdb-data-list-register-values-handler)
3762 3773
3763 (defconst gdb-data-list-register-values-regexp 3774 (defconst gdb-data-list-register-values-regexp
3764 "{.*?number=\"\\(.*?\\)\",.*?value=\"\\(.*?\\)\".*?}") 3775 "{.*?number=\"\\(.*?\\)\".*?,value=\"\\(.*?\\)\".*?}")
3765 3776
3766 (defun gdb-data-list-register-values-handler () 3777 (defun gdb-data-list-register-values-handler ()
3767 (setq gdb-pending-triggers (delq 'gdb-invalidate-registers-1 3778 (setq gdb-pending-triggers (delq 'gdb-invalidate-registers-1
3768 gdb-pending-triggers)) 3779 gdb-pending-triggers))
3769 (goto-char (point-min)) 3780 (goto-char (point-min))
3854 "server interpreter mi -\"stack-list-locals --simple-values\"\n" 3865 "server interpreter mi -\"stack-list-locals --simple-values\"\n"
3855 "-stack-list-locals --simple-values\n") 3866 "-stack-list-locals --simple-values\n")
3856 gdb-stack-list-locals-handler) 3867 gdb-stack-list-locals-handler)
3857 3868
3858 (defconst gdb-stack-list-locals-regexp 3869 (defconst gdb-stack-list-locals-regexp
3859 "{.*?name=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\"") 3870 "{.*?name=\"\\(.*?\\)\".*?,type=\"\\(.*?\\)\"")
3860 3871
3861 (defvar gdb-locals-watch-map-1 3872 (defvar gdb-locals-watch-map-1
3862 (let ((map (make-sparse-keymap))) 3873 (let ((map (make-sparse-keymap)))
3863 (suppress-keymap map) 3874 (suppress-keymap map)
3864 (define-key map "\r" 'gud-watch) 3875 (define-key map "\r" 'gud-watch)
3881 (if event (posn-set-point (event-end event))) 3892 (if event (posn-set-point (event-end event)))
3882 (beginning-of-line) 3893 (beginning-of-line)
3883 (let* ((var (current-word)) 3894 (let* ((var (current-word))
3884 (value (read-string (format "New value (%s): " var)))) 3895 (value (read-string (format "New value (%s): " var))))
3885 (gdb-enqueue-input 3896 (gdb-enqueue-input
3886 (list (concat gdb-server-prefix"set variable " var " = " value "\n") 3897 (list (concat gdb-server-prefix "set variable " var " = " value "\n")
3887 'ignore))))) 3898 'ignore)))))
3888 3899
3889 ;; Dont display values of arrays or structures. 3900 ;; Dont display values of arrays or structures.
3890 ;; These can be expanded using gud-watch. 3901 ;; These can be expanded using gud-watch.
3891 (defun gdb-stack-list-locals-handler () 3902 (defun gdb-stack-list-locals-handler ()