"Disclaimer: Copyright all, welcome reprint. Do not use for commercial purposes. Contact mailbox: feixiaoxing @163.com "
From the beginning of graduate school, I see kernel time is not short. Although the code read a lot, the principle of the book also read a lot, but always think that understanding is not very thorough. debugging kernel It is best to be able to run a single step, just like debugging a normal run file.
After using Qemu a while ago, it is really convenient to debug kernel with QEMU.
(1) Installing QEMU
sudo apt-get install QEMU-KVM
sudo apt-get install Qemu
(2) Compiling kernel
Cp/boot/config-3.8.0-19-generic. config
Make Menuconfig, save
Make Bzimage-j4
(3) file system directly using the Linux distribution's own RAM file system
Cp/boot/initrd.img-3.8.0-19-generic initrd.img
(4) Simulation kernel, start
Qemu-kernel BZIMAGE-INITRD initrd.img
(5) False assumption debugging bzimage, how to do?
Client:qemu-kernel BZIMAGE-INITRD Initrd.img-s-S
Gdb:gdb Vmlinux
Target remote:1234
b Start_kernel
C
(6) Simulation of x86 environment under dual-core
Qemu-kernel BZIMAGE-INITRD INITRD.IMG-SMP 2
QEMU uses multi-threaded methods to emulate multicore, each of which represents a core.
It's really interesting to be able to debug multi-core x86 CPUs with debugging multithreaded methods.
Random recording (QEMU emulation Linux kernel)