为什么不在gcc -c上工作


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

(没有) - foobar.o 正在写明显,但我没有看到它在strace。为什么?

Answers:


1

这是因为 gcc 创建子进程,和 strace 除非您指定子进程,否则不会查看子进程 -ff 旗。

看到 strace -ff 此示例中的标志:

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.