// you’re reading...

Debugging

Using Truss to Debug

Any experienced programmer knows that over the life cycle of a piece of software, more effort and resource is spent in debugging than original code development. Solaris operating system provides a variety of tools to assist in the debugging process. One of the oldest of these tools is truss(1). It can come in handy when you need to take a quick look at a currently executing program’s trace. However, many people seem to limit the use of truss to trace system calls only. While that is the default, the tool is capable of much much more. For example, it can trace use -level functions, follow  processes that fork, show IO buffers of write/read calls, stop the process (for further examination) if it receives a signal etc.

Below is an example usage of truss that will not trace any system call (“-t \!all”), but will trace all user functions in the executable (“-u a.out”) of the process with specified PID .

% truss -t \!all -fl -u a.out -pprocess-id

See more details about various options of truss in the man page. Also available from Sun blue prints is this article, named Application Troubleshooting: Alternate Methods of Debugging which also describes other utilities like psatck, pldd etc. along with truss.

Discussion

No comments for “Using Truss to Debug”

Post a comment