Skip to content

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

  1. Search the sqdbg extension in VS Code Extensions
  2. 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:

  1. Open Run and Debug tab (Ctrl + Shift + D)
  2. Click on create a launch.json file
  3. Pick Squirrel Debugger from debuggers list
  4. Set proper ports for both Client and Server configurations from previous step
  5. Include the "cwd": "${workspaceFolder}" option in both configurations (Client profile requires this option, but the Server is 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!