aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorChong Yidong2012-04-19 16:09:30 +0800
committerChong Yidong2012-04-19 16:09:30 +0800
commitb668fa6eb0d46a8f3c675954dfd8ce79e6441129 (patch)
tree3ecf93953301ce744455f7eaa79d2b18d8c3a631 /lisp/progmodes
parentc5467d73aea190e3712f1e146c326ad2d94ed0bb (diff)
downloademacs-b668fa6eb0d46a8f3c675954dfd8ce79e6441129.tar.gz
emacs-b668fa6eb0d46a8f3c675954dfd8ce79e6441129.zip
Delete the gdb-inferior pty when the gdb process exits.
* lisp/progmodes/gdb-mi.el (gdb-inferior-io--maybe-delete-pty): New function to call delete-process on the gdb-inferior buffer's pty. (gdb-reset): Use it, instead of relying on kill-buffer to kill the pty process. (gdb-update): New arg to suppress talking to the gdb process. (gdb-done-or-error): Use it. (gdb-stopped-functions): Rename from gdb-stopped-hooks. (gdb): Call gdb-inferior-io--maybe-delete-pty as a workaround for sentinel not being called. * lisp/comint.el (make-comint-in-buffer, comint-exec): Doc fix. Fixes: debbugs:11273
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/gdb-mi.el72
1 files changed, 48 insertions, 24 deletions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 89450cd2276..450075fde42 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -375,9 +375,8 @@ Emacs always switches to the thread which caused the stop."
375 :version "23.2" 375 :version "23.2"
376 :link '(info-link "(gdb)GDB/MI Async Records")) 376 :link '(info-link "(gdb)GDB/MI Async Records"))
377 377
378(defcustom gdb-stopped-hooks nil 378(defcustom gdb-stopped-functions nil
379 "This variable holds a list of functions to be called whenever 379 "List of functions called whenever GDB stops.
380GDB stops.
381 380
382Each function takes one argument, a parsed MI response, which 381Each function takes one argument, a parsed MI response, which
383contains fields of corresponding MI *stopped async record: 382contains fields of corresponding MI *stopped async record:
@@ -818,6 +817,11 @@ detailed description of this mode.
818 nil 'local) 817 nil 'local)
819 (local-set-key "\C-i" 'completion-at-point) 818 (local-set-key "\C-i" 'completion-at-point)
820 819
820 ;; FIXME: Under some circumstances, `gud-sentinel' apparently does
821 ;; not get called when the gdb process is killed (Bug#11273).
822 (add-hook 'post-command-hook 'gdb-inferior-io--maybe-delete-pty
823 nil t)
824
821 (setq gdb-first-prompt t) 825 (setq gdb-first-prompt t)
822 (setq gud-running nil) 826 (setq gud-running nil)
823 827
@@ -1510,6 +1514,14 @@ DOC is an optional documentation string."
1510 (gdb-display-buffer 1514 (gdb-display-buffer
1511 (gdb-get-buffer-create 'gdb-inferior-io) t)) 1515 (gdb-get-buffer-create 'gdb-inferior-io) t))
1512 1516
1517(defun gdb-inferior-io--maybe-delete-pty ()
1518 (let ((proc (get-buffer-process gud-comint-buffer))
1519 (inf-pty (get-process "gdb-inferior")))
1520 (and (or (null proc)
1521 (memq (process-status proc) '(exit signal)))
1522 inf-pty
1523 (delete-process inf-pty))))
1524
1513(defconst gdb-frame-parameters 1525(defconst gdb-frame-parameters
1514 '((height . 14) (width . 80) 1526 '((height . 14) (width . 80)
1515 (unsplittable . t) 1527 (unsplittable . t)
@@ -1746,24 +1758,27 @@ If `gdb-thread-number' is nil, just wrap NAME in asterisks."
1746 (setq gdb-output-sink 'user) 1758 (setq gdb-output-sink 'user)
1747 (setq gdb-pending-triggers nil)) 1759 (setq gdb-pending-triggers nil))
1748 1760
1749(defun gdb-update () 1761(defun gdb-update (&optional no-proc)
1750 "Update buffers showing status of debug session." 1762 "Update buffers showing status of debug session.
1763If NO-PROC is non-nil, do not try to contact the GDB process."
1751 (when gdb-first-prompt 1764 (when gdb-first-prompt
1752 (gdb-force-mode-line-update 1765 (gdb-force-mode-line-update
1753 (propertize "initializing..." 'face font-lock-variable-name-face)) 1766 (propertize "initializing..." 'face font-lock-variable-name-face))
1754 (gdb-init-1) 1767 (gdb-init-1)
1755 (setq gdb-first-prompt nil)) 1768 (setq gdb-first-prompt nil))
1756 1769
1757 (gdb-get-main-selected-frame) 1770 (unless no-proc
1771 (gdb-get-main-selected-frame))
1772
1758 ;; We may need to update gdb-threads-list so we can use 1773 ;; We may need to update gdb-threads-list so we can use
1759 (gdb-get-buffer-create 'gdb-threads-buffer) 1774 (gdb-get-buffer-create 'gdb-threads-buffer)
1760 ;; gdb-break-list is maintained in breakpoints handler 1775 ;; gdb-break-list is maintained in breakpoints handler
1761 (gdb-get-buffer-create 'gdb-breakpoints-buffer) 1776 (gdb-get-buffer-create 'gdb-breakpoints-buffer)
1762 1777
1763 (gdb-emit-signal gdb-buf-publisher 'update) 1778 (unless no-proc
1779 (gdb-emit-signal gdb-buf-publisher 'update))
1764 1780
1765 (gdb-get-changed-registers) 1781 (gdb-get-changed-registers)
1766
1767 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) 1782 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
1768 (dolist (var gdb-var-list) 1783 (dolist (var gdb-var-list)
1769 (setcar (nthcdr 5 var) nil)) 1784 (setcar (nthcdr 5 var) nil))
@@ -2045,7 +2060,7 @@ current thread and update GDB buffers."
2045 ;; In all-stop this updates gud-running properly as well. 2060 ;; In all-stop this updates gud-running properly as well.
2046 (gdb-update) 2061 (gdb-update)
2047 (setq gdb-first-done-or-error nil)) 2062 (setq gdb-first-done-or-error nil))
2048 (run-hook-with-args 'gdb-stopped-hooks result))) 2063 (run-hook-with-args 'gdb-stopped-functions result)))
2049 2064
2050;; Remove the trimmings from log stream containing debugging messages 2065;; Remove the trimmings from log stream containing debugging messages
2051;; being produced by GDB's internals, use warning face and send to GUD 2066;; being produced by GDB's internals, use warning face and send to GUD
@@ -2085,23 +2100,28 @@ current thread and update GDB buffers."
2085 (setq gdb-output-sink 'emacs)) 2100 (setq gdb-output-sink 'emacs))
2086 2101
2087 (gdb-clear-partial-output) 2102 (gdb-clear-partial-output)
2088 (when gdb-first-done-or-error
2089 (unless (or token-number gud-running)
2090 (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name)))
2091 (gdb-update)
2092 (setq gdb-first-done-or-error nil))
2093 2103
2094 (setq gdb-filter-output 2104 ;; The process may already be dead (e.g. C-d at the gdb prompt).
2095 (gdb-concat-output gdb-filter-output output-field)) 2105 (let* ((proc (get-buffer-process gud-comint-buffer))
2106 (no-proc (or (null proc)
2107 (memq (process-status proc) '(exit signal)))))
2096 2108
2097 (if token-number 2109 (when gdb-first-done-or-error
2098 (progn 2110 (unless (or token-number gud-running no-proc)
2099 (with-current-buffer 2111 (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name)))
2100 (gdb-get-buffer-create 'gdb-partial-output-buffer) 2112 (gdb-update no-proc)
2101 (funcall 2113 (setq gdb-first-done-or-error nil))
2102 (cdr (assoc (string-to-number token-number) gdb-handler-alist)))) 2114
2103 (setq gdb-handler-alist 2115 (setq gdb-filter-output
2104 (assq-delete-all token-number gdb-handler-alist))))) 2116 (gdb-concat-output gdb-filter-output output-field))
2117
2118 (when token-number
2119 (with-current-buffer
2120 (gdb-get-buffer-create 'gdb-partial-output-buffer)
2121 (funcall
2122 (cdr (assoc (string-to-number token-number) gdb-handler-alist))))
2123 (setq gdb-handler-alist
2124 (assq-delete-all token-number gdb-handler-alist)))))
2105 2125
2106(defun gdb-concat-output (so-far new) 2126(defun gdb-concat-output (so-far new)
2107 (cond 2127 (cond
@@ -4105,9 +4125,13 @@ This arrangement depends on the value of `gdb-many-windows'."
4105 (gud-find-file gdb-main-file))) 4125 (gud-find-file gdb-main-file)))
4106 (setq gdb-source-window win))))) 4126 (setq gdb-source-window win)))))
4107 4127
4128;; Called from `gud-sentinel' in gud.el:
4108(defun gdb-reset () 4129(defun gdb-reset ()
4109 "Exit a debugging session cleanly. 4130 "Exit a debugging session cleanly.
4110Kills the gdb buffers, and resets variables and the source buffers." 4131Kills the gdb buffers, and resets variables and the source buffers."
4132 ;; The gdb-inferior buffer has a pty hooked up to the main gdb
4133 ;; process. This pty must be deleted explicitly.
4134 (gdb-inferior-io--maybe-delete-pty)
4111 (dolist (buffer (buffer-list)) 4135 (dolist (buffer (buffer-list))
4112 (unless (eq buffer gud-comint-buffer) 4136 (unless (eq buffer gud-comint-buffer)
4113 (with-current-buffer buffer 4137 (with-current-buffer buffer