Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C GNU make的回溯跟踪_C_Makefile_Gnu Make - Fatal编程技术网

C GNU make的回溯跟踪

C GNU make的回溯跟踪,c,makefile,gnu-make,C,Makefile,Gnu Make,有没有办法让gnumake打印目标的“回溯”,导致命令失败时被执行?在解决在新系统上构建软件的可移植性问题时,我经常处理严重混淆的makefiles,这似乎对于make来说应该是一件非常简单的事情,这将极大地帮助调试,但我找不到任何方法来请求它。我想看到的是: gcc: error: ... make[2]: error: gcc ... make[2]: error building target bar make[2]: error building dependency bar for t

有没有办法让gnumake打印目标的“回溯”,导致命令失败时被执行?在解决在新系统上构建软件的可移植性问题时,我经常处理严重混淆的makefiles,这似乎对于make来说应该是一件非常简单的事情,这将极大地帮助调试,但我找不到任何方法来请求它。我想看到的是:

gcc: error: ...
make[2]: error: gcc ...
make[2]: error building target bar
make[2]: error building dependency bar for target foo
make[1]: error: make -C subdir
make[1]: error building target subdir
make[1]: error building dependency subdir for target all
...
显示失败命令最终如何执行的整个依赖项路径


有什么方法可以做到这一点吗?

make-p
make-d
提供了有趣的信息,但并不是你想要的。请参阅。

使用。它是GNU Make的修补版本,添加了改进的错误报告、以可理解的方式跟踪执行的能力和调试器。

是的,可以为您提供回溯。下面是使用重拍的Makefile的运行,显示以下内容:

remake --debugger Makefile GNU Make 4.1+dbg0.91 Built for x86_64-unknown-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. Copyright (C) 2015 Rocky Bernstein. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Reading makefiles... Updating makefiles.... -> (/src/github/remake/Makefile:608) Makefile: Makefile.in config.status remake<0> bt =>#0 Makefile at /src/github/remake/Makefile:608 remake<1> s -> (/src/github/remake/Makefile:594) Makefile.in: remake<2> bt =>#0 Makefile.in at /src/github/remake/Makefile:594 #1 Makefile at /src/github/remake/Makefile:608 remake<3> s -> (/src/github/remake/Makefile:618) config.status: configure remake<4> bt =>#0 config.status at /src/github/remake/Makefile:618 #1 Makefile at /src/github/remake/Makefile:608 remake<5> s -> (/src/github/remake/Makefile:621) configure: remake<6> bt =<#0 configure at /src/github/remake/Makefile:621 #1 config.status at /src/github/remake/Makefile:618 #2 Makefile at /src/github/remake/Makefile:608 remake<7> remake——调试器生成文件 GNU Make 4.1+dbg0.91 为x86_64-unknown-linux-gnu构建 版权所有(C)1988年至2014年自由软件基金会。 版权所有(C)2015 Rocky Bernstein。 许可证GPLv3+:GNU GPL版本3或更高版本 这是自由软件:您可以自由更改和重新发布它。 在法律允许的范围内,不存在任何担保。 正在读取生成文件。。。 正在更新生成文件。。。。 ->(/src/github/remake/Makefile:608) Makefile:Makefile.in config.status 重拍bt =>#0 Makefile位于/src/github/remake/Makefile:608 翻拍 ->(/src/github/remake/Makefile:594) Makefile.in: 重拍bt =>#0 Makefile.in at/src/github/remake/Makefile:594 #1 Makefile位于/src/github/remake/Makefile:608 翻拍 ->(/src/github/remake/Makefile:618) config.status:配置 重拍bt =>#0 config.status位于/src/github/remake/Makefile:618 #1 Makefile位于/src/github/remake/Makefile:608 翻拍 ->(/src/github/remake/Makefile:621) 配置: 重拍bt =<#0在/src/github/remake/Makefile:621处配置 #1 config.status位于/src/github/remake/Makefile:618 #2 Makefile位于/src/github/remake/Makefile:608 翻拍
您还可以在特定目标上设置断点(
break
),转到那里(
continue
)并
backtrace
)。如果出现错误,您将返回崩溃时的位置。

OP可能会发现
make-n
很有帮助。是的,他们是您的朋友。如果您的makefile不使用任何内置的make规则,您可以使用
-Rr
(您只需要其中一个,但我永远记不清是哪一个,所以我总是同时使用这两个)。值得注意的是,“回溯”可能不是线性的,因为通常make的依赖关系图是DAG,而不是树。它可以为target
foo
和target
subdir
制作
bar
,为target
subdir
和target
all
制作target
foo
,为
all
制作
subdir
。我不认为这比堆栈回溯更难生成,只是更难阅读……如果你把它看作一种依赖性尝试,是的,它是一个DAG。然而,在GNUMake的遍历中,严格地说有一个依赖堆栈。因此,虽然“回溯”通常指调用堆栈,但这里类似的东西是依赖堆栈。