Crystal Debug
Prerequisites
Debug on VSCode
1. task.json configuration to compile a crystal project
task.json configuration to compile a crystal project{
"version": "2.0.0",
"tasks": [
{
"label": "Compile",
"command": "shards build --debug ${workspaceFolderBasename}",
"type": "shell"
}
]
}2. launch.json configuration to debug a binary
launch.json configuration to debug a binaryUsing GDB
Using LLDB
3. Then hit the DEBUG green play button

Tips and Tricks for debugging Crystal applications
1. Use debugger keyword
2. Avoid breakpoints inside blocks
3. Try @[NoInline] to debug arguments data
@[NoInline] to debug arguments data4. Printing strings objects (GDB)

5. Printing array variables
6. Printing instance variables
7. Print hidden objects
Last updated