strace
システムコールの追跡をするためのコマンド
code:memo.c
// main.c
int main() {
return 0;
}
code:memo
$ gcc main.c
$ strace ./a.out
execve("./a.out", "./a.out", 0x7fffdf3ae040 /* 27 vars */) = 0 brk(NULL) = 0x562823ea2000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffed9c48c70) = -1 EINVAL (Invalid argument)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa7eb2f6000
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
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=34979, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 34979, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa7eb2ed000
close(3) = 0
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\0P\237\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0 \0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 48, 848) = 48
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0i8\235HZ\227\223\333\350s\360\352,\223\340."..., 68, 896) = 68
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=2216304, ...}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2260560, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa7eb0c5000
mmap(0x7fa7eb0ed000, 1658880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7fa7eb0ed000
mmap(0x7fa7eb282000, 360448, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bd000) = 0x7fa7eb282000
mmap(0x7fa7eb2da000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x214000) = 0x7fa7eb2da000
mmap(0x7fa7eb2e0000, 52816, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa7eb2e0000
close(3) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa7eb0c2000
arch_prctl(ARCH_SET_FS, 0x7fa7eb0c2740) = 0
set_tid_address(0x7fa7eb0c2a10) = 273
set_robust_list(0x7fa7eb0c2a20, 24) = 0
rseq(0x7fa7eb0c30e0, 0x20, 0, 0x53053053) = 0
mprotect(0x7fa7eb2da000, 16384, PROT_READ) = 0
mprotect(0x562823008000, 4096, PROT_READ) = 0
mprotect(0x7fa7eb330000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7fa7eb2ed000, 34979) = 0
exit_group(0) = ?
+++ exited with 0 +++
確認用
Q. strace
参考
調査用
/pogi-log/Wikipedia.icon
/pogi-log/Wikipedia.icon