首先有两台机器,我是在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.