18.Feb.17Understanding the strace commandstrace is a utility that traces system calls and signals. It is very useful for debugging purposes, specially if you don't have the source code of the problematic software. In its simple form it works like this: $ strace ls /tmp strace ls /tmp/ execve("/bin/ls", ["ls", "/tmp/"], [/* 80 vars */]) = 0 brk(0) = 0x1c3e000 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) mmap(NULL, 8192, ...
31.Jan.09Tracing an already existing process$ strace -p pid Attaches to the process with PID=pid and shows the utilization of system calls. Very useful when a process seems to be stuck and you want to know what is going on.
27.Jan.09Tracing system calls$ strace ls Traces all the system calls invoked by the process "ls" Let's say we are in directory dir and we execute ls $ ls file1 file2 And now, let's see what the command actually does: $ strace ls open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|0x80000) = 3 getdents(3, /* 4 entries */, 4096) = 112 write(1, "file1 file2\n", 13file1 file2 ) = 13 It opens the current directory, reads the number of entries (4, this is: our two files, plus "." plus "..") and writes the result using write You should keep in mind that strace traces system ...