본문으로 건너뛰기
Skillpedia
테스트48k · #4703

gdb-cli

하는 일

C/C++로 작성된 컴퓨터 프로그램의 오류를 찾고 고치는 데 도움을 줍니다. 프로그램이 충돌하거나 멈췄을 때의 상태를 분석하고, 소스 코드와 비교해 무슨 일이 일어났는지 이해하도록 돕습니다.

사용하는 경우

  • ✓프로그램이 충돌해서 '크래시 덤프' 파일이 있을 때.
  • ✓프로그램이 실행 중인데 응답하지 않을 때(멈춤).
  • ✓프로그램이 왜 충돌했는지 또는 메모리를 너무 많이 쓰는지 이해하고 싶을 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gdb-cli/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gdb-cli/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“'/tmp/core.1234'에 있는 제 프로그램 'my_app'의 크래시 덤프를 분석해서 오류가 어디에 있는지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

GDB라는 도구를 사용해 실패가 발생한 시점의 프로그램 상태를 살펴봅니다. 그다음 찾은 정보를 프로그램의 소스 코드와 비교해 문제를 명확하게 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

# 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:

gdb-cli load --binary <binary_path> --core <core_path> [--gdb-path <gdb_path>]

For live process debugging:

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

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

# 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

# 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:

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:

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:

gdb-cli memory -s $SESSION "&variable" --size 128
gdb-cli registers -s $SESSION

Examples

Example 1: Core Dump Analysis

# 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

# 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

…

자주 묻는 질문

설치해야 할 것이 있나요?

네. GDB(디버깅 도구)와, GDB용 추가 기능인 gdb-cli 도구가 설치되어 있어야 합니다.

모든 프로그래밍 언어에서 작동하나요?

아닙니다. 이 도구는 C와 C++로 작성된 프로그램에만 해당합니다.

「크래시 덤프」란 무엇인가요?

프로그램이 충돌할 때 시스템이 자동으로 만드는 파일로, 그 순간의 프로그램 상태에 대한 정보가 담겨 있습니다.

상세 정보

작성자의 원본 설명

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

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#4703
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬