Skip to content

Instantly share code, notes, and snippets.

@gabrielhamel
Last active June 21, 2024 15:11
Show Gist options
  • Save gabrielhamel/5bbde2878e81d99b0651a18a5b5e38de to your computer and use it in GitHub Desktop.
Save gabrielhamel/5bbde2878e81d99b0651a18a5b5e38de to your computer and use it in GitHub Desktop.
VSCode configuration for GDB debugging with cmake
Put all files into .vscode
- Build: Ctrl+Shift+B
- Launch: Ctrl+F5
{
"version": "0.2.0",
"configurations": [
{
"name": "In debug",
"cwd": "${workspaceFolder}",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/zia", // Binary to exec
"args": ["build/config.yml"], // Arguments passed
"stopAtEntry": false,
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "${defaultBuildTask}",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
{
"tasks": [
{
"type": "shell",
"label": "Create build with debug symbols",
"command": "/usr/bin/cmake",
"args": [
"-DCMAKE_BUILD_TYPE=Debug",
".." // CMakeLists.txt location
],
"options": {
"cwd": "${workspaceFolder}/build" // Build result directory
}
},
{
"type": "shell",
"label": "Launch cmake build",
"command": "/usr/bin/cmake",
"args": [
"--build",
"." // Build cache directory
],
"options": {
"cwd": "${workspaceFolder}/build" // Build result directory
},
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn": [
"Create build with debug symbols"
]
}
],
"version": "2.0.0"
}
@Silver812
Copy link

Thanks!! I couldn't figure out how to set up the tasks.json to work with CMake and VSCode.
It worked first try 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment