Chinaunix首页 | 论坛 | 博客
  • 博客访问: 580291
  • 博文数量: 353
  • 博客积分: 1104
  • 博客等级: 少尉
  • 技术积分: 1457
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-23 23:02
个人简介

1、刚工作时做Linux 流控;后来做安全操作系统;再后来做操作系统加固;现在做TCP 加速。唉!没离开过类Unix!!!但是水平有限。。

文章存档

2015年(80)

2013年(4)

2012年(90)

2011年(177)

2010年(1)

2009年(1)

分类: LINUX

2011-10-26 20:31:49

http://hi.baidu.com/lijunzzu/blog/item/934d35f020d6e2d87931aa9b.html

gdb调试内核是在target machine还没有启动起来的时候就开始调试!!!!(即target machine还没有进入系统的时候)

用development machine 调试target machine 。

target machine:龙芯2F

development machine:X86

错误1:

(gdb) set remotebaud 9600
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Malformed response to offset query, timeout

这种错误,是因为串口已经被占用,或者是因为你刚结束了一个gdb串口调试,没有重启target machine,却又重新串口gdb调试导致的。这种错误归结一点就是:串口已经被占用解决办法:重启target machine,重新进行gdb调试,即可解决!

注:如果使用vmware虚拟机调试,且使用有名管道,有可能需要重新创建二个机器(client,server)间使用的管道



错误2:

target machine能insmod模块,也能停下来,但是development machine不能正常返回到gdb调试状态,如下所示:

root@lijun-HP-Compaq-dx2308-Microtower:/home/lijun/kernel_Compile/linux-2.6.35_Loongson/linux-2.6.35_patched# mips-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=x86_64-unknown-linux-gnu --target=mips-linux"...
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
0xffffffff80231aac in breakinst () at arch/mips/kernel/kgdb.c:55
55        __asm__ __volatile__(
warning: shared library handler failed to enable breakpoint
(gdb) c
Continuing.
^Z
[4]+  已停止               mips-linux-gdb vmlinux
一直在上面红色字体处没反应了,用stty测试串口时发现,development machine在接收数据的时候,target machine发好几条数据,development machine才能收到一条(但是这边往那边发数据正常),最后发现,这种错误的原因是因为数据的丢失。把原来传输的波特率调低一点,就可以解决这种错误了(我原来设的波特率是115200,改成9600就解决问题了)。



正确执行的结果如下:

root@lijun-HP-Compaq-dx2308-Microtower:/home/lijun/kernel_Compile/linux-2.6.35_Loongson/linux-2.6.35_patched# mips-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=x86_64-unknown-linux-gnu --target=mips-linux"...
(gdb) set remotebaud 9600
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
0xffffffff80231aac in breakinst () at arch/mips/kernel/kgdb.c:55
55        __asm__ __volatile__(
warning: shared library handler failed to enable breakpoint
(gdb) b kernel/module.c:2118
Breakpoint 1 at 0xffffffff80284e04: file kernel/module.c, line 2118.
(gdb) b kernel/module.c:2173
Breakpoint 2 at 0xffffffff802845b4: file kernel/module.c, line 2173.
(gdb) b kernel/module.c:2195
Breakpoint 3 at 0xffffffff80284670: file kernel/module.c, line 2195.
(gdb) c
Continuing.
[New thread 1782]
[Switching to thread 1782]

Breakpoint 2, load_module (umod=, len=33532, uargs=0x414008 "")
    at kernel/module.c:2173
2173        for (i = 1; i < hdr->e_shnum; i++) {
(gdb)

然后就可一随意调试了!

阅读(3075) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~