我的问题就是:如何解决gdb breakpoint功能不能用的问题?
大家讨论讨论!
_______________________________________________
Linux 内核开发中文邮件列表
Linux-...@zh-kernel.org
http://zh-kernel.org/mailman/listinfo/linux-kernel
Linux 内核开发中文社区: http://zh-kernel.org
然后在包含内核源码(我是在真机上用该源码编译,然后把整个源码文件夹
拷贝到虚拟机下make modules_install, make install. 再做个initrd.img)的文件夹下
运行gdb就可以了。
你的情况是不是在运行gdb的目录下没有内核源码?
2008/8/7 周超 <pirates...@gmail.com>:
$ arm-linux-gdb vmlinux
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-cygwin --target=arm-linux"...
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x00000000 in ?? ()
warning: shared library handler failed to enable breakpoint//这就是之前提到的警告信息
(gdb) step
Cannot find bounds of current function//step不能用
(gdb) s
Cannot find bounds of current function
(gdb) list//可以list代码
1 /*
2 * linux/arch/arm/kernel/head.S
3 *
4 * Copyright (C) 1994-2002 Russell King
5 * Copyright (c) 2003 ARM Limited
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or
modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
(gdb) break start_kernel
Breakpoint 1 at 0xc000895c: file init/main.c, line 512.//这里显示breakpoint设置成功
(gdb) c
Continuing.//但是并没有执行到start_kernel()的时候break,QEMU顺利完成启动过程
还有,你说的那个"把整个源码文件夹拷贝到虚拟机下make modules_install, make
install.",这是什么意思?你没有表达不够明白还是我能力有限没有看懂,可否请你再讲一下。谢谢!
2008/8/7 sniper <s3c...@gmail.com>
我的意思是: 在真机上编译源码,然后把源码连同编译好出来的文件全部拷贝到虚拟机中的
系统下进行内核安装。 全部拷贝只是为了方便和不搞乱真机的系统。
你以前进行过利用kgdb(不是你现在这个方法)的调试吗?那种利用kgdb调试的方法是不是和
我的方法一样的?
你现在的方法是绕过了kgdb,是传说中的什么什么"模拟硬件调试"?
我其实很摸不着头脑,也不知道我的方法到底是利用了kgdb 还是"模拟硬件调试",还够用,
就没有深究其他的东西。再罗嗦一下:我的方法是步骤:
1. 利用qemu安装一个系统.
2. 给qemu的虚拟系统安装一个新的内核,同时在真机下保留新内核的源码和编译文件。
3. 在真机新内核源码目录下建立一个文件 .gdbinit 内容是
target remote localhost:1234
b start_kernel
c
4启动虚拟机 qemu -hda debian.img -cdrom ../debian-testing-i386-CD-1.iso -m 500 -S -s
5在真机新内核源码目录下运行 gdb ./vmlinux
下面这些网上提到的乱七八糟的东西,我都没有手动设置到
qemu ${QEMU_ARGS} \
-kernel "$VMLINUZ" \
-append "${KERNEL_CMDLINE} kgdboc=ttyS0,115200 kgdbwait" \
-serial tcp::${KGDB_TCPPORT},server \
-hda "${QEMU_HDA}" >/dev/null &
(gdb) set remotebaud 115200
连接目标
(gdb) target remote tcp:localhost:${KGDB_TCPPORT}
我主要参考了下面这三个网页。
http://memyselfandtaco.blogspot.com/2008/06/debugging-linux-kernel-without-kgdb.html
http://forum.ubuntu.org.cn/viewtopic.php?t=46999&start=0&postdays=0&postorder=asc&highlight=
http://blog.chinaunix.net/u/8057/showart_1087126.html