强制gdb使用提供的线程lib

问题描述 投票:2回答:1

我有一个嵌入式ARM应用程序,它捆绑了所有被剥离的库,包括libpthread.so。有时应用程序卡在代码的某些部分,我希望能够使用gdb附加到它,看看发生了什么。问题是gdb拒绝加载所需的线程支持库,并带有以下消息:

Trying host libthread_db library: /home/me/debug_libs/libthread_db.so.1.
td_ta_new failed: application not linked with libthread
thread_db_load_search returning 0
warning: Unable to find libthread_db matching inferior's thread 
library, thread debugging will not be available.

因此,我无法调试应用程序,例如我无法看到所有线程的当前调用堆栈。经过一些调查后,我怀疑td_ta_newapplication not linked with libthread失败是由剥离版本的libpthread引起的,缺少nptl_version符号。有没有办法绕过错误? gdb是为ARM编译的,并在设备本身上运行。我有未解压缩的库版本,但应用程序已经与剥离的库一起运行。

gdb
1个回答
1
投票

有没有办法绕过错误?

想到几种方式:

  1. 使用add-symbol-file覆盖剥离的libpthread.so.0与未剥离的: (gdb) info shared libpthread.so # shows the path and memory address where stripped libpthread.so.0 is loaded (gdb) add-symbol-file /path/to/unstripped/libpthread.so.0 $address # should override with new symbols, and attempt to re-load libthread_db.so.1
  2. 运行gdb -ex 'set sysroot /path/to/unstripped' ...,其中/path/to/unstripped是镜像已安装树的路径(也就是说,如果你使用/lib/libpthread.so.0,应该有/path/to/unstripped/lib/libpthread.so.0。 我没有对此进行测试,但我相信它应该可行。
  3. 您可以在GDB中注释掉版本检查并重建它。
© www.soinside.com 2019 - 2024. All rights reserved.