1.編譯內核
修改Makefile,修改成-O1 或者-O0
ifdef CONFIG_PROFILE_ALL_BRANCHES
KBUILD_CFLAGS += -O1 $(call cc-disable-warning,maybe-uninitialized,)
else
KBUILD_CFLAGS += -O1
endiflinux
啓動虛擬機
id=balloon0,bus=pci.0,addr=0x9 -S -gdb tcp::1234 -msg timestamp=ondom
4.啓動gdb
gdb vmlinuz-4.14.0-generic
(gdb) target remote 127.0.0.1:1234
Remote debugging using 127.0.0.1:1234tcp
編譯kvm
1.進入kvm所在的目錄
linux-4.14/arch/x86/kvm
2.執行編譯命令
make CONFIG_KVM=m CONFIG_INTEL_KVM=m -C /vms/kernel4.14/linux-4.14 M=$PWD modules
/vms/kernel4.14/linux-4.14 內核所在的路徑
M=$PWD kvm所在的路徑ide
進入內核代碼目路
make CONFIG_KVM=m CONFIG_INTEL_KVM=m -C /vms/kernel4.14/linux-4.14 M=/vms/kernel4.14/linux-4.14/arch/x86/kvm modulesdebug