QEMU 调试内核

这个比较简单,首先,启动 qemu的时候,加上 -S -s 参数:

 qemu-system-arm -S -s -M vexpress-a9 -kernel ./linux-3.2/arch/arm/boot/zImage -sd rootfs.img --append "root=/dev/mmcblk0 rw rootfs=ext3 rootdelay=3  physmap.enabled=0  console=tty0" 
这两个参数的含义:

-S              freeze CPU at startup (use 'c' to start execution)
-s              shorthand for -gdb tcp::1234
然后,重新开一个终端窗口,启动 gdb, 连接到 tcp:1234的端口:

$ arm-linux-gnueabi-gdb vmlinux
GNU gdb (crosstool-NG linaro-1.13.1-2012.04-20120426 - Linaro GCC 2012.04) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu --target=arm-linux-gnueabi".
For bug reporting instructions, please see:
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from /home/charles/code/linux-3.2/vmlinux...done.

(gdb)  target remote localhost:1234 
Remote debugging using localhost:1234
0x60000000 in ?? ()
(gdb) 

(gdb) break  start_kernel
Breakpoint 1 at 0x8041b4f4: file init/main.c, line 468.
(gdb) list
1	/*
2	 *  linux/init/main.c
3	 *
4	 *  Copyright (C) 1991, 1992  Linus Torvalds
5	 *
6	 *  GK 2/5/95  -  Changed to support mounting root fs via NFS
7	 *  Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
8	 *  Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
9	 *  Simplified starting of init:  Michael A. Griffith <[email protected]> 
10	 */
(gdb) 
(gdb) c
Continuing.

Breakpoint 1, start_kernel () at init/main.c:468
468	{
(gdb) 






你可能感兴趣的:(QEMU 调试内核)