Skip to content

Debugger

Tyrn debugs through the Debug Adapter Protocol. A debug adapter for each language does the work, and Tyrn gives you breakpoints, stepping, a variables view and a debug console.

Supported languages

Language Adapter Notes
Rust, C, C++ CodeLLDB Downloaded the first time you debug
C, C++ GDB Needs gdb installed and on your PATH
Go Delve Uses dlv from your PATH, or installs it with go install
Python Debugpy Downloaded the first time you debug
JavaScript, TypeScript JavaScript Downloaded the first time you debug

Per-language setup is on the language pages: Rust, C, C++, Go, Python and TypeScript.

Start debugging

Press f4 (Start Debugger in the Run menu). A list shows preconfigured debug tasks for the current project, and any you have defined. You can also click the plus button in the debug panel.

Open the debug panel with cmd-shift-d.

For a language without preconfigured tasks, such as C and C++, define your own configuration.

Define a configuration

Debug configurations live in debug.json. Open the project file with Edit debug.json… in the Run menu, or your global file with tyrn: open debug tasks.

  • Project: .tyrn/debug.json
  • Global: ~/.config/tyrn/debug.json, merged into every project

If a project has no debug.json, Tyrn also offers the configurations in .vscode/launch.json.

debug.json
[
{
"label": "Debug native binary",
"adapter": "CodeLLDB",
"request": "launch",
"program": "$ZED_WORKTREE_ROOT/build/prog",
"cwd": "$ZED_WORKTREE_ROOT",
"build": {
"command": "make",
"args": ["-j8"]
}
}
]

adapter and label are required. request is "launch" to start your program, or "attach" to connect to a running process. Other fields depend on the adapter. They can use the task variables.

build runs before the debugger starts. It can be a task definition, as above, or the label of a task you already have in tasks.json.

Breakpoints

  • Click beside a line number, or press f9, to toggle a breakpoint.
  • Right-click a breakpoint to add a log message, a condition or a hit count, or to disable it. shift-f9 edits a log breakpoint. The condition syntax depends on the adapter.
  • The Breakpoints entry in the debug panel lists every breakpoint in the project, including exception breakpoints where the adapter supports them.
  • Clear All Breakpoints is in the Run menu.

Breakpoints are saved between sessions. Set debugger.save_breakpoints to false to stop that.

Control execution

Task Keybinding
Continue f5
Step over f10 or f7
Step into f11
Step out shift-f11
Pause f6
Stop shift-f5
Restart the session shift-cmd-f5
Rerun the last session f5 when none is running

While stopped, the variables view lets you expand values, edit them (enter), copy a value (cmd-c) or its name (cmd-alt-c), and add watches (alt-enter). With inlay_hints.show_value_hints on (default), variable values also appear inline in the code.

Settings

settings.json
{
"debugger": {
"dock": "bottom",
"stepping_granularity": "line",
"save_breakpoints": true,
"timeout": 2000,
"button": true
}
}
Key Default Meaning
dock "bottom" Where the debug panel docks: "left", "right" or "bottom"
stepping_granularity "line" "statement", "line" or "instruction"
save_breakpoints true Keep breakpoints between sessions
timeout 2000 Milliseconds to wait when connecting to a TCP adapter
button true Show the debugger button in the status bar

To run an adapter from a different location or with different arguments, use dap:

settings.json
{
"dap": {
"CodeLLDB": {
"binary": "/path/to/lldb-dap",
"args": ["--wait-for-debugger"]
}
}
}

binary is the path to a debug adapter, not to a debugger such as lldb itself.

Set a preferred adapter for a language with the language’s debuggers setting. See Configuring languages.

Troubleshooting

  • Run dev: open debug adapter logs from the command palette to see the traffic between Tyrn and the adapter.
  • Check that the program path in your configuration is correct and that the build step succeeds.