//创建工作目录
mkdir workspace_kernel; cd workspace_kernel
//下载相关文件
yum install -y qemu gdb
wget https://download.fedoraproject.org/pub/fedora/linux/releases/35/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-35-1.2.iso
//创建qemu虚拟磁盘
qemu-img create -f qcow2 fedora35.qcow2 100G
//运行qemu安装系统
qemu-system-x86_64 -m 1024 -hda fedora34.qcow2 -cdrom Fedora-Workstation-Live-x86_64-35-1.2.iso -boot d -enable-kvm
//运行安装好的虚拟机,
qemu-system-x86_64 -m 1024 -hda ./fedora34.qcow2 -boot c -enable-kvm
//修改虚拟机的grub启动参数,在启动参数上加上console=tty0 console=ttyS0 nokaslr 3
vi /boot/loader/entries/ed311076f30f44de810c04c1a5b24bc7-5.14.10-300.fc35.x86_64.conf
//加上-s -S参数重新运行虚拟机
//-S freeze CPU at startup (use 'c' to start execution)
//-s shorthand for -gdb tcp::1234
qemu-system-x86_64 -m 1024 -hda fedora34.qcow2 -boot c -enable-kvm -nographic -s -S
//下载内核的debuginfo
debuginfo-install kernel-core-5.14.10-300.fc35.x86_64
//运行GDB
gdb /lib/debug/lib/modules/5.14.10-300.fc35.x86_64/vmlinux
target remote :1234
hbreak start_kernel
c
tip1: yum search --showduplicate kernel-core列出某个软件包的所有版本。
tip2:uname -a查看当前系统内核的版本
tip3:yumdownloader --source kernel-core-5.14.10-300.fc35.x86_64下载软件的源rpm包
tip4: debuginfo-install kernel-core-5.14.10-300.fc35.x86_64安装软件的调试信息