c-使用gdb调试linux内核模块



我想知道API在内核模块中返回了什么<vnos模块.ko>.

从一些表单中可以知道,它并不是那么简单,我们需要加载符号表来调试内核模块。

所以我所做的就是,1.尝试查找内核模块的.text.bss和.data部分地址。2.使用gdb中的Add symbol file命令添加符号表文件。

但我收到一个错误,说"从/fabos/modules/vnos module.ko读取符号…(没有找到调试符号)…完成。"

这里有我遗漏的东西吗?

root@sw0:/sys/module/vnos_module/sections# cat .text .data .bss 
0xf7f7f000
0xf7fb7a30
0xf7fc3da4
root@sw0:/sys/module/vnos_module/sections# gdb /fabos/modules/vnos-module.ko
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /fabos/modules/vnos-module.ko...(no debugging symbols found)...done.
 add-symbol-file /fabos/modules/vnos-module.ko 0xf7f7f000 -s .data 0xf7fb7a -s .bss 0xf7fc3da4
add symbol table from file "/fabos/modules/vnos-module.ko" at
        .text_addr = 0xf7f7f000
        .data_addr = 0xf7fb7a30
(y or n) y
Reading symbols from /fabos/modules/vnos-module.ko...(no debugging symbols found)...done.

请帮忙。

由于我不能发表评论,我将写一个答案。(但我知道这更像是一个评论区的帖子,因为我不能100%确定)

您必须使用调试符号编译模块。为了做到这一点,应该在不剥离的情况下编译模块。您可能还想尝试-g选项,并在内核CONFIG_DEBUG_INFO=y中启用调试。

不确定它是否有效。

最新更新