Skilllibrary terminal-debugging
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/10-cli-systems-and-ops/terminal-debugging" ~/.claude/skills/merceralex397-collab-skilllibrary-terminal-debugging && rm -rf "$T"
manifest:
10-cli-systems-and-ops/terminal-debugging/SKILL.mdsource content
Purpose
Debug running processes from the terminal using strace, ltrace, gdb, and /proc filesystem inspection.
When to use this skill
- tracing syscalls to find why a process hangs or crashes
- inspecting file descriptor leaks via
/proc/<pid>/fd - attaching
to a running process for breakpoint debugginggdb - profiling dynamic library calls with
ltrace
Do not use this skill when
- debugging application logic with IDE debuggers or print statements
- capturing network traffic — use
ortcpdumpwireshark - the issue is a shell scripting bug — prefer
bash
Procedure
- Find process —
orpgrep -a <name>
to get PID.ps aux | grep <name> - Trace syscalls —
.strace -p <pid> -e trace=open,read,write -f -t - Trace from start —
with child processes.strace -f -o /tmp/trace.log ./myapp - Check open files —
;ls -la /proc/<pid>/fd
for details.lsof -p <pid> - Inspect memory —
;cat /proc/<pid>/maps
.grep VmRSS /proc/<pid>/status - Attach GDB —
, thengdb -p <pid>
,bt
,info threads
.continue - Library calls —
to track allocations.ltrace -p <pid> -e malloc+free - Signals —
for pending/blocked/ignored.grep Sig /proc/<pid>/status
Common patterns
# Why is it stuck? strace -p $(pgrep myapp) -e trace=network,file -f -t 2>&1 | head -100 # FD leak detection ls /proc/$(pgrep myapp)/fd | wc -l # CPU profile perf record -g -p $(pgrep myapp) -- sleep 30 perf report --stdio | head -50 # Core dump coredumpctl list coredumpctl gdb <pid>
Decision rules
to follow child processes — many issues are in forked workers.strace -f- Filter with
to reduce noise.-e trace=file,network,process,signal
for syscall summary statistics instead of full trace.strace -c
before running to enable core dumps.ulimit -c unlimited
for non-interactive backtrace in scripts.gdb -batch -ex bt -p <pid>
References
- https://man7.org/linux/man-pages/man1/strace.1.html
- https://sourceware.org/gdb/current/onlinedocs/gdb.html
Related skills
— system-level diagnosticslinux-ubuntu-ops
— scripting debug workflowsbash
— debugging on remote serversssh-tmux-remote-workflow