strace -c 不报告退出系统调用
strace -c doesn't report exit system calls
我正在做一些作业,我需要报告 C 程序使用了哪些系统调用。
我注意到 exit
没有出现在 strace
报告中。
#include <stdlib.h>
int main() {
exit(0);
}
┌─[brendon@parrot]─[~/Desktop/Classes/OSInternals/Lab3]
└──╼ $gcc exit.c
┌─[brendon@parrot]─[~/Desktop/Classes/OSInternals/Lab3]
└──╼ $strace -c ./a.out
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
38.74 0.001056 150 7 mmap
11.12 0.000303 151 2 openat
10.20 0.000278 139 2 fstat
10.09 0.000275 137 2 close
9.21 0.000251 251 1 arch_prctl
7.45 0.000203 67 3 mprotect
6.20 0.000169 169 1 munmap
5.25 0.000143 143 1 read
1.76 0.000048 48 1 1 access
0.00 0.000000 0 1 brk
0.00 0.000000 0 1 execve
------ ----------- ----------- --------- --------- ----------------
100.00 0.002726 22 1 total
如您所见,exit
没有出现在报告中。我错了,这是一个系统调用吗?阅读 usr/include/x86_64-linux-gnu/asm/unistd_64.h
,我可以看到一个 exit
条目:
. . .
#define __NR_execve 59
#define __NR_exit 60
#define __NR_wait4 61
. . .
我在这里错过了什么?
运行 在鹦鹉 OS.
我对 post 犹豫不决,因为不清楚这是否足够主题化。如果确定不是,我可以立即删除它。
出于某种原因,它没有出现在 -c
摘要中,但它确实出现在常规 strace
输出中:
#include <stdlib.h>
int main(void)
{
exit(69);
}
$ strace ./exit
execve("./exit", ["./exit"], 0x7ffddc502ce0 /* 42 vars */) = 0
brk(NULL) = 0x563a56e63000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=113870, ...}) = 0
mmap(NULL, 113870, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f16c8537000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF[=11=][=11=][=11=][=11=][=11=][=11=][=11=][=11=][=11=]>[=11=][=11=][=11=][=11=]0A[=11=][=11=][=11=][=11=][=11=]"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f16c8535000
mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f16c8374000
mprotect(0x7f16c8396000, 1658880, PROT_NONE) = 0
mmap(0x7f16c8396000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f16c8396000
mmap(0x7f16c84de000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f16c84de000
mmap(0x7f16c852b000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f16c852b000
mmap(0x7f16c8531000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f16c8531000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7f16c8536500) = 0
mprotect(0x7f16c852b000, 16384, PROT_READ) = 0
mprotect(0x563a565ba000, 4096, PROT_READ) = 0
mprotect(0x7f16c857a000, 4096, PROT_READ) = 0
munmap(0x7f16c8537000, 113870) = 0
exit_group(69) = ?
+++ exited with 69 +++
$ strace -c ./exit
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 1 read
0.00 0.000000 0 2 close
0.00 0.000000 0 2 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 1 brk
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 arch_prctl
0.00 0.000000 0 2 openat
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 23 1 total
鉴于 -c
测量每个系统调用花费的 时间 ,我想测量 exit
没有任何意义(从来没有returns).
我正在做一些作业,我需要报告 C 程序使用了哪些系统调用。
我注意到 exit
没有出现在 strace
报告中。
#include <stdlib.h>
int main() {
exit(0);
}
┌─[brendon@parrot]─[~/Desktop/Classes/OSInternals/Lab3]
└──╼ $gcc exit.c
┌─[brendon@parrot]─[~/Desktop/Classes/OSInternals/Lab3]
└──╼ $strace -c ./a.out
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
38.74 0.001056 150 7 mmap
11.12 0.000303 151 2 openat
10.20 0.000278 139 2 fstat
10.09 0.000275 137 2 close
9.21 0.000251 251 1 arch_prctl
7.45 0.000203 67 3 mprotect
6.20 0.000169 169 1 munmap
5.25 0.000143 143 1 read
1.76 0.000048 48 1 1 access
0.00 0.000000 0 1 brk
0.00 0.000000 0 1 execve
------ ----------- ----------- --------- --------- ----------------
100.00 0.002726 22 1 total
如您所见,exit
没有出现在报告中。我错了,这是一个系统调用吗?阅读 usr/include/x86_64-linux-gnu/asm/unistd_64.h
,我可以看到一个 exit
条目:
. . .
#define __NR_execve 59
#define __NR_exit 60
#define __NR_wait4 61
. . .
我在这里错过了什么?
运行 在鹦鹉 OS.
我对 post 犹豫不决,因为不清楚这是否足够主题化。如果确定不是,我可以立即删除它。
出于某种原因,它没有出现在 -c
摘要中,但它确实出现在常规 strace
输出中:
#include <stdlib.h>
int main(void)
{
exit(69);
}
$ strace ./exit
execve("./exit", ["./exit"], 0x7ffddc502ce0 /* 42 vars */) = 0
brk(NULL) = 0x563a56e63000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=113870, ...}) = 0
mmap(NULL, 113870, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f16c8537000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "7ELF[=11=][=11=][=11=][=11=][=11=][=11=][=11=][=11=][=11=]>[=11=][=11=][=11=][=11=]0A[=11=][=11=][=11=][=11=][=11=]"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f16c8535000
mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f16c8374000
mprotect(0x7f16c8396000, 1658880, PROT_NONE) = 0
mmap(0x7f16c8396000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f16c8396000
mmap(0x7f16c84de000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f16c84de000
mmap(0x7f16c852b000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f16c852b000
mmap(0x7f16c8531000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f16c8531000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7f16c8536500) = 0
mprotect(0x7f16c852b000, 16384, PROT_READ) = 0
mprotect(0x563a565ba000, 4096, PROT_READ) = 0
mprotect(0x7f16c857a000, 4096, PROT_READ) = 0
munmap(0x7f16c8537000, 113870) = 0
exit_group(69) = ?
+++ exited with 69 +++
$ strace -c ./exit
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 1 read
0.00 0.000000 0 2 close
0.00 0.000000 0 2 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 1 brk
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 arch_prctl
0.00 0.000000 0 2 openat
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 23 1 total
鉴于 -c
测量每个系统调用花费的 时间 ,我想测量 exit
没有任何意义(从来没有returns).