【发布时间】:2010-09-08 11:00:48
【问题描述】:
我有一个庞大的遗留代码库,其中包含非常复杂的 makefile 和很多变量。有时我需要更改它们,我发现很难弄清楚为什么更改没有按我预期的方式进行。我想找到的是一个基本上可以逐步调试“make”过程的工具,我会给它一个目录,我可以在不同的点看到不同变量的值过程。没有一个调试标志似乎向我展示了我想要的东西,尽管我可能遗漏了一些东西。有谁知道这样做的方法吗?
【问题讨论】:
我有一个庞大的遗留代码库,其中包含非常复杂的 makefile 和很多变量。有时我需要更改它们,我发现很难弄清楚为什么更改没有按我预期的方式进行。我想找到的是一个基本上可以逐步调试“make”过程的工具,我会给它一个目录,我可以在不同的点看到不同变量的值过程。没有一个调试标志似乎向我展示了我想要的东西,尽管我可能遗漏了一些东西。有谁知道这样做的方法吗?
【问题讨论】:
您是否一直在查看运行 make -n 和 make -np 以及大人物 make -nd 的输出?
您使用的是最新版本的gmake?
您是否查看过 O'Reilly 网站上关于 Debugging Makefiles 的免费章节,因为他们的优秀著作“使用 GNU Make 管理项目”(Amazon Link)。
【讨论】:
来自 make 命令行选项的手册页:
-n, --just-print, --dry-run, --recon
Print the commands that would be executed, but do not execute them.
-d Print debugging information in addition to normal processing.
The debugging information says
which files are being considered for remaking,
which file-times are being compared and with what results,
which files actually need to be remade,
which implicit rules are considered and which are applied---
everything interesting about how make decides what to do.
--debug[=FLAGS] Print debugging information in addition to normal processing.
If the FLAGS are omitted, then the behaviour is the same as if -d was specified.
FLAGS may be:
'a' for all debugging output same as using -d,
'b' for basic debugging,
'v' for more verbose basic debugging,
'i' for showing implicit rules,
'j' for details on invocation of commands, and
'm' for debugging while remaking makefiles.
【讨论】:
我不知道有任何特定标志可以完全满足您的要求,但是
--print-data-base听起来可能很有用。
【讨论】:
remake --debugger all
【讨论】:
http://gmd.sf.net 有一个 GNU make 调试器项目,看起来非常有用。 gmd 支持的主要功能是断点,它可能比单步更有用。要使用它,您可以从http://gmd.sf.net 下载 gmd 和从http://gmsl.sf.net 下载 gmsl,然后在您的 makefile 中执行“包含 gmd”。
【讨论】: