GitHub - yyoncho/dap-mode: Debug Adapter Protocol for Emacs
source link: https://github.com/yyoncho/dap-mode
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.org
Table of Contents
- Summary
- Screenshot
- Features
- Configuration
- Extending DAP with new Debug servers
- Links
- Troubleshooting
- What’s next
Summary
Emacs client/library for Debug Adapter Protocol Debug Adapter Protocol is a wire protocol for communication between client and Debug Server. It similar to the LSP but providers integration with debug server.
Project status
The project is in it’s early stage and is still not extensively tested. The API considered unstable until 1.0 release is out. It is tested only against Java.
Screenshot
Features
- Launch/Attach
- Breakpoints
- Exceptions
- Pause & Continue
- Step In/Out/Over
- Callstacks
- Threads
- Multiple simultaneous debug sessions
- Evaluating statements
- Debug/Run configurations
Debugger commands
CommandDescriptiondap-breakpoint-toggle
Toggle java breakpoint at linedap-breakpoint-delete
Delete java breakpoint at linedap-breakpoint-add
Add java breakpoint at linedap-breakpoint-condition
Set/unset breakpoint conditiondap-breakpoint-hit-condition
Set/unset breakpoint hit conditiondap-breakpoint-log-message
Set/unset breakpoint log messagedap-eval
Eval stringdap-eval-region
Eval region stringdap-eval-thing-at-point
Eval symbol at pointdap-step-in
Debug step indap-next
Debug nextdap-step-out
Debug step outdap-stop-thread
Stop threaddap-restart-frame
Restart framedap-continue
Debug continuedap-disconnect
Cancel current debug sessiondap-switch-stack-frame
Switch active stack framedap-switch-thread
Switch active threaddap-switch-session
Switch active sessiondap-debug
Create and run new configuration using the available templatesdap-debug-last
Debug previous configurationdap-debug-recent
Select configuration to run from the previously started commanddap-go-to-output-buffer
Go output bufferWindows
CommandDescriptiondap-ui-sessions
Show active/terminated sessions viewdap-ui-locals
Show locals viewdap-ui-breakpoints
Show breakpoints viewdap-ui-inspect
Inspectdap-ui-inspect-region
Inspect regiondap-ui-inspect-thing-at-point
Inspect symbol at pointSessions
The sessions view is showed after invoking dap-ui-sessions
. It represents
the list of the active sessions.
Keybindings
CommandDescriptionKeybindingsdap-ui-session-select
Select object at point<return>dap-ui-session-remove
WIPRemove terminated session from the list of running sessionstree-mode-toggle-expand
Toggle node expand state<tab>Locals
Locals can be viewed after invoking dap-ui-locals
.
Breakpoints
Breakpoints can be viewed after invoking dap-ui-breakpoints
.
Keybindings
CommandDescriptionKeybindingsdap-ui-breakpoints-goto
Go to breakpoint under cursor<return>dap-ui-breakpoints-delete
Delete breakpoint under cursorddap-ui-breakpoints-delete-selected
Delete selected breakpointsDbui-list-mark
Mark breakpoint under pointmbui-list-unmark
Unmark breakpoint under pointubui-list-unmark-all
Unmark breakpoint under pointUConfiguration
DAP mode configuration
Enable both dap-mode
and dap-ui-mode
.
(dap-mode 1) (dap-ui-mode 1)
After enabling DAP mode on emacs side follow the language specific settings.
Java
Installation
Make sure that you have properly installed and configured LSP Java. Download
latest version of Debug Java from Maven Central and add it to
lsp-java-bundles
. If you want to run unit tests you have to download the
JUnit5’s JUnit Platform Console Standalone from Maven Central and you must
swith Eclipse Che JDT server. On Linux/MacOS you can do the following:. On
Linux you can do that by running the following command:
# Download debug plugin mkdir -p ~/.emacs.d/eclipse.jdt.ls/plugins/ mvn dependency:get -DrepoUrl=https://mvnrepository.com/repos/central -DgroupId=com.microsoft.java -DartifactId=com.microsoft.java.debug.plugin -Dversion=0.10.0 cp -v ~/.m2/repository/com/microsoft/java/com.microsoft.java.debug.plugin/0.10.0/com.microsoft.java.debug.plugin-0.10.0.jar ~/.emacs.d/eclipse.jdt.ls/plugins/com.microsoft.java.debug.plugin-0.10.0.jar # Download test runner mkdir -p ~/.emacs.d/eclipse.jdt.ls/runner/ mvn dependency:get -DrepoUrl=https://mvnrepository.com/repos/central -DgroupId=org.junit.platform -DartifactId=junit-platform-console-standalone -Dversion=1.3.0-M1 cp -v ~/.m2/repository/org/junit/platform/junit-platform-console-standalone/1.3.0-M1/junit-platform-console-standalone-1.3.0-M1.jar ~/.emacs.d/eclipse.jdt.ls/runner/junit-platform-console-standalone.jar # Download Che JDT LS. rm -rf ~/.emacs.d/eclipse.jdt.ls/server/ mkdir -p ~/.emacs.d/eclipse.jdt.ls/server/ wget http://download.eclipse.org/che/che-ls-jdt/snapshots/che-jdt-language-server-latest.tar.gz -O /tmp/jdt-latest.tar tar xf /tmp/jdt-latest.tar -C ~/.emacs.d/eclipse.jdt.ls/server/
Then add the following settings in your emacs config file:
(dap-mode 1) (dap-ui-mode 1) (add-to-list 'lsp-java-bundles (expand-file-name (locate-user-emacs-file "eclipse.jdt.ls/plugins/com.microsoft.java.debug.plugin-0.10.0.jar")))
Commands
CommandDescriptiondap-java-debug
Debug javadap-java-run-test-method
Run test methoddap-java-debug-test-method
Debug test methoddap-java-run-test-class
Run test classdap-java-debug-test-class
Debug test classExtending DAP with new Debug servers
There are two methods that are used for registering remote extensions:
dap-register-debug-provider
- register a method to call for populating startup parameters. It should either populate:debugPort
and:host
in case of TCP Debug Adapter Server or:program
when STD out must be used for Debug Adapter Server communication.dap-register-debug-template
register a debug teplate which will be available whendap-debug
is called. The debug template must specify:type
key which will be used to determine the provider to be called to populate missing fields.
Example
For full example you may check dap-java.el
.
(dap-register-debug-provider "java" (lambda (conf) (plist-put conf :debugPort 1234) (plist-put conf :host "localhost") conf)) (dap-register-debug-template "Example Configuration" (list :type "java" :request "launch" :args "" :name "Run Configuration"))
Links
Troubleshooting
If you notice a bug, open an issue on Github Issues.
What’s next
- Watches
- Debug console
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK