Open segevfiner opened 1 month ago
@segevfiner After I add a launch,json file to the project, I can debug successfully. I'm not sure what is causing your error, can you provide a simple project that can reproduce the issue and more detailed steps to do so? Looking forward to your reply!
https://github.com/user-attachments/assets/f4c3cef7-72e4-423e-9e0f-9f58ab3515d6
The without launch.json option, using the CMake: Debug command defined by this extension, and bound to a status bar item and keyboard shortcuts, is failing, not the launch.json debug configuration that is supplied by cpptools.
I also encountered the same problem as you. When using the CMake tools plug-in and lldb to debug the C++ program, an error message was reported
error: unknown option: --interpreter=mi
error: unknown option: --tty=/dev/pts/5
However, when using gdb debugging, the debugging function of CMake tools can run normally, that is, it will output an extra line of information after debugging.
[1] + Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-vxzegz3r.ndl" 1>"/tmp/Microsoft-MIEngine-Out-wdismh3d.muy"
ChatGPT asked me to add the following settings, but it didn't work
"cmake.debugConfig": {
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"miDebuggerPath": "/usr/bin/lldb",
"setupCommands": [
{
"text": "settings set target.run-args arg1 arg2",
"description": "设置程序参数",
"ignoreFailures": true
}
],
"internalConsoleOptions": "openOnFirstSessionStart"
}
@gcampbell-msft @segevfiner I used a simple project to verify this, after adding the project and running the CMake:select a kit command, when I select GCC 13.2.0 x86_64, debugging fails with an error message in the bottom right corner, but running the CMake:select a kit command, when I select Clang 15.0.0 x86_64, I can successfully I can successfully debug. But when I run CMake: select a kit command and select Clang 15.0.0 x86_64, debugging fails with error message displayed in the bottom right corner.
https://github.com/user-attachments/assets/be8c4104-e09a-46c1-ac19-a9672b31309b
@v-frankwang Thank you very much. Following the method you described, the problem that occurs when CMake tools is debugged with lldb can indeed be solved!
In your video, when debugging with the GCC tool chain, you should use gdb for debugging, but CMake tools still seems to use lldb, as can be seen from the output in the figure below:
I used to have trouble debugging with CMake tools on MacOS, but now I can solve it. I am very happy. Thank you very much for your help.
@Jack-Bie Does this mean that this issue can be closed? Or is there still an underlying issue that we should solve to make this experience easier?
You can debug by launch.json using lldb, it's the command from CMake tools that is broken and should be fixed.
@segevfiner Thank you very much for your reply! We'll be going to do further investigation on this issue and we'll update comment with any subsequent developments!
I can confirm that this still very much happens and is a really big annoyance. My projects use a CMakePresets.json (https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) file and I have not found any way to prevent the extension from passing --interpreter=mi
to LLDB....
Any guidance?
FYI I was able to fix following this guide: https://code.visualstudio.com/docs/cpp/lldb-mi
Basically setting
"miDebuggerPath": "<HOME>/.vscode/extensions/ms-vscode.cpptools-<version>-darwin-x64/debugAdapters/lldb-mi/bin/lldb-mi"
It is a convenient workaround but wasn't straightforward to figure out. This does feel like a bug - the extension should be able to use that adapter since it ships within... I'm happy to take a crack at implementing if yall can give me some pointers as to where to look!
@gcampbell-msft The client wants to fix this problem by following the guide https://code.visualstudio.com/docs/cpp/lldb-mi and would like you to provide some help, can you give some advice?
@v-frankwang They have successfully found a workaround, but we still hope to investigate this and make it easier for users.
We have this item in our "On Deck" Milestone which is where we grab issues from when planning our next release. @thomas-bc Thanks for the workaround!
@thomas-bc I haven't been able to take a look at this much yet, but I would anticipate that this stems from something in this file when we interact with the lldb
debugger configuration: https://github.com/microsoft/vscode-cmake-tools/blob/main/src/debugger.ts.
Here is a link to the method where there may be some improvements to be had: https://github.com/microsoft/vscode-cmake-tools/blob/main/src/debugger.ts#L165
Possibly related: https://github.com/microsoft/vscode-cmake-tools/issues/4050
Brief Issue Summary
Debugging fails with:
Likely due to the extension trying to use lldb instead of VS Code's lldb-mi.
CMake Tools Diagnostics
Debug Log
No response
Additional Information
No response