[WIP] Consider migrating to lsp4ij DAP
Once https://github.com/redhat-developer/lsp4ij/pull/735 is merged, investigate whether the current DAP debugger in zigbrains can be rewired to use the LSP4IJ one with feature parity.
Notes:
- LSP4IJ DAP works outside of clion/rustrover/ideaultimate because it uses XDebugger instead of CIDR. This would allow debugging zig code with lldb-dap on ideacommunity and bypass the proprietary IDE restriction the current debugger impl has.
- Memory disassembly view is only available in CIDR debugger API. Can it be hacked onto an XDebugger via reflection magic?
- If the difference is too large, can we have best of both worlds and use lldb-dap on ic and the CIDR debugger on cl/rr/iu?
Point 2 tl;dr: Can we make something like this work in the open source IDEs?
Memory disassembly view is only available in CIDR debugger API. Can it be hacked onto an XDebugger via reflection magic?
I think we should copy/paste code from Memory view and adapt the code to console Memory DAP request / response.
https://github.com/JetBrains/intellij-community/blob/51454bce1c44da85d94e9cb092fbff974280232a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java#L315
I meant the disassembler that clion exposes through the CIDR api for native debuggers, and coupling it with the disassemble DAP request. In zigbrains I just hardwired the DAP integration on top of the cidr debugger api so it just works, but lsp4ij compiles against the open source intellij apis so it's not available there.
See: https://github.com/FalsePattern/ZigBrains/blob/3a5daab063bed81c0897378482a3fec9cbb14d41/cidr/src/main/kotlin/com/falsepattern/zigbrains/debugger/dap/DAPDriver.kt#L798-L839
@FalsePattern I have discovered your issue and I am glad that you could be interested with dap support from LSP4IJ.
Even if it is not perfect and it requires a lot of work again, I merged the PR. You can install nigthy to play with it and you can read the doc at https://github.com/redhat-developer/lsp4ij/blob/main/docs%2Fdap%2FDAP.md
Dont hesitate to create any issues with your idea.
At the moment zigbrains only has the builtin DAP support for debugging zig on windows (lldb cannot parse windows pdb files generated by zig so as a workaround i wrote a DAP adapter for using the msvc debugger), but i'm planning to use the lsp4ij DAP for debugging on idea community. The disassembler is not really required, i'm mostly just curious about how complex would it be to implement
At the moment zigbrains only has the builtin DAP support for debugging zig on windows (lldb cannot parse windows pdb files generated by zig so as a workaround i wrote a DAP adapter for using the msvc debugger), but i'm planning to use the lsp4ij DAP for debugging on idea community. The disassembler is not really required, i'm mostly just curious about how complex would it be to implement
I dont know and I have never seen use it and dont know if the UI is complex.
First I suggest that you play with the LSP4IJ dap support because I am not sure that it works with stdio instead of socket.
I have tried to start lldp dap from swift in stdio but it fails. Only socket is working.
The runInTerminal is not implemented and I have seen that you have implemented it. I dont know if it can work without this runInTerminal.
Dont hesitate to create any issue.
For the moment dap server is not configurable with extension point so perhaps we need to provide it.
In short please dont be disappointed, it is just a basic dap support that it requires to improve it.
@FalsePattern have you time to play with DAP support from LSP4IJ? Please try it with nighty build.
I'm busy with university at the moment, I won't have a lot of free time until about June, so this issue is on hold for now.
No problem, good luck with your university!
@FalsePattern please note that 1.5.0 will improve dap support with runInTerminal which uses the intellij integrated terminal, api is also improved to use your own breakoint, configuration type.
@FalsePattern again for your information I have implemented hover to show dap value with hover. I dont know if your current dap implementation does that.
@FalsePattern again for your information I have implemented hover to show dap value with hover. I dont know if your current dap implementation does that.
My primary blockers for migrating to the lsp4ij dap is support for Disassemble/Memory operations, as my DAP implementation builds on top of com.jetbrains.cidr.execution.debugger.backend.DebuggerDriver
See: https://www.jetbrains.com/help/clion/disassembly-view.html
Example: https://github.com/FalsePattern/ZigBrains/blob/3fb6077b4fe6b64656f12ccfff4b1fe0307b4c0a/cidr/src/main/kotlin/com/falsepattern/zigbrains/debugger/dap/DAPDriver.kt#L854
Example: https://github.com/FalsePattern/ZigBrains/blob/3fb6077b4fe6b64656f12ccfff4b1fe0307b4c0a/cidr/src/main/kotlin/com/falsepattern/zigbrains/debugger/dap/DAPDriver.kt#L854
I understand but my main problem is that I dont know how it is working. Could you please explain me with several screnshot.
I dont know zig, could you explain me how to consume zig debugger and have a basic zig app to debug in order to I have a usecase
This DAP communicates with the MSVC debugger adapter (used for debugging zig on Windows due to an LLDB/GDB compatibility issue in the generated .pdb files), it's not zig-specific
See: https://github.com/microsoft/vscode-cpptools
As a cross-platform reference, LLDB-DAP uses the same requests/responses
https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md
As a cross-platform reference, LLDB-DAP uses the same requests/responses
https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md
Thanks for your info. I need to understand what is disassembly.
If you have some tutorial which uses vscode cpptools with disassembly in order too I see the ui to implement it would be very nice.
Same thing for IJ. I have no idea which UI must be implemented and how dap disassembly works.
The disassembly UI in clion is implemented in proprietary jetbrains code, so unfortunately i cannot provide a example code of the UI for that. The best reference i can give is this documentation page: https://www.jetbrains.com/help/clion/disassembly-view.html and this demo https://www.youtube.com/watch?v=cjJDpRArf_w
Thanks @FalsePattern for your relevant information.
I have started to try to implement this DAP Disassembly support. It was not trivial but I can add an Open Disassembly view with contextual menu on a stack trace and open an editor with a disassembly content:
And as Disassembly is a text editor (readonly), I can add Disassembly breakpoint type
For now, that's it, I need to send disassembly breakpoint to DAP server. I don't know if it will be easy. We will see..
Current status
@FalsePattern I have merged my PR with DAP Disassembly support, see doc at https://github.com/redhat-developer/lsp4ij/blob/main/docs/dap/UserGuide.md#disassemble
You will have to install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds
It is not perfect and I think it will require some improvement, but it starts working.
Don't hesitate to contribute to LSP4IJ if you need some improvement. Thanks!
@FalsePattern just for your info, I am improving syntax coloration for Disassembly https://github.com/redhat-developer/lsp4ij/pull/1328