我正在尝试理解 strace 命令。我首先在一些基本命令上使用 strace,如下所示。
[root@localhost]# strace ls
execve("/bin/ls", ["ls"], 0x7ffd79175190 /* 27 vars */) = 0
brk(NULL) = 0x8b8000
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=38861, ...}) = 0
mmap(NULL, 38861, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe267382000
close(3) = 0
openat(AT_FDCWD, "/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20j\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=155680, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe267380000
mmap(NULL, 2255216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266f41000
mprotect(0x7fe266f65000, 2093056, PROT_NONE) = 0
mmap(0x7fe267164000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x23000) = 0x7fe267164000
mmap(0x7fe267166000, 6512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe267166000
close(3) = 0
openat(AT_FDCWD, "/lib64/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19944, ...}) = 0
mmap(NULL, 2114080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266d3c000
mprotect(0x7fe266d40000, 2093056, PROT_NONE) = 0
mmap(0x7fe266f3f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fe266f3f000
close(3) = 0
openat(AT_FDCWD, "/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\36\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=37000, ...}) = 0
mmap(NULL, 2130560, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266b33000
mprotect(0x7fe266b3a000, 2097152, PROT_NONE) = 0
mmap(0x7fe266d3a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7fe266d3a000
close(3) = 0
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\21\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2066416, ...}) = 0
mmap(NULL, 3889824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe26677d000
mprotect(0x7fe26692a000, 2093056, PROT_NONE) = 0
mmap(0x7fe266b29000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ac000) = 0x7fe266b29000
mmap(0x7fe266b2f000, 15008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe266b2f000
close(3) = 0
openat(AT_FDCWD, "/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=410400, ...}) = 0
mmap(NULL, 2503144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266519000
mprotect(0x7fe26657c000, 2093056, PROT_NONE) = 0
mmap(0x7fe26677b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x62000) = 0x7fe26677b000
close(3) = 0
openat(AT_FDCWD, "/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19208, ...}) = 0
mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266315000
mprotect(0x7fe266318000, 2093056, PROT_NONE) = 0
mmap(0x7fe266517000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fe266517000
close(3) = 0
openat(AT_FDCWD, "/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\23\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19816, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe26737e000
mmap(NULL, 2113896, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe266110000
mprotect(0x7fe266114000, 2093056, PROT_NONE) = 0
mmap(0x7fe266313000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fe266313000
close(3) = 0
openat(AT_FDCWD, "/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340a\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=149272, ...}) = 0
mmap(NULL, 2217064, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe265ef2000
mprotect(0x7fe265f0b000, 2093056, PROT_NONE) = 0
mmap(0x7fe26610a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18000) = 0x7fe26610a000
mmap(0x7fe26610c000, 13416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe26610c000
close(3) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe26737b000
arch_prctl(ARCH_SET_FS, 0x7fe26737b800) = 0
mprotect(0x7fe266b29000, 16384, PROT_READ) = 0
mprotect(0x7fe26610a000, 4096, PROT_READ) = 0
mprotect(0x7fe266313000, 4096, PROT_READ) = 0
mprotect(0x7fe266517000, 4096, PROT_READ) = 0
mprotect(0x7fe26677b000, 4096, PROT_READ) = 0
mprotect(0x7fe266d3a000, 4096, PROT_READ) = 0
mprotect(0x7fe266f3f000, 4096, PROT_READ) = 0
mprotect(0x7fe267164000, 4096, PROT_READ) = 0
mprotect(0x619000, 4096, PROT_READ) = 0
mprotect(0x7fe26738c000, 4096, PROT_READ) = 0
munmap(0x7fe267382000, 38861) = 0
set_tid_address(0x7fe26737bad0) = 2481
set_robust_list(0x7fe26737bae0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7fe265ef7c50, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7fe265f041f0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7fe265ef7cf0, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7fe265f041f0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
statfs("/sys/fs/selinux", 0x7fff604065f0) = -1 ENOENT (No such file or directory)
statfs("/selinux", 0x7fff604065f0) = -1 ENOENT (No such file or directory)
brk(NULL) = 0x8b8000
brk(0x8d9000) = 0x8d9000
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 290
read(3, "", 1024) = 0
close(3) = 0
access("/etc/selinux/config", F_OK) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=113045344, ...}) = 0
mmap(NULL, 113045344, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe25f323000
close(3) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=31, ws_col=111, ws_xpixel=0, ws_ypixel=0}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=244, ...}) = 0
getdents(3, /* 14 entries */, 32768) = 464
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
write(1, "1\t\tfind_vol.log find_vol.sh.1 "..., 791 find_vol.log find_vol.sh.1 instance_list.txt letscode.sh listvol.sh.1
) = 79
write(1, "change_type.sh\tfind_vol.sh fin"..., 89change_type.sh find_vol.sh find_vol.sh.org letscode.log listvol.sh listvol.sh.org
) = 89
close(1) = 0
close(2) = 0
exit_group(0) = ?
+++ exited with 0 +++
我看到有很多 mmap、mprotect 和 brk 系统调用。有人可以用外行术语告诉我有关 brk、mmap、mprotect 系统调用的信息吗?