您的位置:首页 > 运维架构 > Linux

arm-linux-gdb+gdbserver环境搭建以及远程调试 及调试core文件

2010-02-26 17:22 791 查看
arm-linux-gdb+gdbserver环境搭建以及远程调试

这一部分的内容在网上有很多资料 。

注意是注意理解 target, host 的意思

本文主要是描述在调试用gdb 调试coredump文件时出现的问题及解决方法

我编写的一个测试用例

#include <stdio.h>

int main(void){

int man = 0;

scanf("%d",man);

return 0;

}

在pc 上面用 arm-hisi-linux-gcc 编译生成 可执行问题ttt

将ttt在arm板子上面运行的到core文件

将core文件传送回pc

在pc上面用命令sudo ./arm-hisi-linux-gdb -c /home/xiaosw/222/core /home/xiaosw/tttt

[xiaosw@localhost bin]$ sudo ./arm-hisi-linux-gdb -c /home/xiaosw/222/core /home/xiaosw/tttt

This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-hisi-linux"...

Error while mapping shared library sections:

/lib/libc.so.0: No such file or directory.

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

Symbol file not found for /lib/libc.so.0

Reading symbols from /lib/ld-uClibc.so.0...done.

Loaded symbols for /lib/ld-uClibc.so.0

Core was generated by `./tttt'.

Program terminated with signal 11, Segmentation fault.

#0 0x4003abc4 in ?? ()

显示/lib/libc.so.0库没有, 在/lib下面却是没有这个文件, 但是在我的交叉编译目录下面有,所以我用7楼的办法添加了

set solib-search-path /opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib(这个是我的pc机上面的交叉

编译环境的库的目录)

(gdb) set solib-search-path /opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib

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

Reading symbols from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0...done.

Loaded symbols for /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

Reading symbols from /lib/ld-uClibc.so.0...done.

Loaded symbols for /lib/ld-uClibc.so.0

清空以前载入的文件

(gdb) core-file

No core file now.

载入core文件

(gdb) core-file /home/xiaosw/222/core

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

Loaded symbols for /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

Loaded symbols for /lib/ld-uClibc.so.0

Core was generated by `./tttt'.

Program terminated with signal 11, Segmentation fault.

#0 0x4003abc4 in _store_inttype () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

(gdb) where

#0 0x4003abc4 in _store_inttype () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#1 0x4003e028 in __psfs_do_numeric () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#2 0x4003d6cc in vfscanf () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#3 0x4003e1c0 in scanf () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#4 0x000084b0 in main () at gdbtest.c:4

(gdb) bt

#0 0x4003abc4 in _store_inttype () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#1 0x4003e028 in __psfs_do_numeric () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#2 0x4003d6cc in vfscanf () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#3 0x4003e1c0 in scanf () from /opt/hisi-linux/x86-arm-org/gcc-3.4.3-uClibc-0.9.28/usr/arm-hisi-linux/lib/libc.so.0

#4 0x000084b0 in main () at gdbtest.c:4

(gdb)

set solib-absolute-prefix path

If this variable is set, path will be used as a prefix for any absolute
shared library paths; many runtime loaders store the absolute paths to
the shared library in the target program's memory. If you use
`solib-absolute-prefix' to find shared libraries, they need to be laid
out in the same way that they are on the target, with e.g. a `/usr/lib'
hierarchy under path. You can set the default value of
`solib-absolute-prefix' by using the configure-time `--with-sysroot'
option.

如果这一变量被设置,path
将被作为任何绝对路径共享库的前缀;许多运行时的载入器存储目标程序内存中共享库的绝对路径。如果你使用“solib-absolute-prefix”
查找共享库,它们应该和目标上有一样的路径结构,比如path下的一个“/usr/lib”的层次。

show solib-absolute-prefix

Display the current shared library prefix.

显示当前共享库前缀的配置。

set solib-search-path path

If this variable is set, path is a colon-separated list of directories
to search for shared libraries. `solib-search-path' is used after
`solib-absolute-prefix' fails to locate the library, or if the path to
the library is relative instead of absolute. If you want to use
`solib-search-path' instead of `solib-absolute-prefix', be sure to set
`solib-absolute-prefix' to a nonexistant directory to prevent GDB from
finding your host's libraries.

如果这一变量被设置,其中path
是冒号分割的用来搜索共享库的目录的列表。“solib-search-path”在“solib-absolute-prefix”定位库失败后使用,
或者库的路径是相对的,而不是绝对的。如果你想使用“solib-search-path”代替“solib-absolute-prefix”,确定
“solib-absolute-prefix”设置的是不存在的目录,以阻止 GDB 查找宿主机上的库。

show solib-search-path

Display the current shared library search path.

显示当前共享库查找路径的配置。

参考: http://wiki.chinaunix.net/index.php/GDB_Manual_15_1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: