使用gdb和虚拟机调试内核
调试内核很麻烦,即使是有了虚拟机的帮助。在这里记下一些关键的东西,以备忘 。 # 编译内核后, 用新内核启动系统失败,报错 “unable to mount fs ….” 之类. 需要用 update-initramfs 生成initram。 # 对于grub2,我增加了一个自定义的grub开机启动项用来调试内核,如下: #!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the ’exec tail’ line above. echo “Add Debugging entry” cat « EOF menuentry “Debian debug 3.7.4”{ set root=(hd0,1) linux /boot/vmlinuz-3.7.4 root=/dev/vda1 ro quiet kgdboc=ttyS0,115200 kgdbwait initrd /boot/initrd.img-3.7.4 } EOF ...