/gdb
GDB debugger skill for C/C++ programs. Use when starting a GDB session, setting breakpoints, stepping through code, inspecting variables, debugging crashes, using reverse debugging (record/replay), remote debugging with gdbserver, or loading core dumps. Activates on queries
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill gdb --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/gdb
Context preview
The summary Claude sees to decide when to auto-load this skill.
GDB debugger skill for C/C++ programs. Use when starting a GDB session, setting breakpoints, stepping through code, inspecting variables, debugging crashes, using reverse debugging (record/replay), remote debugging with gdbserver, or loading core dumps. Activates on queries
SKILL.md
gdb.SKILL.mdname: gdb
description: GDB debugger skill for C/C++ programs. Use when starting a GDB session, setting breakpoints, stepping through code, inspecting variables, debugging crashes, using reverse debugging (record/replay), remote debugging with gdbserver, or loading core dumps. Activates on queries about GDB commands, segfaults, hangs, watchpoints, conditional breakpoints, pretty-printers, Python GDB scripting, or multi-threaded debugging.
GDB
Purpose
Walk agents through GDB sessions from first launch to advanced workflows: crash diagnosis, reverse debugging, remote debugging, and multi-thread inspection.
Triggers
- "My program segfaults / crashes — how do I debug it?"
- "How do I set a breakpoint on condition X?"
- "How do I inspect memory / variables in GDB?"
- "How do I debug a remote embedded target?"
- "GDB shows `??` frames / no source"
- "How do I replay a bug deterministically?" (record/replay)
Workflow
1. Prerequisite: compile with debug info
Always compile with `-g` (GCC/Clang). Use `-Og` or `-O0` for most debuggable code.
gcc -g -Og -o prog main.c
For release builds: use `-g -O2` and keep the binary with symbols (strip separately with `objcopy`).
2. Start GDB
gdb ./prog # load binary
gdb ./prog core # load with core dump
gdb -p 12345 # attach to running process
gdb --args ./prog arg1 arg2 # pass arguments
gdb -batch -ex 'run' -ex 'bt' ./prog # non-interactive (CI)
3. Essential commands
| Command | Shortcut | Effect | |---------|----------|--------| | `run [args]` | `r` | Start the program | | `continue` | `c` | Resume after break | | `next` | `n` | Step over (source line) | | `step` | `s` | Step into | | `nexti` | `ni` | Step over (instruction) | | `stepi` | `si` | Step into (instruction) | | `finish` | | Run to end of current function | | `until N` | | Run to line N | | `return [val]` | | Force return from function | | `quit` | `q` | Exit GDB |
4. Breakpoints and watchpoints
break main # break at function
break file.c:42 # break at line
break *0x400abc # break at address
break foo if x > 10 # conditional break
tbreak foo # temporary breakpoint (fires once)
rbreak ^mylib_.* # regex breakpoint on all matching functions
watch x # watchpoint: break when x changes
watch *(int*)0x601060 # watch memory address
rwatch x # break when x is read
awatch x # break on read or write
info breakpoints # list all breakpoints
delete 3 # delete breakpoint 3
disable 3 # disable without deleting
enable 3
5. Inspect state
print x # print variable
print/x x # print in hex
print *ptr # dereference pointer
print arr[0]@10 # print 10 elements of array
display x # auto-print x on every stop
undisplay 1
info locals # all local variables
info args # function arguments
info registers # all CPU registers
info registers rip rsp rbp # specific registers
x/10wx 0x7fff0000 # examine 10 words at address
x/s 0x400abc # examine as string
x/i $rip # examine current instruction
backtrace # call stack (bt)
bt full # bt + local vars
frame 2 # switch to frame 2
up / down # move up/down the stack
6. Multi-thread debugging
info threads # list threads
thread 3 # switch to thread 3
thread apply all bt # backtrace all threads
thread apply all bt full # full bt all threads
set scheduler-locking on # pause other threads while stepping
7. Reverse debugging (record/replay)
Record requires `target record-full` or `target record-btrace` (Intel PT):
# Software record (slow but universal)
record # start recording
run
# ... trigger the bug ...
reverse-continue # go back to last break
reverse-next # step backwards
reverse-step
reverse-finish
# Intel Processor Trace (fast, hardware)
target record-btrace pt
run
# view instruction history
record instruction-history
8. Remote debugging with gdbserver
On target:
gdbserver :1234 ./prog
# Or attach:
gdbserver :1234 --attach 5678
On host:
gdb ./prog
(gdb) target remote 192.168.1.10:1234
(gdb) break main
(gdb) continue
For cross-compilation: use `aarch64-linux-gnu-gdb` on the host.
9. Common problems
| Symptom | Cause | Fix | |---------|-------|-----| | `No symbol table` | Binary not compiled with `-g` | Recompile with `-g` | | `??` frames in backtrace | Missing debug info or stack corruption | Install debuginfo package; check for stack smash | | `Cannot access memory at address` | Null dereference / freed memory | Check pointer before deref; use ASan | | `SIGABRT` in backtrace | `abort()` or assertion failure | Go up frames to find the assertion | | GDB hangs on `run` | Binary waiting for input | Redirect stdin: `run < /dev/null` | | Breakpoint in wrong place | Optimiser moved code | Compile with `-Og`; or use `nexti` |
10. GDB init file (~/.gdbinit)
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
For a command cheatsheet, see [references/cheatsheet.md](references/cheatsheet.md). For pretty-printers and Python
Read more
name: gdb description: GDB debugger skill for C/C++ programs. Use when starting a GDB session, setting breakpoints, stepping through code, inspecting variables, debugging crashes, using reverse debugging (record/replay), remote debugging with gdbserver, or loading core dumps. Activates on queries about GDB commands, segfaults, hangs, watchpoints, conditional breakpoints, pretty-printers, Python GDB scripting, or multi-threaded debugging.
GDB
Purpose
Walk agents through GDB sessions from first launch to advanced workflows: crash diagnosis, reverse debugging, remote debugging, and multi-thread inspection.
Triggers
- "My program segfaults / crashes — how do I debug it?"
- "How do I set a breakpoint on condition X?"
- "How do I inspect memory / variables in GDB?"
- "How do I debug a remote embedded target?"
- "GDB shows `??` frames / no source"
- "How do I replay a bug deterministically?" (record/replay)
Workflow
1. Prerequisite: compile with debug info
Always compile with `-g` (GCC/Clang). Use `-Og` or `-O0` for most debuggable code.
gcc -g -Og -o prog main.c
For release builds: use `-g -O2` and keep the binary with symbols (strip separately with `objcopy`).
2. Start GDB
gdb ./prog # load binary gdb ./prog core # load with core dump gdb -p 12345 # attach to running process gdb --args ./prog arg1 arg2 # pass arguments gdb -batch -ex 'run' -ex 'bt' ./prog # non-interactive (CI)
3. Essential commands
| Command | Shortcut | Effect | |---------|----------|--------| | `run [args]` | `r` | Start the program | | `continue` | `c` | Resume after break | | `next` | `n` | Step over (source line) | | `step` | `s` | Step into | | `nexti` | `ni` | Step over (instruction) | | `stepi` | `si` | Step into (instruction) | | `finish` | | Run to end of current function | | `until N` | | Run to line N | | `return [val]` | | Force return from function | | `quit` | `q` | Exit GDB |
4. Breakpoints and watchpoints
break main # break at function break file.c:42 # break at line break *0x400abc # break at address break foo if x > 10 # conditional break tbreak foo # temporary breakpoint (fires once) rbreak ^mylib_.* # regex breakpoint on all matching functions watch x # watchpoint: break when x changes watch *(int*)0x601060 # watch memory address rwatch x # break when x is read awatch x # break on read or write info breakpoints # list all breakpoints delete 3 # delete breakpoint 3 disable 3 # disable without deleting enable 3
5. Inspect state
print x # print variable print/x x # print in hex print *ptr # dereference pointer print arr[0]@10 # print 10 elements of array display x # auto-print x on every stop undisplay 1 info locals # all local variables info args # function arguments info registers # all CPU registers info registers rip rsp rbp # specific registers x/10wx 0x7fff0000 # examine 10 words at address x/s 0x400abc # examine as string x/i $rip # examine current instruction backtrace # call stack (bt) bt full # bt + local vars frame 2 # switch to frame 2 up / down # move up/down the stack
6. Multi-thread debugging
info threads # list threads thread 3 # switch to thread 3 thread apply all bt # backtrace all threads thread apply all bt full # full bt all threads set scheduler-locking on # pause other threads while stepping
7. Reverse debugging (record/replay)
Record requires `target record-full` or `target record-btrace` (Intel PT):
# Software record (slow but universal) record # start recording run # ... trigger the bug ... reverse-continue # go back to last break reverse-next # step backwards reverse-step reverse-finish # Intel Processor Trace (fast, hardware) target record-btrace pt run # view instruction history record instruction-history
8. Remote debugging with gdbserver
On target:
gdbserver :1234 ./prog # Or attach: gdbserver :1234 --attach 5678
On host:
gdb ./prog (gdb) target remote 192.168.1.10:1234 (gdb) break main (gdb) continue
For cross-compilation: use `aarch64-linux-gnu-gdb` on the host.
9. Common problems
| Symptom | Cause | Fix | |---------|-------|-----| | `No symbol table` | Binary not compiled with `-g` | Recompile with `-g` | | `??` frames in backtrace | Missing debug info or stack corruption | Install debuginfo package; check for stack smash | | `Cannot access memory at address` | Null dereference / freed memory | Check pointer before deref; use ASan | | `SIGABRT` in backtrace | `abort()` or assertion failure | Go up frames to find the assertion | | GDB hangs on `run` | Binary waiting for input | Redirect stdin: `run < /dev/null` | | Breakpoint in wrong place | Optimiser moved code | Compile with `-Og`; or use `nexti` |
10. GDB init file (~/.gdbinit)
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
For a command cheatsheet, see [references/cheatsheet.md](references/cheatsheet.md). For pretty-printers and Python
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

