Using strace to Debug Programs in Linux
Novell Cool Solutions: Trench
By Aaron Gresko
|
Digg This -
Slashdot This
Posted: 21 Sep 2005 |
Using strace to Debug Programs
A common tool utilized by Novell Support to troubleshoot Linux systems is strace. strace is a utility that prints all the system calls made by a program to standard error. strace can also redirect the output to a file.
To use strace, open a terminal and enter strace [options] [command]. For example, the command strace -f -o /tmp/tracels ls / runs the command ls / and sends the output to the file /tmp/tracels. The f option tells strace to include forked processes.
strace is useful in lots of different situations, including:
- Finding out what point a program encounters errors. By backtracking from the point of the error, you can identify what caused the error.
- Identifying the files a program is using. Sometimes knowing what files are being used by a program can help identify problems or in just learning how a program works.
- Solve problems with dependent libraries. sctrace output includes the linker process, which is where the libraries a program is dependent on are loaded into memory for use. If a dependent library is missing or the program is using the wrong version, the strace output will reveal this.
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

