调试用gdb一个Linux内核模块 [英] Debug a linux kernel module using gdb

查看:138
本文介绍了调试用gdb一个Linux内核模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的API是一个内核模块&LT在返回; VNOS - module.ko>。

I wanted to know what an API is returning in a kernel module < vnos-module.ko>.

从去几张表格就知道它不是直线前进,我们需要加载符号表调试内核模块。

Go to know from few forms that it is not that straight forward, we need to load the symbol table to debug a kernel module.

所以我所做的就是,
1.试图找到的.text .bss段和内核模块的.data段地址。
2.使用GDB附加符号-file命令添加符号表文件。

So all I did is, 1. tried to find .text .bss and .data section address of the kernel module. 2. Add symbol table file using add-symbol-file command in gdb.

但我得到的错误说:从/fabos/modules/vnos-module.ko...(no调试符号​​读符号中)......完成的。

But I get error saying "Reading symbols from /fabos/modules/vnos-module.ko...(no debugging symbols found)...done."

有什么我很想念在这里?

is there anything I am missing here?

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%肯定它)

Since I can't comment I'll write as an answer. (but I know it's more of a comment section post since I'm not 100% sure about it)

您有调试符号来编译你的模块。为了做到这一点应的模块不剥编译。你可能也想试试 -g 选项,并在你的内核 CONFIG_DEBUG_INFO = Y 启用调试。

You have to compile your module with debugging symbols. In order to do so module should be compiled without stripping. You might also want to try -g option and to have debugging enabled in your kernel CONFIG_DEBUG_INFO=y.

不知道是否会工作。

这篇关于调试用gdb一个Linux内核模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆