【问题标题】:Linux Kernel Debugging: "Python Exception <class 'gdb.error'> There is no member named module_core." when trying to use helper scripts in gdbLinux 内核调试:“Python 异常 <class 'gdb.error'> 没有名为 module_core 的成员。”尝试在 gdb 中使用帮助脚本时
【发布时间】: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.


我的设置

debuggerdebugee 机器都是虚拟机,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


【解决方案1】:

在对脚本和 linux 内核的来源进行了一些挖掘之后,我设法解决了这个问题。

问题在于this commitmodule_core 指针替换为include/linux/module.h 标头中的module_layout 结构。该更改显然已被引入内核 4.4.0,但直到更高版本才在帮助脚本中进行说明。

这已在稍后处理(特别是在 this commit 中),因此 4.4.0 和 4.6-rc1 之间的所有内核版本都会有这个错误。

解决方法是从上述commit下载脚本,并将它们放在相关目录中。

这当然是一个罕见的极端情况,但我希望这个答案有一天会对某人有所帮助。

【讨论】:

    猜你喜欢
    • 2020-02-09
    • 1970-01-01
    • 2017-07-20
    • 2019-09-30
    • 2011-09-11
    • 1970-01-01
    • 2015-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多