gdb vs code code example
Example 1: debugging c++
Run the code with gdb ./yourCode
Use 'run' command to start the program.
When it crashes use 'bt'(back trace) command to find where it happened.
Example 2: how to run cpp using gcc vscode
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
{
"taskName": "Makefile",
"isBuildCommand": true,
"showOutput": "always",
"args": ["all"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}