Debugging an Amber project on VSCode with GDB and Native Debug.
- Crystal
- Amber Project
- GNU Debugger (GDB)
- VSCode + Crystal Support + Native Debug.
task.json
to compile the main file with debug support
{
"version": "2.0.0",
"tasks": [
{
"taskName": "amber",
"command": "crystal build -d -p src/app.cr",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "shared"
}
}
]
}
launch.json
configuration to debug binary
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./app",
"cwd": "${workspaceRoot}",
"preLaunchTask": "amber"
}
]
}
- Then hit the green play button and whoala!
Native Debug allows to set breakpoints, watch variables and execute GDB commands inside VSCode.