Monday, November 20, 2017

Trace Linux Process Execution With strace

1. Generate System call report

$ strace -c ls /home
[root@ip-10-1-1-1 ~]# strace -c ls /root
anaconda-ks.cfg  get-pip.py  original-ks.cfg
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  0.00    0.000000           0         8           read
  0.00    0.000000           0         1           write
  0.00    0.000000           0        10           open
  0.00    0.000000           0        13           close
  0.00    0.000000           0         2           stat
  0.00    0.000000           0        11           fstat
  0.00    0.000000           0        27           mmap
  0.00    0.000000           0        18           mprotect
  0.00    0.000000           0         2           munmap
  0.00    0.000000           0         3           brk
  0.00    0.000000           0         2           rt_sigaction
  0.00    0.000000           0         1           rt_sigprocmask
  0.00    0.000000           0         2           ioctl
  0.00    0.000000           0         2         1 access
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         2           getdents
  0.00    0.000000           0         1           getrlimit
  0.00    0.000000           0         2           statfs
  0.00    0.000000           0         1           arch_prctl
  0.00    0.000000           0         1           set_tid_address
  0.00    0.000000           0         1           openat
  0.00    0.000000           0         1           set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00    0.000000                   112         1 total
[root@ip-10-1-1-1 ~]#
2.  Execute Strace on a Running Linux Process

$  sudo strace -p 1725 -o firefox_trace.txt

No comments:

Post a Comment