【发布时间】:2018-09-16 08:47:30
【问题描述】:
我一直在关注this guide,用 gdb 和 VMWare 搭建 Linux 内核调试环境。 直到那部分,一切都进行得很顺利:
将 GDB 连接到被调试对象
我们还不能从加载的内核模块中看到符号。我们将加载帮助脚本,然后运行 lx-symbols,它将探测加载的模块并适当地配置 GDB:(gdb) source home/alambert/kernel/source/linux-4.13.0/debian/build/build-generic/vmlinux-gdb.py(gdb) lx-symbols
在我的系统上运行此程序时,我收到以下 python 错误:pwndbg> source /home/user/kernel/source/linux-4.4.0/debian/build/build-generic/vmlinux-gdb.py
pwndbg> lx-symbols
loading vmlinux
Python Exception <class 'gdb.error'> There is no member named module_core.:
Error occurred in Python command: There is no member named module_core.
我的设置
debugger 和 debugee 机器都是虚拟机,debugee 是 Ubuntu 16.04,debugger 是 Ubuntu 18.04。
被调试者:$ cat /proc/version
Linux version 4.4.0-134-generic (buildd@lgw01-amd64-033) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #160-Ubuntu SMP Wed Aug 15 14:58:00 UTC 2018
调试器:$ cat /proc/version
Linux version 4.15.0-34-generic (buildd@lgw01-amd64-047) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018
$ gdb --version
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ python -V
Python 2.7.15rc1
我一开始以为是 python3/2 兼容性问题,所以我用 python 2.7 重新编译了 gdb,但得到了完全相同的错误。
我还验证了这不是 pwndbg 问题 - 我用 vanilla gdb 尝试了这个,效果完全相同。
我已经验证了python帮助脚本是在编译被调试内核的过程中创建的。实际上,我让整个构建过程完成,而不是像指南建议的那样在创建脚本后停止它 - 只是为了确保所有这些都到位。
我尝试在网上查找错误,但似乎没有任何提及。
有人遇到过这个问题吗?
【问题讨论】:
-
您能否输入
(gdb) set python print-stack full,然后再次输入source命令,并编辑您的问题以包含显示的完整回溯? -
非常感谢马克,我已经设法解决了这个问题。正如我所发现的,这不是 python 错误,而是
module.h标头和帮助程序脚本之间的不一致。再次感谢您的快速回复!
标签: python linux-kernel gdb kernel