强制gdb使用提供的线程库 [英] Force gdb to use provided thread lib

查看:140
本文介绍了强制gdb使用提供的线程库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌入式ARM应用程序,该应用程序与所有剥离的so-libraries(包括libpthread.so)捆绑在一起.有时,应用程序陷入了代码的某些部分,我希望能够通过gdb附加到它,并查看发生了什么.问题是gdb拒绝加载所需的线程支持库,并显示以下消息:

I have an embedded ARM application which is bundled with all the so-libraries stripped, including the libpthread.so. Sometimes the application gets stuck in some part of code and I want to be able to attach to it with gdb and see what's going on. The problem is that gdb refuses to load the needed threading support library, with the following messages:

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编译的,可以在设备本身上运行.我已经解压了库的版本,但是应用程序已经在与被剥离的库一起运行.

Because of this I cannot debug the application, e.g. I cannot see current call stacks for all threads. After some investigation I suspect that the td_ta_new failing with the application not linked with libthread is caused by the stripped version of libpthread, which lacks the nptl_version symbol. Is there any way to bypass the error? The gdb is compiled for ARM and being run on the device itself. I have unstripped versions of the libraries, but the application is already running with the stripped libraries.

推荐答案

有什么办法可以绕过错误?

Is there any way to bypass the error?

想到的几种方法:

  1. 使用add-symbol-file用未剥离的一个覆盖已剥离的libpthread.so.0:

  1. Use add-symbol-file to override the stripped libpthread.so.0 with un-stripped one:

(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

(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

运行gdb -ex 'set sysroot /path/to/unstripped' ...,其中/path/to/unstripped是反映已安装树的路径(也就是说,如果使用/lib/libpthread.so.0,则应该为/path/to/unstripped/lib/libpthread.so.0.

Run gdb -ex 'set sysroot /path/to/unstripped' ... where /path/to/unstripped is the path that mirrors installed tree (that is, if you are using /lib/libpthread.so.0, there should be /path/to/unstripped/lib/libpthread.so.0.

我还没有测试过,但是我认为它应该可以工作.

I have not tested this, but I believe it should work.

您可以注释掉GDB中的版本检查并重新构建.

You could comment out the version check in GDB and rebuild it.

这篇关于强制gdb使用提供的线程库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆