Skip to content
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

Add Debugging support #68

Closed
11 of 14 tasks
obiwan87 opened this issue Aug 25, 2024 · 11 comments · Fixed by #67 or #69
Closed
11 of 14 tasks

Add Debugging support #68

obiwan87 opened this issue Aug 25, 2024 · 11 comments · Fixed by #67 or #69
Assignees

Comments

@obiwan87
Copy link
Owner

obiwan87 commented Aug 25, 2024

Tasks

  • Separate projects such that community edition can still run without debugging (see ZigBrains, IntelliJ-Rust)
  • Provide settings for debugger
  • Provide debug toolchain downloader and debug toolchain settings
    • MS debugger
    • LLDB-DAP debugger
  • Test native LLDB driver on
    • MacOs
    • Linux
  • Test LLDB-DAP driver on Linux/MacOs
    • MacOs
    • Linux

Fixes/Issues

@obiwan87 obiwan87 linked a pull request Aug 25, 2024 that will close this issue
2 tasks
@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 25, 2024

@timlueg I have created a separate branch for this pull request, as including the native debug plugin would make it incomptabile with community edition. The branch is cidr-debugger

@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 25, 2024

@timlueg Binary needs to be build first and then attached when starting the debug session. We can re-use the command create by the run configuration.

@obiwan87 obiwan87 self-assigned this Aug 27, 2024
@timlueg
Copy link
Contributor

timlueg commented Aug 27, 2024

it incomptabile with community edition.

Yes I defined the plugin as optional in the .xml but have not evaluated it yet. Will probably also require some changes to the build.gradle.kts. Maybe something similar whats done here https://github.com/vlang/intellij-v/blob/main/build.gradle.kts

Binary needs to be build first

Yes, I wasn't sure how you want to structure this yet. I saw you already implemented it now. I just quickly tested your changes and noticed that now it does not correctly start the debugger or at least it does not stop at the breakpoint anymore. I can get it to work again by setting: commandLine.setExePath(pathToExecutable). You also want to use addCommandPart(command, "build"); instead of addCommandPart(command, "run"); in this case.

(I can create a merge request if you haven't already done so before I find the time.)

@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 28, 2024

Yes I defined the plugin as optional in the .xml but have not evaluated it yet. Will probably also require some changes to the build.gradle.kts. Maybe something similar whats done here https://github.com/vlang/intellij-v/blob/main/build.gradle.kts

yes, absolutely right.

You also want to use addCommandPart(command, "build"); instead of addCommandPart(command, "run"); in this case.

You can disregard my commit, as in that scenario the output of the build process is not shown on the console. I'm trying to find a possibility to do so.

@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 28, 2024

Anyway: these are my findings re debugging:

  • gdb is not supported by ODin
  • lldb is supported, but the IntelliJ implementation doesn't seem to work
  • The developer of the zig plugin has allowed us to use his DAPDriver, which would allow to use the lldb-dap tool by LLVM and other DAP-compatible debuggers

The Zig and Rust plugins also have an automatic toolchain download, which is very convenient for downloading the debug tools. We should also consider implementing it, once debugging is figured out.

@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 29, 2024

LLDB-DAP works. Need a place to host it, such that the IDE can download it. Also need figure out what dependencies it has

@timlueg
Copy link
Contributor

timlueg commented Aug 29, 2024

Looks like here they got LLDB to work using the native debug plugin: https://github.com/vlang/intellij-v

Didn't know about DAP. Seems to be again a Microsoft idea like LSP where they use Json and network calls to connect to a local process.... But if this would enabled support for IntelliJ Community Edition.

@obiwan87
Copy link
Owner Author

obiwan87 commented Aug 29, 2024

Looks like here they got LLDB to work using the native debug plugin: https://github.com/vlang/intellij-v

Would be ideal to get the native driver working. however, for me it doesn't. Maybe it's an OS thing? Do you have a Linux system?

But yes, you're right. DAP working means we can just drop the cidr dependency, I think 🤔, and have it working even on Community Edition

EDIT: Getting rid of Cidr means implementing our own XDebugProcess, which handles the logic of interacting between the driver and the IDE. Definitely a project for the future

@obiwan87 obiwan87 linked a pull request Sep 3, 2024 that will close this issue
@obiwan87 obiwan87 reopened this Sep 3, 2024
@obiwan87
Copy link
Owner Author

obiwan87 commented Sep 5, 2024

Debuggers work on every major OS. Bundled LLDB on Linux doesn't work on GoLand apparently but LLDB-DAP does

@timlueg
Copy link
Contributor

timlueg commented Sep 7, 2024

Maybe it's an OS thing? Do you have a Linux system?

Yes I'm on Linux using Clion. I can now also confirm that LLDB works under CIDR using LLDBDriverConfiguration. With LLDB instead of GDB it now automatically loads variables in the Threads&Variables watch window.

(For this test I manually build the executable with -debug, as we know that OdinRunCommandLineState wasn't working yet. I have not looked at your recent changes but happy you got debugging working.

image

@obiwan87
Copy link
Owner Author

obiwan87 commented Sep 8, 2024

As of the newest version, that you can get from the marketplace, debugging is now fully integrated, including the debug build prior to starting the the debug process. I had LLDB and LLDB DAP tested on macOS, too. They also work there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants