native-debugger-triage
Installation
SKILL.md
native-debugger-triage — drive GNU gdb on native binaries, including head-less batch mode
Quick Ref:
gdb -batch -ex run -ex bt --args ./prog ARGSreproduces a crash and prints a backtrace in one non-interactive command. For a core file:gdb -batch -ex bt PROG core.
⚠️ Critical Constraints
-
Build with debug info or the backtrace is useless. A stripped/
-O2binary gives??frames and optimized-out locals. Why: gdb reads DWARF symbols; without them frames have no names or line numbers.- WRONG:
cc prog.c -o progthen wonder whybtshows0x4011 a6 in ?? (). - CORRECT:
cc -g -O0 prog.c -o prog(add-ggdb3for macros; keep symbols un-stripped).
- WRONG:
-
Never run an interactive gdb session inside an automated/agent context — it hangs. An agent has no TTY to answer the
(gdb)prompt. Why: gdb blocks waiting for stdin; the tool call times out with no output.- WRONG:
gdb ./prog(drops to an interactive prompt and stalls). - CORRECT:
gdb -batch -ex run -ex bt --args ./prog(runs, prints, exits non-zero on crash).
- WRONG: