strace changes behavior of the traced process

Yuri yuri at rawbw.com
Mon Jul 28 05:19:56 UTC 2014


When I run 'gdb printf' with and without strace, the output of gdb is 
different in that with strace "Inferior exited" message disappears.
It looks like strace maybe consumes the exit signal of the debugged 
process before gdb does?

$ gdb printf
<...skipped...>
(gdb) r "Hello\n"
Starting program: /usr/bin/printf "Hello\n"
Hello
[Inferior 1 (process 3057) exited normally]
(gdb)


$ strace -f 2>/dev/null gdb printf
<...skipped...>
(gdb) r "Hello\n"
Starting program: /usr/bin/printf "Hello\n"
Hello
(gdb)

Same case run with cgdb instead of gdb shows even larger output differences.

Ideally strace shouldn't affect the program behavior which is otherwise 
deterministic.

Yuri




More information about the Strace-devel mailing list