Choose the boundary to observe
strace records Linux system calls and signals. It helps reconstruct requests such as opening a file, reading data, or creating a connection. It does not list every function executed inside a library, and computation completed entirely in user space may leave no corresponding system-call record.
Start with a concrete question. Investigate openat for path lookup, connect and read for communication, or poll for event waits. Relate the observed request and return value to application behavior rather than treating the presence of any failed call as a complete diagnosis.
Start with a narrow trace
The command below launches a test program named demo and selects a small group of calls. Replace demo with the program under investigation. The -f option follows newly created children, -tt adds timestamps, and -T shows call duration. Narrow filters make the sequence easier to interpret.
Arguments and data fragments can appear in the trace, so choose an appropriate output location and sharing scope. Attaching to an existing process also depends on permissions and ptrace restrictions. A tracing permission error describes the observer’s access; it does not establish a fault in the application being examined.
strace -f -tt -T \
-e trace=openat,read,write,connect,poll \
-s 80 -o trace.log -- ./demoRead returns in their sequence
Suppose an openat call returns ENOENT. A normal search routine may try one missing candidate and then succeed at another path. Inspect following calls and the application error before assigning meaning to that line. Likewise, a zero result from read usually represents an end condition, not the same condition as a negative error return.
A long poll can include waiting for an event rather than continuous CPU execution. The default -c summary reports system CPU time; that differs from individual elapsed durations and total program wall time. Decide which time quantity answers the question before comparing or adding measurements.
Account for the observer
Tracing through ptrace can stop and resume the target and change its timing. Compare behavior with and without tracing when reproducing a timing-sensitive problem. If the suspected work happens within user-space computation, switch to a suitable CPU profiler instead of assuming that an empty trace means no work occurred.
Use the sequence to refine hypotheses about paths, peer state, or permissions. The trace establishes requests and results at one boundary, not every underlying cause. A useful investigation ends with a smaller reproduction and a testable explanation, including any uncertainty introduced by the observation method.