Slide 18
Slide 18 text
18
Ptrace
• strace is a a user mode program which uses ptrace()
• Attach strace to running process you wish to monitor
• Every system call in kernel will add an extra context switch
long ptrace(enum __ptrace_request request, pid_t pid, void * addr, void * data)
rc@robby-dev:~$ strace ls /tmp
execve("/bin/ls", ["ls", "/tmp"], [/* 77 vars */]) = 0
brk(NULL) = 0x887000
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)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=56320, ...}) = 0
mmap(NULL, 56320, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3504e99000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
...