Debug Like a Pro: Strace, Tcpdump, and eBPF
Low-level Linux debugging tools. Understanding syscalls with strace, analyzing packets with tcpdump, and next-gen observability with eBPF.
The Lost Art of Debugging
When logs assume success but the app fails, you need to go deeper.
1. Strace: System Call Tracer
Your app is just a process talking to the kernel. strace shows that conversation.
Problem: PHP script hangs connecting to DB.
Debug:
strace -p 1234 -e trace=connect,poll,select
Result: Returns connect(3, {sa_family=AF_INET, sin_port=htons(3306)...}) = -1 ETIMEDOUT. It's a firewall issue.
2. Tcpdump: Packet Sniffer
"It's a network issue." Prove it.
tcpdump -i eth0 port 80 -A
You can see the raw HTTP headers. If you see a SYN but no SYN-ACK, the destination is dropping you.
3. eBPF: Safe Kernel Scripting
Tools like bpftrace allow you to inspect kernel functions without overhead.
# Count syscalls by process
bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }'
Conclusion: These tools give you X-Ray vision. Use them when the application acts like a black box.