Linux上的strace无法记录所有open()调用

5
我正在使用strace在Linux上捕获对open()、close()和read()的调用,目标进程是Jetty Web服务器。就我所知,strace没有记录所有的open()调用,可能还有其他调用。例如,我使用以下命令启动strace: strace -f -e trace=open,close,read -o /tmp/strace.out -p62881。然后我使用wget获取100个静态文件,所有文件都成功检索到。在一次运行中,只有56个open事件被记录下来;在另一次运行中,我得到了66个open事件。我认为使用"-f"会使strace附加到所有线程的LWPIDs(“Process 62881 attached with 25 threads - interrupt to quit”);当我尝试使用多个"-p"选项显式附加到所有线程时,我会收到单个“attach”成功消息,但会有多个"Operation not permitted messages",每个子PID一个。在我的测试之前,我重新启动了Jetty以清除其缓存。内核版本为2.6.32-504.3.3.el6.x86_64(Red Hat)。strace软件包版本为strace-4.5.19-1.19.el6.x86_64。请问我错过了什么?谢谢。
2个回答

8

在某些系统上,您需要使用openat()而不是open()。

尝试: strace -f -e trace=openat,close,read -o/tmp/strace.out -p62881


这对我来说在Ubuntu 20.04 x86-64上是真的。 - dqbydt

0
尝试使用-ff(除了-f):
-ff: If the -o filename option is in effect, each processes trace is written to filename.pid  where  pid  is
     the  numeric process id of each process.  This is incompatible with -c, since no per-process counts are
     kept.

一个好的建议。不幸的是,它没有导致捕获所有的open()事件。 - Jim Gallagher

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接