Skip to content
/ dape Public
forked from svaante/dape

Debug Adapter Protocol for Emacs

License

Notifications You must be signed in to change notification settings

yssource/dape

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 

Repository files navigation

Dape - Debug Adapter Protocol for Emacs

Dape is an debug adapter client for Emacs.

Use dape-configs to set up your debug adapter configurations. To initiate debugging sessions, use the command dape.

For complete functionality, activate eldoc-mode in your source buffers and enable repeat-mode for ergonomics.

Features

  • Log breakpoints
  • Conditional breakpoints
  • Variable explorer
  • Variable watch
  • Variable hover with eldoc
  • REPL
  • Memory viewer with hexl
  • compile integration
  • Debug adapter configuration ergonomics
  • No dependencies
  • Inline variable hints (experimental)

https://raw.githubusercontent.com/svaante/dape/resources/screenshot.png

https://raw.githubusercontent.com/svaante/dape/resources/screenshot_inline.png

Screenshots taken with ef-trio-dark.

Configuration

Currently Dape does not come with any debug adapter configuration.

(use-package dape
  ;; Currently only on github
  :straight (dape :type git :host github :repo "svaante/dape")
  :config
  ;; Add inline variable hints, this feature is highly experimental
  ;; (setq dape-inline-variables t)

  ;; To remove info buffer on startup
  ;; (remove-hook 'dape-on-start-hooks 'dape-info)

  ;; To remove repl buffer on startup
  ;; (remove-hook 'dape-on-start-hooks 'dape-repl)

  ;; By default dape uses gdb keybinding prefix
  ;; (setq dape-key-prefix "\C-x\C-a")

  ;; Use n for next etc. in REPL
  ;; (setq dape-repl-use-shorthand t)

  ;; Kill compile buffer on build success
  ;; (add-hook 'dape-compile-compile-hooks 'kill-buffer)

  ;; Projectile users
  ;; (setq dape-cwd-fn 'projectile-project-root)
  )

Differences with dap-mode

dap-mode is the most popular alternative and is of course much more mature and probably more feature rich (have not used dap-mode extensively).

Dape has no dependencies outside of packages included in emacs, and tries to use get as much out of them possible.

Dape takes a slightly different approach to configuration.

  • Dape does not support launch.json files, if per project configuration is needed use dir-locals.
  • Tries to simplify configuration, by having just a plist.
  • Dape tries to improve config ergonomics in dape completing-read by using options to change/add plist entries in an already existing config, example: adapter-config :program "/home/user/b.out" compile "gcc -g -o b.out main.c".
  • No magic, no special variables. Instead, functions and variables are resolved before starting a new session.
  • No batteries included. Many, suffer from a significant drawback: they’re tightly coupled with the vscode extension they’re bundled with. This tight coupling results in launch/attach requests being specific to each adapter, devoid of reasonable defaults as they are stored within the extension itself, leading to an ever-changing and unstable API. Consequently, attempting to include default configurations for each adapter seems like a losing proposition.
  • Tries to be envision to how debug adapter configuration would be implemented in emacs if vscode never existed.

Supported debug adapters

In theory all debug adapters should be compatible with Dape.

Javascript - vscode-js-debug

To install vscode-js-debug pull down the repo.

npm install
npx gulp dapDebugServer

Example launch configuration for node.

(add-to-list 'dape-configs
             `(vscode-js-node
               modes (js-mode js-ts-mode)
               host "localhost"
               port 8123
               command "node"
               command-cwd "path/to/vscode-js-debug/dist/"
               command-args ("src/dapDebugServer.js" "8123")
               :type "pwa-node"
               :request "launch"
               :cwd dape-cwd-fn
               :program dape-find-file-buffer-default
               :outputCapture "console"
               :sourceMapRenames t
               :pauseForSourceMap nil
               :enableContentValidation t
               :autoAttachChildProcesses t
               :console "internalConsole"
               :killBehavior "forceful"))

For more information see OPTIONS.md.

Go - delve

See delve installation.

(add-to-list 'dape-configs
             `(delve
               modes (go-mode go-ts-mode)
               command "dlv"
               command-args ("dap" "--listen" "127.0.0.1:55878")
               command-cwd dape-cwd-fn
               host "127.0.0.1"
               port 55878
               :type "debug"
               :request "launch"
               :cwd dape-cwd-fn
               :program dape-cwd-fn))

For more information see documentation.

C, C++ and Rust

Download latest release and unpack vsix file with your favorite unzipper.

(add-to-list 'dape-configs
             '(codelldb
               modes (c-mode c-ts-mode
                      c++-mode c++-ts-mode
                      rust-ts-mode rust-mode)
               ;; Replace vadimcn.vscode-lldb with the vsix directory you just extracted
               command "path/to/vadimcn.vscode-lldb/adapter/codelldb"
               host "localhost"
               port 5818
               command-args ("--port" "5818")
               :type "lldb"
               :request "launch"
               :cwd dape-cwd-fn
               :program dape-find-file))

See manual for more information.

C and C++ - cppdbg

Download latest release and unpack vsix file with your favorite unzipper. Then chmod +x debugAdapters/bin/OpenDebugAD7.

;; Replace ms-vscode.cpptools with the vsix directory you just extracted
(setq dape-cppdbg-command "path/to/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7")
(add-to-list 'dape-configs
             `(cppdbg
               modes (c-mode c-ts-mode c++-mode c++-ts-mode)
               command-cwd ,(file-name-directory
                             dape--cppdbg-command)
               command cppdbg-command
               :type "cppdbg"
               :request "launch"
               :cwd dape-cwd-fn
               :program dape-find-file
               :MIMode ,(cond
                         ((executable-find "gdb") "gdb")
                         ((executable-find "lldb") "lldb"))))

See options.

Python - debugpy

Install debugpy with pip pip install debugpy

(add-to-list 'dape-configs
             `(debugpy
               modes (python-ts-mode python-mode)
               command "python3"
               command-args ("-m" "debugpy.adapter")
               :type "executable"
               :request "launch"
               :cwd dape-cwd-fn
               :program dape-find-file-buffer-default))

See options.

Godot

Configure debug adapter port under “Editor” -> “Editor Settings” -> “Debug Adapter”.

(add-to-list 'dape-configs
             '(godot-launch
               modes (gdscript-mode)
               host "127.0.0.1"
               port 6006
               :type "server"
               :request "launch"))

Other untested adapters

If you find a working configuration for any other debug adapter please submit a PR.

See microsofts list for other adapters, your mileage will vary.

Roadmap

  • More options for indicator placement
  • Improving completion in REPL
  • Usage of “setVariable” inside of *dape-info* buffer
  • Improve memory reader with auto reload and write functionality
  • Individual thread controls
  • Variable values displayed in source buffer, this seams to require integration with lsp-mode and eglot

Bugs and issues

Before reporting any issues take a look at *dape-debug* buffer with all debug messages enabled. (setq dape--debug-on '(io info error std-server).

About

Debug Adapter Protocol for Emacs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Emacs Lisp 100.0%