求助:4.10和4.11版本的kgdb调试问题

JeiGiye 2017-05-24 11:18:38
请问大家,有没有使用kgdb调试过4.10.*或是4.11*版本的内核。

这几天翻遍国内外网页,查kgdb调试的方法,多是基于2.6内核的,我自己成功实现了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
...全文
619 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
JeiGiye 2017-05-25
  • 打赏
  • 举报
回复
补充: 已经参考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
JeiGiye 2017-05-25
  • 打赏
  • 举报
回复
补充: 查到4.7.10版本可以正常断点,但4.8.1版本就不行。

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧