Last active
June 21, 2024 15:11
-
-
Save gabrielhamel/5bbde2878e81d99b0651a18a5b5e38de to your computer and use it in GitHub Desktop.
VSCode configuration for GDB debugging with cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Put all files into .vscode | |
- Build: Ctrl+Shift+B | |
- Launch: Ctrl+F5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!! I couldn't figure out how to set up the tasks.json to work with CMake and VSCode.
It worked first try 👍