obiwan87 / odin-intellij

Odin Support plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/22933-odin-support
MIT License
37 stars 2 forks source link

Add Debugging support #68

Open obiwan87 opened 2 weeks ago

obiwan87 commented 2 weeks ago

Tasks

obiwan87 commented 2 weeks ago

@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 commented 2 weeks ago

@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.

timlueg commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

Anyway: these are my findings re debugging:

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 1 week ago

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

timlueg commented 6 days ago

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 commented 6 days ago

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.