@@ -1037,17 +1037,19 @@ terminal configured (probably xterm)."
10371037 (when dap-print-io
10381038 (let ((inhibit-message dap-inhibit-io))
10391039 (message " Received:\n %s " (dap--json-encode parsed-msg))))
1040- (pcase (gethash " type" parsed-msg)
1041- (" event" (dap--on-event debug-session parsed-msg))
1042- (" response" (if-let (callback (gethash key handlers nil ))
1043- (progn
1044- (funcall callback parsed-msg)
1045- (remhash key handlers)
1046- (run-hook-with-args 'dap-executed-hook
1047- debug-session
1048- (gethash " command" parsed-msg)))
1049- (message " Unable to find handler for %s . " (pp parsed-msg))))
1050- (" request" (dap--start-process debug-session parsed-msg)))))
1040+ (condition-case _
1041+ (pcase (gethash " type" parsed-msg)
1042+ (" event" (dap--on-event debug-session parsed-msg))
1043+ (" response" (if-let (callback (gethash key handlers nil ))
1044+ (progn
1045+ (funcall callback parsed-msg)
1046+ (remhash key handlers)
1047+ (run-hook-with-args 'dap-executed-hook
1048+ debug-session
1049+ (gethash " command" parsed-msg)))
1050+ (message " Unable to find handler for %s . " (pp parsed-msg))))
1051+ (" request" (dap--start-process debug-session parsed-msg)))
1052+ (quit))))
10511053 (dap--parser-read parser msg)))))
10521054
10531055(defun dap--create-output-buffer (session-name )
@@ -1441,9 +1443,8 @@ DEBUG-SESSIONS - list of the currently active sessions."
14411443 (format " %s (%s )" name status)
14421444 name)))
14431445
1444- (defun dap-switch-thread ()
1445- " Switch current thread."
1446- (interactive )
1446+ (defun dap--switch-thread ()
1447+ " Switch current thread using current session."
14471448 (let ((debug-session (dap--cur-active-session-or-die)))
14481449 (dap--send-message
14491450 (dap--make-request " threads" )
@@ -1456,6 +1457,33 @@ DEBUG-SESSIONS - list of the currently active sessions."
14561457 (dap--select-thread-id debug-session thread-id t )))
14571458 debug-session)))
14581459
1460+ (defun dap--switch-thread-all-sessions ()
1461+ " Switch current thread selecting from all sessions."
1462+ (interactive )
1463+ (-when-let ((debug-session . (&hash " id" ))
1464+ (dap--completing-read
1465+ " Select active thread: "
1466+ (->> (dap--get-sessions)
1467+ (-filter #'dap--session-running )
1468+ (-mapcat (lambda (debug-session )
1469+ (->> (dap-request debug-session " threads" )
1470+ (gethash " threads" )
1471+ (-map (-partial #'cons debug-session))))))
1472+ (-lambda ((debug-session . thread))
1473+ (format " %- 80s%s "
1474+ (dap--thread-label debug-session thread)
1475+ (dap--debug-session-name debug-session)))))
1476+ (dap--switch-to-session debug-session)
1477+ (dap--select-thread-id debug-session id t )))
1478+
1479+ (defun dap-switch-thread (&optional all? )
1480+ " Switch current thread.
1481+ When ALL? is non-nil select from threads in all debug sessions."
1482+ (interactive " P" )
1483+ (if all?
1484+ (dap--switch-thread-all-sessions )
1485+ (dap--switch-thread)))
1486+
14591487(defun dap-stop-thread-1 (debug-session thread-id )
14601488 (dap--send-message
14611489 (dap--make-request
0 commit comments