Thursday, March 14, 2013

strace as last resort for Linux debug? - thanks to Stack Overflow


A collegue told me once that the last option when everything has failed to debug on linux was to use strace.
I tried to learn the science there is behind this strange tool but I am not a system admin guru and I Don't really get results.
So what is it exactly and what does it do ?
How to use it ? In which case ?
How to understand the output and process it ?
In brief, how does this stuff work ? In simple words.
...
n simple words, strace traces all system calls issued by a program along with their return codes. Think things such as file/socket operations and a lot more obscure ones.
It is most useful if you have some working knowledge of C since here system calls would more accurately stand for standard C library calls.
Let's say your program is /usr/local/bin/cough. Simply use:
strace /usr/local/bin/cough 
All strace output will go to stderr (beware, the sheer volume of it often asks for a redirection to a file). In the simplest cases, your program will abort with an error and you'll be able to see what where its last interactions with the OS in strace output.
...


linux - How to use strace? - Stack Overflow

'via Blog this'

No comments:

Post a Comment