I am trying to debug my C++ code in VS Code on Mac. I am able to compile it and run the executable, but when I launch the debugger using launch.json, it doesn't stop at breakpoints. The breakpoints get greyed out and when I put the cursor on it, it says Unverified breakpoint. And the call stack shows Unknown source. Am I missing something ?
Launch.json code:
// 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": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/xyz",
"preLaunchTask": "Makefile",
"logging": {
"moduleLoad": false,
"programOutput": true,
"trace": true
},
"args": ["--file", "file", "> abc.json"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
]
}
tasks.json:
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
{
"taskName": "Makefile",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Pass 'all' as the build target
"args": ["all"],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
c_cpp_properties.json :
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${workspaceRoot}/deps"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
for that follow below step
opne work directory
install extension
Name: C/C++ Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools- open debug option and click on setting button that open launch.json file.
- you need to change program feild with your executed file with full path.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.