github地址:https://gitcode.net/mirrors/strace/strace?utm_source=aisoftcloud
./configure
make -j
make install
configure过程中如果出现configure: error: Cannot enable m32 personality support
错误,使用以下命令:
./configure --enable-mpers=no
测试代码:
#include <iostream>
#include <unistd.h>
int32_t main(int32_t argc, char** argv) {
::sleep(1);
return 0;
}
编译:
g++ -g -o main main.cc
运行strace:
sudo strace ./main
输出:
execve("./strace", ["./strace"], 0x7ffd7a487af0 /* 17 vars */) = 0
brk(NULL) = 0x55c694cbd000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
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=181974, ...}) = 0
mmap(NULL, 181974, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2e4d825000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libstdc++.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\220\304\10\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1594864, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e4d823000
mmap(NULL, 3702848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2e4d2a0000
mprotect(0x7f2e4d419000, 2097152, PROT_NONE) = 0
mmap(0x7f2e4d619000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f2e4d619000
mmap(0x7f2e4d625000, 12352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2e4d625000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/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\240\35\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030928, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2e4ceaf000
mprotect(0x7f2e4d096000, 2097152, PROT_NONE) = 0
mmap(0x7f2e4d296000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f2e4d296000
mmap(0x7f2e4d29c000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2e4d29c000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.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\200\272\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1700792, ...}) = 0
mmap(NULL, 3789144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2e4cb11000
mprotect(0x7f2e4ccae000, 2093056, PROT_NONE) = 0
mmap(0x7f2e4cead000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19c000) = 0x7f2e4cead000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.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\300*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2e4c8f9000
mprotect(0x7f2e4c910000, 2093056, PROT_NONE) = 0
mmap(0x7f2e4cb0f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f2e4cb0f000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e4d821000
arch_prctl(ARCH_SET_FS, 0x7f2e4d821d00) = 0
mprotect(0x7f2e4d296000, 16384, PROT_READ) = 0
mprotect(0x7f2e4cb0f000, 4096, PROT_READ) = 0
mprotect(0x7f2e4cead000, 4096, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e4d81f000
mprotect(0x7f2e4d619000, 40960, PROT_READ) = 0
mprotect(0x55c6933d6000, 4096, PROT_READ) = 0
mprotect(0x7f2e4d852000, 4096, PROT_READ) = 0
munmap(0x7f2e4d825000, 181974) = 0
brk(NULL) = 0x55c694cbd000
brk(0x55c694cde000) = 0x55c694cde000
nanosleep({tv_sec=1, tv_nsec=0}, 0x7ffcf81b9090) = 0
exit_group(0) = ?
+++ exited with 0 +++
strace: option requires an argument -- 'p'
Try 'strace -h' for more information.
strace.sh: 11: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]