2
>echo > foobar.c
>strace gcc -c foobar.c 2>&1 | grep foobar.o
>

(nothing) - foobar.o is being written obviously, but I don't see it on strace. Why?

1 Answer 1

1

This is because gcc creates subprocesses, and strace won't look into subprocesses unless you specify the -ff flag.

See strace -ff flag in action in this example:

deltik@workstation [~/Desktop]# echo > foobar.c
deltik@workstation [~/Desktop]# strace -ff gcc -c foobar.c 2>&1 | grep foobar.o
[pid 14220] execve("/usr/local/sbin/as", ["as", "--64", "-o", "foobar.o", "/tmp/ccJhzHTZ.s"], [/* 66 vars */]) = -1 ENOENT (No such file or directory)
[pid 14220] execve("/usr/local/bin/as", ["as", "--64", "-o", "foobar.o", "/tmp/ccJhzHTZ.s"], [/* 66 vars */]) = -1 ENOENT (No such file or directory)
[pid 14220] execve("/usr/sbin/as", ["as", "--64", "-o", "foobar.o", "/tmp/ccJhzHTZ.s"], [/* 66 vars */]) = -1 ENOENT (No such file or directory)
[pid 14220] execve("/usr/bin/as", ["as", "--64", "-o", "foobar.o", "/tmp/ccJhzHTZ.s"], [/* 66 vars */] <unfinished ...>
[pid 14220] stat("foobar.o", 0x7ffed65b3850) = -1 ENOENT (No such file or directory)
[pid 14220] open("foobar.o", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .