Skip to content

Instantly share code, notes, and snippets.

@huihut
Created June 12, 2018 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huihut/9548fe7e1084cf8e844120c5668b8177 to your computer and use it in GitHub Desktop.
Save huihut/9548fe7e1084cf8e844120c5668b8177 to your computer and use it in GitHub Desktop.
Configuring launch.json for C/C++ debugging
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}]
}
@syedidrus
Copy link

Sir is it necessary to put "preLaunchTask": "echo" in this file?

@erhan9398
Copy link

why? what is the reason to put preLaunchTask ?

@dev-Kaustav
Copy link

Man I've got the same conofiguration but whenever I press F5 to debug, the exterernal terminal closes automatically after hitting enter after an input. Could it be an issue with c_cpp_properties.josn?

@LennyAtomz138
Copy link

Man I've got the same configuration but whenever I press F5 to debug, the external terminal closes automatically after hitting enter after an input. Could it be an issue with c_cpp_properties.josn?

Hey @dev-Kaustav: does this link resolve the issue that you're encountering?

@dev-Kaustav
Copy link

Man I've got the same configuration but whenever I press F5 to debug, the external terminal closes automatically after hitting enter after an input. Could it be an issue with c_cpp_properties.josn?

Hey @dev-Kaustav: does this link resolve the issue that you're encountering?

@LennyAtomz138 not exactly but i figured it out somehow, thanks for the help!

@parthvgla
Copy link

parthvgla commented Aug 9, 2022

My vscode debugger is opening stl files(stack, dequeue) middle of the debugging and going through them and then coming back to program. I can't understand what the problem is.
Can anyone help?

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