diff options
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/comint.el | 34 | ||||
| -rw-r--r-- | lisp/progmodes/gdb-mi.el | 72 |
3 files changed, 86 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7ef7628b6d6..1ce5e7fceea 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2012-04-19 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/gdb-mi.el (gdb-inferior-io--maybe-delete-pty): New | ||
| 4 | function to call delete-process on the gdb-inferior buffer's pty. | ||
| 5 | (gdb-reset): Use it, instead of relying on kill-buffer to kill the | ||
| 6 | pty process (Bug#11273). | ||
| 7 | (gdb-update): New arg to suppress talking to the gdb process. | ||
| 8 | (gdb-done-or-error): Use it. | ||
| 9 | (gdb-stopped-functions): Rename from gdb-stopped-hooks. | ||
| 10 | (gdb): Call gdb-inferior-io--maybe-delete-pty as a workaround for | ||
| 11 | sentinel not being called. | ||
| 12 | |||
| 13 | * comint.el (make-comint-in-buffer, comint-exec): Doc fix. | ||
| 14 | |||
| 1 | 2012-04-18 Chong Yidong <cyd@gnu.org> | 15 | 2012-04-18 Chong Yidong <cyd@gnu.org> |
| 2 | 16 | ||
| 3 | * progmodes/grep.el (grep, rgrep): Doc fix (Bug#11268). | 17 | * progmodes/grep.el (grep, rgrep): Doc fix (Bug#11268). |
diff --git a/lisp/comint.el b/lisp/comint.el index 68fedeb88a9..10981675971 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -699,16 +699,21 @@ BUFFER can be either a buffer or the name of one." | |||
| 699 | (defun make-comint-in-buffer (name buffer program &optional startfile &rest switches) | 699 | (defun make-comint-in-buffer (name buffer program &optional startfile &rest switches) |
| 700 | "Make a Comint process NAME in BUFFER, running PROGRAM. | 700 | "Make a Comint process NAME in BUFFER, running PROGRAM. |
| 701 | If BUFFER is nil, it defaults to NAME surrounded by `*'s. | 701 | If BUFFER is nil, it defaults to NAME surrounded by `*'s. |
| 702 | PROGRAM should be either a string denoting an executable program to create | 702 | If there is a running process in BUFFER, it is not restarted. |
| 703 | via `start-file-process', or a cons pair of the form (HOST . SERVICE) denoting | 703 | |
| 704 | a TCP connection to be opened via `open-network-stream'. If there is already | 704 | PROGRAM should be one of the following: |
| 705 | a running process in that buffer, it is not restarted. Optional fourth arg | 705 | - a string, denoting an executable program to create via |
| 706 | STARTFILE is the name of a file, whose contents are sent to the | 706 | `start-file-process' |
| 707 | process as its initial input. | 707 | - a cons pair of the form (HOST . SERVICE), denoting a TCP |
| 708 | connection to be opened via `open-network-stream' | ||
| 709 | - nil, denoting a newly-allocated pty. | ||
| 710 | |||
| 711 | Optional fourth arg STARTFILE is the name of a file, whose | ||
| 712 | contents are sent to the process as its initial input. | ||
| 708 | 713 | ||
| 709 | If PROGRAM is a string, any more args are arguments to PROGRAM. | 714 | If PROGRAM is a string, any more args are arguments to PROGRAM. |
| 710 | 715 | ||
| 711 | Returns the (possibly newly created) process buffer." | 716 | Return the (possibly newly created) process buffer." |
| 712 | (or (fboundp 'start-file-process) | 717 | (or (fboundp 'start-file-process) |
| 713 | (error "Multi-processing is not supported for this system")) | 718 | (error "Multi-processing is not supported for this system")) |
| 714 | (setq buffer (get-buffer-create (or buffer (concat "*" name "*")))) | 719 | (setq buffer (get-buffer-create (or buffer (concat "*" name "*")))) |
| @@ -752,9 +757,18 @@ See `make-comint' and `comint-exec'." | |||
| 752 | (defun comint-exec (buffer name command startfile switches) | 757 | (defun comint-exec (buffer name command startfile switches) |
| 753 | "Start up a process named NAME in buffer BUFFER for Comint modes. | 758 | "Start up a process named NAME in buffer BUFFER for Comint modes. |
| 754 | Runs the given COMMAND with SWITCHES, and initial input from STARTFILE. | 759 | Runs the given COMMAND with SWITCHES, and initial input from STARTFILE. |
| 755 | Blasts any old process running in the buffer. Doesn't set the buffer mode. | 760 | |
| 756 | You can use this to cheaply run a series of processes in the same Comint | 761 | COMMAND should be one of the following: |
| 757 | buffer. The hook `comint-exec-hook' is run after each exec." | 762 | - a string, denoting an executable program to create via |
| 763 | `start-file-process' | ||
| 764 | - a cons pair of the form (HOST . SERVICE), denoting a TCP | ||
| 765 | connection to be opened via `open-network-stream' | ||
| 766 | - nil, denoting a newly-allocated pty. | ||
| 767 | |||
| 768 | This function blasts any old process running in the buffer, and | ||
| 769 | does not set the buffer mode. You can use this to cheaply run a | ||
| 770 | series of processes in the same Comint buffer. The hook | ||
| 771 | `comint-exec-hook' is run after each exec." | ||
| 758 | (with-current-buffer buffer | 772 | (with-current-buffer buffer |
| 759 | (let ((proc (get-buffer-process buffer))) ; Blast any old process. | 773 | (let ((proc (get-buffer-process buffer))) ; Blast any old process. |
| 760 | (if proc (delete-process proc))) | 774 | (if proc (delete-process proc))) |
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. |
| 380 | GDB stops. | ||
| 381 | 380 | ||
| 382 | Each function takes one argument, a parsed MI response, which | 381 | Each function takes one argument, a parsed MI response, which |
| 383 | contains fields of corresponding MI *stopped async record: | 382 | contains 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. |
| 1763 | If 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. |
| 4110 | Kills the gdb buffers, and resets variables and the source buffers." | 4131 | Kills 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 |