$ strace ./syscall2
execve("./syscall2", ["./syscall2"], [/* 43 vars */]) = 0
getpid() = 2467
getuid() = 1000
getgid() = 1000
_exit(0) = ?
参数 | 描述 |
-c | 统计每个系统调用的时间、调用和错误 |
-d | 显示 strace 的一些调试输出 |
-e | 指定输出的过滤表达式 |
-f | 在创建子进程的时候跟踪它们 |
-ff | 如果写入到输出文件,则把每个子进程写入到单独的文件中 |
-i | 显示执行系统调用时的指令指针 |
-o | 把输出写入到指定文件 |
-p | 附加到由PID指定的现有进程 |
-q | 抑制关于附加和分离的消息 |
-r | 对每个系统调用显示一个相对的时间戳 |
-t | 把时间添加到每一行 |
-tt | 把时间添加到每一行,包括微秒 |
-ttt | 添加epoch形式的时间(从1970年1月1日开始的秒数),包括微秒 |
-T | 显示每个系统调用花费的时间 |
-v | 显示系统调用信息的不经省略版本(详细的) |
-x | 以十六进制格式显示所有非ASCII字符 |
-xx | 以十六进制格式显示所有字符串 |
$ strace -e trace=getpid,getgid ./syscall2
getpid() = 2653
getgid() = 1000
$ strace -o outfile id
uid=1000(beyes) gid=1000(beyes) 组=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(beyes)
$ strace -c id
uid=1000(beyes) gid=1000(beyes) 组=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(beyes)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
-nan 0.000000 0 17 read
-nan 0.000000 0 1 write
-nan 0.000000 0 44 3 open
-nan 0.000000 0 47 close
-nan 0.000000 0 1 execve
-nan 0.000000 0 9 9 access
-nan 0.000000 0 3 brk
-nan 0.000000 0 18 munmap
-nan 0.000000 0 10 mprotect
-nan 0.000000 0 20 _llseek
-nan 0.000000 0 51 mmap2
-nan 0.000000 0 40 fstat64
-nan 0.000000 0 1 getuid32
-nan 0.000000 0 1 getgid32
-nan 0.000000 0 1 geteuid32
-nan 0.000000 0 1 getegid32
-nan 0.000000 0 2 getgroups32
-nan 0.000000 0 1 fcntl64
-nan 0.000000 0 1 set_thread_area
-nan 0.000000 0 1 statfs64
-nan 0.000000 0 4 socket
-nan 0.000000 0 4 4 connect
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 278 16 total
$ strace -e trace=open,connect id
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/libselinux.so.1", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libdl.so.2", O_RDONLY) = 3
open("/proc/filesystems", O_RDONLY|O_LARGEFILE) = 3
open("/proc/filesystems", O_RDONLY|O_LARGEFILE) = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_IDENTIFICATION", O_RDONLY) = 3
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_MEASUREMENT", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_TELEPHONE", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_ADDRESS", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_NAME", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_PAPER", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_MESSAGES", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_MONETARY", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_COLLATE", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_TIME", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_NUMERIC", O_RDONLY) = 3
open("/usr/lib/locale/zh_CN.utf8/LC_CTYPE", O_RDONLY) = 3
open("/usr/share/locale/zh_CN/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/zh/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/zh_CN/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
open("/etc/nsswitch.conf", O_RDONLY) = 3
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libnss_compat.so.2", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libnsl.so.1", O_RDONLY) = 3
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libnss_nis.so.2", O_RDONLY) = 3
open("/lib/tls/i686/cmov/libnss_files.so.2", O_RDONLY) = 3
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 3
open("/proc/sys/kernel/ngroups_max", O_RDONLY) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
open("/etc/group", O_RDONLY|O_CLOEXEC) = 3
uid=1000(beyes) gid=1000(beyes) 组=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(beyes)
.section .data
timespec:
.int 5, 0
output:
.ascii "This is a test\n"
output_end:
.equ len, output_end - output
.section .bss
.lcomm rem, 8
.section .text
.global _start
_start:
nop
movl $10, %ecx
loop1:
pushl %ecx
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $len, %edx
int $0x80
movl $162, %eax
movl $timespec, %ebx
movl $rem, %ecx
int $0x80
popl %ecx
loop loop1
movl $1, %eax
movl $0, %ebx
int $0x80
./nanostrace &
$ strace -p 3069
Process 3069 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
write(1, "This is a test\n", 15) = 15
nanosleep({5, 0}, 0x80490d0) = 0
write(1, "This is a test\n", 15) = 15
nanosleep({5, 0}, 0x80490d0) = 0
write(1, "This is a test\n", 15) = 15
nanosleep({5, 0}, 0x80490d0) = 0
write(1, "This is a test\n", 15) = 15
nanosleep({5, 0}, 0x80490d0) = 0
_exit(0) = ?
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |