debug_linux_module_via_gdb
0. 前提
debug linux kernel via gdb is successful
1. 调试linux2.6.34模块
mount procfs before insmod *.ko, as follow:
$ mount -t proc proc /proc当用qemu进行仿真时,模块第一次动态加载时,加载地址都是相同的,所以此处用一种取巧的方法。
先正常加载模块,获得模块加载地址
$ insmod test.ko
$ cat /proc/modules
test 1099 0 - Live 0xffffffffa0000000开始调试模块
## terminal A
$ qemu-system-x86_64 xxx -S -s
## terminal B
$ gdb vmlinux
Reading symbols from vmlinux...done.
(gdb) target remote :1234
## 加载模块符号
(gdb) add-symbol-file test.ko 0xffffffffa0000000
Reading symbols from test.ko...done.
(gdb) b call_func
(gdb) c
## terminal A
$ insmod test.ko
## terminal B start to debug linux modules in code level2. 调试linux5.4模块
想要调试linux5.4模块,除了debug linux kernel via gdb is successful,还需要使能CONFIG_GDB_SCRIPTS
为了执行gdb vmlinux时,自动加载gdb脚本,执行如下命令:
开始调试模块
Last updated
Was this helpful?