gdbでUnable to find libthread_db matching inferior's thread libraryという警告がでる

メモ。

gdbを使おうとした時に以下の様なエラーがでてgdbでデバッグできない場合は、libpthreadやlibthread_dbがstripされていることが原因。

libpthreadやlibthread_dbを生成するクロスコンパイル環境の設定で、これらのライブラリからデバッグ情報を取り除かない設定してビルドしなおすとデバッグできるようになります(glibcの生成段階のオプションになっていることがあります)。

1
2
3
4
5
6
7
8
9
Starting program: sample_program_desu
Trying host libthread_db library: /lib/libthread_db.so.1.
td_ta_new failed: application not linked with libthread
thread_db_load_search returning 0
Cannot access memory at address 0x0
Trying host libthread_db library: /lib/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

fileコマンドでlibpthreadの状態を確認すると、stripされていることがわかります。

1
2
3
file /lib/libpthread-x.xx.so
/lib/libpthread-x.xx.so: ELF 32-bit LSB shared object,
ARM, EABI5 version 1 (SYSV), dynamically linked, for GNU/Linux x.xx.xx, stripped