Closed man-jai closed 4 years ago
I have tried to install the latest version, but I still can't solve the debugging problem
I am publishing a build of lldb-mi that can be used with the new version of cpptools: https://github.com/puremourning/lldb-mi/releases
All you need to do is:
brew install llvm
(this is a dependency)cd $HOME/Downloads && curl -LO https://github.com/puremourning/lldb-mi/releases/download/1015/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
)$HOME/lldb-mi
: mkdir -p $HOME/lldb-mi && tar -C $HOME/lldb-mi -zxvf $HOME/Downloads/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
)miDebuggerPath
to point to it, e.g. add "miDebuggerPath": "/Users/<yourname>/lldb-mi/usr/local/bin/lldb-mi"
I'm trying to upstream the changes so that we can create a brew formula for it
@puremourning I was trying to use the lldb-mi release above, however it seems to require another llvm version than I have. I get this error:
Unable to start debugging. Unable to establish a connection to LLDB. The following message was written to stderr: dyld: Library not loaded: /usr/local/opt/llvm/lib/liblldb.9.0.0.dylib Referenced from: /Users/
/lldb-mi/usr/local/bin/lldb-mi Reason: image not found
I have liblldb.9.0.1.dylib (llvm 9.0.1 installed via Homebrew)
Do you have a suggestion to fix this?
@D-Roberts I rebuilt it yesterday against lldb 9.0.1, so grab the latest release.
@puremourning Thanks. Is this the correct release?
curl -LO https://github.com/puremourning/lldb-mi/releases/download/1041/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
I get the same error (looking for dyld: Library not loaded: /usr/local/opt/llvm/lib/liblldb.9.0.0.dylib).
ugh. looks like the homebrew build for llvm 9.0.1 failed on Mojave (https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/version=mojave/55674/console) meaning that the CI build (which runs on Mojave) is still linking against 9.0.0.
for now, I would just downgrade your llvm to 9.0.0. if you still have it (brew list --versions llvm
), then you can brew switch llvm 9.0.0
.
Alternatively you can build my lldb-mi
yourself:
mkdir build.brew
cd build.brew
../cmake-scripts/run_cmake.brew
Then lldb-mi
is in src/lldb-mi
@zmer007 I was also able to get debug working with codelldb and the config file. One weird thing though. My first test program sends a message to cout, yet I don't see this output anywhere. I'm very new to using VS Code for C++, I've been waiting for the tools to be stable, so this may be a very stupid question. Other than that, it looks good!
@puremourning Thanks. Is this the correct release?
curl -LO https://github.com/puremourning/lldb-mi/releases/download/1041/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
I get the same error (looking for dyld: Library not loaded: /usr/local/opt/llvm/lib/liblldb.9.0.0.dylib).
I was having the same problem of the lldb-mi program saying it was looking for liblldb.9.0.0.dylib when in fact I have liblldb.9.0.1.dylib / llvm 9.0.1 installed
this is likely a terrible work around but its working for me at the moment so .... I will share nevertheless
I simply copyied liblldb.9.0.1.dylib to liblldb.9.0.0.dylib (note I said copy not mv / rename)
this may cause upgrading issues in the future but, like I said my debugger now works...
@amcquistan @D-Roberts I have fixed the dependency and pushed a new build - it now links against lldb 9.0.1 which Is the latest version in homebrew.
@amcquistan @D-Roberts I have fixed the dependency and pushed a new build - it now links against lldb 9.0.1 which Is the latest version in homebrew.
Thanks, puremourning. It really works for me. (Catalina with lldb 9.0.1)
Hi, I am on macOS Catalina (with lldb-1100.0.30.12). I followed this post and the process worked fine. However, when I try debugging C++ in vscode (with a very simple hello-world program), after the "return 0" statement in main(), the debugger goes into the assembly code as I do "step over" or "step into" and goes through the commands in there. The first file it goes into is "@start". Even though I googled it, I couldn't find anything related to this -- do you have any idea what might be the issue here? Also, the same thing happened when I used the CodeLLDB extension. You can see an example of this in the image.
@gokcedilek with CodeLLDB I had the same issue and got it resolved following: https://github.com/vadimcn/vscode-lldb/issues/258
I am publishing a build of lldb-mi that can be used with the new version of cpptools: https://github.com/puremourning/lldb-mi/releases
All you need to do is:
brew install llvm
(this is a dependency)- Download the tarball (e.g.
cd $HOME/Downloads && curl -LO https://github.com/puremourning/lldb-mi/releases/download/1015/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
)- Untar it somewhere (e.g. to put it in
$HOME/lldb-mi
:mkdir -p $HOME/lldb-mi && tar -C $HOME/lldb-mi -zxvf $HOME/Downloads/lldb-mi-db65c20a3d8e09d9ff2f3748c01cf43ec035a4d8.tar.gz
)- in your launch config set
miDebuggerPath
to point to it, e.g. add"miDebuggerPath": "/Users/<yourname>/lldb-mi/usr/local/bin/lldb-mi"
@puremourning this worked great but now I'm facing issues with watched variables. trying to display them as hex I get an error: 'Unrecognized format of field "value" in result...'
I'm wondering something, and I figure that maybe some others monitoring this thread are wondering the same thing. Do we expect the debug experience to be different with lldb-mi as opposed to using CodeLLDB?
I followed @puremourning advice and I'm back up and running. Thanks!
Hey,
I was trying to follow @puremourning advice but ran into an issue. It seems that a full install of Xcode.app is required for llvm, is there a workaround specific to this advice if I can only have the Command Line Tools installed and not the full install? I have looked at another issue where this is a problem, but the solution there seems to have been fixed by the home-brew team but doesn't work here.
Update: never mind. it now works, though I am not sure why.
It persists after I tried every workaround above....What shoule I do...
It persists after I tried every workaround above....What shoule I do...
After hitting against this issue, I started using CodeLLDB and its working perfectly.
The same. I try CodeLLBD and works with no hard. Here I need to compile with flag '-g' to generate some files, so debug on CodeLLBD works To C use: 'gcc name.c -o a.out -g'. To C++ use 'g++ -g *'.
{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "lldb", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [ ] } ] }
It persists after I tried every workaround above....What shoule I do...
After hitting against this issue, I started using CodeLLDB and its working perfectly.
@DonizeteVida @mfornet emm,I installed that extension,but the output showed this messages below:
Acquiring platform package for CodeLLDB.
Package is located at https://github.com/vadimcn/vscode-lldb/releases/download/v1.4.5/vscode-lldb-x86_64-darwin.vsix
Downloading...
Downloaded 0%
while I debugging with codelldb everytime.And I can't also open the download link.Maybe the net in my home or github have something wrong.I guess the codelldb works well if the net is well.
I just upgraded to Mac OS Catalina and I am using CodeLLDB and these configurations worked for me:
### tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"label": "gcc compile",
"type": "shell",
"command": "/usr/bin/gcc",
"args": [
"-g",
"-o${fileBasenameNoExtension}.out",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
### launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "gcc compile",
"type": "lldb",
"request": "launch",
"name": "gcc compile and debug",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
Fixed in our latest Insiders release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. But there's a known issue
Pause (break all) doesn't work when debugging on Mac. Workaround: use kill -2 <pid> to trigger the break.
Debugger freezes when program reading input from keyboard. Program:
int main() {
int a,b;
cin >> a >> b;
int c = a+b;
cout << c;
return 0;
}
Debugger works perfectly but it freezes when hitting line cin >> a >> b;
.
I try redirecting input by add args in launch.json but it not working.
Did you set externalConsole true?
Did you set externalConsole true?
I want to use the internal console so I set it to false. It works with Ubuntu OS but not MacOS.
@vudaoanhtuan how does your launch.json file looks like? With the new insider release of CppTools my issue is now fixed.
When can get this issue done... :(
@dufuhang Have you tried 0.27.0-insiders2? Are you doing Attach or Launch debugging?
I added the miDebuggerPath:
miDebuggerPath: "/Library/Developer/CommandLineTools/usr/bin/lldb"
and the problem became:
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (137) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'\n"},"seq":2} 1: (137) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (149) LaunchOptions ExePath='/Users/shawn/Documents/Code/C_C++/hello_world/helloworld.out'\n"},"seq":4} 1: (149) LaunchOptions ExePath='/Users/shawn/Documents/Code/C_C++/hello_world/helloworld.out' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (149) LaunchOptions WorkingDirectory='/Users/shawn/Documents/Code/C_C++/hello_world'\n"},"seq":6} 1: (149) LaunchOptions WorkingDirectory='/Users/shawn/Documents/Code/C_C++/hello_world' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (149) LaunchOptions ExeArguments=''\n"},"seq":8} 1: (149) LaunchOptions ExeArguments='' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions MIMode='lldb'\n"},"seq":10} 1: (150) LaunchOptions MIMode='lldb' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions MIDebuggerPath='/Library/Developer/CommandLineTools/usr/bin/lldb'\n"},"seq":12} 1: (150) LaunchOptions MIDebuggerPath='/Library/Developer/CommandLineTools/usr/bin/lldb' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions WaitDynamicLibLoad='false'\n"},"seq":14} 1: (150) LaunchOptions WaitDynamicLibLoad='false' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions ExternalConsole='true'\n"},"seq":16} 1: (150) LaunchOptions ExternalConsole='true' --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions>\n"},"seq":18} 1: (150) LaunchOptions> --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (150) LaunchOptions\n"},"seq":20} 1: (150) LaunchOptions --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (245) Starting: \"/Library/Developer/CommandLineTools/usr/bin/lldb\" --interpreter=mi\n"},"seq":22} 1: (245) Starting: "/Library/Developer/CommandLineTools/usr/bin/lldb" --interpreter=mi --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (264) DebuggerPid=3194\n"},"seq":24} 1: (264) DebuggerPid=3194 --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (267) STDERR: warning: ignoring unknown option: --interpreter=mi\n"},"seq":26} 1: (267) STDERR: warning: ignoring unknown option: --interpreter=mi
you have to set miDebuggerPath
to point at lldb-mi
not lldb
. It won't exist in that location. Scroll up and read the thread (e.g. my comments and the maintainers' comments) to understand why.
It persists after I tried every workaround above....What shoule I do...
After hitting against this issue, I started using CodeLLDB and its working perfectly.
@DonizeteVida @mfornet emm,I installed that extension,but the output showed this messages below:
Acquiring platform package for CodeLLDB. Package is located at https://github.com/vadimcn/vscode-lldb/releases/download/v1.4.5/vscode-lldb-x86_64-darwin.vsix Downloading... Downloaded 0%
while I debugging with codelldb everytime.And I can't also open the download link.Maybe the net in my home or github have something wrong.I guess the codelldb works well if the net is well.
Same problem https://github.com/microsoft/vscode/issues/92202
you have to set
miDebuggerPath
to point atlldb-mi
notlldb
. It won't exist in that location. Scroll up and read the thread (e.g. my comments and the maintainers' comments) to understand why.
Thank you for your reply, but I can not find the lldb-mi
in my computer, and I did not install Xcode, only command line tools. lldb version is lldb-1100.0.30.12
Quoting the maintainers @sean-mcmanus
Fixed in our latest Insiders release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. But there's a known issue
Pause (break all) doesn't work when debugging on Mac. Workaround: use kill -2
to trigger the break.
Quoting me from further up, if you don't/can't use that:
https://github.com/puremourning/lldb-mi/releases
instructions: https://github.com/microsoft/vscode-cpptools/issues/3829#issuecomment-578454043
Or use the insiders release per the comments from the maintainer.
@puremourning
after following your instructions (https://github.com/microsoft/vscode-cpptools/issues/3829#issuecomment-578454043) I was facing some issues. I could fix them with the following adjustments, but I am not sure if all of them where necessary:
ln -s ln -s /Users/<user_name>/lldb-mi/usr/local/bin/lldb-mi /usr/local/bin/lldb-mi
cd /usr/local/opt/llvm/lib
and symlink: ln -s liblldb.9.0.1.dylib liblldb.9.0.0.dylib
System: macOS 10.15.3
Fixed in our latest Insiders release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. But there's a known issue
Pause (break all) doesn't work when debugging on Mac. Workaround: use kill -2 <pid> to trigger the break.
I've had a similar issue on 10.15.3. Couldn't get CodeLLDB or the lldb-mi
solutions to work at all. Switching to the insiders build (0.27.0-insiders4
) has solved all the issues for me.
I still have question here with insiders5. My probelm is if set externalConsole false, it will start debugging but no where to get input. (seems not able to input in debug console, but output there is fine) If set true, a now console will pop up but without anything running inside. And there is no output in debug console. My os is Catalina(10.15.4), Xcode is also the newest. launch.json is just like this(copy from official site):
{ "version": "0.2.0", "configurations": [ { "name": "(lldb) launch", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "lldb" } ] }
My probelm is if set externalConsole false, it will start debugging but no where to get input.
@Garithe this is a limitation of LLDB, not vscode-cpptools (it also applies to lldb-vscode
). I'd recommend using "externalConsole": true
.
If set true, a now console will pop up but without anything running inside
This is likely a different issue, probably reolated to the program
argument in your launch configs apparently being a directory not a binary.
My probelm is if set externalConsole false, it will start debugging but no where to get input.
@Garithe this is a limitation of LLDB, not vscode-cpptools (it also applies to
lldb-vscode
). I'd recommend using"externalConsole": true
.If set true, a now console will pop up but without anything running inside
This is likely a different issue, probably reolated to the
program
argument in your launch configs apparently being a directory not a binary.
@puremourning Thanks for replying. But that's just a mistake when I copy the content.I did use "${fileDirname}/${fileBasenameNoExtension}". If it's a name thing, debugger shouldn't run when I set "externalConsole" false. By the way when I click run without debugging there is also nothing in the console, maybe this is indeed another problem
Fixed with 0.27.0.
Yeah, the 0.27.0 works well on 10.15.4.
Here's my configurations:
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "clangBuild",
"type": "shell",
"command": "clang",
"args": [
"-g",
"-o${fileBasenameNoExtension}.out",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
// "preLaunchTask": "clang build active file"
"preLaunchTask": "clangBuild",
}
]
}
However, now although I can uninstall the CodeLLDB extension, I can only debug using external console(Terminal.app). It seems there's no option as "IntegratedTerminal" so I can't use the integrated terminal to debug. When using single screen to debug, that would cause inconvenience. Hope you would support "IntegratedTerminal" option.
Thanks @sean-mcmanus! Looks good to me.
@Saafo To get the integrated terminal, set "externalConsole": false
@spinicist I've tried the "externalConsole": false;
, however, the output printed in the debug console
tab:
and the terminal
tab is like this:
I still can't use the integrated terminal...
I am having the same issue as @Saafo, cant use my debugger
@Saafo That is the expected behaviour. The debugger has its own terminal, that is the "Integrated Terminal". The inability to take input has been a longstanding issue, if you need to provide input to your program then you can use the external console.
@Saafo How do you fix the issue, i have the same issue too.
It's really simple. The integrated terminal is not supported, and never was.
@Kendrick-Song I just can't solve it... I have to use the external terminal now.
I had a very similar problem, but I was able to FINALLY get the debbuger WORKING. So, the one thing I didn't do after setting up my task json file was to press command+shift+B. So to solve the problem I was having, 1)I created a new .c file in a new folder 2)set up my task json file and then went back to my .c file(by pressing its window/tab in vscode) 3) then pressed command+shit+B. After this I then went on to create my launch json file as I had done before. Article that help is below.
Advice: Especial when you are new to anything(in this case Vscode), when asking a question please mention all the steps you took before you ran into an error/problem. For example: my problem was not pressing cmd+shift+B and had nothing to do with the files themselves. So whoever tries to help on let say github will most likely have no idea that--that's what I'm doing wrong. Also shoutout to @WardenGnaw and all the others that contributed to this.
Here is the link to the article that helped with this. The article is for c++ but pretty much the same thing. Now, I did not actual copy and past the code they give because I'm writing in c. The article is on medium so I think the code they provide is save. https://medium.com/gdplabs/build-and-debug-c-on-visual-studio-code-for-mac-77e05537105e
@Kendrick-Song @Saafo read above response might be able to help you guys if you are still interested.
Type: Debugger Input information below
Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.
Describe the bug
To Reproduce
launch.json
``` "version":"0.2.0", "configurations":[ { "type":"cppdbg", "request":"launch", "name":"Debug", "preLaunchTask":"build", "program":"${workspaceFolder}/debug/OpenGLTut.out", "args":[ ], "stopAtEntry":true, "cwd":"${workspaceFolder}", "environment":[ ], "externalConsole":true, "MIMode":"lldb", "internalConsoleOptions":"openOnSessionStart", "showDisplayString":false, "logging":{ "trace":true, "traceResponse":true, "engineLogging":true, "programOutput":true, } } ] ```tasks.json
``` "version":"2.0.0", "tasks":[ { "type":"shell", "label":"build", "command":"clang++", "args":[ "-g", "-std=c++17", "-stdlib=libc++", "-framework", "Cocoa", "-framework", "OpenGL", "-framework", "IOKit", "-framework", "CoreVideo", "-L", "/usr/local/include/", "-lglew", "-lglfw3", "${workspaceFolder}/src/Application.cpp", "-o", "${workspaceFolder}/debug/OpenGlTut.out", "--debug", ], "group":{ "kind":"build", "isDefault":true } } ] ```Steps to reproduce the behaviour: debug using the above tasks and launch files
Additional context If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your
launch.json
Add any other context about the problem here including log or error messages in your Debug Console or Output windows.