Debugger
Thanks to sqdbg it's possible to use the VS:Code extension that provides squirrel debugger intergration.
Video Tutorial (if you don't want to read the below article)
Installing the extension
- Search the
sqdbgextension inVS Code Extensions - Install the extension
Configuration
config.xml
Before you start debugging your code, you need to setup the debug server ports both for client and the server.
You can do that by editing the <debug> config located in config.xml file:
<!-- By default, client_port & server_port are set to these values, but you can adjust them -->
<!-- It's also worth to mention that debugger is only enabled when <debug> tag holds `true` value -->
<debug chcp="1250" log_level="trace" client_port="28971" server_port="28972">true</debug>
launch.json (vs:code)
The next thing that you need to setup debug profiles, to do that you need:
- Open
Run and Debugtab (Ctrl + Shift + D) - Click on
create a launch.json file - Pick
Squirrel Debuggerfrom debuggers list - Set proper ports for both
ClientandServerconfigurations from previous step - Include the
"cwd": "${workspaceFolder}"option in both configurations (Clientprofile requires this option, but theServeris able to run without it)
Example configuration:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "squirrel",
"request": "attach",
"name": "Client",
"port": 28971,
"cwd": "${workspaceFolder}"
},
{
"type": "squirrel",
"request": "attach",
"name": "Server",
"port": 28972,
"cwd": "${workspaceFolder}"
},
]
}
Usage
When you're done with the configuration, you can basically connect to the debug server when you need to debug something in your codebase.
It's also worth poitining out that the extension supports many useful features, including:
- breakpoints (obvious must have)
- disassembly view (ability to take a look at squirrel bytecode)
- callstack
- preview/modify variable(s)
and many, many more, feel free to discover other useful features at your own!