error: curses.h: No such file or directory 基于Debian的发行版(如Debian、Ubuntu):sudo apt-get install libncurses5-dev 基于Red Hat的发行版(如RHEL、CentOS):sudo yum install ncurses-devel
如果出现找不到该包,尝试以下设置: vi /etc/apt/source.list 添加其它系统的源[源列表地址](http://mirrors.163.com/.help/debian.html) 比如kali,我添加的debian jessie的源
如果提示窗口太小出错,说明你的命令行窗口小了,放大一点再试试. 内核调试需要做如下设置:
1 2 3 4 5 6 7
Kernel Hacking –> compile-time checks and compiler options –> [*] Compile the kernel with debug info [*] Compile the kernel with frame pointers [*] kernel debugging [*] KGDB: kernel debugger–> <*> KGDB: use kgdb over the serial console
完成上述选项后, 直接save后推出.
编译内核
1 2 3 4
make -j 4 bzImage # -j 代表用多少线程, 不要超过cpu的最大线程数 make modules make modules_install make install
1 # grub.conf generated by anaconda 2 # 3 # Note that you do not have to rerun grub after making changes to this file 4 # NOTICE: You have a /boot partition. This means that 5 # all kernel and initrd paths are relative to /boot/, eg. 6 # root (hd0,0) 7 # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 8 # initrd /initrd-version.img 9 #boot=/dev/hda 10 default=0 11 timeout=5 12 splashimage=(hd0,0)/grub/splash.xpm.gz 13 hiddenmenu 14 title CentOS (2.6.26) 15 root (hd0,0) 16 kernel /vmlinuz-2.6.26 ro root=/dev/VolGroup00/LogVol00 17 initrd /initrd-2.6.26.img 18 title CentOS-4 i386 (2.6.9-67.ELsmp) 19 root (hd0,0) 20 kernel /vmlinuz-2.6.9-67.ELsmp ro root=/dev/VolGroup00/LogVol00 <--------------------- 21 initrd /initrd-2.6.9-67.ELsmp.img
Remote debugging using /dev/ttyS0 kgdb_breakpoint () at kernel/kgdb.c:1674 1674 wmb(); /*Sync point after breakpoint */ warning: shared library handler failed to enable breakpoint
(gdb)
如果”set remotebaud 115200”的时候出错,就换成”set serial baud 115200”
root@ubuntu:/home/vv# cat /proc/modules |grep kvm kvm_intel 294912 0 - Live 0xffffffffc066c000 kvm 843776 1 kvm_intel, Live 0xffffffffc055e000
此处可以看到, kvm的基址是0xffffffffc055e000. 然后通过echo g >/proc/sysrq-tirgger 使内核中断. 然后在调试器里输入以下命令添加符号:
1 2 3 4 5
gdb$ add-symbol-file arch/x86/kvm/kvm.ko 0xffffffffc055e000 add symbol table from file "arch/x86/kvm/kvm.ko" at .text_addr = 0xffffffffc055e000 Reading symbols from arch/x86/kvm/kvm.ko... gdb$