i'm currently working on an ubuntu 18.0.4.5 machine and i've been trying to figure out the whole kernel debugging process. I've stumbled upon the need to auto run GDB scripts along with the vmlinux file, particulary the script residing under /usr/src/linux../scripts/gdb/vmlinux-gdb.py. I made sure the script ran on initialization with the vmlinux file and had the following error
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'
After this error occured I checked the /usr/share/gdb/auto-load/gdb/linux directory to look for the missing file and only found 2 related files:
constants.py.in
Makefile
Inside the constants.py.in file was C code mixed with python and was commented that the build will take care of that. The exact Makefile and constants.py.in files can be found here for reference: 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
Trying to build for the first time resulted in this:
make: *** No rule to make target '/constants.py.in', needed by '/constants.py'. Stop.
After some trial and error (i'm not experienced in Makefile language) I copied constants.py.in to the /
directory and tried to build again and recieved the following error:
make: *** No rule to make target 'FORCE', needed by '/constants.py'. Stop.
I don't understand what does that FORCE
is, looks like some kind of makefile configuration but i can't find a reasonable explantion or patch, the same errors occur when trying to build anything under /usr/src/linux-.../
trying to understand how to fix the build process and eventually create the correct constants.py that is hopefully the last piece to making the vmlinux-gdb.py
work during debugging