- name
- interactive-debugging
- description
- Patterns for controlling interactive debuggers (pdb, ipdb, gdb, lldb, node debug) via terminalcp
# Interactive Debugging with terminalcp
This skill provides comprehensive patterns for automating interactive debugger sessions using terminalcp MCP. It enables AI agents to spawn, control, and extract information from debuggers in real-time.
## Overview
terminalcp enables:
- Real-time debugger control via PTY
- Breakpoint management and inspection
- Step-by-step execution with state capture
- Variable inspection and expression evaluation
- Multi-debugger session management
The MCP server runs via `npx @mariozechner/terminalcp@latest --mcp` and provides full terminal emulation for debugger interaction.
## Python Debugging (pdb/ipdb)
### Starting a Debug Session
```json
{
"action": "start",
"command": "python -m pdb script.py",
"name": "python-debug"
}
```
Or with ipdb for enhanced debugging:
```json
{
"action": "start",
"command": "python -m ipdb script.py",
"name": "python-debug"
}
```
### Setting Breakpoints
```json
{
"action": "stdin",
"id": "python-debug",
"data": "b script.py:42\r"
}
```
Set conditional breakpoint:
```json
{
"action": "stdin",
"id": "python-debug",
"data": "b script.py:42, x > 10\r"
}
```
Set breakpoint in function:
```json
{
"action": "stdin",
"id": "python-debug",
"data": "b my_function\r"
}
```
### Execution Control
```json
// Continue execution
{
"action": "stdin",
"id": "python-debug",
"data": "c\r"
}
// Step into function
{
"action": "stdin",
"id": "python-debug",
"data": "s\r"
}
// Step over (next line)
{
"action": "stdin",
"id": "python-debug",
"data": "n\r"
}
// Return from current function
{
"action": "stdin",
"id": "python-debug",
"data": "r\r"
}
// Continue until next breakpoint or return
{
"action": "stdin",
"id": "python-debug",
"data": "unt 50\r"
}
```
### Variable Inspection
```json
// Print variable value
{
"action": "stdin",
"id": "python-debug",
"data": "p variable_name\r"
}
// Pretty print
{
"action": "stdin",
"id": "python-debug",
"data": "pp complex_object\r"
}
// List all local variables
{
"action": "stdin",
"id": "python-debug",
"data": "locals()\r"
}
// Evaluate expression
{
"action": "stdin",
"id": "python-debug",
"data": "p len(my_list) + 5\r"
}
```
### Stack Frame Navigation
```json
// Show stack trace
{
"action": "stdin",
"id": "python-debug",
"data": "w\r"
}
// Move up one frame
{
"action": "stdin",
"id": "python-debug",
"data": "u\r"
}
// Move down one frame
{
"action": "stdin",
"id": "python-debug",
"data": "d\r"
}
// List source code at current location
{
"action": "stdin",
"id": "python-debug",
"data": "l\r"
}
```
### Capturing Debugger Output
```json
{
"action": "stdout",
"id": "python-debug"
}
```
This returns the current terminal state including all debugger output, variable values, and stack traces.
## GDB/LLDB Debugging (C/C++)
### Starting GDB Session
```json
{
"action": "start",
"command": "gdb ./myprogram",
"name": "gdb-debug"
}
```
### Starting LLDB Session
```json
{
"action": "start",
"command": "lldb ./myprogram",
"name": "lldb-debug"
}
```
### GDB Breakpoint Management
```json
// Set breakpoint at line
{
"action": "stdin",
"id": "gdb-debug",
"data": "break main.c:42\r"
}
// Set breakpoint at function
{
"action": "stdin",
"id": "gdb-debug",
"data": "break my_function\r"
}
// Conditional breakpoint
{
"action": "stdin",
"id": "gdb-debug",
"data": "break main.c:42 if x > 10\r"
}
// List all breakpoints
{
"action": "stdin",
"id": "gdb-debug",
"data": "info breakpoints\r"
}
// Delete breakpoint
{
"action": "stdin",
"id": "gdb-debug",
"data": "delete 1\r"
}
```
### LLDB Breakpoint Management
```json
// Set breakpoint at line
{
"action": "stdin",
"id": "lldb-debug",
"data": "breakpoint set --file main.c --line 42\r"
}
// Set breakpoint at function
{
"action": "stdin",
"id": "lldb-debug",
"data": "breakpoint set --name my_function\r"
}
// List breakpoints
{
"action": "stdin",
"id": "lldb-debug",
"data": "breakpoint list\r"
}
```
### GDB Execution Control
```json
// Start program
{
"action": "stdin",
"id": "gdb-debug",
"data": "run\r"
}
// Start with arguments
{
"action": "stdin",
"id": "gdb-debug",
"data": "run arg1 arg2\r"
}
// Continue
{
"action": "stdin",
"id": "gdb-debug",
"data": "continue\r"
}
// Step into
{
"action": "stdin",
"id": "gdb-debug",
"data": "step\r"
}
// Step over
{
"action": "stdin",
"id": "gdb-debug",
"data": "next\r"
}
// Finish current function
{
"action": "stdin",
"id": "gdb-debug",
"data": "finish\r"
}
```
### GDB Variable Inspection
```json
// Print variable
{
"action": "stdin",
"id": "gdb-debug",
"data": "print variable_name\r"
}
// Print with format (hex)
{
"action": "stdin",
"id": "gdb-debug",
"data": "print/x pointer\r"
}
// Display variable (auto-display on each stop)
{
"action": "stdin",
"id": "gdb-debug",
"data": "display my_var\r"
}
// Show all local variables
{
"action": "stdin",
"id": "gdb-debug",
"data": "info locals\r"
}
// Examine memory
{
"action": "stdin",
"id": "gdb-debug",
"data": "x/10x $rsp\r"
}
```
### Stack and Backtrace
```json
// Show backtrace
{
"action": "stdin",
"id": "gdb-debug",
"data": "backtrace\r"
}
// Show full backtrace with locals
{
"action": "stdin",
"id": "gdb-debug",
"data": "backtrace full\r"
}
// Select frame
{
"action": "stdin",
"id": "gdb-debug",
"data": "frame 2\r"
}
// Move up frame
{
"action": "stdin",
"id": "gdb-debug",
"data": "up\r"
}
// Move down frame
{
"action": "stdin",
"id": "gdb-debug",
"data": "down\r"
}
```
## Node.js Debugging
### Starting Node Debug Session
```json
{
"action": "start",
"command": "node inspect script.js",
"name": "node-debug"
}
```
### Node Debugger Commands
```json
// Continue execution
{
"action": "stdin",
"id": "node-debug",
"data": "c\r"
}
// Step over
{
"action": "stdin",
"id": "node-debug",
"data": "n\r"
}
// Step into
{
"action": "stdin",
"id": "node-debug",
"data": "s\r"
}
// Step out
{
"action": "stdin",
"id": "node-debug",
"data": "o\r"
}
// Set breakpoint at current line
{
"action": "stdin",
"id": "node-debug",
"data": "sb()\r"
}
// Set breakpoint at line
{
"action": "stdin",
"id": "node-debug",
"data": "sb('script.js', 42)\r"
}
// List breakpoints
{
"action": "stdin",
"id": "node-debug",
"data": "breakpoints\r"
}
// Clear breakpoint
{
"action": "stdin",
"id": "node-debug",
"data": "cb('script.js', 42)\r"
}
```
### Node Variable Inspection
```json
// Evaluate expression
{
"action": "stdin",
"id": "node-debug",
"data": "exec('myVariable')\r"
}
// Enter REPL mode
{
"action": "stdin",
GitHub에서 보기