Datasheet
“main” (Installation and Administration) — 2004/6/25 — 13:29 — page 720 — #746
i
i
i
i
i
i
i
i
Information about device name resolution is obtained from file /usr/
share/pci.ids. PCI IDs not listed in this file are marked “Unknown de-
vice”.
The parameter -vv produces all the information that could be queried by
the program. To view the pure numeric values, you should use the parame-
ter -n.
28.14 System Calls of a Program Run:
strace
The utility strace enables you to trace all the system calls of a process cur-
rently running. Enter the command in the normal way, adding strace at
the beginning of the line:
$ strace ls
execve("/bin/ls", ["ls"], [/* 88 vars */]) = 0
uname({sys="Linux", node="edison", ...}) = 0
brk(0) = 0x805b000
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) \
= 0x40017000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=76333, ...}) = 0
old_mmap(NULL, 76333, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40018000
[...]
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=53, ws_col=110, ws_xpixel=897, ws_ypixel=693}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=144, ...}) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
getdents64(3, /* 5 entries */, 4096) = 160
getdents64(3, /* 0 entries */, 4096) = 0
close(3) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 48), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) \
= 0x40018000
write(1, "ltrace-ls.txt myfile.txt strac"..., 41) = 41
munmap(0x40018000, 4096) = 0
exit_group(0) = ?
For example, to trace all attempts to open a particular file, use the follow-
ing:
$ strace ls myfile.txt 2>&1 | grep open
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/librt.so.1", O_RDONLY) = 3
720
28.14. System Calls of a Program Run: strace










