Hello all,
The python implemented in gdb uses imported external modules. For example, the following "math.py":
import mathprint("2^3 = %d\n" % math.pow(2, 3))
Gdb on gcc-arm-11.2-2022.02 works fine.
$ aarch64-none-linux-gnu-gdb -x math.py...2^3 = 8
However, gdb on arm-gnu-toolchain-11.3.rel1 or later results in an error.
$ aarch64-none-linux-gnu-gdb -x math.py...Traceback (most recent call last):File "test_math.py", line 3, in <module>import mathModuleNotFoundError: No module named 'math'
Up to 11.2, it referred to libpython installed in OS, but since 11.3, I think it uses external C-python extension modules.
Therefore, I specified PYTHONPATH to load the C-python extensions, which are the same version as python in 11.3 or later.
(gdb) python print(sys.version)3.8.11 (default, Jul 20 2022, 16:43:30)[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Gdb 11.3 contains python 3.8.11. However, specifying the 3.8.11 external modules resulted in a symbol error.
$ PYTHONPATH=/home/user/Python-3.8.11/build/lib.linux-x86_64-3.8 aarch64-none-linux-gnu-gdb -x math.py...Traceback (most recent call last):File "math.py", line 3, in <module>import mathImportError: /home/user/Python-3.8.11/build/lib.linux-x86_64-3.8/math.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type
Actually, aarch64-none-linux-gnu-gdb contains PyFloat_Type, but it cannot be referenced.
I'd like you to tell me why this happens.
Thank you.