summaryrefslogtreecommitdiff
path: root/lisp/progmodes/gdb-ui.el
diff options
context:
space:
mode:
authorNick Roberts <nickrob@snap.net.nz>2004-11-22 09:44:23 +0000
committerNick Roberts <nickrob@snap.net.nz>2004-11-22 09:44:23 +0000
commitcc615d5a024fe7b43c227f8a3eaad60ab6672180 (patch)
tree224ba6ec1ac0ac9512d25a54b96bcb6fc5d4ce52 /lisp/progmodes/gdb-ui.el
parent771aad8e44c3c0c3d58cbf01808a9e4a71a1cdfd (diff)
downloademacs-cc615d5a024fe7b43c227f8a3eaad60ab6672180.tar.gz
emacs-cc615d5a024fe7b43c227f8a3eaad60ab6672180.tar.bz2
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.
Diffstat (limited to 'lisp/progmodes/gdb-ui.el')
-rw-r--r--lisp/progmodes/gdb-ui.el156
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 @@
(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 @@ detailed description of this mode.
(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 @@ INDENT is the current indentation depth."
(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 @@ This filter may simply queue input for a later time."
(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 @@ This filter may simply queue input for a later time."
("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 @@ This filter may simply queue input for a later time."
;; 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 @@ happens to be in effect."
((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 @@ This sends the next command (if any) to gdb."
(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 @@ not GDB."
(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 @@ being debugged."
(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 @@ being debugged."
(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 @@ sink to `user' in `gdb-stopping', that is fine."
((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 @@ happens to be appropriate."
((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 @@ happens to be appropriate."
((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)