Q. How do I install Strace utility under FreeBSD operating system so that I can trace and debug my applications and report 3rd party software bugs?
A. Strace is a process tracer, i.e. a debugging tool that prints out a trace of all the system calls made and signals received by a process itself or a process and its descendants.
Strace is similar to the native BSD truss utility, but it’s output style is more convenient in most cases.
For strace to work, procfs has to be mounted. FreeBSD does not mount it by default.
These examples only work for i386 32 bit FreeBSD computer (strace is not ported to amd64 arch [64 bit]).
First update FreeBSD ports collection and install strace from /usr/ports/devel/strace:
# portsnap fetch update
# cd /usr/ports/devel/strace
# make install clean
Mount /proc file system
You need to mount /proc filesystem to use trace command under FreeBSD, enter:
# mount -t procfs proc /proc
How do I use Strace tool?
Please see our previous FAQ / tutorials about strace command:
- Debugging Tip: Trace the Process and See What It is Doing with strace
- Truss like command under Linux to monitor and diagnostic the system calls
Q. Solaris and FreeBSD both provide the truss command to monitor and debug system calls. I’m unable to find this command or package. How can I install truss under Linux?
A. truss is a debugging utility in Solaris and FreeBSD to monitor the system calls used. It is used to trace call and useful debugging many problems. Linux provides strace command. This command is installed by default. strace is a useful diagnostic, instructional, and debugging tool. System administrators, diagnosticians and troubleshooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them.
[click to continue…]