Mercurial > emacs
comparison lisp/progmodes/gdb-ui.el @ 58431:da65edef151e
(gdb-flush-pending-output): New variable.
(gdb-send-item, gdb-resync, gud-gdba-marker-filter): Use it.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Mon, 22 Nov 2004 20:08:26 +0000 |
parents | 97e4fc5c7297 |
children | 7858de1f2bdf |
comparison
equal
deleted
inserted
replaced
58430:4cca56bdde13 | 58431:da65edef151e |
---|---|
67 (defvar gdb-var-list nil "List of variables in watch window.") | 67 (defvar gdb-var-list nil "List of variables in watch window.") |
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-server-prefix nil) | 71 (defvar gdb-server-prefix nil) |
72 (defvar gdb-flush-pending-output nil) | |
72 | 73 |
73 (defvar gdb-buffer-type nil | 74 (defvar gdb-buffer-type nil |
74 "One of the symbols bound in `gdb-buffer-rules'.") | 75 "One of the symbols bound in `gdb-buffer-rules'.") |
75 | 76 |
76 (defvar gdb-input-queue () | 77 (defvar gdb-input-queue () |
232 (setq gdb-input-queue nil) | 233 (setq gdb-input-queue nil) |
233 (setq gdb-current-item nil) | 234 (setq gdb-current-item nil) |
234 (setq gdb-pending-triggers nil) | 235 (setq gdb-pending-triggers nil) |
235 (setq gdb-output-sink 'user) | 236 (setq gdb-output-sink 'user) |
236 (setq gdb-server-prefix "server ") | 237 (setq gdb-server-prefix "server ") |
238 (setq gdb-flush-pending-output nil) | |
237 ;; | 239 ;; |
238 (setq gdb-buffer-type 'gdba) | 240 (setq gdb-buffer-type 'gdba) |
239 ;; | 241 ;; |
240 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) | 242 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) |
241 ;; | 243 ;; |
641 (let ((last (car (last queue)))) | 643 (let ((last (car (last queue)))) |
642 (unless (nbutlast queue) (setq gdb-input-queue '())) | 644 (unless (nbutlast queue) (setq gdb-input-queue '())) |
643 last)))) | 645 last)))) |
644 | 646 |
645 (defun gdb-send-item (item) | 647 (defun gdb-send-item (item) |
648 (setq gdb-flush-pending-output nil) | |
646 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) | 649 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) |
647 (setq gdb-current-item item) | 650 (setq gdb-current-item item) |
648 (with-current-buffer gud-comint-buffer | 651 (with-current-buffer gud-comint-buffer |
649 (if (eq gud-minor-mode 'gdba) | 652 (if (eq gud-minor-mode 'gdba) |
650 (if (stringp item) | 653 (if (stringp item) |
704 ("frame-begin" gdb-frame-begin) | 707 ("frame-begin" gdb-frame-begin) |
705 ("stopped" gdb-stopped) | 708 ("stopped" gdb-stopped) |
706 ) "An assoc mapping annotation tags to functions which process them.") | 709 ) "An assoc mapping annotation tags to functions which process them.") |
707 | 710 |
708 (defun gdb-resync() | 711 (defun gdb-resync() |
712 (setq gdb-flush-pending-output t) | |
709 (setq gud-running nil) | 713 (setq gud-running nil) |
710 (setq gdb-output-sink 'user) | 714 (setq gdb-output-sink 'user) |
711 (setq gdb-input-queue nil) | 715 (setq gdb-input-queue nil) |
712 (setq gdb-pending-triggers nil) | 716 (setq gdb-pending-triggers nil) |
713 (setq gdb-prompting t)) | 717 (setq gdb-prompting t)) |
852 (gdb-resync) | 856 (gdb-resync) |
853 (error "Phase error in gdb-post-prompt (got %s)" sink))))) | 857 (error "Phase error in gdb-post-prompt (got %s)" sink))))) |
854 | 858 |
855 (defun gud-gdba-marker-filter (string) | 859 (defun gud-gdba-marker-filter (string) |
856 "A gud marker filter for gdb. Handle a burst of output from GDB." | 860 "A gud marker filter for gdb. Handle a burst of output from GDB." |
857 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log)) | 861 (if gdb-flush-pending-output |
858 ;; Recall the left over gud-marker-acc from last time | 862 nil |
859 (setq gud-marker-acc (concat gud-marker-acc string)) | 863 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log)) |
860 ;; Start accumulating output for the GUD buffer | 864 ;; Recall the left over gud-marker-acc from last time |
861 (let ((output "")) | 865 (setq gud-marker-acc (concat gud-marker-acc string)) |
862 ;; | 866 ;; Start accumulating output for the GUD buffer |
863 ;; Process all the complete markers in this chunk. | 867 (let ((output "")) |
864 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) | 868 ;; |
865 (let ((annotation (match-string 1 gud-marker-acc))) | 869 ;; Process all the complete markers in this chunk. |
870 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) | |
871 (let ((annotation (match-string 1 gud-marker-acc))) | |
872 ;; | |
873 ;; Stuff prior to the match is just ordinary output. | |
874 ;; It is either concatenated to OUTPUT or directed | |
875 ;; elsewhere. | |
876 (setq output | |
877 (gdb-concat-output | |
878 output | |
879 (substring gud-marker-acc 0 (match-beginning 0)))) | |
880 ;; | |
881 ;; Take that stuff off the gud-marker-acc. | |
882 (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) | |
883 ;; | |
884 ;; Parse the tag from the annotation, and maybe its arguments. | |
885 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) | |
886 (let* ((annotation-type (match-string 1 annotation)) | |
887 (annotation-arguments (match-string 2 annotation)) | |
888 (annotation-rule (assoc annotation-type | |
889 gdb-annotation-rules))) | |
890 ;; Call the handler for this annotation. | |
891 (if annotation-rule | |
892 (funcall (car (cdr annotation-rule)) | |
893 annotation-arguments) | |
894 ;; Else the annotation is not recognized. Ignore it silently, | |
895 ;; so that GDB can add new annotations without causing | |
896 ;; us to blow up. | |
897 )))) | |
898 ;; | |
899 ;; Does the remaining text end in a partial line? | |
900 ;; If it does, then keep part of the gud-marker-acc until we get more. | |
901 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | |
902 gud-marker-acc) | |
903 (progn | |
904 ;; Everything before the potential marker start can be output. | |
905 (setq output | |
906 (gdb-concat-output output | |
907 (substring gud-marker-acc 0 | |
908 (match-beginning 0)))) | |
909 ;; | |
910 ;; Everything after, we save, to combine with later input. | |
911 (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0)))) | |
866 ;; | 912 ;; |
867 ;; Stuff prior to the match is just ordinary output. | 913 ;; In case we know the gud-marker-acc contains no partial annotations: |
868 ;; It is either concatenated to OUTPUT or directed | |
869 ;; elsewhere. | |
870 (setq output | |
871 (gdb-concat-output | |
872 output | |
873 (substring gud-marker-acc 0 (match-beginning 0)))) | |
874 ;; | |
875 ;; Take that stuff off the gud-marker-acc. | |
876 (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) | |
877 ;; | |
878 ;; Parse the tag from the annotation, and maybe its arguments. | |
879 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) | |
880 (let* ((annotation-type (match-string 1 annotation)) | |
881 (annotation-arguments (match-string 2 annotation)) | |
882 (annotation-rule (assoc annotation-type | |
883 gdb-annotation-rules))) | |
884 ;; Call the handler for this annotation. | |
885 (if annotation-rule | |
886 (funcall (car (cdr annotation-rule)) | |
887 annotation-arguments) | |
888 ;; Else the annotation is not recognized. Ignore it silently, | |
889 ;; so that GDB can add new annotations without causing | |
890 ;; us to blow up. | |
891 )))) | |
892 ;; | |
893 ;; Does the remaining text end in a partial line? | |
894 ;; If it does, then keep part of the gud-marker-acc until we get more. | |
895 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" | |
896 gud-marker-acc) | |
897 (progn | 914 (progn |
898 ;; Everything before the potential marker start can be output. | 915 (setq output (gdb-concat-output output gud-marker-acc)) |
899 (setq output | 916 (setq gud-marker-acc ""))) |
900 (gdb-concat-output output | 917 output))) |
901 (substring gud-marker-acc 0 | |
902 (match-beginning 0)))) | |
903 ;; | |
904 ;; Everything after, we save, to combine with later input. | |
905 (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0)))) | |
906 ;; | |
907 ;; In case we know the gud-marker-acc contains no partial annotations: | |
908 (progn | |
909 (setq output (gdb-concat-output output gud-marker-acc)) | |
910 (setq gud-marker-acc ""))) | |
911 output)) | |
912 | 918 |
913 (defun gdb-concat-output (so-far new) | 919 (defun gdb-concat-output (so-far new) |
914 (let ((sink gdb-output-sink)) | 920 (let ((sink gdb-output-sink)) |
915 (cond | 921 (cond |
916 ((eq sink 'user) (concat so-far new)) | 922 ((eq sink 'user) (concat so-far new)) |