Use Qemu and Gdb debug the kernel
Author: wugsh15
Review:
Date: 2015-12-18
Expires: 2015-12-18
Keywords: qemu gdb kernel
Ref: http://blog.csdn.net/silangquan/article/details/9090915 http://www.jianshu.com/p/6d3ae604b4cf
1. Ready to work : apt-get install vim cscope exuberant-ctags build-essential qemu
2. Download linux kernel and compiling it, when "make menuconfig" you must selected the options "Compile the kernel with debug info" and "Compile the kernel with frame pointers" in the project of "Kernel hacking" and usethe command " make -j* bzImage" compiling the kernel. * means the number of cores.
3. In the terminal use the command "qemu -S -kernel /arch/x86/boot/bzImage" start qemu. Then use "ctrl+alt+2" jump the console panel of qemu in the qemu's panel input the command "gdbserver tcp::1234" meaning that start gdbserver and monitor the port(1234) of tcp.
4. Open a new terminal input "gdb":
(gdb)file vmlinux # loading the symbol table.
(gdb)target remote:1234 # building the link between gdb and gdbserver.
(gdb)break start_kernel # set a breakpoint at start_kernel int the kernel.
(gdb)c #continue the program.
5. If you want to view other functions, you can do like the step of 4.
Author: wugsh15
Review:
Date: 2015-12-18
Expires: 2015-12-18
Keywords: qemu gdb kernel
Ref: http://blog.csdn.net/silangquan/article/details/9090915 http://www.jianshu.com/p/6d3ae604b4cf
1. Ready to work : apt-get install vim cscope exuberant-ctags build-essential qemu
2. Download linux kernel and compiling it, when "make menuconfig" you must selected the options "Compile the kernel with debug info" and "Compile the kernel with frame pointers" in the project of "Kernel hacking" and usethe command " make -j* bzImage" compiling the kernel. * means the number of cores.
3. In the terminal use the command "qemu -S -kernel /arch/x86/boot/bzImage" start qemu. Then use "ctrl+alt+2" jump the console panel of qemu in the qemu's panel input the command "gdbserver tcp::1234" meaning that start gdbserver and monitor the port(1234) of tcp.
4. Open a new terminal input "gdb":
(gdb)file vmlinux # loading the symbol table.
(gdb)target remote:1234 # building the link between gdb and gdbserver.
(gdb)break start_kernel # set a breakpoint at start_kernel int the kernel.
(gdb)c #continue the program.
5. If you want to view other functions, you can do like the step of 4.