본문으로 건너뛰기
cccskills
무료GitHub에 공개

gdb

Use when running GDB: breakpoints, watchpoints, segfault or hang debugging, reverse debugging, remote gdbserver, core dumps, pretty-printers, Python scripting, or multi-threaded debugging.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(4)

  • SKILL.md6.2 KB
  • agents/openai.yaml245 B
  • references/cheatsheet.md5.1 KB
  • references/scripting.md1.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

GDB

Contract

FieldBound contract
TriggerA C or C++ program needs a GDB session: breakpoints, watchpoints, stepping, crash or hang diagnosis, reverse debugging, remote debugging with gdbserver, core files, or Python scripting.
AuthorityRead-only. Emits analysis and commands for the operator to run on the target; no file writes, no rollback needed. No remote mutation.
Side effectDiagnostic commands and a verdict in chat. Nothing is written.
DoneThe bug is localized to a frame, variable, or instruction, or the next diagnostic step is stated with its reason.

Inputs

  1. Binary (required): compiled with -g; -Og or -O0 gives the most debuggable code.
  2. Symptom (required): crash, hang, wrong value, or a question about program state.
  3. Core file, PID, or remote target (optional): for post-mortem, attach, or gdbserver workflows.

Procedure

  1. Build with debug info.

    gcc -g -Og -o prog main.c
    

    For release builds use -g -O2 and keep an unstripped copy; split symbols with objcopy as in core-dumps. Done when: the binary carries debug info.

  2. Start the session.

    gdb ./prog                            # load a binary
    gdb ./prog core                       # binary plus core dump
    gdb -p 12345                          # attach to a running process
    gdb --args ./prog arg1 arg2           # pass arguments
    gdb -batch -ex 'run' -ex 'bt' ./prog  # non-interactive, for CI
    

    Done when: GDB has a live inferior or a loaded core.

  3. Control execution.

    CommandShortcutEffect
    run [args]rStart the program
    continuecResume after a stop
    nextnStep over, source line
    stepsStep into, source line
    nextiniStep over, one instruction
    stepisiStep into, one instruction
    finishRun to the end of the function
    until NRun to line N
    return [val]Force a return from the function
    quitqExit

    Done when: the program is stopped at the point of interest.

  4. Set breakpoints and watchpoints.

    break main                          # function
    break file.c:42                     # line
    break *0x400abc                     # address
    break foo if x > 10                 # conditional
    tbreak foo                          # fires once
    rbreak ^mylib_.*                    # regex over function names
    catch throw                         # C++ exception
    catch syscall mmap                  # syscall
    
    watch x                             # break when x is written
    watch *(int*)0x601060               # watch an address
    rwatch x                            # break on read
    awatch x                            # break on read or write
    
    info breakpoints
    delete 3 / disable 3 / enable 3
    ignore 3 100                        # skip the next 100 hits
    commands 3 ... end                  # run commands on each hit
    

    Done when: execution stops at the condition that matters.

  5. Inspect state.

    print x / print/x x                 # value, hex
    print *ptr                          # dereference
    print arr[0]@10                     # ten elements from arr[0]
    display x                           # print on every stop
    info locals / info args
    info registers rip rsp rbp
    x/10wx 0x7fff0000                   # examine memory: count/format/unit
    x/s 0x400abc                        # as string
    x/i $rip                            # current instruction
    backtrace / bt full
    frame 2 / up / down
    

    Done when: the variable, register, or memory region in question is read.

  6. Debug threads.

    info threads
    thread 3
    thread apply all bt full
    set scheduler-locking on            # only the current thread runs while stepping
    

    Done when: each thread's state is known. For deadlock cycles and race reports, use concurrency-debugging.

  7. Reverse debug when the bug is easier to catch going backward.

    (gdb) record                        # software record, slow but universal
    (gdb) run
    (gdb) reverse-continue              # back to the last event
    (gdb) reverse-next / reverse-step / reverse-finish
    (gdb) record btrace                 # hardware branch trace (Intel PT or BTS)
    (gdb) record instruction-history    # replay recorded instructions
    

    Done when: the execution history reaches the state before the bug.

  8. Debug a remote or embedded target with gdbserver.

    gdbserver :1234 ./prog              # on the target
    gdbserver :1234 --attach 5678       # attach variant
    
    (gdb) target remote 192.168.1.10:1234
    

    For cross-compiled targets use the matching GDB, for example aarch64-linux-gnu-gdb. Done when: the host GDB controls the target process.

  9. Configure ~/.gdbinit once.

    set history save on
    set history size 1000
    set print pretty on
    set print array on
    set print array-indexes on
    set pagination off
    set confirm off
    

    Done when: the session defaults are set.

For the full command cheatsheet see references/cheatsheet.md. For pretty-printers and the Python API see references/scripting.md.

Failure and recovery

SymptomCauseFix
No symbol tableBuilt without -gRebuild with -g
?? frames in the backtraceMissing debug info or stack corruptionInstall the debug package; suspect a stack smash
Cannot access memory at addressNull or freed pointerCheck the pointer; run under ASan
SIGABRT in the backtraceabort() or a failed assertionWalk up frames to the check
GDB hangs on runProgram waits on stdinrun < /dev/null
Breakpoint lands wrongOptimizer moved the codeRebuild with -Og, or step with nexti; see debug-optimized-builds

Output

The bug localized to a frame, variable, register, or instruction, with the commands that produced the evidence; or the named blocker (no symbols, no core, unreachable target) with its fix.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

af-xdp

무료

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

agents-md

무료

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

OutlineDriven의 스킬 모두 보기

이 스킬의 문제 신고