Formatting code for LinuxStrace


show source only

{{parent page="Linux"}}

===strace===
strace is an important utility to query system call usage.

==tracing a running process==
%%
strace -p $PID
%%

==Get a process's system call category report==
Use **strace -c**

%%
strace -p 3712 -c
Process 3712 attached - interrupt to quit
Process 3712 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
94.27 0.006843 3 2641 poll
4.16 0.000302 0 7781 gettimeofday
1.20 0.000087 1 70 futex
0.37 0.000027 0 5244 ioctl
0.00 0.000000 0 510 read
0.00 0.000000 0 233 write
------ ----------- ----------- --------- --------- ----------------
100.00 0.007259 16479 total
%%

==Tracing a hung process==

Do a strace -p on the process, if it ends with
%%
read(13,
%%

That means the system is hung on a read system call, to the file descriptor 13. Do a **lsof** to find out what fd #13 is.


Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki