AI-powered debugging skill for C/C++ projects with GDB/LLDB support.
- 🔍 Smart Breakpoint Management - Set, remove, enable/disable breakpoints with conditional support
- 📊 Variable Inspection - View local and global variables, evaluate expressions
- 🎯 Step Execution Control - Run, step, next, finish, continue, pause, terminate
- 🔄 Multi-Session Support - Manage multiple debugging sessions simultaneously
- 🤖 AI-Assisted Debugging - JSON-based command interface for AI integration
- 🌍 Cross-Platform - Works with GDB (Linux/macOS/Windows MinGW) and LLDB (macOS/Windows)
- Python 3.8 or higher
- GDB 9.0+ or LLDB 12.0+
# Install Python dependencies
pip install pygdbmi
# Optional: for LLDB support
# LLDB Python module comes with Xcode (macOS) or LLVM installation# Linux (Ubuntu/Debian)
sudo apt-get install gdb
# macOS
brew install gdb
# Windows (MinGW)
pacman -S mingw-w64-x86_64-gdb# macOS (comes with Xcode)
xcode-select --install
# Linux
sudo apt-get install lldb
# Windows
# Download and install LLVM from https://releases.llvm.org/from src.debugger import AIDebugger
import json
# Initialize debugger
debugger = AIDebugger()
# Create a debug session
result = debugger.execute_command(json.dumps({
'action': 'create_session',
'params': {
'program_path': './my_program'
}
}))
response = json.loads(result)
session_id = response['result']['session_id']
# Set a breakpoint
debugger.execute_command(json.dumps({
'action': 'set_breakpoint',
'params': {
'session_id': session_id,
'location': 'main.cpp:42'
}
}))
# Run the program
debugger.execute_command(json.dumps({
'action': 'run',
'params': {
'session_id': session_id
}
}))
# Get variables
result = debugger.execute_command(json.dumps({
'action': 'get_variables',
'params': {
'session_id': session_id,
'scope': 'local'
}
}))
# Close session
debugger.execute_command(json.dumps({
'action': 'close_session',
'params': {
'session_id': session_id
}
}))| Action | Description | Required Parameters |
|---|---|---|
create_session |
Create a new debugging session | program_path |
close_session |
Close a debugging session | session_id |
list_sessions |
List all active sessions | - |
| Action | Description | Required Parameters |
|---|---|---|
set_breakpoint |
Set a breakpoint | session_id, location |
remove_breakpoint |
Remove a breakpoint | session_id, breakpoint_id |
enable_breakpoint |
Enable a breakpoint | session_id, breakpoint_id |
disable_breakpoint |
Disable a breakpoint | session_id, breakpoint_id |
list_breakpoints |
List all breakpoints | session_id |
| Action | Description | Required Parameters |
|---|---|---|
run |
Start/restart program | session_id |
continue |
Continue execution | session_id |
step |
Step into function | session_id |
next |
Step over function | session_id |
finish |
Execute until return | session_id |
pause |
Pause execution | session_id |
terminate |
Terminate program | session_id |
| Action | Description | Required Parameters |
|---|---|---|
get_variables |
Get variable values | session_id |
get_backtrace |
Get call stack | session_id |
evaluate_expression |
Evaluate expression | session_id, expression |
get_registers |
Get CPU registers | session_id |
read_memory |
Read memory | session_id, address |
get_current_location |
Get current location | session_id |
get_context |
Get full context | session_id |
Breakpoints can be set using various location formats:
# File and line number
'location': 'main.cpp:42'
# Function name
'location': 'main'
# Class method
'location': 'MyClass::myMethod'
# File and function
'location': 'main.cpp:main'
# Memory address
'location': '*0x4005a0'debugger.execute_command(json.dumps({
'action': 'set_breakpoint',
'params': {
'session_id': session_id,
'location': 'main.cpp:42',
'condition': 'x > 10 && y < 100'
}
}))All commands return JSON responses:
Success:
{
"success": true,
"result": {
// Action-specific result
}
}Error:
{
"success": false,
"error": "Error description"
}See the examples/ directory for complete examples:
- simple_breakpoint.py - Basic debugging workflow
- multi_session.py - Managing multiple sessions
# Run unit tests
pytest tests/
# Run integration tests (requires GDB/LLDB)
pytest tests/ --run-integrationcpp-debugger-skill/
├── SKILL.md # Trae skill definition
├── README.md # This file
├── requirements.txt # Python dependencies
├── setup.py # Setup script
├── src/
│ ├── __init__.py
│ ├── debugger.py # Main AI interface
│ ├── session.py # Session management
│ ├── context.py # Debug context
│ └── adapters/
│ ├── __init__.py
│ ├── base.py # Abstract base class
│ ├── gdb_adapter.py # GDB implementation
│ ├── lldb_adapter.py # LLDB implementation
│ └── factory.py # Debugger factory
├── tests/
│ ├── __init__.py
│ └── test_debugger.py # Unit tests
├── examples/
│ ├── simple_breakpoint.py
│ └── multi_session.py
└── docs/
├── getting-started.md
├── api-reference.md
└── examples.md
# Linux
sudo apt-get install gdb
# macOS
brew install gdb
# Windows (MinGW)
pacman -S mingw-w64-x86_64-gdb# Temporary fix
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
# Permanent fix (add to /etc/sysctl.d/10-ptrace.conf)
kernel.yama.ptrace_scope = 0# macOS - Install Xcode command line tools
xcode-select --install
# Linux - Install LLDB development package
sudo apt-get install python3-lldb-12
# Windows - Install LLVM with Python bindings
# Download from https://releases.llvm.org/Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
Your Name (your.email@example.com)