TRACING SYSTEM CALLS
The strace command allows us to trace the system calls made by a program. This is
useful for debugging, or simply to find out what a program is doing. In its simplest
form, we use strace as follows:
$ strace command arg...
This runs command, with the given command-line arguments, producing a trace of
the system calls it makes. By default, strace writes its output to stderr, but we can
change this using the –o filename option.
Examples of the type of output produced by strace include the following (taken
from the output of the command strace date):
execve("/bin/date", ["date"], [/* 114 vars */]) = 0
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=111059, ...}) = 0
mmap2(NULL, 111059, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f38000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0755, st_size=1491141, ...}) = 0
close(3) = 0
write(1, "Mon Jan 17 12:14:24 CET 2011\n", 29) = 29
exit_group(0) =?