簡體   English   中英

使用gdb調試Linux內核模塊

[英]Debug a linux kernel module using gdb

我想知道內核模塊<vnos-module.ko>中API返回的內容。

從幾種形式中得知不是那么簡單,我們需要加載符號表來調試內核模塊。

因此,我所做的只是,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啟用調試功能。

不確定是否會工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM