debugging
debugging. Use when you need help with debugging.
SKILL.mdskills/debugging/SKILL.md
GitHubDebugging Workflow
Use this file for runtime debugging, attach/load diagnosis, missing-event investigation, and host-level eBPF troubleshooting.
When to Use This File
- program loads but does nothing
- attach fails or succeeds inconsistently
- events are missing, out of order, or unexpectedly empty
- maps are not updating
- the host seems not to support the expected feature
First Pass
Start with the smallest observable checks:
mount -t bpf bpffs /sys/fs/bpf
bpftool prog list
bpftool map list
bpftool feature
bpftool prog tracelog
cat /sys/kernel/debug/tracing/trace_pipe
Guidance:
- use
bpftool prog tracelogfirst when available instead of assuming the user will watchtrace_pipe - if the host seems feature-poor, verify with
bpftool featurebefore redesigning the program - if LSM is involved, inspect
/sys/kernel/security/lsm - if hook behavior is missing, verify both kernel support and runtime enablement
Load and Attach Diagnosis
Typical sequence:
mount -t bpf bpffs /sys/fs/bpf
bpftool prog load prog.bpf.o /sys/fs/bpf/test
export LIBBPF_LOG_LEVEL=debug
bpftool prog show
bpftool map dump name <map_name>
Use this workflow:
- Confirm the object actually loads.
- Confirm the program is attached where you think it is.
- Confirm maps exist and contain expected state.
- Confirm events or debug output are observable.
- Only then change logic.
If Attach Succeeds But Behavior Is Missing
Check these before rewriting the program:
- wrong hook or wrong attach target
- feature unsupported on that kernel
- feature compiled in but disabled at boot/runtime
- filter too narrow or global variable misconfigured
- wrong map chosen for the access pattern
- user-space reader not polling or parsing correctly
Good confirmations:
bpftool prog show id <ID>
bpftool map dump name <map_name>
bpftrace -l 'tracepoint:*'
bpftrace -l 'kprobe:<pattern>'
Runtime Signal Sources
Use the least noisy source that answers the question:
bpftool prog tracelogfor printk-style outputtrace_pipewhentracelogis unavailable or insufficientbpftool map dumpfor live state inspectionbpftool prog dump xlatedwhen instruction-level review mattersbpftraceone-liners to cross-check whether expected events are firing at all
Noise Reduction
- clear or ignore stale tracing noise before a repro
- make the repro path as small as possible
- reduce filters and globals to permissive values before suspecting verifier or kernel issues
- prefer one hook and one event path while debugging
Common Runtime Failure Patterns
| Symptom | Likely Cause | First Check |
|---|---|---|
| program loads, no events | wrong hook, wrong target, over-filtering | attachment details and globals |
| maps stay empty | hook not firing or key path never reached | add temporary prints or dump xlated code |
| lost or missing events | undersized ring/perf buffers | increase buffer size and inspect reader loop |
| feature appears unavailable | kernel/config mismatch | bpftool feature, config, boot state |
| attach works on one host only | kernel/version/runtime differences | compare bpftool feature and attach mode |
Useful External Tools
bpftopwhen overhead and loaded-program visibility matter- upstream
bpftoolreleases when distro packages lag too far behind