aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1993-07-30 01:39:20 +0000
committerJim Blandy1993-07-30 01:39:20 +0000
commit768c29d02fd693e801d9010b787b14cc980e5188 (patch)
treecfd2a69662f9c281954d5e0be93cd8b3e498ed79
parentf582564f7b77df08ab0741a3e85500ccf369f5cf (diff)
downloademacs-768c29d02fd693e801d9010b787b14cc980e5188.tar.gz
emacs-768c29d02fd693e801d9010b787b14cc980e5188.zip
* gud.el (gud-gdb-marker-filter): Do not assume that the position
markers from GDB will always be received in one chunk of input; gud-gdb-marker-filter may be called several times, each time providing a little more of the position marker. (gud-gdb-marker-acc): New variable. (gud-gdb-marker-filter): If we have received what could be the beginning of a position marker, hold that text in gud-gdb-marker-acc for the next time we get called, until we have enough information to decide for sure. * gud.el (gud-gdb-marker-filter): Only recognize GDB position markers if they occur at the beginning of the line. They always do, and this reduces the likelihood that the above change will hold back output that isn't really a position marker.
-rw-r--r--lisp/gud.el64
1 files changed, 50 insertions, 14 deletions
diff --git a/lisp/gud.el b/lisp/gud.el
index ada164633b3..3b89c240637 100644
--- a/lisp/gud.el
+++ b/lisp/gud.el
@@ -156,21 +156,57 @@ we're in the GUD buffer)."
156(defun gud-gdb-massage-args (file args) 156(defun gud-gdb-massage-args (file args)
157 (cons "-fullname" (cons file args))) 157 (cons "-fullname" (cons file args)))
158 158
159;; There's no guarantee that Emacs will hand the filter the entire
160;; marker at once; it could be broken up across several strings. We
161;; might even receive a big chunk with several markers in it. If we
162;; receive a chunk of text which looks like it might contain the
163;; beginning of a marker, we save it here between calls to the
164;; filter.
165(defvar gud-gdb-marker-acc "")
166
159(defun gud-gdb-marker-filter (string) 167(defun gud-gdb-marker-filter (string)
160 (if (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" string) 168 (setq gud-gdb-marker-acc (concat gud-gdb-marker-acc string))
161 (progn 169 (let ((output ""))
162 (setq gud-last-frame 170
163 (cons 171 ;; Process all the complete markers in this chunk.
164 (substring string (match-beginning 1) (match-end 1)) 172 (while (string-match "^\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
165 (string-to-int 173 gud-gdb-marker-acc)
166 (substring string (match-beginning 2) (match-end 2))))) 174 (setq
167 ;; this computation means the ^Z^Z-initiated marker in the 175
168 ;; input string is never emitted. 176 ;; Extract the frame position from the marker.
169 (concat 177 gud-last-frame
170 (substring string 0 (match-beginning 0)) 178 (cons (substring gud-gdb-marker-acc (match-beginning 1) (match-end 1))
171 (substring string (match-end 0)) 179 (string-to-int (substring gud-gdb-marker-acc
172 )) 180 (match-beginning 2)
173 string)) 181 (match-end 2))))
182
183 ;; Append any text before the marker to the output we're going
184 ;; to return - we don't include the marker in this text.
185 output (concat output
186 (substring gud-gdb-marker-acc 0 (match-beginning 0)))
187
188 ;; Set the accumulator to the remaining text.
189 gud-gdb-marker-acc (substring gud-gdb-marker-acc (match-end 0))))
190
191 ;; Does the remaining text look like it might end with the
192 ;; beginning of another marker? If it does, then keep it in
193 ;; gud-gdb-marker-acc until we receive the rest of it. Since we
194 ;; know the full marker regexp above failed, it's pretty simple to
195 ;; test for marker starts.
196 (if (string-match "^\032.*\\'" gud-gdb-marker-acc)
197 (progn
198 ;; Everything before the potential marker start can be output.
199 (setq output (concat output (substring gud-gdb-marker-acc
200 0 (match-beginning 0))))
201
202 ;; Everything after, we save, to combine with later input.
203 (setq gud-gdb-marker-acc
204 (substring gud-gdb-marker-acc (match-beginning 0))))
205
206 (setq output gud-gdb-marker-acc
207 gud-gdb-marker-acc ""))
208
209 output))
174 210
175(defun gud-gdb-find-file (f) 211(defun gud-gdb-find-file (f)
176 (find-file-noselect f)) 212 (find-file-noselect f))