找回密码
 骑士注册

QQ登录

微博登录

搜索
❏ 站外平台:

查看: 928|回复: 8
收起左侧

[求助] 关于linux内核kgdb调试

[复制链接]
叶竹贵 发表于 2017-05-24 22:53:22 | 显示全部楼层 |阅读模式

请问大家,有没有使用kgdb调试过4.10.*或是4.11*版本的内核。

这几天翻遍国内外网页,查kgdb调试的方法,成功实现了3.18.35和4.4.60两个版本的linux内核调试。

但使用4.8.17\4.10.17\4.11-rc*版本编译后,调试时看不到函数名,设置断点后,c 继续运行报错,不能access断点的内存。

不知道大家是否有解决方案。

# gdb ./vmlinux-4.8.17
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 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 "x86_64-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 ./vmlinux-4.8.17...done.
(gdb) set debug auto-load on
(gdb) set serial baud 115200
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0xffffffffb7525e37 in ?? ()
(gdb) ba
#0  0xffffffffb7525e37 in ?? ()
#1  0xffff98c5e77cfde0 in ?? ()
#2  0xffffffffb7525ea1 in ?? ()
#3  0xffff98c5e77cfe10 in ?? ()
#4  0xffffffffb78dedfd in ?? ()
#5  0x0000000000000002 in irq_stack_union ()
#6  0x000000000095f408 in ?? ()
#7  0xffff98c5e77cff18 in ?? ()
#8  0xffff98c5e77cfe28 in ?? ()
#9  0xffffffffb78df28d in ?? ()
#10 0xffff98c62a0ad180 in ?? ()
#11 0xffff98c5e77cfe48 in ?? ()
#12 0xffffffffb76806da in ?? ()
#13 0xffff98c62864a500 in ?? ()
#14 0xffff98c5e77cff18 in ?? ()
#15 0xffff98c5e77cfed0 in ?? ()
#16 0xffffffffb7612fe7 in ?? ()
#17 0x000000005b7e68f1 in ?? ()
#18 0x000000000000000a in irq_stack_union ()
#19 0xffffffffb7630db0 in ?? ()
#20 0xffff98c5e77cfe80 in ?? ()
#21 0xffffffffb777f5b1 in ?? ()
#22 0xffff98c5e77cfeb0 in ?? ()
---Type <return> to continue, or q <return> to quit---b
#23 0xffffffffb774172b in ?? ()
#24 0x0000000000000001 in irq_stack_union ()
#25 0xffff98c62864a500 in ?? ()
#26 0x000000000095f408 in ?? ()
#27 0xffff98c5e77cff18 in ?? ()
#28 0xffffffffb74c2952 in ?? ()
#29 0x000000005b7e68f1 in ?? ()
#30 0xffff98c62864a500 in ?? ()
#31 0x0000000000000002 in irq_stack_union ()
#32 0xffffffffb76136fe in ?? ()
#33 0xffff98c62864a500 in ?? ()
#34 0xffff98c62864a500 in ?? ()
#35 0x000000000095f408 in ?? ()
#36 0x0000000000000002 in irq_stack_union ()
#37 0xffff98c5e77cff48 in ?? ()
#38 0xffffffffb7614abb in ?? ()
#39 0x0000000000000000 in ?? ()
(gdb) b bio_alloc
Breakpoint 1 at 0xffffffff810cb05f: bio_alloc. (25 locations)
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff810cb05f
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff811d3cac
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff81248800
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124df25
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124e146
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124e458
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124e673
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124ea7b
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124ecac
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124efc5
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124f1e4
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124fd9c
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8124fffd
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff81250371
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff812505df
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff8125098a
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff81250beb
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff81251278
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff812512b2
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff812629f8
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff812a6dcc
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff812e75e6
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff813ae833
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff813b2dc9
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff816788e1

Command aborted.
(gdb) q
A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y

本站网友  发表于 2017-08-30 13:45:14
一樣有這個問題

將ubuntu 16.04 kernel source 下來也是 4.10.17

在這一版必須自己去Kconfig將RODATA def n,但也一樣一開始就辨認不到函式名稱

待會打算測4.12看看是否有解決問題

 楼主| 叶竹贵 发表于 2017-06-01 09:01:27 | 显示全部楼层
发现还一个4.8版本,编译后还是不行。看来要diff全目录来看了。

本站网友  发表于 2017-09-12 10:41:45
楼主最后解决了?能发一下解决方案吗,我最近也遇到了这个问题

a4651386 发表于 2017-09-12 07:50:38 | 显示全部楼层
补充:
已经参考https://www.kernel.org/doc/htmldocs/kgdb/index.html
关闭内核的只读,这个需要修改arch/x86下的Kconfig文件。
4.10之前是RODATA和RONX,4.11之后是ARCH_HAS_STRICT_KERNEL_RWX和ARCH_HAS_STRICT_MODULE_RWX
ARCH_HAS_STRICT_KERNEL_RWX和ARCH_HAS_STRICT_MODULE_RWX是怎么设置的呀,我一开始直接删除该选项,编译启用新版本后死机,后来把他放到n选项下面还是不行,你最后能单步了吗?4.10以后

 楼主| 叶竹贵 发表于 2017-05-25 09:19:29 | 显示全部楼层
补充:
已经参考https://www.kernel.org/doc/htmldocs/kgdb/index.html
关闭内核的只读,这个需要修改arch/x86下的Kconfig文件。
4.10之前是RODATA和RONX,4.11之后是ARCH_HAS_STRICT_KERNEL_RWX和ARCH_HAS_STRICT_MODULE_RWX

 楼主| 叶竹贵 发表于 2017-05-25 17:33:27 | 显示全部楼层
补充:
查到4.7.10版本可以正常断点,但4.8.1版本就不行。

用户4072468931 发表于 2017-08-30 14:34:30 | 显示全部楼层
請問這個有任何進展嗎?

Ubuntu 16.04.3的Kernel 版本也是4.10.17

會發生函式名稱全都是"?????"的問題,而且同樣的無法插入中斷點,已經在Kconfig將 RODATA的選項設定為n 結果也是一樣

我自己正在嘗試mainLine的 4.12.9 如果還是有問題,打算發到社群上詢問看看

本站网友  发表于 2017-09-12 07:46:23
补充:
已经参考https://www.kernel.org/doc/htmldocs/kgdb/index.html
关闭内核的只读,这个需要修改arch/x86下的Kconfig文件。
4.10之前是RODATA和RONX,4.11之后是ARCH_HAS_STRICT_KERNEL_RWX和ARCH_HAS_STRICT_MODULE_RWX
ARCH_HAS_STRICT_KERNEL_RWX和ARCH_HAS_STRICT_MODULE_RWX怎么弄呀,我先是删除这两项,启用新版本内核后死机,后来放到n的序列里面也包错死机

您需要登录后才可以回帖 登录

本版积分规则

快速回复 返回顶部 返回列表

分享到微信

打开微信,点击顶部的“╋”,
使用“扫一扫”将网页分享至微信。