-
Notifications
You must be signed in to change notification settings - Fork 37
Home
You will find documentation and adapter installation details in the README.org.
On this page you will find useful dape configurations.
Feel free to add useful configurations!
Make sure that remote application imports and starts debugpy
.
import debugpy
# Port does not matter just needs to match port in config
# dape debugpy-remote-attach
debugpy.listen(("0.0.0.0", 5678))
(add-to-list 'dape-configs
`(debugpy-remote-attach
modes (python-mode python-ts-mode)
host (lambda () (read-string "Host: " "localhost"))
port (lambda () (read-number "Port: "))
:request "attach"
:type "python"
:pathMappings [(:localRoot (lambda ()
(read-directory-name "Local source directory: "
(funcall dape-cwd-fn)))
:remoteRoot (lambda ()
(read-string "Remote source directory: ")))]
:justMyCode nil
:showReturnValue t))
Thanks to @Gavinok for contributing.
(add-to-list 'dape-configs
`(delve-unit-test
modes (go-mode go-ts-mode)
ensure dape-ensure-command
fn dape-config-autoport
command "dlv"
command-args ("dap" "--listen" "127.0.0.1::autoport")
command-cwd dape-cwd-fn
port :autoport
:type "debug"
:request "launch"
:mode (lambda () (if (string-suffix-p "_test.go" (buffer-name)) "test" "debug"))
:cwd dape-cwd-fn
:program (lambda () (if (string-suffix-p "_test.go" (buffer-name))
(concat "./" (file-relative-name default-directory (funcall dape-cwd-fn)))
(funcall dape-cwd-fn)))
:args (lambda ()
(require 'which-func)
(if (string-suffix-p "_test.go" (buffer-name))
(when-let* ((test-name (which-function))
(test-regexp (concat "^" test-name "$")))
(if test-name `["-test.run" ,test-regexp]
(error "No test selected")))
[]))))
The point can be anywhere in function TestDemo, then call dape
and “Run adapter: delve-unit-test
” it will execute go test -test.run TestDemo
.
func TestDemo(t *testing.T) {
t.Error("hello")
}
Thanks to @jixiuf for contributing.
Follow the steps in the README.org
on how to install codelldb in section “C, C++ and Rust - codelldb”
Add the following configuration to your init.el
:
(add-to-list 'dape-configs
`(ios
modes (swift-mode)
command-cwd dape-command-cwd
command ,(file-name-concat dape-adapter-dir
"codelldb"
"extension"
"adapter"
"codelldb")
command-args ("--port" :autoport
"--settings" "{\"sourceLanguages\":[\"swift\"]}"
"--liblldb" "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB")
port :autoport
simulator-id "iPhone 15 Pro"
app-bundle-id "com.yourcompany.ProductName"
fn (dape-config-autoport
,(lambda (config)
(with-temp-buffer
(let* ((command
(format "xcrun simctl launch --wait-for-debugger --terminate-running-process %S %S"
(plist-get config 'simulator-id)
(plist-get config 'app-bundle-id)))
(code (call-process-shell-command command nil (current-buffer))))
(dape--repl-message (format "* Running: %S *" command))
(dape--repl-message (buffer-string))
(save-match-data
(if (and (zerop code)
(progn (goto-char (point-min))
(search-forward-regexp "[[:digit:]]+" nil t)))
(plist-put config :pid (string-to-number (match-string 0)))
(dape--repl-message (format "* Running: %S *" command))
(dape--repl-message (format "Failed to start simulator:\n%s" (buffer-string)))
(user-error "Failed to start simulator")))))
config))
:type "lldb"
:request "attach"
:cwd "."))
Start simulator:
open -n "Simulator"
Compile program, see xcodebuild (could use compile flag in dape
)
NodeJS (vscode-js-debug)
The following configuration can be used to run an entire file of jest tests (works as of dape
0.5.0).
(defun dape-jest/find-file-buffer-default ()
"Read filename at project root, defaulting to current buffer. Return vector of jest args to run said file"
(let ((file (dape-buffer-default)))
(if file
`["--runInBand" "--no-coverage" ,file]
(user-error "No file found"))))
(put 'dape-jest/find-file-buffer-default 'dape--minibuffer-hint t)
(defun dape-jest/ensure (config)
"Ensure node is available, jest is installed, that the dapDebugServer is installed"
(dape-ensure-command config)
(let ((cwd (dape-cwd))
(js-debug-file (expand-file-name
(dape--config-eval-value (car (plist-get config 'command-args)))
(dape--config-eval-value (plist-get config 'command-cwd))))
(node-jest-file (expand-file-name
(dape--config-eval-value (plist-get config :program))
(dape--config-eval-value (plist-get config :cwd)))))
(unless (file-exists-p js-debug-file)
(user-error "Debug server file %S does not exist" js-debug-file))
(unless (file-exists-p node-jest-file)
(user-error "Jest executable not found at %S" node-jest-file))))
(add-to-list 'dape-configs
`(jest
modes (js-mode js-ts-mode typescript-mode)
ensure dape-jest/ensure
command "node"
command-cwd dape-command-cwd
command-args (,(expand-file-name
(file-name-concat dape-adapter-dir
"js-debug"
"src"
"dapDebugServer.js"))
:autoport)
port :autoport
fn dape-config-autoport
:type "pwa-node"
:cwd dape-cwd
:env (:VAR1 "some value" :VAR2 "another value")
:program "node_modules/.bin/jest"
:args dape-jest/find-file-buffer-default
:outputCapture "console"
:sourceMapRenames t
:pauseForSourceMap nil
:autoAttachChildProcesses t
:console "internalConsole"
:outputCapture "std"
:killBehavior "forceful"))