我看到很多链接显示 strace 在其输出中将 gettimeofday 列为系统调用,但就我而言,我觉得它正在分解为其他调用。我错过了什么吗?
我在 linux 4.4 内核和 ubuntu 16.04 上的 VM 中运行
root@ak-dev-1:~# cat trial.c && gcc trial.c && strace -c ./a.out
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
int main() {
struct timeval tv;
gettimeofday(&tv, NULL);
printf("%lu.%lu\n", tv.tv_sec, tv.tv_usec);
}
1584465316.623916
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 1 read
0.00 0.000000 0 1 write
0.00 0.000000 0 2 open
0.00 0.000000 0 2 close
0.00 0.000000 0 3 fstat
0.00 0.000000 0 7 mmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 1 munmap
0.00 0.000000 0 3 brk
0.00 0.000000 0 3 3 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 arch_prctl
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 29 3 total
root@ak-dev-1:~# uname -a
Linux ak-dev-1 4.4.0-137-generic #163-Ubuntu SMP Mon Sep 24 13:14:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux