6,534
edits
Changes
Fixed grammar and in some cases wording
Suppose some program on your system refuses to work or it works,but musch much slower then you've expected. How can you investigate yourself the reasonof such undesirable behaviour? First of all , you can read and analyze logs that this program does (if it does). It's very usefull useful to run unkindly program with<tt>--verbose</tt> argument or somehow else increase the log level, if the program allows that.
But what can you do, if logs are poor and it's impossible to infer the reason of badness from them?
One way is to use strace program to follow system calls performed by given process.
Commonly to use strace you should give the following command:
<ttpre>strace -o strace.out -ff touch /tmp/file</tt> <tt>-o strace.out</tt> option means that strace program will output all investigated informationto the file named <tt>strace.out</tt> <tt>touch /tmp/file</ttpre> is the program with arguments to strace
== Strace results ==
So this is what we have in <tt>strace.out</tt>:
<pre>
execve("/usr/bin/touch", ["touch", "/tmp/file"], [/* 51 vars */]) = 0
</pre>
== Additional notes ==
Sometimes (for example if a program works slow) you are also intersted in time, that the program spends in syscalls. Than
options <tt>-tt</tt> and <tt>-T</tt> are helpful.
As you've seen strace program shows arguments of syscalls. But if arguments are a pointers it shows us only 32 bytes from these pointers.To increase this number use <tt>-s</tt> option.
[[Category: Troubleshooting]]