8

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?

benmmurphy
  • 2,503
  • 1
  • 20
  • 30
  • 1
    if I output to files using -ff -o I can get the result I'm looking for. However, I would prefer writing the output to my console instead of a hundred different files. :) – benmmurphy May 18 '12 at 15:28
  • .. but there's a chronology problem: that particular mutex operation really does start in one thread, block that thread, and cause a return in another thread. – pjc50 May 18 '12 at 15:37
  • i would't mind if it printed: syscall(args) = unfinished, resumed: syscall(args) = result. that doesn't have a chronological problem and i can still match args to a result. the problem is the second line it prints at the moment is syscall(resumed) = result which is not very useful to me. – benmmurphy May 18 '12 at 15:39
  • oh.. i see what you are talking about. the futex operation :).. does it really do that? block on one thread and return to another? – benmmurphy May 18 '12 at 15:43
  • The "[pid number]" at the start of the line is different, so that's what it looks like, and it makes sense for a mutex wake operation. – pjc50 May 18 '12 at 15:51

1 Answers1

10

use strace -ff cmd 2> log.out

DukeLion
  • 356
  • 3
  • 4