- 论坛徽章:
- 0
|
用kgdb调试内核没有问题,但调试模块始终不能成功,找不到源文件,也不能设断点,google了一段时间问题还不清楚
程序用简单的hello world
void myfunc(void)
{
printk("<1>in myfunc\n");
}
static int __init hello_init(void)
{
printk("<1>Hello, mod\n");
myfunc();
return 0;
}
static void __exit hello_exit(void)
{
printk("<1>Hello, exit\n");
}
module_init(hello_init);
module_exit(hello_exit);
放在开发机的/home/work/hellomod目录下,然后整个目录copy到测试机下, 开发机上的内核2.6.23
测试机2.6.28, 所以copy后重新编译了hellomod.c
过程大致为:
1. 测试机重启,加启动参数kgdbwait kgdboc=ttyS0, 9600
2. 开发机设置stty ispeed 9600 ospeed 9600
gdbmod vmlinux
target remote /dev/ttyS0
continue 后又切换到开发机上来
set solib-search-path /home/work/hellomod
br myfunc 提示Make breakpoint pending on future shared library load? (y or [n]) y
3. 测试机上
insmod hellomod.ko
切不到开发机上来,设的断点没用
值得注意的2个地方:
target remote /dev/ttyS0后提示:
Remote debugging using /dev/ttyS0
0xc04686bc in kgdb_register_io_module ()
warning: shared library handler failed to enable breakpoint
另外是编译时的-g选项,不用我编译使用
obj-m := hellomod.o
default:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(shell pwd)
应该包含了-g吧
求高人指点! |
|