kgdb 调试内核模块

首先有两台机器,我是在development 机器上,用gdb调试target 机器加载cha_driver,cha_driver是一个简单的字符串驱动,

下面就是我一些简单的配置:

development machine                                                                                            

1,compile the kernel with serial and kgdb option                                                  

2,compile the cha_driver module to cha_driver.ko                                                

 

 target machine                                                                                                                      1

1,copy the bzImage and modules from development machine   

2,copy the cha_driverk.ko from the development machine      

3,modify the target machine grub as the following:                                                                                                                       

add serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1

add terminal --timeout=5 console 

add console=ttyS0,115200n8 console=tty0 at the kernel line

after finishing the above operations, you can reboot the target machine to debug:

at the development machine, do the following things:

#cd linux_path

#gdb vmlinux

#set remotebaud 115200

#target remote /dev/ttyS0

#b kernel/module.c:2111   //at the  load_module function, where ptr is the module symbol address

#b kernel/module.c:2465  //enter the module init funciton

#continue

then you can do #insmod cha_driver,ko at the target machine,it will stop at you development machine,then do the following things at your development machine

#p ptr //print you module address

#add-symbol-file path/cha_driver.ko  0x0c88c8000(it is the value of ptr)

#c  //then it will stop at line 2465

#s

#s //enter into globalmem_init function

ok,by now we debug the init function,then enter contiunue command at gdb,you can write a program to open your  device and do the write ,read  operation, the gdb will trace the function.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值