svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

Cannot start dape with jdtls and java-debug #89

Closed manuel-uberti closed 5 months ago

manuel-uberti commented 5 months ago

Hi,

first of all thanks for this package.

I am trying to start a debugging session on sample project just to understand how to move around dape. This is what I did from emacs -Q after installing date via with package-install:

(with-eval-after-load 'eglot (push '((java-mode java-ts-mode) . mu-jdtls-setup) eglot-server-programs))

- `C-c C-e` to evaluate the buffer
- `mkdir ~/code/test-java`
- `cd ~/code/test-java`
- `git init` (I want Emacs `project.el` to consider this a project)
- in Emacs `C-x C-f ~/code/test-java/Test.java`
- I wrote this in the Java file:
```java
public class Test {
    public static void main(String[] args) {
        int x = 1;
        System.out.println("test: " + x);
    }
}

test: 1

I am using GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.16.0) of 2024-03-13 built on commit 4ac4cec652ffaca4333d8f297b8a6c0e5bd79c68.

If you need me to provide more details, let me know.

svaante commented 5 months ago

First of all thanks for the debug information.

It looks like everything works on your end.

"[jsonrpc] Server exited with status 0" means that the debugging adapter has quit, which is expected as your java program has finished it's execution.

What I recommend is setting the point (cursor) in your main function and C-x C-a b to setup a breakpoint (C-x C-a can be easily changed. See Readme) If you prefer using the mouse you need to enable dape-breakpoint-global-mode and setting an breakpoint by clicking in the left fringe.

  1. "navigate" with dape-global-map (M-x describe-keymap RETURN dape-global-map) highly recommend enabling the global (repeat-mode) C-x C-a d n n n c (start debugging step three times then continue)
  2. "navigate" by REPL "Available Dape commands: debug, next, continue, pause, step, out, restart, kill, disconnect, quit" in the repl (shorthands exist and are marked by a different face next) use empty input in the REPL to run the previous command.
manuel-uberti commented 5 months ago

Thank you so much for the kind explanation and the details. It works as expected indeed, and (repeat-mode) makes it even more pleasant.