diff options
| author | Nick Roberts | 2003-12-28 13:52:38 +0000 |
|---|---|---|
| committer | Nick Roberts | 2003-12-28 13:52:38 +0000 |
| commit | 486f00c0490780e52cf09742e1546229473d8629 (patch) | |
| tree | c9a2c049763b9442ad080e4ff72a94c50d239438 | |
| parent | d7af32300b2a92ddcececa2f36dd94d46caaaf0e (diff) | |
| download | emacs-486f00c0490780e52cf09742e1546229473d8629.tar.gz emacs-486f00c0490780e52cf09742e1546229473d8629.zip | |
(gdb-prompt): Change filter for level 3 annotations,
if necessary.
(gdb-ann3): New function. Initialise M-x gdb as for M-x gdba if
annotations are detected.
(gud-gdba-marker-filter): Use global variable gud-marker-acc
instead of a local one to allow transition from
gud-gdb-marker-filter.
Remove trailing white space.
| -rw-r--r-- | lisp/gdb-ui.el | 151 |
1 files changed, 107 insertions, 44 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el index 2c9b3390b58..9a1e112b02a 100644 --- a/lisp/gdb-ui.el +++ b/lisp/gdb-ui.el | |||
| @@ -42,8 +42,8 @@ | |||
| 42 | ;; info manual. Some GDB/MI commands are also used through th CLI command | 42 | ;; info manual. Some GDB/MI commands are also used through th CLI command |
| 43 | ;; 'interpreter mi <mi-command>'. | 43 | ;; 'interpreter mi <mi-command>'. |
| 44 | ;; | 44 | ;; |
| 45 | ;; Known Bugs: | 45 | ;; Known Bugs: |
| 46 | ;; | 46 | ;; |
| 47 | 47 | ||
| 48 | ;;; Code: | 48 | ;;; Code: |
| 49 | 49 | ||
| @@ -144,8 +144,10 @@ The following interactive lisp functions help control operation : | |||
| 144 | (gud-call "until *%a" arg))) | 144 | (gud-call "until *%a" arg))) |
| 145 | "\C-u" "Continue to current line or address.") | 145 | "\C-u" "Continue to current line or address.") |
| 146 | 146 | ||
| 147 | (define-key gud-minor-mode-map [left-margin mouse-1] 'gdb-mouse-toggle-breakpoint) | 147 | (define-key gud-minor-mode-map [left-margin mouse-1] |
| 148 | (define-key gud-minor-mode-map [left-fringe mouse-1] 'gdb-mouse-toggle-breakpoint) | 148 | 'gdb-mouse-toggle-breakpoint) |
| 149 | (define-key gud-minor-mode-map [left-fringe mouse-1] | ||
| 150 | 'gdb-mouse-toggle-breakpoint) | ||
| 149 | 151 | ||
| 150 | (setq comint-input-sender 'gdb-send) | 152 | (setq comint-input-sender 'gdb-send) |
| 151 | ;; | 153 | ;; |
| @@ -158,6 +160,7 @@ The following interactive lisp functions help control operation : | |||
| 158 | (setq gdb-selected-view 'source) | 160 | (setq gdb-selected-view 'source) |
| 159 | (setq gdb-var-list nil) | 161 | (setq gdb-var-list nil) |
| 160 | (setq gdb-var-changed nil) | 162 | (setq gdb-var-changed nil) |
| 163 | (setq gdb-first-pre-prompt nil) | ||
| 161 | ;; | 164 | ;; |
| 162 | (mapc 'make-local-variable gdb-variables) | 165 | (mapc 'make-local-variable gdb-variables) |
| 163 | (setq gdb-buffer-type 'gdba) | 166 | (setq gdb-buffer-type 'gdba) |
| @@ -184,7 +187,7 @@ speedbar." | |||
| 184 | "Watch expression at point." | 187 | "Watch expression at point." |
| 185 | (interactive) | 188 | (interactive) |
| 186 | (let ((expr (tooltip-identifier-from-point (point)))) | 189 | (let ((expr (tooltip-identifier-from-point (point)))) |
| 187 | (if (and (string-equal gdb-current-language "c") | 190 | (if (and (string-equal gdb-current-language "c") |
| 188 | gdb-use-colon-colon-notation) | 191 | gdb-use-colon-colon-notation) |
| 189 | (setq expr (concat gdb-current-frame "::" expr))) | 192 | (setq expr (concat gdb-current-frame "::" expr))) |
| 190 | (catch 'already-watched | 193 | (catch 'already-watched |
| @@ -212,9 +215,9 @@ speedbar." | |||
| 212 | (speedbar 1) | 215 | (speedbar 1) |
| 213 | (if (equal (nth 2 var) "0") | 216 | (if (equal (nth 2 var) "0") |
| 214 | (gdb-enqueue-input | 217 | (gdb-enqueue-input |
| 215 | (list (concat "server interpreter mi \"-var-evaluate-expression " | 218 | (list (concat "server interpreter mi \"-var-evaluate-expression " |
| 216 | (nth 1 var) "\"\n") | 219 | (nth 1 var) "\"\n") |
| 217 | `(lambda () (gdb-var-evaluate-expression-handler | 220 | `(lambda () (gdb-var-evaluate-expression-handler |
| 218 | ,(nth 1 var) nil)))) | 221 | ,(nth 1 var) nil)))) |
| 219 | (setq gdb-var-changed t))) | 222 | (setq gdb-var-changed t))) |
| 220 | (if (re-search-forward "Undefined command" nil t) | 223 | (if (re-search-forward "Undefined command" nil t) |
| @@ -267,11 +270,11 @@ speedbar." | |||
| 267 | (push varchild var-list) | 270 | (push varchild var-list) |
| 268 | (if (equal (nth 2 varchild) "0") | 271 | (if (equal (nth 2 varchild) "0") |
| 269 | (gdb-enqueue-input | 272 | (gdb-enqueue-input |
| 270 | (list | 273 | (list |
| 271 | (concat | 274 | (concat |
| 272 | "server interpreter mi \"-var-evaluate-expression " | 275 | "server interpreter mi \"-var-evaluate-expression " |
| 273 | (nth 1 varchild) "\"\n") | 276 | (nth 1 varchild) "\"\n") |
| 274 | `(lambda () (gdb-var-evaluate-expression-handler | 277 | `(lambda () (gdb-var-evaluate-expression-handler |
| 275 | ,(nth 1 varchild) nil)))))))) | 278 | ,(nth 1 varchild) nil)))))))) |
| 276 | (push var var-list))) | 279 | (push var var-list))) |
| 277 | (setq gdb-var-list (nreverse var-list)))))) | 280 | (setq gdb-var-list (nreverse var-list)))))) |
| @@ -279,7 +282,7 @@ speedbar." | |||
| 279 | (defun gdb-var-update () | 282 | (defun gdb-var-update () |
| 280 | (if (not (member 'gdb-var-update (gdb-get-pending-triggers))) | 283 | (if (not (member 'gdb-var-update (gdb-get-pending-triggers))) |
| 281 | (progn | 284 | (progn |
| 282 | (gdb-enqueue-input (list "server interpreter mi \"-var-update *\"\n" | 285 | (gdb-enqueue-input (list "server interpreter mi \"-var-update *\"\n" |
| 283 | 'gdb-var-update-handler)) | 286 | 'gdb-var-update-handler)) |
| 284 | (gdb-set-pending-triggers (cons 'gdb-var-update | 287 | (gdb-set-pending-triggers (cons 'gdb-var-update |
| 285 | (gdb-get-pending-triggers)))))) | 288 | (gdb-get-pending-triggers)))))) |
| @@ -292,9 +295,9 @@ speedbar." | |||
| 292 | (while (re-search-forward gdb-var-update-regexp nil t) | 295 | (while (re-search-forward gdb-var-update-regexp nil t) |
| 293 | (let ((varnum (match-string 1))) | 296 | (let ((varnum (match-string 1))) |
| 294 | (gdb-enqueue-input | 297 | (gdb-enqueue-input |
| 295 | (list (concat "server interpreter mi \"-var-evaluate-expression " | 298 | (list (concat "server interpreter mi \"-var-evaluate-expression " |
| 296 | varnum "\"\n") | 299 | varnum "\"\n") |
| 297 | `(lambda () (gdb-var-evaluate-expression-handler | 300 | `(lambda () (gdb-var-evaluate-expression-handler |
| 298 | ,varnum t))))))) | 301 | ,varnum t))))))) |
| 299 | (gdb-set-pending-triggers | 302 | (gdb-set-pending-triggers |
| 300 | (delq 'gdb-var-update (gdb-get-pending-triggers)))) | 303 | (delq 'gdb-var-update (gdb-get-pending-triggers)))) |
| @@ -683,6 +686,9 @@ output from a previous command if that happens to be in effect." | |||
| 683 | (defun gdb-prompt (ignored) | 686 | (defun gdb-prompt (ignored) |
| 684 | "An annotation handler for `prompt'. | 687 | "An annotation handler for `prompt'. |
| 685 | This sends the next command (if any) to gdb." | 688 | This sends the next command (if any) to gdb." |
| 689 | (when gdb-first-pre-prompt | ||
| 690 | (gdb-ann3) | ||
| 691 | (setq gdb-first-pre-prompt nil)) | ||
| 686 | (let ((sink (gdb-get-output-sink))) | 692 | (let ((sink (gdb-get-output-sink))) |
| 687 | (cond | 693 | (cond |
| 688 | ((eq sink 'user) t) | 694 | ((eq sink 'user) t) |
| @@ -702,6 +708,66 @@ This sends the next command (if any) to gdb." | |||
| 702 | (gdb-set-prompting t) | 708 | (gdb-set-prompting t) |
| 703 | (gud-display-frame))))) | 709 | (gud-display-frame))))) |
| 704 | 710 | ||
| 711 | (defun gdb-ann3 () | ||
| 712 | (set (make-local-variable 'gud-minor-mode) 'gdba) | ||
| 713 | (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter) | ||
| 714 | ;; | ||
| 715 | (gud-def gud-break (if (not (string-equal mode-name "Machine")) | ||
| 716 | (gud-call "break %f:%l" arg) | ||
| 717 | (save-excursion | ||
| 718 | (beginning-of-line) | ||
| 719 | (forward-char 2) | ||
| 720 | (gud-call "break *%a" arg))) | ||
| 721 | "\C-b" "Set breakpoint at current line or address.") | ||
| 722 | ;; | ||
| 723 | (gud-def gud-remove (if (not (string-equal mode-name "Machine")) | ||
| 724 | (gud-call "clear %f:%l" arg) | ||
| 725 | (save-excursion | ||
| 726 | (beginning-of-line) | ||
| 727 | (forward-char 2) | ||
| 728 | (gud-call "clear *%a" arg))) | ||
| 729 | "\C-d" "Remove breakpoint at current line or address.") | ||
| 730 | ;; | ||
| 731 | (gud-def gud-until (if (not (string-equal mode-name "Machine")) | ||
| 732 | (gud-call "until %f:%l" arg) | ||
| 733 | (save-excursion | ||
| 734 | (beginning-of-line) | ||
| 735 | (forward-char 2) | ||
| 736 | (gud-call "until *%a" arg))) | ||
| 737 | "\C-u" "Continue to current line or address.") | ||
| 738 | |||
| 739 | (define-key gud-minor-mode-map [left-margin mouse-1] | ||
| 740 | 'gdb-mouse-toggle-breakpoint) | ||
| 741 | (define-key gud-minor-mode-map [left-fringe mouse-1] | ||
| 742 | 'gdb-mouse-toggle-breakpoint) | ||
| 743 | |||
| 744 | (setq comint-input-sender 'gdb-send) | ||
| 745 | ;; | ||
| 746 | ;; (re-)initialise | ||
| 747 | (setq gdb-current-address "main") | ||
| 748 | (setq gdb-previous-address nil) | ||
| 749 | (setq gdb-previous-frame nil) | ||
| 750 | (setq gdb-current-frame "main") | ||
| 751 | (setq gdb-view-source t) | ||
| 752 | (setq gdb-selected-view 'source) | ||
| 753 | (setq gdb-var-list nil) | ||
| 754 | (setq gdb-var-changed nil) | ||
| 755 | ;; | ||
| 756 | (mapc 'make-local-variable gdb-variables) | ||
| 757 | (setq gdb-buffer-type 'gdba) | ||
| 758 | ;; | ||
| 759 | (gdb-clear-inferior-io) | ||
| 760 | ;; | ||
| 761 | (if (eq window-system 'w32) | ||
| 762 | (gdb-enqueue-input (list "set new-console off\n" 'ignore))) | ||
| 763 | (gdb-enqueue-input (list "set height 0\n" 'ignore)) | ||
| 764 | ;; find source file and compilation directory here | ||
| 765 | (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program | ||
| 766 | (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program | ||
| 767 | (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) | ||
| 768 | ;; | ||
| 769 | (run-hooks 'gdba-mode-hook)) | ||
| 770 | |||
| 705 | (defun gdb-subprompt (ignored) | 771 | (defun gdb-subprompt (ignored) |
| 706 | "An annotation handler for non-top-level prompts." | 772 | "An annotation handler for non-top-level prompts." |
| 707 | (gdb-set-prompting t)) | 773 | (gdb-set-prompting t)) |
| @@ -775,15 +841,14 @@ output from the current command if that happens to be appropriate." | |||
| 775 | 841 | ||
| 776 | (defun gud-gdba-marker-filter (string) | 842 | (defun gud-gdba-marker-filter (string) |
| 777 | "A gud marker filter for gdb. Handle a burst of output from GDB." | 843 | "A gud marker filter for gdb. Handle a burst of output from GDB." |
| 778 | (let ( | 844 | ;; Recall the left over gud-marker-acc from last time |
| 779 | ;; Recall the left over burst from last time | 845 | (setq gud-marker-acc (concat gud-marker-acc string)) |
| 780 | (burst (concat (gdb-get-burst) string)) | 846 | ;; Start accumulating output for the GUD buffer |
| 781 | ;; Start accumulating output for the GUD buffer | 847 | (let ((output "")) |
| 782 | (output "")) | ||
| 783 | ;; | 848 | ;; |
| 784 | ;; Process all the complete markers in this chunk. | 849 | ;; Process all the complete markers in this chunk. |
| 785 | (while (string-match "\n\032\032\\(.*\\)\n" burst) | 850 | (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) |
| 786 | (let ((annotation (match-string 1 burst))) | 851 | (let ((annotation (match-string 1 gud-marker-acc))) |
| 787 | ;; | 852 | ;; |
| 788 | ;; Stuff prior to the match is just ordinary output. | 853 | ;; Stuff prior to the match is just ordinary output. |
| 789 | ;; It is either concatenated to OUTPUT or directed | 854 | ;; It is either concatenated to OUTPUT or directed |
| @@ -791,11 +856,11 @@ output from the current command if that happens to be appropriate." | |||
| 791 | (setq output | 856 | (setq output |
| 792 | (gdb-concat-output | 857 | (gdb-concat-output |
| 793 | output | 858 | output |
| 794 | (substring burst 0 (match-beginning 0)))) | 859 | (substring gud-marker-acc 0 (match-beginning 0)))) |
| 795 | 860 | ;; | |
| 796 | ;; Take that stuff off the burst. | 861 | ;; Take that stuff off the gud-marker-acc. |
| 797 | (setq burst (substring burst (match-end 0))) | 862 | (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) |
| 798 | 863 | ;; | |
| 799 | ;; Parse the tag from the annotation, and maybe its arguments. | 864 | ;; Parse the tag from the annotation, and maybe its arguments. |
| 800 | (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) | 865 | (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) |
| 801 | (let* ((annotation-type (match-string 1 annotation)) | 866 | (let* ((annotation-type (match-string 1 annotation)) |
| @@ -812,25 +877,23 @@ output from the current command if that happens to be appropriate." | |||
| 812 | )))) | 877 | )))) |
| 813 | ;; | 878 | ;; |
| 814 | ;; Does the remaining text end in a partial line? | 879 | ;; Does the remaining text end in a partial line? |
| 815 | ;; If it does, then keep part of the burst until we get more. | 880 | ;; If it does, then keep part of the gud-marker-acc until we get more. |
| 816 | (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | 881 | (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" |
| 817 | burst) | 882 | gud-marker-acc) |
| 818 | (progn | 883 | (progn |
| 819 | ;; Everything before the potential marker start can be output. | 884 | ;; Everything before the potential marker start can be output. |
| 820 | (setq output | 885 | (setq output |
| 821 | (gdb-concat-output output | 886 | (gdb-concat-output output |
| 822 | (substring burst 0 (match-beginning 0)))) | 887 | (substring gud-marker-acc 0 |
| 888 | (match-beginning 0)))) | ||
| 823 | ;; | 889 | ;; |
| 824 | ;; Everything after, we save, to combine with later input. | 890 | ;; Everything after, we save, to combine with later input. |
| 825 | (setq burst (substring burst (match-beginning 0)))) | 891 | (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0)))) |
| 826 | ;; | 892 | ;; |
| 827 | ;; In case we know the burst contains no partial annotations: | 893 | ;; In case we know the gud-marker-acc contains no partial annotations: |
| 828 | (progn | 894 | (progn |
| 829 | (setq output (gdb-concat-output output burst)) | 895 | (setq output (gdb-concat-output output gud-marker-acc)) |
| 830 | (setq burst ""))) | 896 | (setq gud-marker-acc ""))) |
| 831 | ;; | ||
| 832 | ;; Save the remaining burst for the next call to this function. | ||
| 833 | (gdb-set-burst burst) | ||
| 834 | output)) | 897 | output)) |
| 835 | 898 | ||
| 836 | (defun gdb-concat-output (so-far new) | 899 | (defun gdb-concat-output (so-far new) |
| @@ -1552,7 +1615,7 @@ the source buffer." | |||
| 1552 | ) | 1615 | ) |
| 1553 | 1616 | ||
| 1554 | (let ((menu (make-sparse-keymap "View"))) | 1617 | (let ((menu (make-sparse-keymap "View"))) |
| 1555 | (define-key gud-menu-map [view] | 1618 | (define-key gud-menu-map [view] |
| 1556 | `(menu-item "View" ,menu :visible (eq gud-minor-mode 'gdba))) | 1619 | `(menu-item "View" ,menu :visible (eq gud-minor-mode 'gdba))) |
| 1557 | ; (define-key menu [both] '(menu-item "Both" gdb-view-both | 1620 | ; (define-key menu [both] '(menu-item "Both" gdb-view-both |
| 1558 | ; :help "Display both source and assembler" | 1621 | ; :help "Display both source and assembler" |
| @@ -1619,7 +1682,7 @@ the source buffer." | |||
| 1619 | (other-window 1) | 1682 | (other-window 1) |
| 1620 | (switch-to-buffer (gdb-locals-buffer-name)) | 1683 | (switch-to-buffer (gdb-locals-buffer-name)) |
| 1621 | (other-window 1) | 1684 | (other-window 1) |
| 1622 | (if (and gdb-view-source | 1685 | (if (and gdb-view-source |
| 1623 | (eq gdb-selected-view 'source)) | 1686 | (eq gdb-selected-view 'source)) |
| 1624 | (switch-to-buffer | 1687 | (switch-to-buffer |
| 1625 | (if gud-last-last-frame | 1688 | (if gud-last-last-frame |
| @@ -1665,7 +1728,7 @@ This arrangement depends on the value of `gdb-many-windows'." | |||
| 1665 | (delete-other-windows) | 1728 | (delete-other-windows) |
| 1666 | (split-window) | 1729 | (split-window) |
| 1667 | (other-window 1) | 1730 | (other-window 1) |
| 1668 | (if (and gdb-view-source | 1731 | (if (and gdb-view-source |
| 1669 | (eq gdb-selected-view 'source)) | 1732 | (eq gdb-selected-view 'source)) |
| 1670 | (switch-to-buffer | 1733 | (switch-to-buffer |
| 1671 | (if gud-last-last-frame | 1734 | (if gud-last-last-frame |
| @@ -1888,7 +1951,7 @@ BUFFER nil or omitted means use the current buffer." | |||
| 1888 | (unless (string-equal gdb-current-frame gdb-previous-frame) | 1951 | (unless (string-equal gdb-current-frame gdb-previous-frame) |
| 1889 | (if (or (not (member 'gdb-invalidate-assembler | 1952 | (if (or (not (member 'gdb-invalidate-assembler |
| 1890 | (gdb-get-pending-triggers))) | 1953 | (gdb-get-pending-triggers))) |
| 1891 | (not (string-equal gdb-current-address | 1954 | (not (string-equal gdb-current-address |
| 1892 | gdb-previous-address))) | 1955 | gdb-previous-address))) |
| 1893 | (progn | 1956 | (progn |
| 1894 | ;; take previous disassemble command off the queue | 1957 | ;; take previous disassemble command off the queue |
| @@ -1896,7 +1959,7 @@ BUFFER nil or omitted means use the current buffer." | |||
| 1896 | (let ((queue (gdb-get-input-queue)) (item)) | 1959 | (let ((queue (gdb-get-input-queue)) (item)) |
| 1897 | (dolist (item queue) | 1960 | (dolist (item queue) |
| 1898 | (if (equal (cdr item) '(gdb-assembler-handler)) | 1961 | (if (equal (cdr item) '(gdb-assembler-handler)) |
| 1899 | (gdb-set-input-queue | 1962 | (gdb-set-input-queue |
| 1900 | (delete item (gdb-get-input-queue))))))) | 1963 | (delete item (gdb-get-input-queue))))))) |
| 1901 | (gdb-enqueue-input | 1964 | (gdb-enqueue-input |
| 1902 | (list (concat "server disassemble " gdb-current-address "\n") | 1965 | (list (concat "server disassemble " gdb-current-address "\n") |
| @@ -1928,14 +1991,14 @@ BUFFER nil or omitted means use the current buffer." | |||
| 1928 | (let ((address (match-string 1))) | 1991 | (let ((address (match-string 1))) |
| 1929 | ;; remove leading 0s from output of info frame command. | 1992 | ;; remove leading 0s from output of info frame command. |
| 1930 | (if (string-match "^0+\\(.*\\)" address) | 1993 | (if (string-match "^0+\\(.*\\)" address) |
| 1931 | (setq gdb-current-address | 1994 | (setq gdb-current-address |
| 1932 | (concat "0x" (match-string 1 address))) | 1995 | (concat "0x" (match-string 1 address))) |
| 1933 | (setq gdb-current-address (concat "0x" address)))) | 1996 | (setq gdb-current-address (concat "0x" address)))) |
| 1934 | (if (or (if (not (looking-at ".*(\\S-*:[0-9]*)")) | 1997 | (if (or (if (not (looking-at ".*(\\S-*:[0-9]*)")) |
| 1935 | (progn (setq gdb-view-source nil) t)) | 1998 | (progn (setq gdb-view-source nil) t)) |
| 1936 | (eq gdb-selected-view 'assembler)) | 1999 | (eq gdb-selected-view 'assembler)) |
| 1937 | (progn | 2000 | (progn |
| 1938 | (set-window-buffer | 2001 | (set-window-buffer |
| 1939 | gdb-source-window | 2002 | gdb-source-window |
| 1940 | (gdb-get-create-buffer 'gdb-assembler-buffer)) | 2003 | (gdb-get-create-buffer 'gdb-assembler-buffer)) |
| 1941 | ;;update with new frame for machine code if necessary | 2004 | ;;update with new frame for machine code if necessary |