gdb core文件函数出现问号

本文详细介绍了在Linux PC上使用arm-linux-gdb调试ARM架构程序时遇到的问题,包括核心转储文件分析、库加载失败、版本不匹配等,并提供了针对性的解决方案。通过设置共享库加载路径,最终成功定位并解决了程序崩溃问题。

原创地址 http://blog.youkuaiyun.com/yudingding6197/article/details/5528989


我的程序crash,有了coredump文件,在Linux PC上用arm-linux-gdb debug it. The result is:

#0  0x4022b178 in ?? ()
(gdb) bt
#0  0x4022b178 in ?? ()
#1  0x4022b134 in ?? ()
#2  0x4022b134 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
why? I can't locate the correct location, find the really reason.

看看加载的内容

GNU gdb 6.6
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-linux-gnu --target=arm-linux"...

warning: core file may not match specified executable file.

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

warning: .dynamic section for "/lib/libpthread.so.0" is not at the expected address (wrong library or version mismatch?)
Error while mapping shared library sections:
/lib/libstdc++.so.6: No such file or directory.

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

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?)

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

warning: .dynamic section for "/lib/libnss_files.so.2" is not at the expected address (wrong library or version mismatch?)
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Symbol file not found for /lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Core was generated by `./6800plusEth.bin'.
Program terminated with signal 11, Segmentation fault.

一些库找不到(/lib/libstdc++.so.6),或者版本不匹配。我不应该加载/lib/libdl..so.... 这些文件,这是针对X86的。

所以两个命令至关重要:

set solib-absolute-prefix -- Set prefix for loading absolute shared library symbol files
set solib-search-path -- Set the search path for loading non-absolute shared library symbol files

比如:set solib-... /usr/local/arm-linux/arm-linux/lib/, 两个参数的值一样就可以了。

先启动arm-linux-gdb,设置变量以后,via core-file load core dump file to analyze it.

#gdb

#set solib-absolute-prefix "library path"

#set solib-search-path "library path"

#file file.debug

#core-file core.1234

但是还是不能准确定位,查询embedded linux版本:

uname -a

ls -l /usr/arm-linux/gcc-3.4.1-glibc-2.3.3/arm-linux/lib/libc-2.3.3.so

Linux PC上的呢:

ll /usr/local/arm/3.4.1/arm-linux/lib/libc-2.3.2.so

原来库文件不对,一个是2.3.3,另一个是2.3.2,此时发现版本匹配是至关的重要啊!!

换了一个Linux PC,它的交叉编译环境是2.3.3

哈哈!立即定位到了错误的原因!!


转载于:https://my.oschina.net/miffa/blog/402291

### 如何解决 GDB 调试 Core 文件时出现问号的问题 当使用 GDB 调试 core 文件时,如果函数名显示为问号,通常是因为缺少必要的调试信息或配置不当。以下是几种可能的解决方案: #### 方法一:确保编译时加入 `-g` 选项 为了使 GDB 正确解析程序中的符号信息,在编译源码时应加上 `-g` 参数以包含调试信息。 ```bash gcc -g program.c -o program ``` 这一步骤能确保生成的目标文件中包含了足够的调试数据[^1]。 #### 方法二:指定可执行文件路径 有时仅通过 `gdb -c core` 命令启动可能会导致问题,建议显式提供对应的可执行文件作为参数给 GDB: ```bash gdb ./executable_file_path core_dump_file_name ``` 此方式有助于 GDB 更好地关联核心转储与原始应用程序之间的关系[^3]。 #### 方法三:设置共享库路径 对于依赖外部共享库的应用而言,若这些库不在标准位置,则需告知 GDB 它们的具体所在之处。可以通过环境变量 `LD_LIBRARY_PATH` 或者在 GDB 中运行以下指令来实现这一点: ```bash set solib-search-path /path/to/shared/libraries ``` 这样做可以防止因找不到合适的动态链接器而导致的信息缺失情况发生[^5]。 #### 方法四:验证并安装匹配版本的开发包 某些情况下,操作系统更新后可能导致旧版应用与其新内核不兼容,进而影响到 GDB 的正常工作。此时应当确认已安装了对应发行版下的所有必要开发工具链组件,并保持其处于最新状态。 以上措施结合起来往往能够有效改善甚至彻底消除 GDB 在处理 core dump 期间所遭遇的各种异常现象。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值