Reputation: 16439
I'm trying to learn to debug using VS Code. I created a launch configuration in launch.json
, for attaching to my process (a C++ program). I'm on macOS, so it uses LLDB. It attaches, and I can stop in a breakpoint and step through code. But nothing else is working well.
I'll focus my question here on the "Debug Console". I thought I'd be able to use LLDB commands, but it doesn't seem like it.
If I type -exec bt
in the Debug Console panel, it responds with an error (below). Other simple LLDB commands don't work.
-exec bt
error: invalid target, create a target using the 'target create' command
-exec info registers
error: 'info' is not a valid command.
-exec p this
error: expression failed to parse:
error: <user expression 13>:1:1: invalid use of 'this' outside of a non-static member function
this
^
I'm stopped in a member function, so p this
should work.
Is this "Debug Console" not connected to the current LLDB session? Should these commands be working?
In my launch.json
:
"configurations": [
{
"name": "(lldb) Attach to my_program",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/build/macos/my_program",
"MIMode": "lldb"
},
...
I tried another kind of debug configuration, where I launch it directly rather than attach (which I need in this case). In this case (launch instead of attach) I can run commands like -exec bt
, and -exec p this
. So something is different about attaching to a process.
VSCode: 1.79.2
macOS: 13.4
Extension CodeLLDB: 1.9.2
LLDB: from Apple Xcode 14: lldb-1403.0.17.64
Upvotes: 1
Views: 1772
Reputation: 16439
I got this working. My main mistake was not changing my launch configuration to point to the new extension. The key: "type": "cppdbg"
is wrong. It should be "lldb"
instead, as documented here.
For example:
{
"name": "(lldb) Attach to myapp",
"type": "lldb",
"request": "attach",
"program": "${workspaceFolder}/build/macos/myapp"
},
I also had to set the extension's lldb.library
setting to point to my custom build of LLDB.
"lldb.library": "/Dev/llvm-project/build_phase3/lib/liblldb.dylib"
Upvotes: 1