我正在运行我的应用程序的 ARM 板上运行基于 OpenEmbedded 的 Linux。我曾经运行内核 2.6.35、gdb 6.8 和 gcc 4.3。最近我将系统更新到内核 2.6.37、gdb 7.4(也尝试过 7.3)和 gcc 4.6。
现在,我的应用程序无法再被调试(在 ARM 板上),每次我尝试在 gdb 中运行它时,我都会收到错误“gdb:找不到新线程:通用错误”。该应用程序使用 pthreads 并链接 pthreads(readelf 将 libpthread.so.0 列为依赖项)。到目前为止,我发现的建议解决方案都建议链接到我已经在做的 pthread。我发现的另一个建议是使用 LD_PRELOAD=/lib/libpthread.so.0 这对我没有任何影响。
调试应用程序的 x86 版本没有问题。
编辑:为了回答第一个答案中提出的问题,我在目标(ARM)上使用 gdb,即没有跨 gdb。我也没有剥离 libpthread.so.0 (/lib/libpthread-2.9.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamiclinked (uses shared libs), for GNU/Linux 2.6. 16,未剥离)。glibc 保持在 2.9 版本,更新涉及重新编译整个 linux 映像
EDIT2:删除 /lib/libthread-db* 允许调试(随之而来的警告和显然某些功能将不起作用)
EDIT3:使用 set debug libthread-db 1 我得到:
Starting program: /home/root/app
Trying host libthread_db library: libthread_db.so.1.
Host libthread_db.so.1 resolved to: /lib/libthread_db.so.1.
td_ta_new failed: application not linked with libthread
thread_db_load_search returning 0
Trying host libthread_db library: libthread_db.so.1.
Host libthread_db.so.1 resolved to: /lib/libthread_db.so.1.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
warning: Unable to set global thread event mask: generic error
Warning: find_new_threads_once: find_new_threads_callback: cannot get thread info: generic error
Found 0 new threads in iteration 0.
Warning: find_new_threads_once: find_new_threads_callback: cannot get thread info: generic error
Found 0 new threads in iteration 1.
Warning: find_new_threads_once: find_new_threads_callback: cannot get thread info: generic error
Found 0 new threads in iteration 2.
Warning: find_new_threads_once: find_new_threads_callback: cannot get thread info: generic error
Found 0 new threads in iteration 3.
thread_db_load_search returning 1
Warning: find_new_threads_once: find_new_threads_callback: cannot get thread info: generic error
Found 0 new threads in iteration 0.
Cannot find new threads: generic error
(gdb) Write failed: Broken pipe