(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*.
(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))
(if (string-match (concat token "\\.") (nth 1 var))
(setq gdb-var-list (delq var gdb-var-list))))
(setq gdb-var-changed t))))
-\f
-(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
(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)))))
\f
;;
;; output -- things gdb prints to emacs
("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]*\\)")
;; 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
((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)
(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
(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.
(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))
(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'.
((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'.
((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)
((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)