Chen Zhiwei 20135125
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
Experimental guidance
Open the shell using the virtual machine of the lab building:
- CD linuxkernel/
- Qemu-kernel linux-3.18.6/arch/x86/boot/bzimage -initrd rootfs.img
Debug kernel with GDB trace
- Qemu-kernel linux-3.18.6/arch/x86/boot/bzimage -initrd rootfs.img-s -S # Description of the-s and-s options:
- #-S Freeze CPU at startup (with ' C ' to start execution)
- #-S Shorthand for-gdb tcp::1234 If you do not want to use port 1234, you can use-GDB tcp:xxxx to replace the-s option
Open another Shell window
- gdb
- file Linux-3.18.6/vmlinux # in GdB interface targe Remote before loading symbol table
- (GDB) Target remote:1234 # establish a connection between GDB and Gdbserver, press c Let Linux on Qemu continue to run
- break start_kernel # Breakpoints can be set before Target remote, or after
Understanding and experience of experimental results:
After analyzing the Start_kernel () function, I found that Start_kernel () called a series of initialization functions to complete the kernel itself. These actions are public, and others need to be configured to execute.
As the Monensin teacher said, the Start_kernel () function is equivalent to the MAIN.C function in the C language function, and Start_kernel () will persist after startup and Rest_init in Kernel_init and create process number 1th. That is, the INIT process, the first user-state process.
Construct a simple Linux system menuos