Showing posts with label debug. Show all posts
Showing posts with label debug. Show all posts

Tuesday, September 05, 2006

strace, an useful diagnostic toolstrace

You will always occours some boring situation when using Linux-like system. For example, when you are trying the new feature of emacs unicode branch, such as xft fonts supporting. You input the command "emacs --enable-font-backend -fn monospace", and wish to enjoy the rounded and smooth fonts. However, your Emacs could not start up, and throwed out a fault, like "Fatal error (11)Segmentation fault". If you are a newbie, You may be distracted and donnot how to resolve.

Now, there is a cute tool, strace, to help us diagnose where it crashes. strace can be binded on an existed PID, and trace its system calls. here are some useful arguments:

-f : trace current process and its sub-processes -o file : redirect the output into a file, but not stderr -p pid : bind on a process with pid, which is often used to debug on background.

Here is an example to trace the emacs process, the result will be written into the file emacs.strace.

strace -f -o emacs.strace emacs

Here is an advanced article to explain how strace to work: http://www.linuxforum.net/forum/showflat.php?Cat=&Board=security&Number=534712&page=0&view=collapsed&sb=5&o=31&fpart=