๐ฆ FreeBSD Debugging Tools
FreeBSD provides a comprehensive suite of debugging and diagnostic tools that allow administrators and developers to inspect system behavior, troubleshoot performance issues, and analyze application problems effectively.
๐ Core Debugging Utilities
truss โ System Call Tracing
FreeBSD's equivalent of Linux's strace, used for tracing system calls made by processes.
1 2 3 4 5 6 7 8 | |
๐ก Tip: Use
-fto follow child processes and-Dto show syscall durations.
ktrace / kdump โ Kernel-Level Tracing
More detailed than truss, allows tracing multiple processes and kernel activities.
1 2 3 4 5 6 7 8 | |
gdb โ GNU Debugger
Same as on Linux, used for debugging compiled programs with debug symbols.
1 2 3 4 5 6 7 8 9 10 11 | |
๐ ๏ธ Ensure binary was compiled with
-gflag for debug info.
๐ Performance Analysis Tools
top โ Process Activity Monitor
Built-in tool showing real-time system resource usage.
1 2 3 4 5 | |
procstat โ Process Information Utility
Provides detailed statistics about running processes including memory maps, file descriptors, and threads.
1 2 3 4 5 6 7 8 | |
vmstat โ Virtual Memory Statistics
Reports virtual memory statistics, process scheduling, disk I/O, and more.
1 2 3 4 5 | |
๐๏ธ Filesystem & Storage Diagnostics
fstat โ File Status Information
Shows which files are currently open by processes.
1 2 3 4 5 6 7 8 | |
iostat โ I/O Statistics
Monitors disk I/O performance and utilization.
1 2 3 4 5 | |
geom โ GEOM Subsystem Control
Manages and queries the GEOM (Geometry) subsystem for disk devices.
1 2 3 4 5 6 7 8 | |
๐ Network Troubleshooting
sockstat โ Socket Statistics
Lists active sockets and associated processes.
1 2 3 4 5 6 7 8 | |
tcpdump โ Packet Sniffer
Captures and analyzes network traffic packets.
1 2 3 4 5 6 7 8 | |
netstat โ Network Statistics
Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
1 2 3 4 5 6 7 8 | |
๐ง Memory Debugging
valgrind โ Memory Error Detectorยน
Available via Ports or Packages, detects memory leaks and invalid accesses.
1 2 3 4 5 | |
ยน Note: Must be installed separately using
pkg install valgrind.
/proc/*/status โ Process Memory Info
Access process memory information directly from procfs (if mounted).
1 2 | |
๐ต๏ธโโ๏ธ Logs and System Messages
dmesg โ Kernel Ring Buffer
Views boot-time messages and runtime kernel diagnostics.
1 2 3 4 5 | |
syslogd + logger โ System Logging
Standard Unix logging facilities supported in FreeBSD.
1 2 3 4 5 | |
๐งฐ Advanced Diagnostic Tools
DTrace โ Dynamic Tracing Frameworkยฒ
Powerful instrumentation framework for examining live systems.
Example probe:
1 2 3 4 | |
Run with:
1 | |
ยฒ Available on most architectures except some ARM variants.
kgdb โ Kernel Debuggerยณ
Used for debugging the running kernel or crash dumps.
1 2 | |
ยณ Requires kernel debugging enabled and proper setup.
๐งพ Summary Table
| Tool | Purpose |
|---|---|
truss |
System call tracing |
ktrace |
Kernel-level process tracing |
gdb |
Source-level debugging |
procstat |
Detailed process information |
fstat |
Open file descriptor tracking |
sockstat |
Socket and connection monitoring |
tcpdump |
Network packet capture |
valgrind |
Memory error detection |
dmesg |
Kernel diagnostic messages |
DTrace |
Dynamic system-wide tracing |
๐ง Best Practices
โ
Use truss for quick syscall troubleshooting
โ
Leverage procstat for deep process introspection
โ
Enable DTrace for production-safe observability
โ
Regularly review dmesg for hardware or driver issues
โ
Combine tools for layered diagnostics
โ
Store logs centrally for audit trails
๐งพ See Also
- FreeBSD BSD Userland Differences
- FreeBSD RC and Jails
- FreeBSD Shell Basics
- Reference: BSD vs GNU Tools
- Patterns: Logging and Telemetry