qemu搭建调试环境见前面,现在已经将裸kernel起来,马上进行debug:
1. 在qemu界面,用ctrl+alt+1 或 ctrl+alt+2, 切换到qemu输出与控制页面
2. 在qemu控制页面下,输入: gdbserver 1234;(这里我总是提示 could not open device on device ‘1234’, 输入gdbserver tcp::1234就ok了!)
3. 回到shell,gdb vmlinux
提示:
This GDB was configured as “i686-linux-gnu”.
For bug reporting instructions, please see:
<
http://www.gnu.org/software/gdb/bugs/
>…
Reading symbols from /root/linux-code/linux-stable-3.8.3/vmlinux…done.
(gdb)
4. target remote 127.0.0.1:1234
显示:
Remote debugging using 127.0.0.1:1234
0x0000fff0 in ?? ()
5. 简单的一个测试:
(gdb) b start_kernel
Breakpoint 1 at 0xc164662b: file init/main.c, line 469.
(gdb) i b