gdb查看嵌入式core文件的问题

luanxushen 2014-08-06 02:01:34
Hi,板上的大牛们,本人目前由于一个偶发的bug(可能十多天才出一次)需要对嵌入式进程进行调试,因此用到了core dump功能,但是在使用过程中遇到了下列问题,网上查了好多方法还是无法解决,因此在版上请教一下。

为了使用core文件,本人首先在主机linux做了测试(特意做了一个崩溃的进程例子),具体如下:
源代码:

#include <stdio.h>
int main(){
printf("this is a test\n");
int i= 10/0;
return 0;
}

在主机上进行编译:
gcc -g main.c -o main
运行结果:
this is a test
Floating point exception (core dumped)
执行gdb ./main core后:
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/wangwei/dm365/MyDoc/test/main...done.
[New Thread 4048]

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./main'.
Program terminated with signal 8, Arithmetic exception.
#0 0x0804840b in main () at main.c:4
4 int i= 10/0;


红色部分可以看出通过gdb将core文件正常读出,下面进行嵌入式版本测试,源代码同上。
交叉编译:
arm-none-linux-gnueabi-gcc -g main.c -o main
在嵌入式上运行:
root@dm365-evm:/home/test# ./main
this is a test
Floating point exception (core dumped)
将./main和core拷贝到主机上,执行gdb ./main core查看
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 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 "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/wangwei/dm365/MyDoc/test/main...done.

warning: Couldn't find general-purpose registers in core file.

warning: .dynamic section for "/lib/libgcc_s.so.1" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
Error while mapping shared library sections:
/lib/ld-linux.so.3: No such file or directory.
Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Symbol file not found for /lib/ld-linux.so.3

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Core was generated by `./main'.

warning: Couldn't find general-purpose registers in core file.
#0 0x00000000 in ?? ()

如上红色部分,查看core文件失败;
根据上面的提示,我的理解是否是gdb需要用到嵌入式下的库文件?或者需要嵌入式版的gdb来查看?请大神们指点,万分感激。
...全文
1397 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
CLANNADZY 2015-09-05
  • 打赏
  • 举报
回复
今天正好也再搞调试,楼主不能用X86的GDB调试并加载ARM的程序和ARM的CORE DUMP. 要用arm-linux-gdb的,这是个运行在x86下的调试ARM程序的gdb,能从gdb源码编译处理的
luanxushen 2014-08-06
  • 打赏
  • 举报
回复
2楼正解,原gdb的target architecture是i386,我后来改用arm-linux-gdb后target architecture为arm,这样就可以了,终于见到debug信息了
帅得不敢出门 2014-08-06
  • 打赏
  • 举报
回复 3
gdb不对,如果是arm的需要arm-linux-gdb
zhxianbin 2014-08-06
  • 打赏
  • 举报
回复
要远程调试,google 远程调试 http://my.oschina.net/shelllife/blog/167914

18,829

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧