comparison lisp/progmodes/gdb-ui.el @ 91867:79ba128d9b58

(gdb-ready): Move declaration from gud.el to here. (gdb-early-user-input): New variable. (gdb): Reset gdb-flush-pending-output to nil and set comint-input-sender here (before gdb-prompt), instead of... (gdb-init-1): ...here. (gdb-send): If Emacs is not ready, defer user input to... (gdb-prompt): ...here.
author Nick Roberts <nickrob@snap.net.nz>
date Sat, 16 Feb 2008 06:45:07 +0000
parents fa454b3c5b7b
children d758efc0f23f
comparison
equal deleted inserted replaced
91866:92bbc86bf75c 91867:79ba128d9b58
135 (defvar gdb-look-up-stack nil) 135 (defvar gdb-look-up-stack nil)
136 (defvar gdb-frame-begin nil 136 (defvar gdb-frame-begin nil
137 "Non-nil when GDB generates frame-begin annotation.") 137 "Non-nil when GDB generates frame-begin annotation.")
138 (defvar gdb-printing t) 138 (defvar gdb-printing t)
139 (defvar gdb-parent-bptno-enabled nil) 139 (defvar gdb-parent-bptno-enabled nil)
140 (defvar gdb-ready nil)
141 (defvar gdb-early-user-input nil)
140 142
141 (defvar gdb-buffer-type nil 143 (defvar gdb-buffer-type nil
142 "One of the symbols bound in `gdb-buffer-rules'.") 144 "One of the symbols bound in `gdb-buffer-rules'.")
143 (make-variable-buffer-local 'gdb-buffer-type) 145 (make-variable-buffer-local 'gdb-buffer-type)
144 146
282 (error 284 (error
283 "Multiple debugging requires restarting in text command mode")) 285 "Multiple debugging requires restarting in text command mode"))
284 286
285 (gud-common-init command-line nil 'gud-gdba-marker-filter) 287 (gud-common-init command-line nil 'gud-gdba-marker-filter)
286 (set (make-local-variable 'gud-minor-mode) 'gdba) 288 (set (make-local-variable 'gud-minor-mode) 'gdba)
289 (setq comint-input-sender 'gdb-send)
287 290
288 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") 291 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
289 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" 292 (gud-def gud-tbreak "tbreak %f:%l" "\C-t"
290 "Set temporary breakpoint at current line.") 293 "Set temporary breakpoint at current line.")
291 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") 294 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line")
315 (setq comint-prompt-regexp "^(.*gdb[+]?) *") 318 (setq comint-prompt-regexp "^(.*gdb[+]?) *")
316 (setq paragraph-start comint-prompt-regexp) 319 (setq paragraph-start comint-prompt-regexp)
317 (setq gdb-first-prompt t) 320 (setq gdb-first-prompt t)
318 (setq gud-running nil) 321 (setq gud-running nil)
319 (setq gdb-ready nil) 322 (setq gdb-ready nil)
323 (setq gdb-flush-pending-output nil)
324 (setq gdb-early-user-input nil)
320 (setq gud-filter-pending-text nil) 325 (setq gud-filter-pending-text nil)
321 (run-hooks 'gdb-mode-hook)) 326 (run-hooks 'gdb-mode-hook))
322 327
323 (defcustom gdb-debug-log-max 128 328 (defcustom gdb-debug-log-max 128
324 "Maximum size of `gdb-debug-log'. If nil, size is unlimited." 329 "Maximum size of `gdb-debug-log'. If nil, size is unlimited."
572 (define-key gud-minor-mode-map [left-fringe C-mouse-3] 577 (define-key gud-minor-mode-map [left-fringe C-mouse-3]
573 'gdb-mouse-jump) 578 'gdb-mouse-jump)
574 (define-key gud-minor-mode-map [left-margin C-mouse-3] 579 (define-key gud-minor-mode-map [left-margin C-mouse-3]
575 'gdb-mouse-jump) 580 'gdb-mouse-jump)
576 581
577 (setq comint-input-sender 'gdb-send)
578
579 ;; (re-)initialize 582 ;; (re-)initialize
580 (setq gdb-pc-address (if gdb-show-main "main" nil)) 583 (setq gdb-pc-address (if gdb-show-main "main" nil))
581 (setq gdb-previous-frame-address nil 584 (setq gdb-previous-frame-address nil
582 gdb-memory-address "main" 585 gdb-memory-address "main"
583 gdb-previous-frame nil 586 gdb-previous-frame nil
591 gdb-input-queue nil 594 gdb-input-queue nil
592 gdb-current-item nil 595 gdb-current-item nil
593 gdb-pending-triggers nil 596 gdb-pending-triggers nil
594 gdb-output-sink 'user 597 gdb-output-sink 'user
595 gdb-server-prefix "server " 598 gdb-server-prefix "server "
596 gdb-flush-pending-output nil
597 gdb-location-alist nil 599 gdb-location-alist nil
598 gdb-source-file-list nil 600 gdb-source-file-list nil
599 gdb-error nil 601 gdb-error nil
600 gdb-macro-info nil 602 gdb-macro-info nil
601 gdb-buffer-fringe-width (car (window-fringes)) 603 gdb-buffer-fringe-width (car (window-fringes))
1192 ;; 1194 ;;
1193 1195
1194 (defun gdb-send (proc string) 1196 (defun gdb-send (proc string)
1195 "A comint send filter for gdb. 1197 "A comint send filter for gdb.
1196 This filter may simply queue input for a later time." 1198 This filter may simply queue input for a later time."
1197 (when gdb-ready 1199 (if gdb-ready
1198 (with-current-buffer gud-comint-buffer 1200 (progn
1199 (let ((inhibit-read-only t)) 1201 (with-current-buffer gud-comint-buffer
1200 (remove-text-properties (point-min) (point-max) '(face)))) 1202 (let ((inhibit-read-only t))
1201 (if gud-running 1203 (remove-text-properties (point-min) (point-max) '(face))))
1202 (progn 1204 (if gud-running
1203 (let ((item (concat string "\n"))) 1205 (progn
1204 (if gdb-enable-debug (push (cons 'send item) gdb-debug-log)) 1206 (let ((item (concat string "\n")))
1205 (process-send-string proc item))) 1207 (if gdb-enable-debug (push (cons 'send item) gdb-debug-log))
1206 (if (string-match "\\\\\\'" string) 1208 (process-send-string proc item)))
1207 (setq gdb-continuation (concat gdb-continuation string "\n")) 1209 (if (string-match "\\\\\\'" string)
1208 (let ((item (concat gdb-continuation string 1210 (setq gdb-continuation (concat gdb-continuation string "\n"))
1209 (if (not comint-input-sender-no-newline) "\n")))) 1211 (let ((item (concat
1210 (gdb-enqueue-input item) 1212 gdb-continuation string
1211 (setq gdb-continuation nil)))))) 1213 (if (not comint-input-sender-no-newline) "\n"))))
1214 (gdb-enqueue-input item)
1215 (setq gdb-continuation nil)))))
1216 (push (concat string "\n") gdb-early-user-input)))
1212 1217
1213 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it 1218 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
1214 ;; is a query, or other non-top-level prompt. 1219 ;; is a query, or other non-top-level prompt.
1215 1220
1216 (defun gdb-enqueue-input (item) 1221 (defun gdb-enqueue-input (item)
1360 (let ((input (gdb-dequeue-input))) 1365 (let ((input (gdb-dequeue-input)))
1361 (if input 1366 (if input
1362 (gdb-send-item input) 1367 (gdb-send-item input)
1363 (progn 1368 (progn
1364 (setq gdb-prompting t) 1369 (setq gdb-prompting t)
1365 (gud-display-frame))))) 1370 (gud-display-frame)
1371 (setq gdb-early-user-input (nreverse gdb-early-user-input))
1372 (while gdb-early-user-input
1373 (gdb-enqueue-input (car gdb-early-user-input))
1374 (setq gdb-early-user-input (cdr gdb-early-user-input)))))))
1366 1375
1367 (defun gdb-subprompt (ignored) 1376 (defun gdb-subprompt (ignored)
1368 "An annotation handler for non-top-level prompts." 1377 "An annotation handler for non-top-level prompts."
1369 (setq gdb-prompting t)) 1378 (setq gdb-prompting t))
1370 1379