[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape 4a97094b10 077/123: Kill adapter on terminate even
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape 4a97094b10 077/123: Kill adapter on terminate event |
Date: |
Tue, 5 Dec 2023 03:58:02 -0500 (EST) |
branch: externals/dape
commit 4a97094b10a7515f4448b4843bb71fb8d8595b55
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>
Kill adapter on terminate event
---
dape.el | 69 +++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/dape.el b/dape.el
index 2a6672dc2b..d1c5469991 100644
--- a/dape.el
+++ b/dape.el
@@ -281,6 +281,8 @@ The hook is run with one argument, the compilation buffer."
"Debug adapter communications process.")
(defvar dape--parent-process nil
"Debug adapter parent process. Used for by startDebugging adapters.")
+(defvar dape--restart-in-progress nil
+ "Used for prevent adapter killing when restart request is in flight.")
(defvar dape--tree-widget-open-p (make-hash-table :test 'equal)
"Hash table of open `dape--tree-widget' widgets.")
@@ -660,7 +662,8 @@ If NOWARN does not error on no active process."
(dape--debug 'error
"Timeout for reached for seq %d"
seq)
- (dape--update-state "timed out")
+ (when (dape--live-process t)
+ (dape--update-state "timed out"))
(remhash seq dape--timers)
(when-let ((cb (gethash seq dape--cb)))
(clrhash dape--tree-widget-open-p)
@@ -1118,7 +1121,9 @@ Starts a new process as per request of the debug adapter."
"Handle terminated events."
(dape--update-state "terminated")
(dape--remove-stack-pointers)
- (dape--repl-insert-text "* Program terminated *\n" 'italic))
+ (dape--repl-insert-text "* Program terminated *\n" 'italic)
+ (unless dape--restart-in-progress
+ (dape-kill)))
;;; Startup/Setup
@@ -1135,8 +1140,9 @@ Starts a new process as per request of the debug adapter."
dape--capabilities nil
dape--threads nil
dape--stack-id nil
- dape--process process)
- (setq dape--widget-guard nil
+ dape--process process
+ dape--restart-in-progress nil
+ dape--widget-guard nil
dape--repl-insert-text-guard nil)
(dape--update-state "starting")
(run-hook-with-args 'dape-on-start-hooks)
@@ -1253,12 +1259,15 @@ Starts a new process as per request of the debug
adapter."
(plist-get dape--capabilities :supportsRestartRequest))
(setq dape--threads nil)
(setq dape--thread-id nil)
- (dape-request dape--process "restart" nil))
+ (setq dape--restart-in-progress t)
+ (dape-request dape--process "restart" nil
+ (dape--callback
+ (setq dape--restart-in-progress nil))))
((and dape--config)
(dape dape--config))
((user-error "Unable to derive session to restart"))))
-(defun dape-kill ()
+(defun dape-kill (&optional busy-wait)
"Kill debug session."
(interactive)
(let (done)
@@ -1272,15 +1281,16 @@ Starts a new process as per request of the debug
adapter."
(dape--callback
(dape--kill-processes)
(setq done t)))
- ;; Busy wait for response at least 2 seconds
- (cl-loop with max-iterations = 20
- for i from 1 to max-iterations
- until done
- do (accept-process-output nil 0.1)
- finally (unless done
- (dape--kill-processes)
- (dape--debug 'error
- "Terminate request timed out"))))
+ (when busy-wait
+ ;; Busy wait for response at least 2 seconds
+ (cl-loop with max-iterations = 20
+ for i from 1 to max-iterations
+ until done
+ do (accept-process-output nil 0.1)
+ finally (unless done
+ (dape--kill-processes)
+ (dape--debug 'error
+ "Terminate request timed out")))))
((and (dape--live-process t)
(plist-get dape--capabilities
:supportTerminateDebuggee))
@@ -1291,15 +1301,16 @@ Starts a new process as per request of the debug
adapter."
(dape--callback
(dape--kill-processes)
(setq done t)))
- ;; Busy wait for response at least 2 seconds
- (cl-loop with max-iterations = 20
- for i from 1 to max-iterations
- until done
- do (accept-process-output nil 0.1)
- finally (unless done
- (dape--kill-processes)
- (dape--debug 'error
- "Disconnect request timed out"))))
+ (when busy-wait
+ ;; Busy wait for response at least 2 seconds
+ (cl-loop with max-iterations = 20
+ for i from 1 to max-iterations
+ until done
+ do (accept-process-output nil 0.1)
+ finally (unless done
+ (dape--kill-processes)
+ (dape--debug 'error
+ "Disconnect request timed out")))))
(t
(dape--kill-processes)))))
@@ -1465,7 +1476,7 @@ Executes alist key `launch' in `dape-configs' with
:program as \"bin\".
Use SKIP-COMPILE to skip compilation."
(interactive (list (dape--read-config)))
(unless (plist-get config 'start-debugging)
- (dape-kill)
+ (dape-kill 'busy-wait)
(when-let ((buffer (get-buffer "*dape-debug*")))
(with-current-buffer buffer
(let ((inhibit-read-only t))
@@ -2767,10 +2778,7 @@ See `eldoc-documentation-functions', for more
infomation."
"Format Dape mode line."
(format "Dape:%s"
(propertize
- (or (and (dape--live-process t)
- (or dape--state
- "unknown"))
- "not running")
+ (or dape--state "unknown")
'face 'mode-line-emphasis)))
(add-to-list 'mode-line-misc-info
@@ -2823,7 +2831,8 @@ See `eldoc-documentation-functions', for more infomation."
;;; Hooks
;; Cleanup process before bed time
-(add-hook 'kill-emacs-hook #'dape-kill)
+(add-hook 'kill-emacs-hook (defun dape-kill-busy-wait ()
+ (dape-kill 'busy-wait)))
(provide 'dape)
- [elpa] externals/dape ee2aaad60f 038/123: Invoke customize-variable if dape-configs is null, (continued)
- [elpa] externals/dape ee2aaad60f 038/123: Invoke customize-variable if dape-configs is null, ELPA Syncer, 2023/12/05
- [elpa] externals/dape a23bcb8e66 040/123: Add naively inline variable overlays, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2a478560e9 052/123: Move breakpoint indications into the buffer margin #2, ELPA Syncer, 2023/12/05
- [elpa] externals/dape beaaca9c77 053/123: Fix missing server std out/err in debug buffer, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ad8d8797fa 054/123: Fix missing newline for "stopped" event description, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 9eebb3c246 055/123: Fix missing newline from compilation failed msg, ELPA Syncer, 2023/12/05
- [elpa] externals/dape d6d79670f7 056/123: Slight rework of dape--read-config, ELPA Syncer, 2023/12/05
- [elpa] externals/dape cbbb807604 050/123: Fix type in readme cppdbg adapter example #3, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ae98178a3e 064/123: Improve repl when adapter process non live, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 1d0cdcc466 070/123: Fix dape.el header #13, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 4a97094b10 077/123: Kill adapter on terminate event,
ELPA Syncer <=
- [elpa] externals/dape bda32e7780 096/123: Fix issue of resetting start-debugging args #15, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ba63e50434 106/123: Batteries included, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 87c91273ec 107/123: Add error message on launch/attach fail, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2620078517 117/123: Improve error message on failed restart, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 0f545358e2 118/123: Fix strange usage of add to watch in scope buffer, ELPA Syncer, 2023/12/05
- [elpa] externals/dape c3fb0ebc32 075/123: Remove `dape--name', ELPA Syncer, 2023/12/05
- [elpa] externals/dape bc17ae80ff 078/123: Fix debuggee cleanup, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 30b2695154 087/123: Cancel timeout timers on process kill, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 41cfcc3ce3 089/123: Variety of dape--tree-widget performance "hacks", ELPA Syncer, 2023/12/05
- [elpa] externals/dape b7c578992d 094/123: Fix unnecessary newline in stopped repl text, ELPA Syncer, 2023/12/05