Mercurial > emacs
diff lisp/progmodes/gud.el @ 103504:b2b747edcf7e
* progmodes/gdb-ui.el: Replace with ...
* progmodes/gdb-ui.el: ... this file.
* progmodes/gud.el: Modify for gdb-mi.el.
* fadr.el: New file.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sun, 21 Jun 2009 12:08:53 +0000 |
parents | a9dc0e7c3f2b |
children | e48e0579baed |
line wrap: on
line diff
--- a/lisp/progmodes/gud.el Sun Jun 21 12:07:34 2009 +0000 +++ b/lisp/progmodes/gud.el Sun Jun 21 12:08:53 2009 +0000 @@ -45,7 +45,6 @@ (defvar gdb-active-process) (defvar gdb-define-alist) (defvar gdb-macro-info) -(defvar gdb-server-prefix) (defvar gdb-show-changed-values) (defvar gdb-source-window) (defvar gdb-var-list) @@ -125,13 +124,13 @@ (throw 'info-found nil)))) nil 0) (select-frame (make-frame))) - (if (memq gud-minor-mode '(gdbmi gdba)) + (if (eq gud-minor-mode 'gdbmi) (info "(emacs)GDB Graphical Interface") (info "(emacs)Debuggers")))) (defun gud-tool-bar-item-visible-no-fringe () (not (or (eq (buffer-local-value 'major-mode (window-buffer)) 'speedbar-mode) - (and (memq gud-minor-mode '(gdbmi gdba)) + (and (eq gud-minor-mode 'gdbmi) (> (car (window-fringes)) 0))))) (defun gud-stop-subjob () @@ -150,7 +149,7 @@ (display-graphic-p) (fboundp 'x-show-tip)) :visible (memq gud-minor-mode - '(gdbmi gdba dbx sdb xdb pdb)) + '(gdbmi dbx sdb xdb pdb)) :button (:toggle . gud-tooltip-mode)) ([refresh] "Refresh" . gud-refresh) ([run] menu-item "Run" gud-run @@ -158,14 +157,14 @@ :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) ([go] menu-item (if gdb-active-process "Continue" "Run") gud-go :visible (and (not gud-running) - (eq gud-minor-mode 'gdba))) + (eq gud-minor-mode 'gdbmi))) ([stop] menu-item "Stop" gud-stop-subjob - :visible (or (not (memq gud-minor-mode '(gdba pdb))) + :visible (or (not (memq gud-minor-mode '(gdbmi pdb))) (and gud-running - (eq gud-minor-mode 'gdba)))) + (eq gud-minor-mode 'gdbmi)))) ([until] menu-item "Continue to selection" gud-until :enable (not gud-running) - :visible (and (memq gud-minor-mode '(gdbmi gdba gdb perldb)) + :visible (and (memq gud-minor-mode '(gdbmi gdb perldb)) (gud-tool-bar-item-visible-no-fringe))) ([remove] menu-item "Remove Breakpoint" gud-remove :enable (not gud-running) @@ -173,50 +172,50 @@ ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdba gdb sdb xdb))) + '(gdbmi gdb sdb xdb))) ([break] menu-item "Set Breakpoint" gud-break :enable (not gud-running) :visible (gud-tool-bar-item-visible-no-fringe)) ([up] menu-item "Up Stack" gud-up :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdba gdb dbx xdb jdb pdb))) + '(gdbmi gdb dbx xdb jdb pdb))) ([down] menu-item "Down Stack" gud-down :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdba gdb dbx xdb jdb pdb))) + '(gdbmi gdb dbx xdb jdb pdb))) ([pp] menu-item "Print S-expression" gud-pp :enable (and (not gud-running) gdb-active-process) :visible (and (string-equal (buffer-local-value 'gud-target-name gud-comint-buffer) "emacs") - (eq gud-minor-mode 'gdba))) + (eq gud-minor-mode 'gdbmi))) ([print*] menu-item "Print Dereference" gud-pstar :enable (not gud-running) - :visible (memq gud-minor-mode '(gdbmi gdba gdb))) + :visible (memq gud-minor-mode '(gdbmi gdb))) ([print] menu-item "Print Expression" gud-print :enable (not gud-running)) ([watch] menu-item "Watch Expression" gud-watch :enable (not gud-running) - :visible (memq gud-minor-mode '(gdbmi gdba))) + :visible (eq gud-minor-mode 'gdbmi)) ([finish] menu-item "Finish Function" gud-finish :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdba gdb xdb jdb pdb))) + '(gdbmi gdb xdb jdb pdb))) ([stepi] menu-item "Step Instruction" gud-stepi :enable (not gud-running) - :visible (memq gud-minor-mode '(gdbmi gdba gdb dbx))) + :visible (memq gud-minor-mode '(gdbmi gdb dbx))) ([nexti] menu-item "Next Instruction" gud-nexti :enable (not gud-running) - :visible (memq gud-minor-mode '(gdbmi gdba gdb dbx))) + :visible (memq gud-minor-mode '(gdbmi gdb dbx))) ([step] menu-item "Step Line" gud-step :enable (not gud-running)) ([next] menu-item "Next Line" gud-next :enable (not gud-running)) ([cont] menu-item "Continue" gud-cont :enable (not gud-running) - :visible (not (eq gud-minor-mode 'gdba)))) + :visible (not (eq gud-minor-mode 'gdbmi)))) "Menu for `gud-mode'." :name "Gud") @@ -238,21 +237,21 @@ . (,(propertize "next" 'face 'font-lock-doc-face) . gud-next)) ([menu-bar until] menu-item ,(propertize "until" 'face 'font-lock-doc-face) gud-until - :visible (memq gud-minor-mode '(gdbmi gdba gdb perldb))) + :visible (memq gud-minor-mode '(gdbmi gdb perldb))) ([menu-bar cont] menu-item ,(propertize "cont" 'face 'font-lock-doc-face) gud-cont - :visible (not (eq gud-minor-mode 'gdba))) + :visible (not (eq gud-minor-mode 'gdbmi))) ([menu-bar run] menu-item ,(propertize "run" 'face 'font-lock-doc-face) gud-run :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) ([menu-bar go] menu-item ,(propertize " go " 'face 'font-lock-doc-face) gud-go :visible (and (not gud-running) - (eq gud-minor-mode 'gdba))) + (eq gud-minor-mode 'gdbmi))) ([menu-bar stop] menu-item ,(propertize "stop" 'face 'font-lock-doc-face) gud-stop-subjob :visible (or gud-running - (not (eq gud-minor-mode 'gdba)))) + (not (eq gud-minor-mode 'gdbmi)))) ([menu-bar print] . (,(propertize "print" 'face 'font-lock-doc-face) . gud-print)) ([menu-bar tools] . undefined) @@ -315,7 +314,7 @@ (setq directories (cdr directories))) result))) -(declare-function gdb-create-define-alist "gdb-ui" ()) +(declare-function gdb-create-define-alist "gdb-mi" ()) (defun gud-find-file (file) ;; Don't get confused by double slashes in the name that comes from GDB. @@ -331,7 +330,7 @@ (set (make-local-variable 'gud-minor-mode) minor-mode) (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) (when (and gud-tooltip-mode - (memq gud-minor-mode '(gdbmi gdba))) + (eq gud-minor-mode 'gdbmi)) (make-local-variable 'gdb-define-alist) (unless gdb-define-alist (gdb-create-define-alist)) (add-hook 'after-save-hook 'gdb-create-define-alist nil t)) @@ -460,21 +459,21 @@ (defvar gud-speedbar-menu-items '(["Jump to stack frame" speedbar-edit-line - :visible (not (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba)))] + :visible (not (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi))] ["Edit value" speedbar-edit-line - :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba))] + :visible (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi)] ["Delete expression" gdb-var-delete - :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba))] + :visible (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi)] ["Auto raise frame" gdb-speedbar-auto-raise :style toggle :selected gdb-speedbar-auto-raise - :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba))] + :visible (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi)] ("Output Format" - :visible (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba)) + :visible (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi) ["Binary" (gdb-var-set-format "binary") t] ["Natural" (gdb-var-set-format "natural") t] ["Hexadecimal" (gdb-var-set-format "hexadecimal") t])) @@ -503,7 +502,7 @@ (start (window-start window)) (p (window-point window))) (cond - ((memq minor-mode '(gdbmi gdba)) + ((eq minor-mode 'gdbmi) (erase-buffer) (insert "Watch Expressions:\n") (let ((var-list gdb-var-list) parent) @@ -591,7 +590,7 @@ (car frame) 'speedbar-file-face 'speedbar-highlight-face - (cond ((memq minor-mode '(gdbmi gdba gdb)) + (cond ((memq minor-mode '(gdbmi gdb)) 'gud-gdb-goto-stackframe) (t (error "Should never be here"))) frame t)))) @@ -648,8 +647,6 @@ ;; Set the accumulator to the remaining text. gud-marker-acc (substring gud-marker-acc (match-end 0)))) - ;; Check for annotations and change gud-minor-mode to 'gdba if - ;; they are found. (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) (let ((match (match-string 1 gud-marker-acc))) @@ -713,10 +710,10 @@ (defvar gud-filter-pending-text nil "Non-nil means this is text that has been saved for later in `gud-filter'.") -;; If in gdba mode, gdb-ui is loaded. -(declare-function gdb-restore-windows "gdb-ui" ()) - -;; The old gdb command (text command mode). The new one is in gdb-ui.el. +;; If in gdb mode, gdb-mi is loaded. +(declare-function gdb-restore-windows "gdb-mi" ()) + +;; The old gdb command (text command mode). The new one is in gdb-mi.el. ;;;###autoload (defun gud-gdb (command-line) "Run gdb on program FILE in buffer *gud-FILE*. @@ -727,10 +724,10 @@ (when (and gud-comint-buffer (buffer-name gud-comint-buffer) (get-buffer-process gud-comint-buffer) - (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))) - (gdb-restore-windows) - (error - "Multiple debugging requires restarting in text command mode")) + (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdbmi))) + (gdb-restore-windows) + (error + "Multiple debugging requires restarting in text command mode")) (gud-common-init command-line nil 'gud-gdb-marker-filter) (set (make-local-variable 'gud-minor-mode) 'gdb) @@ -2600,7 +2597,7 @@ (defvar gud-overlay-arrow-position nil) (add-to-list 'overlay-arrow-variable-list 'gud-overlay-arrow-position) -(declare-function gdb-reset "gdb-ui" ()) +(declare-function gdb-reset "gdb-mi" ()) (defun gud-sentinel (proc msg) (cond ((null (buffer-name (process-buffer proc))) @@ -2612,14 +2609,14 @@ (string-equal speedbar-initial-expansion-list-name "GUD")) (speedbar-change-initial-expansion-list speedbar-previously-used-expansion-list-name)) - (if (memq gud-minor-mode-type '(gdbmi gdba)) + (if (eq gud-minor-mode-type 'gdbmi) (gdb-reset) (gud-reset))) ((memq (process-status proc) '(signal exit)) ;; Stop displaying an arrow in a source file. (setq gud-overlay-arrow-position nil) - (if (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdba gdbmi)) + (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi) (gdb-reset) (gud-reset)) (let* ((obuf (current-buffer))) @@ -2650,7 +2647,9 @@ (defun gud-kill-buffer-hook () (setq gud-minor-mode-type gud-minor-mode) (condition-case nil - (kill-process (get-buffer-process (current-buffer))) + (progn + (kill-process (get-buffer-process (current-buffer))) + (delete-process (get-process "gdb-inferior"))) (error nil))) (defun gud-reset () @@ -2673,8 +2672,8 @@ (declare-function global-hl-line-highlight "hl-line" ()) (declare-function hl-line-highlight "hl-line" ()) -(declare-function gdb-display-source-buffer "gdb-ui" (buffer)) -(declare-function gdb-display-buffer "gdb-ui" (buf dedicated &optional size)) +(declare-function gdb-display-source-buffer "gdb-mi" (buffer)) +(declare-function gdb-display-buffer "gdb-mi" (buf dedicated &optional size)) ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen ;; and that its line LINE is visible. @@ -2690,7 +2689,7 @@ (gud-find-file true-file))) (window (and buffer (or (get-buffer-window buffer) - (if (memq gud-minor-mode '(gdbmi gdba)) + (if (eq gud-minor-mode 'gdbmi) (or (if (get-buffer-window buffer 'visible) (display-buffer buffer nil 'visible)) (unless (gdb-display-source-buffer buffer) @@ -2726,7 +2725,7 @@ (goto-char pos)))) (when window (set-window-point window gud-overlay-arrow-position) - (if (memq gud-minor-mode '(gdbmi gdba)) + (if (eq gud-minor-mode 'gdbmi) (setq gdb-source-window window))))))) ;; The gud-call function must do the right thing whether its invoking @@ -2832,7 +2831,7 @@ (forward-line 0)) (if (looking-at comint-prompt-regexp) (set-marker gud-delete-prompt-marker (point))) - (if (memq gud-minor-mode '(gdbmi gdba)) + (if (eq gud-minor-mode 'gdbmi) (apply comint-input-sender (list proc command)) (process-send-string proc (concat command "\n"))))))) @@ -3239,6 +3238,7 @@ ;;; Customizable settings +;;;###autoload (define-minor-mode gud-tooltip-mode "Toggle the display of GUD tooltips." :global t @@ -3258,14 +3258,14 @@ (gud-tooltip-activate-mouse-motions-if-enabled) (if (and gud-comint-buffer (buffer-name gud-comint-buffer); gud-comint-buffer might be killed - (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer) - '(gdbmi gdba))) + (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) + 'gdbmi)) (if gud-tooltip-mode (progn (dolist (buffer (buffer-list)) (unless (eq buffer gud-comint-buffer) (with-current-buffer buffer - (when (and (memq gud-minor-mode '(gdbmi gdba)) + (when (and (eq gud-minor-mode 'gdbmi) (not (string-match "\\`\\*.+\\*\\'" (buffer-name)))) (make-local-variable 'gdb-define-alist) @@ -3391,8 +3391,8 @@ ; Larger arrays (say 400 elements) are displayed in ; the tooltip incompletely and spill over into the gud buffer. ; Switching the process-filter creates timing problems and -; it may be difficult to do better. Using annotations as in -; gdb-ui.el gets round this problem. +; it may be difficult to do better. Using GDB/MI as in +; gdb-mi.el gets round this problem. (defun gud-tooltip-process-output (process output) "Process debugger output and show it in a tooltip window." (set-process-filter process gud-tooltip-original-filter) @@ -3402,12 +3402,11 @@ (defun gud-tooltip-print-command (expr) "Return a suitable command to print the expression EXPR." (case gud-minor-mode - (gdba (concat "server print " expr)) ((dbx gdbmi) (concat "print " expr)) ((xdb pdb) (concat "p " expr)) (sdb (concat expr "/")))) -(declare-function gdb-enqueue-input "gdb-ui" (item)) +(declare-function gdb-input "gdb-mi" (item)) (declare-function tooltip-expr-to-print "tooltip" (event)) (declare-function tooltip-event-buffer "tooltip" (event)) @@ -3427,12 +3426,12 @@ (buffer-name gud-comint-buffer); might be killed (setq process (get-buffer-process gud-comint-buffer)) (posn-point (event-end event)) - (or (and (eq gud-minor-mode 'gdba) (not gdb-active-process)) + (or (and (eq gud-minor-mode 'gdbmi) (not gdb-active-process)) (progn (setq gud-tooltip-event event) (eval (cons 'and gud-tooltip-display))))) (let ((expr (tooltip-expr-to-print event))) (when expr - (if (and (eq gud-minor-mode 'gdba) + (if (and (eq gud-minor-mode 'gdbmi) (not gdb-active-process)) (progn (with-current-buffer (tooltip-event-buffer event) @@ -3450,13 +3449,13 @@ (message-box "Using GUD tooltips in this mode is unsafe\n\ so they have been disabled.")) (unless (null cmd) ; CMD can be nil if unknown debugger - (if (memq gud-minor-mode '(gdba gdbmi)) + (if (eq gud-minor-mode 'gdbmi) (if gdb-macro-info - (gdb-enqueue-input + (gdb-input (list (concat - gdb-server-prefix "macro expand " expr "\n") + "server macro expand " expr "\n") `(lambda () (gdb-tooltip-print-1 ,expr)))) - (gdb-enqueue-input + (gdb-input (list (concat cmd "\n") `(lambda () (gdb-tooltip-print ,expr))))) (setq gud-tooltip-original-filter (process-filter process))