diff options
| author | Nick Roberts | 2004-11-22 09:44:23 +0000 |
|---|---|---|
| committer | Nick Roberts | 2004-11-22 09:44:23 +0000 |
| commit | cc615d5a024fe7b43c227f8a3eaad60ab6672180 (patch) | |
| tree | 224ba6ec1ac0ac9512d25a54b96bcb6fc5d4ce52 | |
| parent | 771aad8e44c3c0c3d58cbf01808a9e4a71a1cdfd (diff) | |
| download | emacs-cc615d5a024fe7b43c227f8a3eaad60ab6672180.tar.gz emacs-cc615d5a024fe7b43c227f8a3eaad60ab6672180.zip | |
(gdb-resync): New function.
(gdb-pre-prompt, gdb-prompt, gdb-starting, gdb-stopping)
(gdb-frame-begin, gdb-stopped, gdb-post-prompt):
Use it to fail more gracefully.
(gdb-variables): Delete variable.
Re-order variables to reduce byte-compiler warnings.
| -rw-r--r-- | lisp/progmodes/gdb-ui.el | 156 |
1 files changed, 85 insertions, 71 deletions
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el index 7086e3b0b01..34bc3a33e80 100644 --- a/lisp/progmodes/gdb-ui.el +++ b/lisp/progmodes/gdb-ui.el | |||
| @@ -68,10 +68,48 @@ | |||
| 68 | (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") | 68 | (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") |
| 69 | (defvar gdb-buffer-type nil) | 69 | (defvar gdb-buffer-type nil) |
| 70 | (defvar gdb-overlay-arrow-position nil) | 70 | (defvar gdb-overlay-arrow-position nil) |
| 71 | (defvar gdb-variables '() | ||
| 72 | "A list of variables that are local to the GUD buffer.") | ||
| 73 | (defvar gdb-server-prefix nil) | 71 | (defvar gdb-server-prefix nil) |
| 74 | 72 | ||
| 73 | (defvar gdb-buffer-type nil | ||
| 74 | "One of the symbols bound in `gdb-buffer-rules'.") | ||
| 75 | |||
| 76 | (defvar gdb-input-queue () | ||
| 77 | "A list of gdb command objects.") | ||
| 78 | |||
| 79 | (defvar gdb-prompting nil | ||
| 80 | "True when gdb is idle with no pending input.") | ||
| 81 | |||
| 82 | (defvar gdb-output-sink 'user | ||
| 83 | "The disposition of the output of the current gdb command. | ||
| 84 | Possible values are these symbols: | ||
| 85 | |||
| 86 | `user' -- gdb output should be copied to the GUD buffer | ||
| 87 | for the user to see. | ||
| 88 | |||
| 89 | `inferior' -- gdb output should be copied to the inferior-io buffer | ||
| 90 | |||
| 91 | `pre-emacs' -- output should be ignored util the post-prompt | ||
| 92 | annotation is received. Then the output-sink | ||
| 93 | becomes:... | ||
| 94 | `emacs' -- output should be collected in the partial-output-buffer | ||
| 95 | for subsequent processing by a command. This is the | ||
| 96 | disposition of output generated by commands that | ||
| 97 | gdb mode sends to gdb on its own behalf. | ||
| 98 | `post-emacs' -- ignore output until the prompt annotation is | ||
| 99 | received, then go to USER disposition. | ||
| 100 | |||
| 101 | gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two | ||
| 102 | \(`user' and `emacs').") | ||
| 103 | |||
| 104 | (defvar gdb-current-item nil | ||
| 105 | "The most recent command item sent to gdb.") | ||
| 106 | |||
| 107 | (defvar gdb-pending-triggers '() | ||
| 108 | "A list of trigger functions that have run later than their output | ||
| 109 | handlers.") | ||
| 110 | |||
| 111 | ;; end of gdb variables | ||
| 112 | |||
| 75 | ;;;###autoload | 113 | ;;;###autoload |
| 76 | (defun gdba (command-line) | 114 | (defun gdba (command-line) |
| 77 | "Run gdb on program FILE in buffer *gud-FILE*. | 115 | "Run gdb on program FILE in buffer *gud-FILE*. |
| @@ -197,7 +235,6 @@ detailed description of this mode. | |||
| 197 | (setq gdb-output-sink 'user) | 235 | (setq gdb-output-sink 'user) |
| 198 | (setq gdb-server-prefix "server ") | 236 | (setq gdb-server-prefix "server ") |
| 199 | ;; | 237 | ;; |
| 200 | (mapc 'make-local-variable gdb-variables) | ||
| 201 | (setq gdb-buffer-type 'gdba) | 238 | (setq gdb-buffer-type 'gdba) |
| 202 | ;; | 239 | ;; |
| 203 | (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) | 240 | (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) |
| @@ -412,46 +449,6 @@ INDENT is the current indentation depth." | |||
| 412 | (if (string-match (concat token "\\.") (nth 1 var)) | 449 | (if (string-match (concat token "\\.") (nth 1 var)) |
| 413 | (setq gdb-var-list (delq var gdb-var-list)))) | 450 | (setq gdb-var-list (delq var gdb-var-list)))) |
| 414 | (setq gdb-var-changed t)))) | 451 | (setq gdb-var-changed t)))) |
| 415 | |||
| 416 | (defvar gdb-buffer-type nil | ||
| 417 | "One of the symbols bound in `gdb-buffer-rules'.") | ||
| 418 | |||
| 419 | (defvar gdb-input-queue () | ||
| 420 | "A list of gdb command objects.") | ||
| 421 | |||
| 422 | (defvar gdb-prompting nil | ||
| 423 | "True when gdb is idle with no pending input.") | ||
| 424 | |||
| 425 | (defvar gdb-output-sink 'user | ||
| 426 | "The disposition of the output of the current gdb command. | ||
| 427 | Possible values are these symbols: | ||
| 428 | |||
| 429 | `user' -- gdb output should be copied to the GUD buffer | ||
| 430 | for the user to see. | ||
| 431 | |||
| 432 | `inferior' -- gdb output should be copied to the inferior-io buffer | ||
| 433 | |||
| 434 | `pre-emacs' -- output should be ignored util the post-prompt | ||
| 435 | annotation is received. Then the output-sink | ||
| 436 | becomes:... | ||
| 437 | `emacs' -- output should be collected in the partial-output-buffer | ||
| 438 | for subsequent processing by a command. This is the | ||
| 439 | disposition of output generated by commands that | ||
| 440 | gdb mode sends to gdb on its own behalf. | ||
| 441 | `post-emacs' -- ignore output until the prompt annotation is | ||
| 442 | received, then go to USER disposition. | ||
| 443 | |||
| 444 | gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two | ||
| 445 | \(`user' and `emacs').") | ||
| 446 | |||
| 447 | (defvar gdb-current-item nil | ||
| 448 | "The most recent command item sent to gdb.") | ||
| 449 | |||
| 450 | (defvar gdb-pending-triggers '() | ||
| 451 | "A list of trigger functions that have run later than their output | ||
| 452 | handlers.") | ||
| 453 | |||
| 454 | ;; end of gdb variables | ||
| 455 | 452 | ||
| 456 | (defun gdb-get-target-string () | 453 | (defun gdb-get-target-string () |
| 457 | (with-current-buffer gud-comint-buffer | 454 | (with-current-buffer gud-comint-buffer |
| @@ -644,6 +641,26 @@ This filter may simply queue input for a later time." | |||
| 644 | (let ((last (car (last queue)))) | 641 | (let ((last (car (last queue)))) |
| 645 | (unless (nbutlast queue) (setq gdb-input-queue '())) | 642 | (unless (nbutlast queue) (setq gdb-input-queue '())) |
| 646 | last)))) | 643 | last)))) |
| 644 | |||
| 645 | (defun gdb-send-item (item) | ||
| 646 | (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) | ||
| 647 | (setq gdb-current-item item) | ||
| 648 | (with-current-buffer gud-comint-buffer | ||
| 649 | (if (eq gud-minor-mode 'gdba) | ||
| 650 | (if (stringp item) | ||
| 651 | (progn | ||
| 652 | (setq gdb-output-sink 'user) | ||
| 653 | (process-send-string (get-buffer-process gud-comint-buffer) item)) | ||
| 654 | (progn | ||
| 655 | (gdb-clear-partial-output) | ||
| 656 | (setq gdb-output-sink 'pre-emacs) | ||
| 657 | (process-send-string (get-buffer-process gud-comint-buffer) | ||
| 658 | (car item)))) | ||
| 659 | ;; case: eq gud-minor-mode 'gdbmi | ||
| 660 | (gdb-clear-partial-output) | ||
| 661 | (setq gdb-output-sink 'emacs) | ||
| 662 | (process-send-string (get-buffer-process gud-comint-buffer) | ||
| 663 | (car item))))) | ||
| 647 | 664 | ||
| 648 | ;; | 665 | ;; |
| 649 | ;; output -- things gdb prints to emacs | 666 | ;; output -- things gdb prints to emacs |
| @@ -688,6 +705,13 @@ This filter may simply queue input for a later time." | |||
| 688 | ("stopped" gdb-stopped) | 705 | ("stopped" gdb-stopped) |
| 689 | ) "An assoc mapping annotation tags to functions which process them.") | 706 | ) "An assoc mapping annotation tags to functions which process them.") |
| 690 | 707 | ||
| 708 | (defun gdb-resync() | ||
| 709 | (setq gud-running nil) | ||
| 710 | (setq gdb-output-sink 'user) | ||
| 711 | (setq gdb-input-queue nil) | ||
| 712 | (setq gdb-pending-triggers nil) | ||
| 713 | (setq gdb-prompting t)) | ||
| 714 | |||
| 691 | (defconst gdb-source-spec-regexp | 715 | (defconst gdb-source-spec-regexp |
| 692 | "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") | 716 | "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") |
| 693 | 717 | ||
| @@ -705,26 +729,6 @@ This filter may simply queue input for a later time." | |||
| 705 | ;; stopped annotation | 729 | ;; stopped annotation |
| 706 | (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user))) | 730 | (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user))) |
| 707 | 731 | ||
| 708 | (defun gdb-send-item (item) | ||
| 709 | (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) | ||
| 710 | (setq gdb-current-item item) | ||
| 711 | (with-current-buffer gud-comint-buffer | ||
| 712 | (if (eq gud-minor-mode 'gdba) | ||
| 713 | (if (stringp item) | ||
| 714 | (progn | ||
| 715 | (setq gdb-output-sink 'user) | ||
| 716 | (process-send-string (get-buffer-process gud-comint-buffer) item)) | ||
| 717 | (progn | ||
| 718 | (gdb-clear-partial-output) | ||
| 719 | (setq gdb-output-sink 'pre-emacs) | ||
| 720 | (process-send-string (get-buffer-process gud-comint-buffer) | ||
| 721 | (car item)))) | ||
| 722 | ;; case: eq gud-minor-mode 'gdbmi | ||
| 723 | (gdb-clear-partial-output) | ||
| 724 | (setq gdb-output-sink 'emacs) | ||
| 725 | (process-send-string (get-buffer-process gud-comint-buffer) | ||
| 726 | (car item))))) | ||
| 727 | |||
| 728 | (defun gdb-pre-prompt (ignored) | 732 | (defun gdb-pre-prompt (ignored) |
| 729 | "An annotation handler for `pre-prompt'. | 733 | "An annotation handler for `pre-prompt'. |
| 730 | This terminates the collection of output from a previous command if that | 734 | This terminates the collection of output from a previous command if that |
| @@ -735,7 +739,7 @@ happens to be in effect." | |||
| 735 | ((eq sink 'emacs) | 739 | ((eq sink 'emacs) |
| 736 | (setq gdb-output-sink 'post-emacs)) | 740 | (setq gdb-output-sink 'post-emacs)) |
| 737 | (t | 741 | (t |
| 738 | (setq gdb-output-sink 'user) | 742 | (gdb-resync) |
| 739 | (error "Phase error in gdb-pre-prompt (got %s)" sink))))) | 743 | (error "Phase error in gdb-pre-prompt (got %s)" sink))))) |
| 740 | 744 | ||
| 741 | (defun gdb-prompt (ignored) | 745 | (defun gdb-prompt (ignored) |
| @@ -752,7 +756,7 @@ This sends the next command (if any) to gdb." | |||
| 752 | (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | 756 | (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) |
| 753 | (funcall handler)))) | 757 | (funcall handler)))) |
| 754 | (t | 758 | (t |
| 755 | (setq gdb-output-sink 'user) | 759 | (gdb-resync) |
| 756 | (error "Phase error in gdb-prompt (got %s)" sink)))) | 760 | (error "Phase error in gdb-prompt (got %s)" sink)))) |
| 757 | (let ((input (gdb-dequeue-input))) | 761 | (let ((input (gdb-dequeue-input))) |
| 758 | (if input | 762 | (if input |
| @@ -776,7 +780,9 @@ not GDB." | |||
| 776 | (setq gud-running t) | 780 | (setq gud-running t) |
| 777 | (if gdb-use-inferior-io-buffer | 781 | (if gdb-use-inferior-io-buffer |
| 778 | (setq gdb-output-sink 'inferior)))) | 782 | (setq gdb-output-sink 'inferior)))) |
| 779 | (t (error "Unexpected `starting' annotation"))))) | 783 | (t |
| 784 | (gdb-resync) | ||
| 785 | (error "Unexpected `starting' annotation"))))) | ||
| 780 | 786 | ||
| 781 | (defun gdb-stopping (ignored) | 787 | (defun gdb-stopping (ignored) |
| 782 | "An annotation handler for `exited' and other annotations. | 788 | "An annotation handler for `exited' and other annotations. |
| @@ -787,7 +793,9 @@ being debugged." | |||
| 787 | (cond | 793 | (cond |
| 788 | ((eq sink 'inferior) | 794 | ((eq sink 'inferior) |
| 789 | (setq gdb-output-sink 'user)) | 795 | (setq gdb-output-sink 'user)) |
| 790 | (t (error "Unexpected stopping annotation")))))) | 796 | (t |
| 797 | (gdb-resync) | ||
| 798 | (error "Unexpected stopping annotation")))))) | ||
| 791 | 799 | ||
| 792 | (defun gdb-frame-begin (ignored) | 800 | (defun gdb-frame-begin (ignored) |
| 793 | (let ((sink gdb-output-sink)) | 801 | (let ((sink gdb-output-sink)) |
| @@ -796,7 +804,9 @@ being debugged." | |||
| 796 | (setq gdb-output-sink 'user)) | 804 | (setq gdb-output-sink 'user)) |
| 797 | ((eq sink 'user) t) | 805 | ((eq sink 'user) t) |
| 798 | ((eq sink 'emacs) t) | 806 | ((eq sink 'emacs) t) |
| 799 | (t (error "Unexpected frame-begin annotation (%S)" sink))))) | 807 | (t |
| 808 | (gdb-resync) | ||
| 809 | (error "Unexpected frame-begin annotation (%S)" sink))))) | ||
| 800 | 810 | ||
| 801 | (defun gdb-stopped (ignored) | 811 | (defun gdb-stopped (ignored) |
| 802 | "An annotation handler for `stopped'. | 812 | "An annotation handler for `stopped'. |
| @@ -808,7 +818,9 @@ sink to `user' in `gdb-stopping', that is fine." | |||
| 808 | ((eq sink 'inferior) | 818 | ((eq sink 'inferior) |
| 809 | (setq gdb-output-sink 'user)) | 819 | (setq gdb-output-sink 'user)) |
| 810 | ((eq sink 'user) t) | 820 | ((eq sink 'user) t) |
| 811 | (t (error "Unexpected stopped annotation"))))) | 821 | (t |
| 822 | (gdb-resync) | ||
| 823 | (error "Unexpected stopped annotation"))))) | ||
| 812 | 824 | ||
| 813 | (defun gdb-post-prompt (ignored) | 825 | (defun gdb-post-prompt (ignored) |
| 814 | "An annotation handler for `post-prompt'. | 826 | "An annotation handler for `post-prompt'. |
| @@ -837,7 +849,7 @@ happens to be appropriate." | |||
| 837 | ((eq sink 'pre-emacs) | 849 | ((eq sink 'pre-emacs) |
| 838 | (setq gdb-output-sink 'emacs)) | 850 | (setq gdb-output-sink 'emacs)) |
| 839 | (t | 851 | (t |
| 840 | (setq gdb-output-sink 'user) | 852 | (gdb-resync) |
| 841 | (error "Phase error in gdb-post-prompt (got %s)" sink))))) | 853 | (error "Phase error in gdb-post-prompt (got %s)" sink))))) |
| 842 | 854 | ||
| 843 | (defun gud-gdba-marker-filter (string) | 855 | (defun gud-gdba-marker-filter (string) |
| @@ -909,7 +921,9 @@ happens to be appropriate." | |||
| 909 | ((eq sink 'inferior) | 921 | ((eq sink 'inferior) |
| 910 | (gdb-append-to-inferior-io new) | 922 | (gdb-append-to-inferior-io new) |
| 911 | so-far) | 923 | so-far) |
| 912 | (t (error "Bogon output sink %S" sink))))) | 924 | (t |
| 925 | (gdb-resync) | ||
| 926 | (error "Bogon output sink %S" sink))))) | ||
| 913 | 927 | ||
| 914 | (defun gdb-append-to-partial-output (string) | 928 | (defun gdb-append-to-partial-output (string) |
| 915 | (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) | 929 | (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) |