When running strace on a multithreaded program I get results like this:
[pid 14778] futex(0x7fd8082f266c, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7fd8082f2668, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1} <unfinished ...>
[pid 14780] <... futex resumed> ) = 0
Notice the arguments are on one line with <unfinished...>
and the result is on another line with <...resumed>
. Not having arguments correlated with their results reduces the utility of strace. Is it possible to make strace print the results and the arguments on the same line when tracing a multithreaded program?
To attach strace to a running process, we can use the flag -p followed by the PID.
strace(1) is a great tool, but the current version (using ptrace()) can slow down the target severely. Be aware of the overhead strace causes, and consider other alternates for Linux that use lower-cost buffered tracing. These include perf_events, sysdig, ktap, and SystemTap.
strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state.
use strace -ff cmd 2> log.out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With