-
Notifications
You must be signed in to change notification settings - Fork 866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending lsp.client with support for DAP #8098
Conversation
Debugging Python inside NetBeansRun the Python file like this:
It should now wait for connections from the IDE. In the IDE, select In the dialog, fill in:
Confirm the dialog - the IDE should now debug the Python code. |
The debugging works with GraalVM based languages as well. Just download GraalVM for JDK 17 and Graal.js 17 and debug sieve.js with following command debugger connects and one can step over the code. |
All the CI checks are green. Is there anything else to do before merging this functionality in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting addition! I left a few inline comments from experiences with LSP/CDT.
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/DAPActionsProvider.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/DAPActionsProvider.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/DAPDebugger.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/Utils.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/Utils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So am I understanding this right, that the java lsp server invented its own DAP protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, not sure what you mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The java lsp server has provided its own DAP protocol implementation since ages to allow JVM debugging in the VSCode. However that's the other side of the DAP protocol - VSCode was DAP client and NetBeans was DAP server.
The changes in lsp.client
aim towards NetBeans being DAP client and the server can be anything.
...t/src/org/netbeans/modules/lsp/client/debugger/breakpoints/BreakpointAnnotationProvider.java
Outdated
Show resolved
Hide resolved
....client/src/org/netbeans/modules/lsp/client/debugger/breakpoints/DAPBreakpointConvertor.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/spi/BreakpointConvertor.java
Outdated
Show resolved
Hide resolved
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/LineBreakpointData.java
Outdated
Show resolved
Hide resolved
… matthiasblaesing: - cleaning up use of String urls, using URIs internally - cleaning up the breakpoint to not hold paths, but rather only hold FileObjects - cleaning up the BreakpointAnnotationProvider to not use a weak listener, and holder for the listeners. Using ordinary listeners, which will be held as long as the DataObject exists, and should be automatically GCed when the DO is removed, which is presumably the intent - renaming (DAP)Utils to DAPStackTraceAnnotationHolder
FWIW, based on @matthiasblaesing's comments, I tried to do some more cleanup: notably:
I believe the only two unhandled comments are:
|
… matthiasblaesing
For the URI discussion: I did not mean, that usage should switch over to URI. That maybe a valid target, but it highly depends on the actual protocol promises. I see the type I looked a bit further and this is I think the relevant part: https://microsoft.github.io/debug-adapter-protocol/overview#initialization
The default according to https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize default is So we need to decide: How to handle this wildcard. I bet there will be DAPs, that only support Each has drawbacks:
It would be interesting to get samples of both and see how they react if they detected, that they can't comply with the request of the IDE. I.e. will the adapters correctly fail initialization if a source path type is requested, that it can't provide or will it pretend to work and just silently send invalid data. |
I guess I don't quite see the huge problem. The protocol by default uses path, and this code apparently does not change the default, i.e. what goes over the wire is a path. (And to make things work, both client and server must see the same file using the same path.) What The main point of the |
all tests green, removing the label again (only added it to check it at least once) |
The review has revealed bugs in treating the two kinds of strings. By using
I like the separation.
For now, let's make the interface package private in 8049bec650 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. Good job.
ide/lsp.client/src/org/netbeans/modules/lsp/client/debugger/spi/BreakpointConvertor.java
Show resolved
Hide resolved
To my knowledge: in the NetBeans API, every mime type (language) needs to provide its own breakpoint implementations. And there can be only sensibly one breakpoint implementation for each language (technically, we can have multiple breakpoint implementations, I think, but the UI for that would not be sensible). So while this PR adds a "generic" implementation of breakpoints that can be used for languages that don't provide other breakpoint implementations, this generic implementation cannot (to my knowledge) be used for the languages that already provide breakpoint implementations, like Java, C/C++, PHP or JavaScript. But, it may still be sensible to permit the use of the DAP debugger even for these languages in some cases. Hence the convertor - it can provide data from language-specific breakpoints to the DAP debugger, so that the DAP debugger can use them. That's my understanding at least. So, we have breakpoints for Java, C/C++, PHP, JavaScript, and possibly other languages. And, with |
715410b
to
bf75e98
Compare
Yeah, now when I see how other systems like VSCode handle breakpoints I agree we made a mistake letting/forcing every language to implement its own line breakpoint. Rather than that there should have been a generic line breakpoint assignable to "almost" any file. When a new debugging session is about to start each language debugger would read such a generic line breakpoints and convert them to whatever is reasonable for the language debugger. Alas, we don't have such a system and we end up with "Almost"Languages shall control whether clicking the editor gutter adds line breakpoint or not and whether they display breakpoint line in the editor, but technically the line breakpoint could be anywhere. |
I think the contribution is reviewed and tested. Let's integrate it and hope it won't need to be reverted (as sometimes happens to my PRs). |
was this just merged without squashing? |
This PR already contains contributions from other authors. It would be against netiquete to squash it all into a single commit. However yes, I could do better with my own commits as I see I left a little more noise in the history than necessary. I'll learn to behave. I promise. |
This might be helpful: https://lists.apache.org/thread/l2bkws1cz0s68n471wqsn3h6yz92hqjo |
I'd like NetBeans to have a support for DAP. To debug GraalVM based languages as well as Python, for example.