Hey all,
are there any plans to improve the `perf trace` utility to make it a drop-in
replacement for `strace`? `man strace` says "A traced process runs slowly.",
and if I remember correctly, Brendan Gregg said this is due to strace using
the PTrace subsystem and not the faster alternative that `perf trace` is based
upon. But, currently, `perf trace` is far from capable of replacing `strace`
for my common usecases:
$ touch test
$ strace -e file cat test
execve("/usr/bin/cat", ["cat", "file"], [/* 90 vars */]) = 0
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("file", O_RDONLY) = 3
+++ exited with 0 +++
$ perf trace -e file cat file
perf: Segmentation fault
Obtained 10 stack frames.
perf(dump_stack+0x32) [0x4d8652]
perf(sighandler_dump_stack+0x29) [0x4d86e9]
/usr/lib/libc.so.6(+0x335b0) [0x7f15bba065b0]
perf(perf_evlist__mmap_read+0x35) [0x487445]
perf(cmd_trace+0xe4b) [0x4582cb]
perf() [0x47b593]
perf(main+0x622) [0x427fe2]
/usr/lib/libc.so.6(__libc_start_main+0xf0) [0x7f15bb9f3790]
perf(_start+0x29) [0x428109]
[(nil)]
Two things to notice: perf version 4.1.0, and every trace call ends with the
above crash. But the file event group is not known to perf list, and thus
nothing gets traced. I'd expect an error message instead, i.e.:
$ strace -e asdf cat file
strace: invalid system call 'asdf'
Now, if I instead do this:
$ perf trace -e open cat file
0.070 ( 0.003 ms): cat/8663 open(filename: 0x7f04b76a4a05, flags: CLOEXEC
) = 3
0.092 ( 0.003 ms): cat/8663 open(filename: 0x7f04b78acef0, flags: CLOEXEC
) = 3
0.245 ( 0.005 ms): cat/8663 open(filename: 0x7f04b7453310, flags: CLOEXEC
) = 3
0.277 ( 0.002 ms): cat/8663 open(filename: 0x7ffdba0902f8, mode: 131072
) = 3
This is nice, esp. the time measurements. But why are the file names not
printed as strings? The pointer address does not help one at all. Also, the
O_RDONLY flag is not properly handled (compare to the strace output above).
I'd love to see someone working on this gem, as it really promises to be a
good replacement for strace.
Bye
--
Milian Wolff
[email protected]
http://milianw.de
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html