Force gdb to use provided thread lib

Asked by At

I have an embedded ARM application which is bundled with all the so-libraries stripped, including the 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/
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.

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.

1 Answers

Employed Russian On Best Solutions

Is there any way to bypass the error?

A few ways that come to mind:

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

    (gdb) info shared # shows the path and memory address where stripped is loaded (gdb) add-symbol-file /path/to/unstripped/ $address # should override with new symbols, and attempt to re-load

  2. 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/, there should be /path/to/unstripped/lib/

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

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