Mercurial > emacs
changeset 58420:97e4fc5c7297
(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.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Mon, 22 Nov 2004 09:44:23 +0000 |
parents | ef93e6f37cef |
children | 15fca0a00f5e |
files | lisp/progmodes/gdb-ui.el |
diffstat | 1 files changed, 85 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/gdb-ui.el Mon Nov 22 09:43:44 2004 +0000 +++ b/lisp/progmodes/gdb-ui.el Mon Nov 22 09:44:23 2004 +0000 @@ -68,10 +68,48 @@ (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.") (defvar gdb-buffer-type nil) (defvar gdb-overlay-arrow-position nil) -(defvar gdb-variables '() - "A list of variables that are local to the GUD buffer.") (defvar gdb-server-prefix nil) +(defvar gdb-buffer-type nil + "One of the symbols bound in `gdb-buffer-rules'.") + +(defvar gdb-input-queue () + "A list of gdb command objects.") + +(defvar gdb-prompting nil + "True when gdb is idle with no pending input.") + +(defvar gdb-output-sink 'user + "The disposition of the output of the current gdb command. +Possible values are these symbols: + + `user' -- gdb output should be copied to the GUD buffer + for the user to see. + + `inferior' -- gdb output should be copied to the inferior-io buffer + + `pre-emacs' -- output should be ignored util the post-prompt + annotation is received. Then the output-sink + becomes:... + `emacs' -- output should be collected in the partial-output-buffer + for subsequent processing by a command. This is the + disposition of output generated by commands that + gdb mode sends to gdb on its own behalf. + `post-emacs' -- ignore output until the prompt annotation is + received, then go to USER disposition. + +gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two +\(`user' and `emacs').") + +(defvar gdb-current-item nil + "The most recent command item sent to gdb.") + +(defvar gdb-pending-triggers '() + "A list of trigger functions that have run later than their output +handlers.") + +;; end of gdb variables + ;;;###autoload (defun gdba (command-line) "Run gdb on program FILE in buffer *gud-FILE*. @@ -197,7 +235,6 @@ (setq gdb-output-sink 'user) (setq gdb-server-prefix "server ") ;; - (mapc 'make-local-variable gdb-variables) (setq gdb-buffer-type 'gdba) ;; (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) @@ -412,46 +449,6 @@ (if (string-match (concat token "\\.") (nth 1 var)) (setq gdb-var-list (delq var gdb-var-list)))) (setq gdb-var-changed t)))) - -(defvar gdb-buffer-type nil - "One of the symbols bound in `gdb-buffer-rules'.") - -(defvar gdb-input-queue () - "A list of gdb command objects.") - -(defvar gdb-prompting nil - "True when gdb is idle with no pending input.") - -(defvar gdb-output-sink 'user - "The disposition of the output of the current gdb command. -Possible values are these symbols: - - `user' -- gdb output should be copied to the GUD buffer - for the user to see. - - `inferior' -- gdb output should be copied to the inferior-io buffer - - `pre-emacs' -- output should be ignored util the post-prompt - annotation is received. Then the output-sink - becomes:... - `emacs' -- output should be collected in the partial-output-buffer - for subsequent processing by a command. This is the - disposition of output generated by commands that - gdb mode sends to gdb on its own behalf. - `post-emacs' -- ignore output until the prompt annotation is - received, then go to USER disposition. - -gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two -\(`user' and `emacs').") - -(defvar gdb-current-item nil - "The most recent command item sent to gdb.") - -(defvar gdb-pending-triggers '() - "A list of trigger functions that have run later than their output -handlers.") - -;; end of gdb variables (defun gdb-get-target-string () (with-current-buffer gud-comint-buffer @@ -644,6 +641,26 @@ (let ((last (car (last queue)))) (unless (nbutlast queue) (setq gdb-input-queue '())) last)))) + +(defun gdb-send-item (item) + (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) + (setq gdb-current-item item) + (with-current-buffer gud-comint-buffer + (if (eq gud-minor-mode 'gdba) + (if (stringp item) + (progn + (setq gdb-output-sink 'user) + (process-send-string (get-buffer-process gud-comint-buffer) item)) + (progn + (gdb-clear-partial-output) + (setq gdb-output-sink 'pre-emacs) + (process-send-string (get-buffer-process gud-comint-buffer) + (car item)))) + ;; case: eq gud-minor-mode 'gdbmi + (gdb-clear-partial-output) + (setq gdb-output-sink 'emacs) + (process-send-string (get-buffer-process gud-comint-buffer) + (car item))))) ;; ;; output -- things gdb prints to emacs @@ -688,6 +705,13 @@ ("stopped" gdb-stopped) ) "An assoc mapping annotation tags to functions which process them.") +(defun gdb-resync() + (setq gud-running nil) + (setq gdb-output-sink 'user) + (setq gdb-input-queue nil) + (setq gdb-pending-triggers nil) + (setq gdb-prompting t)) + (defconst gdb-source-spec-regexp "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)") @@ -705,26 +729,6 @@ ;; stopped annotation (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user))) -(defun gdb-send-item (item) - (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) - (setq gdb-current-item item) - (with-current-buffer gud-comint-buffer - (if (eq gud-minor-mode 'gdba) - (if (stringp item) - (progn - (setq gdb-output-sink 'user) - (process-send-string (get-buffer-process gud-comint-buffer) item)) - (progn - (gdb-clear-partial-output) - (setq gdb-output-sink 'pre-emacs) - (process-send-string (get-buffer-process gud-comint-buffer) - (car item)))) - ;; case: eq gud-minor-mode 'gdbmi - (gdb-clear-partial-output) - (setq gdb-output-sink 'emacs) - (process-send-string (get-buffer-process gud-comint-buffer) - (car item))))) - (defun gdb-pre-prompt (ignored) "An annotation handler for `pre-prompt'. This terminates the collection of output from a previous command if that @@ -735,7 +739,7 @@ ((eq sink 'emacs) (setq gdb-output-sink 'post-emacs)) (t - (setq gdb-output-sink 'user) + (gdb-resync) (error "Phase error in gdb-pre-prompt (got %s)" sink))))) (defun gdb-prompt (ignored) @@ -752,7 +756,7 @@ (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) (funcall handler)))) (t - (setq gdb-output-sink 'user) + (gdb-resync) (error "Phase error in gdb-prompt (got %s)" sink)))) (let ((input (gdb-dequeue-input))) (if input @@ -776,7 +780,9 @@ (setq gud-running t) (if gdb-use-inferior-io-buffer (setq gdb-output-sink 'inferior)))) - (t (error "Unexpected `starting' annotation"))))) + (t + (gdb-resync) + (error "Unexpected `starting' annotation"))))) (defun gdb-stopping (ignored) "An annotation handler for `exited' and other annotations. @@ -787,7 +793,9 @@ (cond ((eq sink 'inferior) (setq gdb-output-sink 'user)) - (t (error "Unexpected stopping annotation")))))) + (t + (gdb-resync) + (error "Unexpected stopping annotation")))))) (defun gdb-frame-begin (ignored) (let ((sink gdb-output-sink)) @@ -796,7 +804,9 @@ (setq gdb-output-sink 'user)) ((eq sink 'user) t) ((eq sink 'emacs) t) - (t (error "Unexpected frame-begin annotation (%S)" sink))))) + (t + (gdb-resync) + (error "Unexpected frame-begin annotation (%S)" sink))))) (defun gdb-stopped (ignored) "An annotation handler for `stopped'. @@ -808,7 +818,9 @@ ((eq sink 'inferior) (setq gdb-output-sink 'user)) ((eq sink 'user) t) - (t (error "Unexpected stopped annotation"))))) + (t + (gdb-resync) + (error "Unexpected stopped annotation"))))) (defun gdb-post-prompt (ignored) "An annotation handler for `post-prompt'. @@ -837,7 +849,7 @@ ((eq sink 'pre-emacs) (setq gdb-output-sink 'emacs)) (t - (setq gdb-output-sink 'user) + (gdb-resync) (error "Phase error in gdb-post-prompt (got %s)" sink))))) (defun gud-gdba-marker-filter (string) @@ -909,7 +921,9 @@ ((eq sink 'inferior) (gdb-append-to-inferior-io new) so-far) - (t (error "Bogon output sink %S" sink))))) + (t + (gdb-resync) + (error "Bogon output sink %S" sink))))) (defun gdb-append-to-partial-output (string) (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)