ClaudeCursorGeminiCodexDevelopment

gdb-cli

GDB debugging assistant for AI agents - analyze core dumps, debug live processes, investigate crashes and deadlocks with source code correlation

31,392 stars
Complexity: medium

About this skill

The GDB Debugging Assistant is a specialized AI agent skill designed to provide intelligent debugging support for C/C++ programs. It combines deep source code analysis with runtime state inspection using the gdb-cli tool. This skill empowers AI agents to efficiently analyze core dumps, debug running processes, and pinpoint the root cause of crashes, deadlocks, and memory-related issues by correlating GDB output with the provided source code context.

Best use case

Debugging C/C++ applications; post-mortem analysis of software failures; real-time investigation of program behavior; root cause analysis of critical software bugs.

GDB debugging assistant for AI agents - analyze core dumps, debug live processes, investigate crashes and deadlocks with source code correlation

Detailed insights into program crashes or behavior; identification of the root cause of errors (e.g., segfaults, deadlocks); stack traces, variable values, and register states at critical points; suggestions for potential fixes or areas to investigate in the source code.

Practical example

Example input

```json
{
  "skill_name": "gdb-cli",
  "command": "analyze_coredump",
  "core_file": "/var/crash/my_app.core",
  "executable": "/usr/local/bin/my_app",
  "source_path": "/home/dev/my_app_source"
}
```

Example output

```json
{
  "status": "success",
  "analysis_summary": "Core dump indicates a segmentation fault at address 0xdeadbeef within `my_critical_function`.",
  "root_cause_hypothesis": "Null pointer dereference in `my_critical_function` on line 123 of `src/module_a.cpp` when accessing `data_ptr`.",
  "stack_trace": [
    {"frame": 0, "function": "my_critical_function", "file": "src/module_a.cpp", "line": 123, "address": "0x0000deadbeef"},
    {"frame": 1, "function": "process_data", "file": "src/main.cpp", "line": 45, "address": "0x0000beefdead"}
  ],
  "variables_at_fault_line": {
    "data_ptr": "0x0 (NULL)",
    "input_size": "1024"
  },
  "registers_excerpt": {
    "rip": "0x0000deadbeef",
    "rsp": "0x00007fffffffe000"
  },
  "suggestions": [
    "Review `my_critical_function` at `src/module_a.cpp:123` for proper pointer initialization and validation of `data_ptr`.",
    "Add null checks before dereferencing `data_ptr` to prevent segmentation faults."
  ],
  "raw_gdb_output_excerpt": "(gdb) bt\n#0  0x0000deadbeef in my_critical_function (data_ptr=0x0) at src/module_a.cpp:123\n#1  0x0000beefdead in process_data () at src/main.cpp:45\n...\n(gdb) p data_ptr\n$1 = (void *) 0x0\n"
}
```

When to use this skill

  • Analyze core dumps or crash dumps to understand program state at the point of failure.
  • Debug running processes by attaching GDB to investigate live issues without restarting the application.
  • Investigate complex crashes, deadlocks, segmentation faults, or memory leaks in C/C++ applications.
  • Correlate runtime errors with specific lines in the source code for faster root cause identification.

When not to use this skill

  • For debugging applications written in languages other than C/C++ (e.g., Python, Java, JavaScript), where GDB is not the primary or most effective debugger.
  • When a simpler, high-level debugger or logging tool is sufficient to identify the problem.
  • In environments where GDB is not installed or accessible to the AI agent.
  • For superficial syntax errors or compilation issues that do not require runtime analysis.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/gdb-cli/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/gdb-cli/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/gdb-cli/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How gdb-cli Compares

Feature / Agentgdb-cliStandard Approach
Platform SupportClaude, Cursor, Gemini, CodexLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

GDB debugging assistant for AI agents - analyze core dumps, debug live processes, investigate crashes and deadlocks with source code correlation

Which AI agents support this skill?

This skill is designed for Claude, Cursor, Gemini, Codex.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# GDB Debugging Assistant

## Overview

A GDB debugging skill designed for AI agents. Combines **source code analysis** with **runtime state inspection** using gdb-cli to provide intelligent debugging assistance for C/C++ programs.

## When to Use This Skill

- Analyze core dumps or crash dumps
- Debug running processes with GDB attach
- Investigate crashes, deadlocks, or memory issues
- Get intelligent debugging assistance with source code context
- Debug multi-threaded applications

## Do Not Use This Skill When

- The task is unrelated to C/C++ debugging
- The user needs general-purpose assistance without debugging
- No GDB is available (GDB 9.0+ with Python support required)

## Prerequisites

```bash
# Install gdb-cli
pip install gdb-cli

# Or from GitHub
pip install git+https://github.com/Cerdore/gdb-cli.git

# Verify GDB has Python support
gdb -nx -q -batch -ex "python print('OK')"
```

**Requirements:**
- Python 3.6.8+
- GDB 9.0+ with Python support enabled
- Linux OS

## How It Works

### Step 1: Initialize Debug Session

**For core dump analysis:**
```bash
gdb-cli load --binary <binary_path> --core <core_path> [--gdb-path <gdb_path>]
```

**For live process debugging:**
```bash
gdb-cli attach --pid <pid> [--binary <binary_path>]
```

**Output:** A session_id like `"session_id": "a1b2c3"`. Store this for subsequent commands.

### Step 2: Gather Initial Information

```bash
SESSION="<session_id>"

# List all threads
gdb-cli threads -s $SESSION

# Get backtrace (with local variables)
gdb-cli bt -s $SESSION --full

# Get registers
gdb-cli registers -s $SESSION
```

### Step 3: Correlate Source Code (CRITICAL)

For each frame in the backtrace:
1. **Extract frame info**: `{file}:{line} in {function}`
2. **Read source context**: Get ±20 lines around the crash point
3. **Get local variables**: `gdb-cli locals-cmd -s $SESSION --frame <N>`
4. **Analyze**: Correlate code logic with variable values

**Example correlation:**
```
Frame #0: process_data() at src/worker.c:87
Source code shows:
  85: Node* node = get_node(id);
  86: if (node == NULL) return;
  87: node->data = value;  <- Crash here

Variables show:
  node = 0x0 (NULL)

Analysis: The NULL check on line 86 didn't catch the issue.
```

### Step 4: Deep Investigation

```bash
# Examine variables
gdb-cli eval-cmd -s $SESSION "variable_name"
gdb-cli eval-cmd -s $SESSION "ptr->field"
gdb-cli ptype -s $SESSION "struct_name"

# Memory inspection
gdb-cli memory -s $SESSION "0x7fffffffe000" --size 64

# Disassembly
gdb-cli disasm -s $SESSION --count 20

# Check all threads (for deadlock analysis)
gdb-cli thread-apply -s $SESSION bt --all

# View shared libraries
gdb-cli sharedlibs -s $SESSION
```

### Step 5: Session Management

```bash
# List active sessions
gdb-cli sessions

# Check session status
gdb-cli status -s $SESSION

# Stop session (cleanup)
gdb-cli stop -s $SESSION
```

## Common Debugging Patterns

### Pattern: Null Pointer Dereference

**Indicators:**
- Crash on memory access instruction
- Pointer variable is 0x0

**Investigation:**
```bash
gdb-cli registers -s $SESSION  # Check RIP
gdb-cli eval-cmd -s $SESSION "ptr"  # Check pointer value
```

### Pattern: Deadlock

**Indicators:**
- Multiple threads stuck in lock functions
- `pthread_mutex_lock` in backtrace

**Investigation:**
```bash
gdb-cli thread-apply -s $SESSION bt --all
# Look for circular wait patterns
```

### Pattern: Memory Corruption

**Indicators:**
- Crash in malloc/free
- Garbage values in variables

**Investigation:**
```bash
gdb-cli memory -s $SESSION "&variable" --size 128
gdb-cli registers -s $SESSION
```

## Examples

### Example 1: Core Dump Analysis

```bash
# Load core dump
gdb-cli load --binary ./myapp --core /tmp/core.1234

# Get crash location
gdb-cli bt -s a1b2c3 --full

# Examine crash frame
gdb-cli locals-cmd -s a1b2c3 --frame 0
```

### Example 2: Live Process Debugging

```bash
# Attach to stuck server
gdb-cli attach --pid 12345

# Check all threads
gdb-cli threads -s b2c3d4

# Get all backtraces
gdb-cli thread-apply -s b2c3d4 bt --all
```

## Best Practices

- Always read source code before drawing conclusions from variable values
- Use `--range` for pagination on large thread counts or deep backtraces
- Use `ptype` to understand complex data structures before examining values
- Check all threads for multi-threaded issues
- Cross-reference types with source code definitions

## Security & Safety Notes

- This skill requires GDB access to processes and core dumps
- Attaching to processes may require appropriate permissions (sudo, ptrace_scope)
- Core dumps may contain sensitive data - handle with care
- Only debug processes you have authorization to analyze

## Related Skills

- `@systematic-debugging` - General debugging methodology
- `@test-driven-development` - Write tests before implementation

## Links

- **Repository**: https://github.com/Cerdore/gdb-cli
- **PyPI**: https://pypi.org/project/gdb-cli/
- **Documentation**: https://github.com/Cerdore/gdb-cli#readme

Related Skills

frontend-developer

31392
from sickn33/antigravity-awesome-skills

Build React components, implement responsive layouts, and handle client-side state management. Masters React 19, Next.js 15, and modern frontend architecture.

DevelopmentClaude

codebase-audit-pre-push

31392
from sickn33/antigravity-awesome-skills

Deep audit before GitHub push: removes junk files, dead code, security holes, and optimization issues. Checks every file line-by-line for production readiness.

DevelopmentClaude

bug-hunter

31392
from sickn33/antigravity-awesome-skills

Systematically finds and fixes bugs using proven debugging techniques. Traces from symptoms to root cause, implements fixes, and prevents regression.

DevelopmentClaude

workspace-surface-audit

144923
from affaan-m/everything-claude-code

Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.

DevelopmentClaude

safety-guard

144923
from affaan-m/everything-claude-code

Use this skill to prevent destructive operations when working on production systems or running agents autonomously.

DevelopmentClaude

repo-scan

144923
from affaan-m/everything-claude-code

Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.

DevelopmentClaude

project-flow-ops

144923
from affaan-m/everything-claude-code

Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.

DevelopmentClaude

manim-video

144923
from affaan-m/everything-claude-code

Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.

DevelopmentClaude

laravel-plugin-discovery

144923
from affaan-m/everything-claude-code

Discover and evaluate Laravel packages via LaraPlugins.io MCP. Use when the user wants to find plugins, check package health, or assess Laravel/PHP compatibility.

DevelopmentClaude

design-system

144923
from affaan-m/everything-claude-code

Use this skill to generate or audit design systems, check visual consistency, and review PRs that touch styling.

DevelopmentClaude

click-path-audit

144923
from affaan-m/everything-claude-code

Trace every user-facing button/touchpoint through its full state change sequence to find bugs where functions individually work but cancel each other out, produce wrong final state, or leave the UI in an inconsistent state. Use when: systematic debugging found no bugs but users report broken buttons, or after any major refactor touching shared state stores.

DevelopmentClaude

ck

144923
from affaan-m/everything-claude-code

Persistent per-project memory for Claude Code. Auto-loads project context on session start, tracks sessions with git activity, and writes to native memory. Commands run deterministic Node.js scripts — behavior is consistent across model versions.

DevelopmentClaude