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 文件中,C 代码与python 混合在一起,并被评论说构建会处理这个问题。 可以在此处找到确切的 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 配置,但我找不到合理的解释或补丁,尝试在 {{1} 下构建任何东西时会发生同样的错误}}

试图了解如何修复构建过程并最终创建正确的constants.py,希望这是使/usr/src/linux-.../ 在调试期间工作的最后一部分

解决方法

在源代码树的顶层运行 make scripts_gdb 将运行其他一些 Makefile 并最终构建 constants.py。你会看到一些像下面这样的喋喋不休:

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...