linux - Makefile:没有规则可以使“/constants.py”需要目标“/constants.py.in”。停止
问题描述
我目前正在使用 ubuntu 18.0.4.5 机器,我一直在试图弄清楚整个内核调试过程。我偶然发现需要自动运行 GDB 脚本以及 vmlinux 文件,特别是驻留在 /usr/src/linux../scripts/gdb/vmlinux-gdb.py 下的脚本。我确保脚本在使用 vmlinux 文件初始化时运行并出现以下错误
gdb vmlinux
File "/usr/src/linux-hwe-5.4-headers-5.4.0-42/scripts/gdb/vmlinux-gdb.py", line 34, in <module>
import linux.proc
File "/usr/share/gdb/auto-load/gdb/linux/proc.py", line 15, in <module>
from linux import constants
ImportError: cannot import name 'constants'
发生此错误后,我检查了 /usr/share/gdb/auto-load/gdb/linux 目录以查找丢失的文件,仅找到 2 个相关文件:
constants.py.in
Makefile
在 constants.py.in 文件中是与 python 混合的 C 代码,并评论说构建会处理这个问题。可以在此处找到确切的 Makefile 和 constants.py.in 文件以供参考:https ://elixir.bootlin.com/linux/v5.4/source/scripts/gdb/linux/Makefile https://elixir.bootlin。 com/linux/v5.4/source/scripts/gdb/linux/constants.py.in
第一次尝试构建导致以下结果:
make: *** No rule to make target '/constants.py.in', needed by '/constants.py'. Stop.
经过一些试验和错误(我对 Makefile 语言没有经验),我将 constants.py.in 复制到/
目录并尝试再次构建并收到以下错误:
make: *** No rule to make target 'FORCE', needed by '/constants.py'. Stop.
我不明白那FORCE
是什么,看起来像是某种makefile配置,但我找不到合理的解释或补丁,尝试在下面构建任何东西时都会发生同样的错误/usr/src/linux-.../
试图了解如何修复构建过程并最终创建正确的 constants.py ,希望这是vmlinux-gdb.py
在调试期间完成工作的最后一部分
解决方案
make scripts_gdb
在源代码树的顶层运行将运行几个其他 Makefile 并最终构建constants.py
. 你会看到一些 make chatter 像下面这样:
builder@localhost:/tmp/linux/linux-5.4.125$ make V=1 scripts_gdb
make -f ./scripts/Makefile.build obj=scripts/basic
...
make -f ./scripts/Makefile.build obj=scripts/gdb
make -f ./scripts/Makefile.build obj=scripts/gdb/linux
gcc -E -E -x c -P -Wp,-MD,scripts/gdb/linux/.constants.py.d ... \
scripts/gdb/linux/constants.py.in > scripts/gdb/linux/constants.py ;\
sed -i '1,/<!-- end-c-headers -->/d;' scripts/gdb/linux/constants.py
ln -fsn /tmp/linux/linux-5.4.125/scripts/gdb/vmlinux-gdb.py
这完成后,vmlinux-gdb.py
就可以使用了。
推荐阅读
- c# - HTTP 请求在 Postman 中有效,但在 C# 代码中无效
- python - pathlib 的 glob() 如何处理不存在和无效的路径?
- java - Android:组织显示警报对话框的方法的最佳实践是什么
- flutter - 如何检测用户已停止在 TextField 中输入?
- javascript - 如何使用节点 js api 将 JavaScript 文件对象上传到 Cloudinary?
- presto - 为什么 AWS Athena 在“显示创建表”命令或描述表时向所有表的字段返回“字符串”数据类型
- javascript - 无法打印返回的 div
- php - 如果我在其内部重新运行一个函数,PDO 将不起作用
- python - 如何将 QLabel 对象添加到 qheaderview?
- javascript - 在 JavaScript 中更改对象的键