1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| [root@arch ostep-hm-code]$ perf trace -T -f ./a.out 2>&1 ? ( ): a.out/69578 ... [continued]: execve()) = 0 132465724.834 ( 0.002 ms): a.out/69578 brk() = 0x5e348fcb3000 132465724.995 ( 0.003 ms): a.out/69578 access(filename: "/etc/ld.so.preload", mode: R) = -1 ENOENT (No such file or directory) 132465725.002 ( 0.004 ms): a.out/69578 openat(dfd: CWD, filename: "/etc/ld.so.cache", flags: RDONLY|CLOEXEC) = 8 132465725.008 ( 0.002 ms): a.out/69578 fstat(fd: 8, statbuf: 0x7ffdf42c2a50) = 0 132465725.010 ( 0.006 ms): Hello world (pid:69578) a.out/69578 mmap(len: 149027, prot: READ, flags: PRIVATE, fd: 8) = 0x7d8cafc17000 132465725.017 ( 0.001 ms): a.out/69578 close(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>) = 0
\\这里其实就提示了 flags. 132465725.025 ( 0.002 ms): a.out/69578 openat(dfd: CWD, filename: "/usr/lib/libc.so.6", flags: RDONLY|CLOEXEC) = 8
132465725.029 ( 0.002 ms): a.out/69578 read(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>, buf: 0x7ffdf42c2bc8, count: 832) = 832 132465725.031 ( 0.001 ms): a.out/69578 pread64(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>, buf: 0x7ffdf42c27d0, count: 784, pos: 64) = 784 132465725.034 ( 0.001 ms): a.out/69578 fstat(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>, statbuf: 0x7ffdf42c2a50) = 0 132465725.036 ( 0.003 ms): a.out/69578 mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS) = 0x7d8cafc15000 132465725.042 ( 0.001 ms): a.out/69578 pread64(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>, buf: 0x7ffdf42c26a0, count: 784, pos: 64) = 784 132465725.045 ( 0.004 ms): a.out/69578 mmap(len: 2014064, prot: READ, flags: PRIVATE|DENYWRITE, fd: 8) = 0x7d8cafa29000 132465725.049 ( 0.008 ms): a.out/69578 mmap(addr: 0x7d8cafa4d000, len: 1490944, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 8, off: 0x24000) = 0x7d8cafa4d000 132465725.059 (Output FD Content: 8 0.005 ms): a.out/69578 mmap(addr: 0x7d8cafbb9000, len: 319488, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 8, off: 0x190000) = 0x7d8cafbb9000 132465725.064 ( 0.005 ms): a.out/69578 mmap(addr: 0x7d8cafc07000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 8, off: 0x1dd000) = 0x7d8cafc07000 read failed: Bad file descriptor 132465725.073 ( 0.003 ms): a.out/69578 mmap(addr: 0x7d8cafc0d000, len: 31600, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) = 0x7d8cafc0d000
\\ 这里是对应的close. 我追踪的那个 132465725.084 ( 0.001 ms): a.out/69578 close(fd: 8</home/ec2-user/ostep-hm-code/open_test.log>) = 0
132465725.092 ( 0.002 ms): a.out/69578 mmap(len: 12288, prot: READ|WRITE, flags: PRIVATE|ANONYMOUSOutput FD Content: 8 ) = 0x7d8cafa26000 132465725.098 ( 0.001 ms): a.out/69578 arch_prctl(option: SET_FS, arg2: 0x7d8cafa26740) = 0 132465725.100 ( 0.001 ms): a.out/69578 set_tid_address(tidptr: 0x7d8cafa26a10) = 69578 (a.out) read failed: Bad file descriptor 132465725.102 ( 0.001 ms): a.out/69578 set_robust_list(head: 0x7d8cafa26a20, len: 24) = 0 132465725.103 ( 0.001 ms): a.out/69578 rseq(rseq: 0x7d8cafa27060, rseq_len: 32, sig: 1392848979) = 0 132465725.153 ( 0.006 ms): a.out/69578 mprotect(start: 0x7d8cafc07000, len: 16384, prot: READ) = 0 132465725.162 ( 0.007 ms): a.out/69578 mprotect(start: 0x5e348ea0b000, len: 4096, prot: READ) = 0 132465725.173 ( 0.005 ms): a.out/69578 mprotect(start: 0x7d8cafc6e000, len: 8192, prot: READ) = 0 132465725.189 ( 0.001 ms): a.out/69578 prlimit64(resource: STACK, old_rlim: 0x7ffdf42c35b0) = 0 132465725.197 ( 0.008 ms): a.out/69578 munmap(addr: 0x7d8cafc17000, len: 149027) = 0 132465725.222 ( 0.001 ms): a.out/69578 getpid() = 69578 132465725.241 ( 0.002 ms): a.out/69578 fstat(fd: 1, statbuf: 0x7ffdf42c3490) = 0 132465725.247 ( 0.002 ms): a.out/69578 getrandom(ubuf: 0x7d8cafc12178, len: 8, flags: NONBLOCK) = 8 132465725.252 ( 0.001 ms): a.out/69578 brk() = 0x5e348fcb3000 132465725.255 ( 0.004 ms): a.out/69578 brk(brk: 0x5e348fcd4000) = 0x5e348fcd4000 132465725.265 ( 0.008 ms): a.out/69578 write(fd: 1, buf: 0x5e348fcb32a0, count: 24) = 24 132465725.275 ( 0.005 ms): a.out/69578 openat(dfd: CWD, filename: "./open_test.log", flags: WRONLY) = 8 132465725.286 ( 0.186 ms): a.out/69578 clone(clone_flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_tidptr: 0x7d8cafa26a10) = 69579 (a.out) 132465725.485 ( 0.001 ms): a.out/69578 read(fd: 8, buf: 0x7ffdf42c3450, count: 1023) = -1 EBADF (Bad file descriptor) 132465725.496 ( 0.003 ms): a.out/69578 write(fd: 1, buf: 0x5e348fcb32a0, count: 21) = 21 132465725.501 ( 0.002 ms): a.out/69578 dup(fildes: 2) = 9 132465725.505 ( 0.002 ms): a.out/69578 fcntl(fd: 9, cmd: GETFL) = RDWR 132465725.519 ( 0.002 ms): a.out/69578 fstat(fd: 9, statbuf: 0x7ffdf42c2720) = 0 132465725.522 ( 0.002 ms): a.out/69578 write(fd: 9, buf: 0x5e348fcb3890, count: 33) = 33 132465725.526 ( 0.002 ms): a.out/69578 close(fd: 9) = 0 132465725.538 ( ): a.out/69578 exit_group(error_code: 1) = ? ? ( ): a.out/69579 ... [continued]: clone()) = 132465725.497 ( 0.001 ms): a.out/69579 set_robust_list(head: 0x7d8cafa26a20, len: 24) = 0 132465725.526 ( 0.002 ms): a.out/69579 lseek(fd: 8, whence: SET) = 0 132465725.530 ( 0.001 ms): a.out/69579 read(fd: 8, buf: 0x7ffdf42c3450, count: 1023) = -1 EBADF (Bad file descriptor) 132465725.551 ( 0.003 ms): a.out/69579 write(fd: 1, buf: 0x5e348fcb32a0, count: 21) = 21 132465725.558 ( 0.001 ms): a.out/69579 dup(fildes: 2) = 9 132465725.561 ( 0.001 ms): a.out/69579 fcntl(fd: 9, cmd: GETFL) = RDWR 132465725.574 ( 0.002 ms): a.out/69579 fstat(fd: 9, statbuf: 0x7ffdf42c2720) = 0 132465725.577 ( 0.002 ms): a.out/69579 write(fd: 9, buf: 0x5e348fcb3890, count: 33) = 33 132465725.581 ( 0.001 ms): a.out/69579 close(fd: 9) = 0 132465725.593 ( ): a.out/69579 exit_group(error_code: 1) = ?
|