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

Debugging doesn't work on Windows (CLion limitation) #37

Closed
JensvandeWiel opened this issue Mar 4, 2024 · 5 comments
Closed

Debugging doesn't work on Windows (CLion limitation) #37

JensvandeWiel opened this issue Mar 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@JensvandeWiel
Copy link
Contributor

Running debug on windows is useless, see video: https://imgur.com/a/ISjXXdt

@FalsePattern FalsePattern self-assigned this Mar 4, 2024
@FalsePattern FalsePattern added bug Something isn't working help wanted Extra attention is needed labels Mar 4, 2024
@FalsePattern
Copy link
Owner

After some investigation, I've reached the following conclusion:

  • Neither the bundled clion LLDB and GDB are usable for debugging zig on windows due to their inability to load .pdb files
  • Latest LLDB binaries do have support for .pdb files, but the .pdb files generated by the zig compiler are "broken" and lldb cannot ingest them Can't debug with LLDB on Windows ziglang/zig#13095

On VSCode, the common solution to this is to use the vscode C++ tools https://github.com/microsoft/vscode-cpptools, which includes a (proprietary) debug adapter to the Microsoft Visual Studio debugger called vsdbg, which uses the Debug Adapter Protocol for communicating with an invoking IDE.

However, JetBrains does not support the DAP protocol, but luckily, there is an implementation of it in the LSP4Eclipse project: https://github.com/eclipse/lsp4e/tree/master/org.eclipse.lsp4e.debug/src/org/eclipse/lsp4e/debug

Possible solutions:

  1. Wait until zig fixes the debug symbol file generation, and use LLDB on windows
  2. Port the DAP adapter from LSP4Eclipse over to ZigBrains, and then use that to interface with the Microsoft proprietary debugger adapter.

Unfortunately, i don't have enough free time to implement the second solution, as writing a debug adapter for IntelliJ in an extremely tedious task, and I don't feel like burning most of my free time on a feature that I personally will never use (as I don't use Windows for development).

Personally, I would just wait until the Zig team fixes the debug symbol generation on their side, but if anybody is motivated enough to take on this task, please let me know.

@FalsePattern FalsePattern pinned this issue Mar 4, 2024
@FalsePattern FalsePattern changed the title Debug breakpoints don't work on windows Debugging doesn't work on Windows (CLion limitation) Mar 4, 2024
@FalsePattern FalsePattern removed their assignment Mar 4, 2024
@FalsePattern
Copy link
Owner

Good news: LSP4J (used by ZigBrains' ZLS connector) already includes a DAP adapter, so a full port of the LSP4E adapter is NOT required. This might be doable in a reasonable time frame after all.
https://github.com/eclipse-lsp4j/lsp4j/tree/main/org.eclipse.lsp4j.debug

@FalsePattern FalsePattern self-assigned this Mar 5, 2024
@FalsePattern
Copy link
Owner

Debugging should be working now in 13.0.0 with the MSVC debugger. See the plugin description for how to set that up.

@FalsePattern FalsePattern removed the help wanted Extra attention is needed label Mar 12, 2024
@FalsePattern FalsePattern unpinned this issue Mar 13, 2024
@DasGandlaf
Copy link

DasGandlaf commented Jun 25, 2024

It doesn't recognize MSVC debugger for me on Windows in CLion. I've installed VS 2022 with C++ development checked.

When selecting MSVC, it says "Need to be downloaded", when I click on the hyperlink on "downloaded", it does nothing. Download button on error popup when starting debugger does nothing either.

vsdbg.exe, cl.exe is in the PATH as well. Any ideas what the issue might be? In ZigBrains code I saw for MSVC debugger the cli argument --interpreter=vscode, maybe I have to setup VsCode?

@DasGandlaf
Copy link

DasGandlaf commented Jun 25, 2024

By looking at the code, I've found copying the vsdbg.exe installed by vscode to: C:\Users\user\AppData\Local\JetBrains\CLion2024.1\zigbrains\msvc\vsdbg.exe (CLion2024.1 being the IDE and version I'm using) fixes the Need to be downloaded text.

But when running the MSVC debugger, I get java.io.IOException: Stream Closed in the console output. That doesn't happen when running normally with zig build run.

Edit 1: vscode with c++ extension installed, copied entire folder containing vsdbg.exe from vscode to zigbrains path explained above. Now there is no error at all, but debugging just doesn't work.

Edit 2: With the steps on edit 1, I got it working: I had run in Extra command line arguments, to run the program immediately after build. When debugging, the plugin should start the program itself to attach correctly.

Edit 3: Viewing variable values with hover or evaluating expression doesn't seem to work, although watch and variables window does work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants