Skip to content

Instantly share code, notes, and snippets.

@timll
Last active May 29, 2022 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timll/1c4c542c7c98e3610c14aec19cdf7e91 to your computer and use it in GitHub Desktop.
Save timll/1c4c542c7c98e3610c14aec19cdf7e91 to your computer and use it in GitHub Desktop.
VSCode GCC Debugging Setup
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "tab",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && (resourceExtname == .cc || resourceExtname == .h || resourceExtname == .c)",
"args": {
"snippet": " "
}
}
]
{
"configurations": [
{
"preLaunchTask": "Start gdbserver",
"postDebugTask": "Exit gdbserver",
"name": "Connect to GDB",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/host-x86_64-pc-linux-gnu/gcc/xgcc",
"miDebuggerServerAddress": "localhost:2345",
"miDebuggerArgs": "-x ${workspaceFolder}/.gdbinit",
"cwd": "${workspaceRoot}",
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"postRemoteConnectCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
],
}
{
"version": "2.0.0",
"tasks": [
{
"label": "Build gcc",
"type": "shell",
"command": "make",
"args": [],
"options": {
"cwd": "${workspaceFolder}/host-x86_64-pc-linux-gnu/gcc"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Start gdbserver",
"type": "shell",
"command": "${workspaceFolder}/host-x86_64-pc-linux-gnu/gcc/xgcc",
"args": [
"-B",
"/home/tim/Projects/gcc/host-x86_64-pc-linux-gnu/gcc/",
"/home/tim/Projects/simple_c/main.c",
"-o",
"/home/tim/Projects/simple_c/main",
"-fanalyzer",
"-Wall",
"-wrapper",
"gdbserver,localhost:2345"
],
"options": {
"cwd": "${workspaceFolder}/host-x86_64-pc-linux-gnu/gcc"
},
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
},
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "Process",
},
"endsPattern": {
"regexp": "Listening on port 2345",
}
}
}
},
{
"label": "Exit gdbserver",
"type": "shell",
"command": "pkill",
"args": [
"gdbserver"
],
"options": {
"cwd": "${workspaceFolder}/host-x86_64-pc-linux-gnu/gcc"
},
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment