1.编译内核
https://www.cnblogs.com/luohaixian/p/9313863.html
http://www.kgdb.info/enable_kgdb_option/
2.配置串口,grub
https://www.jianshu.com/p/c384b719d6dc
https://tunnelshade.in/blog/2019/05/linux-kernel-gdb-setup/
# Add this to default parameters in /etc/default/grub console=ttyS0,115200 kgdboc=ttyS0,115200 nokaslr $ grub2-mkconfig -o /boot/grub2/grub.cfg
3.调试
https://www.codercto.com/a/67786.html
获取各段地址脚本:
#!/bin/bash # # usage: gdbline.sh module_name module_path # # This script will outputs an add-symbol-file line suitable for pasting into gdb to examine # a loaded module. # cd /sys/module/$1/sections echo -n add-symbol-file $2 `/bin/cat .text` for section in .[a-z]* *; do if [ $section != ".text" ]; then echo " \\" echo -n " -s" $section `/bin/cat $section` fi done echo
获取内核模块各段地址:
gdbline.sh module_name module_path
目标:
echo g > /proc/sysrq-trigger
调试机:
gdb ./vmlinux target remote /dev/ttyS1
add-symbol-file xxxx xxx
下断点:
b可能不行,使用hb