comparison lisp/gdb-ui.el @ 52443:31a30e670e11

(gud-display1): Use gud-call to prevent extra prompt being displayed in GUD buffer. (gdb-idle-input-queue): Remove var. Use just one queue. (gdb-enqueue-idle-input,gdb-dequeue-idle-input): Remove functions. Use just one queue. (gdb-prompt, gdb-subprompt, def-gdb-auto-update-trigger) (gdb-invalidate-assembler, gdb-get-current-frame): Modify functions. Use just one queue.
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 04 Sep 2003 22:34:47 +0000
parents 695cf19ef79e
children 367c1b29dbee
comparison
equal deleted inserted replaced
52442:2fbdc8355e43 52443:31a30e670e11
197 (progn 197 (progn
198 (gdb-set-output-sink 'user) 198 (gdb-set-output-sink 'user)
199 (gud-call (concat "server ptype " expr))) 199 (gud-call (concat "server ptype " expr)))
200 (goto-char (- (point-max) 1)) 200 (goto-char (- (point-max) 1))
201 (if (equal (char-before) (string-to-char "\*")) 201 (if (equal (char-before) (string-to-char "\*"))
202 (gdb-enqueue-input 202 (gud-call (concat "display* " expr))
203 (list (concat "display* " expr "\n") 'ignore)) 203 (gud-call (concat "display " expr)))))
204 (gdb-enqueue-input
205 (list (concat "display " expr "\n") 'ignore)))))
206 204
207 ; this would messy because these bindings don't work with M-x gdb 205 ; this would messy because these bindings don't work with M-x gdb
208 ; (define-key global-map "\C-x\C-a\C-a" 'gud-display) 206 ; (define-key global-map "\C-x\C-a\C-a" 'gud-display)
209 ; (define-key gud-minor-mode-map "\C-c\C-a" 'gud-display) 207 ; (define-key gud-minor-mode-map "\C-c\C-a" 'gud-display)
210 208
237 235
238 (def-gdb-var burst "" 236 (def-gdb-var burst ""
239 "A string of characters from gdb that have not yet been processed.") 237 "A string of characters from gdb that have not yet been processed.")
240 238
241 (def-gdb-var input-queue () 239 (def-gdb-var input-queue ()
242 "A list of high priority gdb command objects.") 240 "A list of gdb command objects.")
243
244 (def-gdb-var idle-input-queue ()
245 "A list of low priority gdb command objects.")
246 241
247 (def-gdb-var prompting nil 242 (def-gdb-var prompting nil
248 "True when gdb is idle with no pending input.") 243 "True when gdb is idle with no pending input.")
249 244
250 (def-gdb-var output-sink 'user 245 (def-gdb-var output-sink 'user
430 ;; gdb communications 425 ;; gdb communications
431 ;; 426 ;;
432 427
433 ;; INPUT: things sent to gdb 428 ;; INPUT: things sent to gdb
434 ;; 429 ;;
435 ;; There is a high and low priority input queue. Low priority input is sent
436 ;; only when the high priority queue is idle.
437 ;;
438 ;; The queues are lists. Each element is either a string (indicating user or 430 ;; The queues are lists. Each element is either a string (indicating user or
439 ;; user-like input) or a list of the form: 431 ;; user-like input) or a list of the form:
440 ;; 432 ;;
441 ;; (INPUT-STRING HANDLER-FN) 433 ;; (INPUT-STRING HANDLER-FN)
442 ;; 434 ;;
451 "A comint send filter for gdb. 443 "A comint send filter for gdb.
452 This filter may simply queue output for a later time." 444 This filter may simply queue output for a later time."
453 (gdb-enqueue-input (concat string "\n"))) 445 (gdb-enqueue-input (concat string "\n")))
454 446
455 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it 447 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
456 ;; is a query, or other non-top-level prompt. To guarantee stuff will get 448 ;; is a query, or other non-top-level prompt.
457 ;; sent to the top-level prompt, currently it must be put in the idle queue.
458 ;; ^^^^^^^^^
459 ;; [This should encourage gdb extensions that invoke gdb commands to let
460 ;; the user go first; it is not a bug. -t]
461 ;;
462 449
463 (defun gdb-enqueue-input (item) 450 (defun gdb-enqueue-input (item)
464 (if (gdb-get-prompting) 451 (if (gdb-get-prompting)
465 (progn 452 (progn
466 (gdb-send-item item) 453 (gdb-send-item item)
472 (let ((queue (gdb-get-input-queue))) 459 (let ((queue (gdb-get-input-queue)))
473 (and queue 460 (and queue
474 (if (not (cdr queue)) 461 (if (not (cdr queue))
475 (let ((answer (car queue))) 462 (let ((answer (car queue)))
476 (gdb-set-input-queue '()) 463 (gdb-set-input-queue '())
477 answer)
478 (gdb-take-last-elt queue)))))
479
480 (defun gdb-enqueue-idle-input (item)
481 (if (and (gdb-get-prompting)
482 (not (gdb-get-input-queue)))
483 (progn
484 (gdb-send-item item)
485 (gdb-set-prompting nil))
486 (gdb-set-idle-input-queue
487 (cons item (gdb-get-idle-input-queue)))))
488
489 (defun gdb-dequeue-idle-input ()
490 (let ((queue (gdb-get-idle-input-queue)))
491 (and queue
492 (if (not (cdr queue))
493 (let ((answer (car queue)))
494 (gdb-set-idle-input-queue '())
495 answer) 464 answer)
496 (gdb-take-last-elt queue))))) 465 (gdb-take-last-elt queue)))))
497 466
498 ;; Don't use this in general. 467 ;; Don't use this in general.
499 (defun gdb-take-last-elt (l) 468 (defun gdb-take-last-elt (l)
607 ((eq sink 'post-emacs) 576 ((eq sink 'post-emacs)
608 (gdb-set-output-sink 'user)) 577 (gdb-set-output-sink 'user))
609 (t 578 (t
610 (gdb-set-output-sink 'user) 579 (gdb-set-output-sink 'user)
611 (error "Phase error in gdb-prompt (got %s)" sink)))) 580 (error "Phase error in gdb-prompt (got %s)" sink))))
612 (let ((highest (gdb-dequeue-input))) 581 (let ((input (gdb-dequeue-input)))
613 (if highest 582 (if input
614 (gdb-send-item highest) 583 (gdb-send-item input)
615 (let ((lowest (gdb-dequeue-idle-input))) 584 (progn
616 (if lowest 585 (gdb-set-prompting t)
617 (gdb-send-item lowest) 586 (gud-display-frame)))))
618 (progn
619 (gdb-set-prompting t)
620 (gud-display-frame)))))))
621 587
622 (defun gdb-subprompt (ignored) 588 (defun gdb-subprompt (ignored)
623 "An annotation handler for non-top-level prompts." 589 "An annotation handler for non-top-level prompts."
624 (let ((highest (gdb-dequeue-input))) 590 (gdb-set-prompting t))
625 (if highest
626 (gdb-send-item highest)
627 (gdb-set-prompting t))))
628 591
629 (defun gdb-starting (ignored) 592 (defun gdb-starting (ignored)
630 "An annotation handler for `starting'. This says that I/O for the 593 "An annotation handler for `starting'. This says that I/O for the
631 subprocess is now the program being debugged, not GDB." 594 subprocess is now the program being debugged, not GDB."
632 (let ((sink (gdb-get-output-sink))) 595 (let ((sink (gdb-get-output-sink)))
1174 ;; 1137 ;;
1175 ;; There are two aspects to this: gdb has to tell us when the output for that 1138 ;; There are two aspects to this: gdb has to tell us when the output for that
1176 ;; command might have changed, and we have to be able to run the command 1139 ;; command might have changed, and we have to be able to run the command
1177 ;; behind the user's back. 1140 ;; behind the user's back.
1178 ;; 1141 ;;
1179 ;; The idle input queue and the output phasing associated with the variable 1142 ;; The output phasing associated with the variable gdb-output-sink
1180 ;; gdb-output-sink help us to run commands behind the user's back. 1143 ;; help us to run commands behind the user's back.
1181 ;; 1144 ;;
1182 ;; Below is the code for specificly managing buffers of output from one 1145 ;; Below is the code for specificly managing buffers of output from one
1183 ;; command. 1146 ;; command.
1184 ;; 1147 ;;
1185 1148
1186 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES 1149 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
1187 ;; It adds an idle input for the command we are tracking. It should be the 1150 ;; It adds an input for the command we are tracking. It should be the
1188 ;; annotation rule binding of whatever gdb sends to tell us this command 1151 ;; annotation rule binding of whatever gdb sends to tell us this command
1189 ;; might have changed it's output. 1152 ;; might have changed it's output.
1190 ;; 1153 ;;
1191 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed. 1154 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
1192 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the 1155 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
1197 `(defun ,name (&optional ignored) 1160 `(defun ,name (&optional ignored)
1198 (if (and (,demand-predicate) 1161 (if (and (,demand-predicate)
1199 (not (member ',name 1162 (not (member ',name
1200 (gdb-get-pending-triggers)))) 1163 (gdb-get-pending-triggers))))
1201 (progn 1164 (progn
1202 (gdb-enqueue-idle-input 1165 (gdb-enqueue-input
1203 (list ,gdb-command ',output-handler)) 1166 (list ,gdb-command ',output-handler))
1204 (gdb-set-pending-triggers 1167 (gdb-set-pending-triggers
1205 (cons ',name 1168 (cons ',name
1206 (gdb-get-pending-triggers))))))) 1169 (gdb-get-pending-triggers)))))))
1207 1170
2374 (not (string-equal gdb-current-address 2337 (not (string-equal gdb-current-address
2375 gdb-previous-address))) 2338 gdb-previous-address)))
2376 (progn 2339 (progn
2377 ;; take previous disassemble command off the queue 2340 ;; take previous disassemble command off the queue
2378 (with-current-buffer gud-comint-buffer 2341 (with-current-buffer gud-comint-buffer
2379 (let ((queue (gdb-get-idle-input-queue)) (item)) 2342 (let ((queue (gdb-get-input-queue)) (item))
2380 (dolist (item queue) 2343 (dolist (item queue)
2381 (if (equal (cdr item) '(gdb-assembler-handler)) 2344 (if (equal (cdr item) '(gdb-assembler-handler))
2382 (gdb-set-idle-input-queue 2345 (gdb-set-input-queue
2383 (delete item (gdb-get-idle-input-queue))))))) 2346 (delete item (gdb-get-input-queue)))))))
2384 (gdb-enqueue-idle-input 2347 (gdb-enqueue-input
2385 (list (concat "server disassemble " gdb-current-address "\n") 2348 (list (concat "server disassemble " gdb-current-address "\n")
2386 'gdb-assembler-handler)) 2349 'gdb-assembler-handler))
2387 (gdb-set-pending-triggers 2350 (gdb-set-pending-triggers
2388 (cons 'gdb-invalidate-assembler 2351 (cons 'gdb-invalidate-assembler
2389 (gdb-get-pending-triggers))) 2352 (gdb-get-pending-triggers)))
2391 (setq gdb-previous-frame gdb-current-frame))))))) 2354 (setq gdb-previous-frame gdb-current-frame)))))))
2392 2355
2393 (defun gdb-get-current-frame () 2356 (defun gdb-get-current-frame ()
2394 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers))) 2357 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers)))
2395 (progn 2358 (progn
2396 (gdb-enqueue-idle-input 2359 (gdb-enqueue-input
2397 (list (concat "server info frame\n") 'gdb-frame-handler)) 2360 (list (concat "server info frame\n") 'gdb-frame-handler))
2398 (gdb-set-pending-triggers 2361 (gdb-set-pending-triggers
2399 (cons 'gdb-get-current-frame 2362 (cons 'gdb-get-current-frame
2400 (gdb-get-pending-triggers)))))) 2363 (gdb-get-pending-triggers))))))
2401 2364