aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Roberts2004-05-23 20:28:47 +0000
committerNick Roberts2004-05-23 20:28:47 +0000
commit2cec1d1ae49d4396ff36f0ce2c982dd71392103d (patch)
tree1b47a9e2636284f121b3d8734a6dd2b71e13ae5d
parent0145381ff82848535b0c27fae03097547f35ecdf (diff)
downloademacs-2cec1d1ae49d4396ff36f0ce2c982dd71392103d.tar.gz
emacs-2cec1d1ae49d4396ff36f0ce2c982dd71392103d.zip
(gdb-server-prefix): New variable.
(gud-watch, gdb-send-item, gdb-breakpoints-mode, gdb-frames-mode) (gdb-locals-mode, gdb-send-item, gdb-toggle-breakpoint) (gdb-delete-breakpoint, gdb-frames-select, gdb-threads-buffer) (gdb-registers-buffer, gdb-reset, gdb-assembler-buffer): Handle new value for gud-minor-mode (gdbmi). (gdb-buffer-type, gdb-input-queue, gdb-prompting) (gdb-output-sink, gdb-current-item, gdb-pending-triggers): Change from local to global gdb variable set. (gdb-ann3): Initialise above gdb variable set. (gdb-var-update, gdb-var-update-handler, gdb-enqueue-input) (gdb-dequeue-input, gdb-source, gdb-pre-prompt, gdb-prompt) (gdb-subprompt, gdb-starting, gdb-stopping, gdb-frame-begin) (gdb-stopped, gdb-post-prompt, gdb-concat-output) (def-gdb-auto-update-trigger, def-gdb-auto-update-handler) (gdb-info-locals-handler, gdb-invalidate-assembler) (gdb-get-current-frame, gdb-frame-handler): Handle gdb variable set as global variables. (gdb-get-create-buffer): Don't make gud-comint buffer-local. Handle gdbmi. (gdb-info-breakpoints-custom): Fix regexp. (def-gdb-var): Delete.
-rw-r--r--lisp/progmodes/gdb-ui.el242
1 files changed, 116 insertions, 126 deletions
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el
index 1fa6f8f2645..5fca67dcb80 100644
--- a/lisp/progmodes/gdb-ui.el
+++ b/lisp/progmodes/gdb-ui.el
@@ -63,7 +63,8 @@
63(defvar gdb-overlay-arrow-position nil) 63(defvar gdb-overlay-arrow-position nil)
64(defvar gdb-variables '() 64(defvar gdb-variables '()
65 "A list of variables that are local to the GUD buffer.") 65 "A list of variables that are local to the GUD buffer.")
66 66(defvar gdb-server-prefix nil)
67
67;;;###autoload 68;;;###autoload
68(defun gdba (command-line) 69(defun gdba (command-line)
69 "Run gdb on program FILE in buffer *gud-FILE*. 70 "Run gdb on program FILE in buffer *gud-FILE*.
@@ -73,7 +74,7 @@ and source-file directory for your debugger.
73If `gdb-many-windows' is nil (the default value) then gdb just 74If `gdb-many-windows' is nil (the default value) then gdb just
74pops up the GUD buffer unless `gdb-show-main' is t. In this case 75pops up the GUD buffer unless `gdb-show-main' is t. In this case
75it starts with two windows: one displaying the GUD buffer and the 76it starts with two windows: one displaying the GUD buffer and the
76other with the source file with the main routine of the debugee. 77other with the source file with the main routine of the inferior.
77 78
78If `gdb-many-windows' is t, regardless of the value of 79If `gdb-many-windows' is t, regardless of the value of
79`gdb-show-main', the layout below will appear unless 80`gdb-show-main', the layout below will appear unless
@@ -100,7 +101,7 @@ detailed description of this mode.
100 | 101 |
101 | 102 |
102--------------------------------------------------------------------- 103---------------------------------------------------------------------
103 Source buffer | Input/Output (of debugee) buffer 104 Source buffer | Input/Output (of inferior) buffer
104 | (comint-mode) 105 | (comint-mode)
105 | 106 |
106 | 107 |
@@ -180,6 +181,11 @@ detailed description of this mode.
180 (setq gdb-var-list nil) 181 (setq gdb-var-list nil)
181 (setq gdb-var-changed nil) 182 (setq gdb-var-changed nil)
182 (setq gdb-first-prompt nil) 183 (setq gdb-first-prompt nil)
184 (setq gdb-prompting nil)
185 (setq gdb-current-item nil)
186 (setq gdb-pending-triggers nil)
187 (setq gdb-output-sink 'user)
188 (setq gdb-server-prefix "server ")
183 ;; 189 ;;
184 (mapc 'make-local-variable gdb-variables) 190 (mapc 'make-local-variable gdb-variables)
185 (setq gdb-buffer-type 'gdba) 191 (setq gdb-buffer-type 'gdba)
@@ -215,7 +221,10 @@ speedbar."
215 (if (string-equal expr (car var)) (throw 'already-watched nil))) 221 (if (string-equal expr (car var)) (throw 'already-watched nil)))
216 (set-text-properties 0 (length expr) nil expr) 222 (set-text-properties 0 (length expr) nil expr)
217 (gdb-enqueue-input 223 (gdb-enqueue-input
218 (list (concat "server interpreter mi \"-var-create - * " expr "\"\n") 224 (list
225 (if (eq gud-minor-mode 'gdba)
226 (concat "server interpreter mi \"-var-create - * " expr "\"\n")
227 (concat"-var-create - * " expr "\n"))
219 `(lambda () (gdb-var-create-handler ,expr)))))) 228 `(lambda () (gdb-var-create-handler ,expr))))))
220 (select-window (get-buffer-window gud-comint-buffer 'visible))) 229 (select-window (get-buffer-window gud-comint-buffer 'visible)))
221 230
@@ -308,12 +317,11 @@ speedbar."
308 (setq gdb-var-list (nreverse var-list)))))) 317 (setq gdb-var-list (nreverse var-list))))))
309 318
310(defun gdb-var-update () 319(defun gdb-var-update ()
311 (if (not (member 'gdb-var-update (gdb-get-pending-triggers))) 320 (if (not (member 'gdb-var-update gdb-pending-triggers))
312 (progn 321 (progn
313 (gdb-enqueue-input (list "server interpreter mi \"-var-update *\"\n" 322 (gdb-enqueue-input (list "server interpreter mi \"-var-update *\"\n"
314 'gdb-var-update-handler)) 323 'gdb-var-update-handler))
315 (gdb-set-pending-triggers (cons 'gdb-var-update 324 (push 'gdb-var-update gdb-pending-triggers))))
316 (gdb-get-pending-triggers))))))
317 325
318(defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"") 326(defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"")
319 327
@@ -327,8 +335,8 @@ speedbar."
327 varnum "\"\n") 335 varnum "\"\n")
328 `(lambda () (gdb-var-evaluate-expression-handler 336 `(lambda () (gdb-var-evaluate-expression-handler
329 ,varnum t))))))) 337 ,varnum t)))))))
330 (gdb-set-pending-triggers 338 (setq gdb-pending-triggers
331 (delq 'gdb-var-update (gdb-get-pending-triggers)))) 339 (delq 'gdb-var-update gdb-pending-triggers)))
332 340
333(defun gdb-var-delete () 341(defun gdb-var-delete ()
334 "Delete watched expression from the speedbar." 342 "Delete watched expression from the speedbar."
@@ -378,43 +386,17 @@ INDENT is the current indentation depth."
378 (if (string-match (concat token "\\.") (nth 1 var)) 386 (if (string-match (concat token "\\.") (nth 1 var))
379 (setq gdb-var-list (delq var gdb-var-list)))) 387 (setq gdb-var-list (delq var gdb-var-list))))
380 (setq gdb-var-changed t)))) 388 (setq gdb-var-changed t))))
381
382 389
383;; ====================================================================== 390(defvar gdb-buffer-type nil
384;;
385;; In this world, there are gdb variables (of unspecified
386;; representation) and buffers associated with those objects.
387;; The list of variables is built up by the expansions of
388;; def-gdb-variable
389
390(defmacro def-gdb-var (root-symbol &optional default doc)
391 (let* ((root (symbol-name root-symbol))
392 (accessor (intern (concat "gdb-get-" root)))
393 (setter (intern (concat "gdb-set-" root)))
394 (name (intern (concat "gdb-" root))))
395 `(progn
396 (defvar ,name ,default ,doc)
397 (if (not (memq ',name gdb-variables))
398 (push ',name gdb-variables))
399 (defun ,accessor ()
400 (buffer-local-value ',name gud-comint-buffer))
401 (defun ,setter (val)
402 (with-current-buffer gud-comint-buffer
403 (setq ,name val))))))
404
405(def-gdb-var buffer-type nil
406 "One of the symbols bound in `gdb-buffer-rules'.") 391 "One of the symbols bound in `gdb-buffer-rules'.")
407 392
408(def-gdb-var burst "" 393(defvar gdb-input-queue ()
409 "A string of characters from gdb that have not yet been processed.")
410
411(def-gdb-var input-queue ()
412 "A list of gdb command objects.") 394 "A list of gdb command objects.")
413 395
414(def-gdb-var prompting nil 396(defvar gdb-prompting nil
415 "True when gdb is idle with no pending input.") 397 "True when gdb is idle with no pending input.")
416 398
417(def-gdb-var output-sink 'user 399(defvar gdb-output-sink 'user
418 "The disposition of the output of the current gdb command. 400 "The disposition of the output of the current gdb command.
419Possible values are these symbols: 401Possible values are these symbols:
420 402
@@ -432,12 +414,14 @@ Possible values are these symbols:
432 gdb mode sends to gdb on its own behalf. 414 gdb mode sends to gdb on its own behalf.
433 post-emacs -- ignore output until the prompt annotation is 415 post-emacs -- ignore output until the prompt annotation is
434 received, then go to USER disposition. 416 received, then go to USER disposition.
435")
436 417
437(def-gdb-var current-item nil 418gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two
419(user and emacs).")
420
421(defvar gdb-current-item nil
438 "The most recent command item sent to gdb.") 422 "The most recent command item sent to gdb.")
439 423
440(def-gdb-var pending-triggers '() 424(defvar gdb-pending-triggers '()
441 "A list of trigger functions that have run later than their output 425 "A list of trigger functions that have run later than their output
442handlers.") 426handlers.")
443 427
@@ -481,8 +465,8 @@ The key should be one of the cars in `gdb-buffer-rules-assoc'."
481 (set (make-local-variable 'gdb-buffer-type) key) 465 (set (make-local-variable 'gdb-buffer-type) key)
482 (if (cdr (cdr rules)) 466 (if (cdr (cdr rules))
483 (funcall (car (cdr (cdr rules))))) 467 (funcall (car (cdr (cdr rules)))))
484 (set (make-local-variable 'gud-comint-buffer) gud-comint-buffer) 468 (set (make-local-variable 'gud-minor-mode)
485 (set (make-local-variable 'gud-minor-mode) 'gdba) 469 (with-current-buffer gud-comint-buffer gud-minor-mode))
486 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) 470 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
487 new)))) 471 new))))
488 472
@@ -550,7 +534,7 @@ The key should be one of the cars in `gdb-buffer-rules-assoc'."
550 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof) 534 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
551 map)) 535 map))
552 536
553(define-derived-mode gdb-inferior-io-mode comint-mode "Debuggee I/O" 537(define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
554 "Major mode for gdb inferior-io." 538 "Major mode for gdb inferior-io."
555 :syntax-table nil :abbrev-table nil 539 :syntax-table nil :abbrev-table nil
556 ;; We want to use comint because it has various nifty and familiar 540 ;; We want to use comint because it has various nifty and familiar
@@ -622,20 +606,18 @@ This filter may simply queue output for a later time."
622;; is a query, or other non-top-level prompt. 606;; is a query, or other non-top-level prompt.
623 607
624(defun gdb-enqueue-input (item) 608(defun gdb-enqueue-input (item)
625 (if (gdb-get-prompting) 609 (if gdb-prompting
626 (progn 610 (progn
627 (gdb-send-item item) 611 (gdb-send-item item)
628 (gdb-set-prompting nil)) 612 (setq gdb-prompting nil))
629 (gdb-set-input-queue 613 (push item gdb-input-queue)))
630 (cons item (gdb-get-input-queue)))))
631 614
632(defun gdb-dequeue-input () 615(defun gdb-dequeue-input ()
633 (let ((queue (gdb-get-input-queue))) 616 (let ((queue gdb-input-queue))
634 (and queue 617 (and queue
635 (let ((last (car (last queue)))) 618 (let ((last (car (last queue))))
636 (unless (nbutlast queue) (gdb-set-input-queue '())) 619 (unless (nbutlast queue) (setq gdb-input-queue '()))
637 last)))) 620 last))))
638
639 621
640;; 622;;
641;; output -- things gdb prints to emacs 623;; output -- things gdb prints to emacs
@@ -664,6 +646,7 @@ This filter may simply queue output for a later time."
664 ("commands" gdb-subprompt) 646 ("commands" gdb-subprompt)
665 ("overload-choice" gdb-subprompt) 647 ("overload-choice" gdb-subprompt)
666 ("query" gdb-subprompt) 648 ("query" gdb-subprompt)
649 ;; Need this prompt for GDB 6.1
667 ("nquery" gdb-subprompt) 650 ("nquery" gdb-subprompt)
668 ("prompt-for-continue" gdb-subprompt) 651 ("prompt-for-continue" gdb-subprompt)
669 ("post-prompt" gdb-post-prompt) 652 ("post-prompt" gdb-post-prompt)
@@ -693,87 +676,95 @@ This filter may simply queue output for a later time."
693 (setq gdb-view-source t) 676 (setq gdb-view-source t)
694 ;; cover for auto-display output which comes *before* 677 ;; cover for auto-display output which comes *before*
695 ;; stopped annotation 678 ;; stopped annotation
696 (if (eq (gdb-get-output-sink) 'inferior) (gdb-set-output-sink 'user))) 679 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
697 680
698(defun gdb-send-item (item) 681(defun gdb-send-item (item)
699 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) 682 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log))
700 (gdb-set-current-item item) 683 (setq gdb-current-item item)
701 (if (stringp item) 684 (with-current-buffer gud-comint-buffer
702 (progn 685 (if (eq gud-minor-mode 'gdba)
703 (gdb-set-output-sink 'user) 686 (progn
704 (process-send-string (get-buffer-process gud-comint-buffer) item)) 687 (if (stringp item)
705 (progn 688 (progn
689 (setq gdb-output-sink 'user)
690 (process-send-string (get-buffer-process gud-comint-buffer) item))
691 (progn
692 (gdb-clear-partial-output)
693 (setq gdb-output-sink 'pre-emacs)
694 (process-send-string (get-buffer-process gud-comint-buffer)
695 (car item)))))
696 ; case: eq gud-minor-mode 'gdbmi
706 (gdb-clear-partial-output) 697 (gdb-clear-partial-output)
707 (gdb-set-output-sink 'pre-emacs) 698 (setq gdb-output-sink 'emacs)
708 (process-send-string (get-buffer-process gud-comint-buffer) 699 (process-send-string (get-buffer-process gud-comint-buffer)
709 (car item))))) 700 (car item)))))
710 701
711(defun gdb-pre-prompt (ignored) 702(defun gdb-pre-prompt (ignored)
712 "An annotation handler for `pre-prompt'. This terminates the collection of 703 "An annotation handler for `pre-prompt'. This terminates the collection of
713output from a previous command if that happens to be in effect." 704output from a previous command if that happens to be in effect."
714 (let ((sink (gdb-get-output-sink))) 705 (let ((sink gdb-output-sink))
715 (cond 706 (cond
716 ((eq sink 'user) t) 707 ((eq sink 'user) t)
717 ((eq sink 'emacs) 708 ((eq sink 'emacs)
718 (gdb-set-output-sink 'post-emacs)) 709 (setq gdb-output-sink 'post-emacs))
719 (t 710 (t
720 (gdb-set-output-sink 'user) 711 (setq gdb-output-sink 'user)
721 (error "Phase error in gdb-pre-prompt (got %s)" sink))))) 712 (error "Phase error in gdb-pre-prompt (got %s)" sink)))))
722 713
723(defun gdb-prompt (ignored) 714(defun gdb-prompt (ignored)
724 "An annotation handler for `prompt'. 715 "An annotation handler for `prompt'.
725This sends the next command (if any) to gdb." 716This sends the next command (if any) to gdb."
726 (when gdb-first-prompt (gdb-ann3)) 717 (when gdb-first-prompt (gdb-ann3))
727 (let ((sink (gdb-get-output-sink))) 718 (let ((sink gdb-output-sink))
728 (cond 719 (cond
729 ((eq sink 'user) t) 720 ((eq sink 'user) t)
730 ((eq sink 'post-emacs) 721 ((eq sink 'post-emacs)
731 (gdb-set-output-sink 'user) 722 (setq gdb-output-sink 'user)
732 (let ((handler 723 (let ((handler
733 (car (cdr (gdb-get-current-item))))) 724 (car (cdr gdb-current-item))))
734 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) 725 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
735 (funcall handler)))) 726 (funcall handler))))
736 (t 727 (t
737 (gdb-set-output-sink 'user) 728 (setq gdb-output-sink 'user)
738 (error "Phase error in gdb-prompt (got %s)" sink)))) 729 (error "Phase error in gdb-prompt (got %s)" sink))))
739 (let ((input (gdb-dequeue-input))) 730 (let ((input (gdb-dequeue-input)))
740 (if input 731 (if input
741 (gdb-send-item input) 732 (gdb-send-item input)
742 (progn 733 (progn
743 (gdb-set-prompting t) 734 (setq gdb-prompting t)
744 (gud-display-frame))))) 735 (gud-display-frame)))))
745 736
746(defun gdb-subprompt (ignored) 737(defun gdb-subprompt (ignored)
747 "An annotation handler for non-top-level prompts." 738 "An annotation handler for non-top-level prompts."
748 (gdb-set-prompting t)) 739 (setq gdb-prompting t))
749 740
750(defun gdb-starting (ignored) 741(defun gdb-starting (ignored)
751 "An annotation handler for `starting'. This says that I/O for the 742 "An annotation handler for `starting'. This says that I/O for the
752subprocess is now the program being debugged, not GDB." 743subprocess is now the program being debugged, not GDB."
753 (let ((sink (gdb-get-output-sink))) 744 (let ((sink gdb-output-sink))
754 (cond 745 (cond
755 ((eq sink 'user) 746 ((eq sink 'user)
756 (progn 747 (progn
757 (setq gud-running t) 748 (setq gud-running t)
758 (if gdb-use-inferior-io-buffer 749 (if gdb-use-inferior-io-buffer
759 (gdb-set-output-sink 'inferior)))) 750 (setq gdb-output-sink 'inferior))))
760 (t (error "Unexpected `starting' annotation"))))) 751 (t (error "Unexpected `starting' annotation")))))
761 752
762(defun gdb-stopping (ignored) 753(defun gdb-stopping (ignored)
763 "An annotation handler for `exited' and other annotations which say that I/O 754 "An annotation handler for `exited' and other annotations which say that I/O
764for the subprocess is now GDB, not the program being debugged." 755for the subprocess is now GDB, not the program being debugged."
765 (if gdb-use-inferior-io-buffer 756 (if gdb-use-inferior-io-buffer
766 (let ((sink (gdb-get-output-sink))) 757 (let ((sink gdb-output-sink))
767 (cond 758 (cond
768 ((eq sink 'inferior) 759 ((eq sink 'inferior)
769 (gdb-set-output-sink 'user)) 760 (setq gdb-output-sink 'user))
770 (t (error "Unexpected stopping annotation")))))) 761 (t (error "Unexpected stopping annotation"))))))
771 762
772(defun gdb-frame-begin (ignored) 763(defun gdb-frame-begin (ignored)
773 (let ((sink (gdb-get-output-sink))) 764 (let ((sink gdb-output-sink))
774 (cond 765 (cond
775 ((eq sink 'inferior) 766 ((eq sink 'inferior)
776 (gdb-set-output-sink 'user)) 767 (setq gdb-output-sink 'user))
777 ((eq sink 'user) t) 768 ((eq sink 'user) t)
778 ((eq sink 'emacs) t) 769 ((eq sink 'emacs) t)
779 (t (error "Unexpected frame-begin annotation (%S)" sink))))) 770 (t (error "Unexpected frame-begin annotation (%S)" sink)))))
@@ -782,17 +773,17 @@ for the subprocess is now GDB, not the program being debugged."
782 "An annotation handler for `stopped'. It is just like gdb-stopping, except 773 "An annotation handler for `stopped'. It is just like gdb-stopping, except
783that if we already set the output sink to 'user in gdb-stopping, that is fine." 774that if we already set the output sink to 'user in gdb-stopping, that is fine."
784 (setq gud-running nil) 775 (setq gud-running nil)
785 (let ((sink (gdb-get-output-sink))) 776 (let ((sink gdb-output-sink))
786 (cond 777 (cond
787 ((eq sink 'inferior) 778 ((eq sink 'inferior)
788 (gdb-set-output-sink 'user)) 779 (setq gdb-output-sink 'user))
789 ((eq sink 'user) t) 780 ((eq sink 'user) t)
790 (t (error "Unexpected stopped annotation"))))) 781 (t (error "Unexpected stopped annotation")))))
791 782
792(defun gdb-post-prompt (ignored) 783(defun gdb-post-prompt (ignored)
793 "An annotation handler for `post-prompt'. This begins the collection of 784 "An annotation handler for `post-prompt'. This begins the collection of
794output from the current command if that happens to be appropriate." 785output from the current command if that happens to be appropriate."
795 (if (not (gdb-get-pending-triggers)) 786 (if (not gdb-pending-triggers)
796 (progn 787 (progn
797 (gdb-get-current-frame) 788 (gdb-get-current-frame)
798 (gdb-invalidate-frames) 789 (gdb-invalidate-frames)
@@ -809,13 +800,13 @@ output from the current command if that happens to be appropriate."
809 (dolist (var gdb-var-list) 800 (dolist (var gdb-var-list)
810 (setcar (nthcdr 5 var) nil)))) 801 (setcar (nthcdr 5 var) nil))))
811 (gdb-var-update)))) 802 (gdb-var-update))))
812 (let ((sink (gdb-get-output-sink))) 803 (let ((sink gdb-output-sink))
813 (cond 804 (cond
814 ((eq sink 'user) t) 805 ((eq sink 'user) t)
815 ((eq sink 'pre-emacs) 806 ((eq sink 'pre-emacs)
816 (gdb-set-output-sink 'emacs)) 807 (setq gdb-output-sink 'emacs))
817 (t 808 (t
818 (gdb-set-output-sink 'user) 809 (setq gdb-output-sink 'user)
819 (error "Phase error in gdb-post-prompt (got %s)" sink))))) 810 (error "Phase error in gdb-post-prompt (got %s)" sink)))))
820 811
821(defun gud-gdba-marker-filter (string) 812(defun gud-gdba-marker-filter (string)
@@ -877,7 +868,7 @@ output from the current command if that happens to be appropriate."
877 output)) 868 output))
878 869
879(defun gdb-concat-output (so-far new) 870(defun gdb-concat-output (so-far new)
880 (let ((sink (gdb-get-output-sink ))) 871 (let ((sink gdb-output-sink))
881 (cond 872 (cond
882 ((eq sink 'user) (concat so-far new)) 873 ((eq sink 'user) (concat so-far new))
883 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far) 874 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far)
@@ -939,19 +930,17 @@ output from the current command if that happens to be appropriate."
939 `(defun ,name (&optional ignored) 930 `(defun ,name (&optional ignored)
940 (if (and (,demand-predicate) 931 (if (and (,demand-predicate)
941 (not (member ',name 932 (not (member ',name
942 (gdb-get-pending-triggers)))) 933 gdb-pending-triggers)))
943 (progn 934 (progn
944 (gdb-enqueue-input 935 (gdb-enqueue-input
945 (list ,gdb-command ',output-handler)) 936 (list ,gdb-command ',output-handler))
946 (gdb-set-pending-triggers 937 (push ',name gdb-pending-triggers)))))
947 (cons ',name
948 (gdb-get-pending-triggers)))))))
949 938
950(defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun) 939(defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun)
951 `(defun ,name () 940 `(defun ,name ()
952 (gdb-set-pending-triggers 941 (setq gdb-pending-triggers
953 (delq ',trigger 942 (delq ',trigger
954 (gdb-get-pending-triggers))) 943 gdb-pending-triggers))
955 (let ((buf (gdb-get-buffer ',buf-key))) 944 (let ((buf (gdb-get-buffer ',buf-key)))
956 (and buf 945 (and buf
957 (with-current-buffer buf 946 (with-current-buffer buf
@@ -1083,7 +1072,7 @@ static char *magick[] = {
1083 (dolist (buffer (buffer-list)) 1072 (dolist (buffer (buffer-list))
1084 (with-current-buffer buffer 1073 (with-current-buffer buffer
1085 (if (and (eq gud-minor-mode 'gdba) 1074 (if (and (eq gud-minor-mode 'gdba)
1086 (not (string-match "^\*" (buffer-name)))) 1075 (not (string-match "\\`\\*.+\\*\\'" (buffer-name))))
1087 (gdb-remove-breakpoint-icons (point-min) (point-max))))) 1076 (gdb-remove-breakpoint-icons (point-min) (point-max)))))
1088 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) 1077 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
1089 (save-excursion 1078 (save-excursion
@@ -1181,7 +1170,9 @@ static char *magick[] = {
1181 (setq mode-name "Breakpoints") 1170 (setq mode-name "Breakpoints")
1182 (use-local-map gdb-breakpoints-mode-map) 1171 (use-local-map gdb-breakpoints-mode-map)
1183 (setq buffer-read-only t) 1172 (setq buffer-read-only t)
1184 (gdb-invalidate-breakpoints)) 1173 (if (eq gud-minor-mode 'gdba)
1174 (gdb-invalidate-breakpoints)
1175 (gdbmi-invalidate-breakpoints)))
1185 1176
1186(defun gdb-toggle-breakpoint () 1177(defun gdb-toggle-breakpoint ()
1187 "Enable/disable the breakpoint at current line." 1178 "Enable/disable the breakpoint at current line."
@@ -1194,8 +1185,8 @@ static char *magick[] = {
1194 (list 1185 (list
1195 (concat 1186 (concat
1196 (if (eq ?y (char-after (match-beginning 2))) 1187 (if (eq ?y (char-after (match-beginning 2)))
1197 "server disable " 1188 gdb-server-prefix "disable "
1198 "server enable ") 1189 gdb-server-prefix "enable ")
1199 (match-string 1) "\n") 1190 (match-string 1) "\n")
1200 'ignore))))) 1191 'ignore)))))
1201 1192
@@ -1206,7 +1197,7 @@ static char *magick[] = {
1206 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")) 1197 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
1207 (error "Not recognized as break/watchpoint line") 1198 (error "Not recognized as break/watchpoint line")
1208 (gdb-enqueue-input 1199 (gdb-enqueue-input
1209 (list (concat "server delete " (match-string 1) "\n") 'ignore)))) 1200 (list (concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))))
1210 1201
1211(defun gdb-goto-breakpoint () 1202(defun gdb-goto-breakpoint ()
1212 "Display the breakpoint location specified at current line." 1203 "Display the breakpoint location specified at current line."
@@ -1299,7 +1290,9 @@ static char *magick[] = {
1299 (setq buffer-read-only t) 1290 (setq buffer-read-only t)
1300 (use-local-map gdb-frames-mode-map) 1291 (use-local-map gdb-frames-mode-map)
1301 (font-lock-mode -1) 1292 (font-lock-mode -1)
1302 (gdb-invalidate-frames)) 1293 (if (eq gud-minor-mode 'gdba)
1294 (gdb-invalidate-frames)
1295 (gdbmi-invalidate-frames)))
1303 1296
1304(defun gdb-get-frame-number () 1297(defun gdb-get-frame-number ()
1305 (save-excursion 1298 (save-excursion
@@ -1311,7 +1304,7 @@ static char *magick[] = {
1311 "Select the frame and display the relevant source." 1304 "Select the frame and display the relevant source."
1312 (interactive) 1305 (interactive)
1313 (gdb-enqueue-input 1306 (gdb-enqueue-input
1314 (list (concat "server frame " (gdb-get-frame-number) "\n") 'ignore)) 1307 (list (concat gdb-server-prefix "frame " (gdb-get-frame-number) "\n") 'ignore))
1315 (gud-display-frame)) 1308 (gud-display-frame))
1316 1309
1317(defun gdb-frames-mouse-select (event) 1310(defun gdb-frames-mouse-select (event)
@@ -1329,7 +1322,7 @@ static char *magick[] = {
1329 1322
1330(def-gdb-auto-updated-buffer gdb-threads-buffer 1323(def-gdb-auto-updated-buffer gdb-threads-buffer
1331 gdb-invalidate-threads 1324 gdb-invalidate-threads
1332 "server info threads\n" 1325 (concat gdb-server-prefix "info threads\n")
1333 gdb-info-threads-handler 1326 gdb-info-threads-handler
1334 gdb-info-threads-custom) 1327 gdb-info-threads-custom)
1335 1328
@@ -1370,7 +1363,7 @@ static char *magick[] = {
1370(defun gdb-threads-mode () 1363(defun gdb-threads-mode ()
1371 "Major mode for gdb frames. 1364 "Major mode for gdb frames.
1372 1365
1373\\{gdb-frames-mode-map}" 1366\\{gdb-threads-mode-map}"
1374 (setq major-mode 'gdb-threads-mode) 1367 (setq major-mode 'gdb-threads-mode)
1375 (setq mode-name "Threads") 1368 (setq mode-name "Threads")
1376 (setq buffer-read-only t) 1369 (setq buffer-read-only t)
@@ -1404,7 +1397,7 @@ static char *magick[] = {
1404 1397
1405(def-gdb-auto-updated-buffer gdb-registers-buffer 1398(def-gdb-auto-updated-buffer gdb-registers-buffer
1406 gdb-invalidate-registers 1399 gdb-invalidate-registers
1407 "server info registers\n" 1400 (concat gdb-server-prefix "info registers\n")
1408 gdb-info-registers-handler 1401 gdb-info-registers-handler
1409 gdb-info-registers-custom) 1402 gdb-info-registers-custom)
1410 1403
@@ -1458,8 +1451,8 @@ static char *magick[] = {
1458;; Abbreviate for arrays and structures. 1451;; Abbreviate for arrays and structures.
1459;; These can be expanded using gud-display. 1452;; These can be expanded using gud-display.
1460(defun gdb-info-locals-handler nil 1453(defun gdb-info-locals-handler nil
1461 (gdb-set-pending-triggers (delq 'gdb-invalidate-locals 1454 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals
1462 (gdb-get-pending-triggers))) 1455 gdb-pending-triggers))
1463 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer))) 1456 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
1464 (with-current-buffer buf 1457 (with-current-buffer buf
1465 (goto-char (point-min)) 1458 (goto-char (point-min))
@@ -1497,7 +1490,9 @@ static char *magick[] = {
1497 (setq mode-name "Locals") 1490 (setq mode-name "Locals")
1498 (setq buffer-read-only t) 1491 (setq buffer-read-only t)
1499 (use-local-map gdb-locals-mode-map) 1492 (use-local-map gdb-locals-mode-map)
1500 (gdb-invalidate-locals)) 1493 (if (eq gud-minor-mode 'gdba)
1494 (gdb-invalidate-locals)
1495 (gdbmi-invalidate-locals)))
1501 1496
1502(defun gdb-locals-buffer-name () 1497(defun gdb-locals-buffer-name ()
1503 (with-current-buffer gud-comint-buffer 1498 (with-current-buffer gud-comint-buffer
@@ -1567,24 +1562,22 @@ static char *magick[] = {
1567 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba))) 1562 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
1568 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer)) 1563 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
1569 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer)) 1564 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
1565 (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
1570 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer)) 1566 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
1571 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) 1567 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
1572 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer)) 1568 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
1573 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)) 1569 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)))
1574; (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
1575)
1576 1570
1577(let ((menu (make-sparse-keymap "GDB-Windows"))) 1571(let ((menu (make-sparse-keymap "GDB-Windows")))
1578 (define-key gud-menu-map [displays] 1572 (define-key gud-menu-map [displays]
1579 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba))) 1573 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba)))
1580 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer)) 1574 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
1575 (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
1581 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer)) 1576 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
1582 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer)) 1577 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
1583 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) 1578 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
1584 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer)) 1579 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
1585 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)) 1580 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
1586; (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
1587)
1588 1581
1589(let ((menu (make-sparse-keymap "View"))) 1582(let ((menu (make-sparse-keymap "View")))
1590 (define-key gud-menu-map [view] 1583 (define-key gud-menu-map [view]
@@ -1686,7 +1679,7 @@ static char *magick[] = {
1686 "Nil (the default value) means just pop up the GUD buffer 1679 "Nil (the default value) means just pop up the GUD buffer
1687unless `gdb-show-main' is t. In this case it starts with two 1680unless `gdb-show-main' is t. In this case it starts with two
1688windows: one displaying the GUD buffer and the other with the 1681windows: one displaying the GUD buffer and the other with the
1689source file with the main routine of the debugee. Non-nil means 1682source file with the main routine of the inferior. Non-nil means
1690display the layout shown for `gdba'." 1683display the layout shown for `gdba'."
1691 :type 'boolean 1684 :type 'boolean
1692 :group 'gud) 1685 :group 'gud)
@@ -1730,7 +1723,7 @@ This arrangement depends on the value of `gdb-many-windows'."
1730 (dolist (buffer (buffer-list)) 1723 (dolist (buffer (buffer-list))
1731 (unless (eq buffer gud-comint-buffer) 1724 (unless (eq buffer gud-comint-buffer)
1732 (with-current-buffer buffer 1725 (with-current-buffer buffer
1733 (if (memq gud-minor-mode '(gdba pdb)) 1726 (if (memq gud-minor-mode '(gdbmi gdba))
1734 (if (string-match "\\`\\*.+\\*\\'" (buffer-name)) 1727 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
1735 (kill-buffer nil) 1728 (kill-buffer nil)
1736 (gdb-remove-breakpoint-icons (point-min) (point-max) t) 1729 (gdb-remove-breakpoint-icons (point-min) (point-max) t)
@@ -1872,7 +1865,7 @@ BUFFER nil or omitted means use the current buffer."
1872 1865
1873(def-gdb-auto-updated-buffer gdb-assembler-buffer 1866(def-gdb-auto-updated-buffer gdb-assembler-buffer
1874 gdb-invalidate-assembler 1867 gdb-invalidate-assembler
1875 (concat "server disassemble " gdb-current-address "\n") 1868 (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
1876 gdb-assembler-handler 1869 gdb-assembler-handler
1877 gdb-assembler-custom) 1870 gdb-assembler-custom)
1878 1871
@@ -1956,38 +1949,35 @@ BUFFER nil or omitted means use the current buffer."
1956 (progn 1949 (progn
1957 (unless (string-equal gdb-current-frame gdb-previous-frame) 1950 (unless (string-equal gdb-current-frame gdb-previous-frame)
1958 (if (or (not (member 'gdb-invalidate-assembler 1951 (if (or (not (member 'gdb-invalidate-assembler
1959 (gdb-get-pending-triggers))) 1952 gdb-pending-triggers))
1960 (not (string-equal gdb-current-address 1953 (not (string-equal gdb-current-address
1961 gdb-previous-address))) 1954 gdb-previous-address)))
1962 (progn 1955 (progn
1963 ;; take previous disassemble command off the queue 1956 ;; take previous disassemble command off the queue
1964 (with-current-buffer gud-comint-buffer 1957 (with-current-buffer gud-comint-buffer
1965 (let ((queue (gdb-get-input-queue)) (item)) 1958 (let ((queue gdb-input-queue) (item))
1966 (dolist (item queue) 1959 (dolist (item queue)
1967 (if (equal (cdr item) '(gdb-assembler-handler)) 1960 (if (equal (cdr item) '(gdb-assembler-handler))
1968 (gdb-set-input-queue 1961 (setq gdb-input-queue
1969 (delete item (gdb-get-input-queue))))))) 1962 (delete item gdb-input-queue))))))
1970 (gdb-enqueue-input 1963 (gdb-enqueue-input
1971 (list (concat "server disassemble " gdb-current-address "\n") 1964 (list (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
1972 'gdb-assembler-handler)) 1965 'gdb-assembler-handler))
1973 (gdb-set-pending-triggers 1966 (push 'gdb-invalidate-assembler gdb-pending-triggers)
1974 (cons 'gdb-invalidate-assembler
1975 (gdb-get-pending-triggers)))
1976 (setq gdb-previous-address gdb-current-address) 1967 (setq gdb-previous-address gdb-current-address)
1977 (setq gdb-previous-frame gdb-current-frame))))))) 1968 (setq gdb-previous-frame gdb-current-frame)))))))
1978 1969
1979(defun gdb-get-current-frame () 1970(defun gdb-get-current-frame ()
1980 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers))) 1971 (if (not (member 'gdb-get-current-frame gdb-pending-triggers))
1981 (progn 1972 (progn
1982 (gdb-enqueue-input 1973 (gdb-enqueue-input
1983 (list (concat "server info frame\n") 'gdb-frame-handler)) 1974 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
1984 (gdb-set-pending-triggers 1975 (push 'gdb-get-current-frame
1985 (cons 'gdb-get-current-frame 1976 gdb-pending-triggers))))
1986 (gdb-get-pending-triggers))))))
1987 1977
1988(defun gdb-frame-handler () 1978(defun gdb-frame-handler ()
1989 (gdb-set-pending-triggers 1979 (setq gdb-pending-triggers
1990 (delq 'gdb-get-current-frame (gdb-get-pending-triggers))) 1980 (delq 'gdb-get-current-frame gdb-pending-triggers))
1991 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) 1981 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
1992 (goto-char (point-min)) 1982 (goto-char (point-min))
1993 (forward-line) 1983 (forward-line)