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 <grif@acm.org> 
10	 */
(gdb) 
(gdb) c
Continuing.

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






  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值