Linux kernel code debugging is very cumbersome, usually add printk, or with Jtag debugging. The method here is to use QEMU to debug the Linux kernel. Because QEMU implements a GDB server itself, it is very convenient to use GDB to tune the kernel.
This is also very helpful for learning from the kernel.
To minimize the time spent on QEMU settings, use the following kernel image directly:
http://free-electrons.com/community/demos/qemu-arm-directfb/
Installation of 1,qemu
This can go to Qemu's official website to download the compilation, if you have a distribution on hand with the corresponding QEMU package, it can also be installed directly.
CentOS Word reference in front of CentOS rpm additional package source
2. Download the corresponding kernel image
Download from: http://free-electrons.com/pub/qemu/demos/arm/directfb/1.0/There's a vmlinuz-qemu-arm-2.6.20 in there.
3, start QEMU
Start with the following command:
$ qemu-system-arm-m versatilepb-m 16-kernel vmlinuz-qemu-arm-2.6.20-append "Clocksource=pit quiet rw"-s-s
4, Debug kernel
This requires a Vmlinux file containing debug information, which can be compiled directly http://free-electrons.com/pub/qemu/demos/arm/directfb/1.0/src/linux-2.6.20.tar.7z
If you do not want to compile, you can use a compiled Vmlinux file.
Then execute the following command:
$ arm-none-linux-gnueabi-gdb Vmlinux
In the GDB console, enter:
(GDB) Target remote:1234
(GDB) B start_kernel
(GDB) C
At this point the program execution will fall on the breakpoint Start_kernel you set. Ok. Then you can debug the kernel code at will!
More wonderful Linux video tutorials at 51CTO Academy: http://edu.51cto.com/course/courseList/id-48.html