Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strace Multithreaded Program

Tags:

linux

strace

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?

like image 843
benmmurphy Avatar asked May 18 '12 15:05

benmmurphy


People also ask

How does strace attach to a process?

To attach strace to a running process, we can use the flag -p followed by the PID.

Does strace slow down a process?

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.

What is an strace?

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.


1 Answers

use strace -ff cmd 2> log.out

like image 197
DukeLion Avatar answered Sep 23 '22 18:09

DukeLion