我正在 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 位 LSB 共享对象,ARM,版本 1 (SYSV),动态链接(使用共享库),适用于 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
导致此错误的常见原因有两个:
- 您之间不匹配
libpthread.so.0
and libthread_db.so.1
- 你已经脱光了
libpthread.so.0
您的消息并不完全清楚:
- 您是否使用跨 GDB 从 x86 主机调试在 ARM 上运行的应用程序?
- 你更新(或重建)了吗
glibc
除了更新内核等。
如果你脱光了libpthread.so.0
, then 不要那样做 -- libthread_db
需要它not剥离。
如果您正在交叉调试,请确保重建libthread_db.so.1
在主机上进行匹配glibc
估计的正好。
Update:
不交叉调试
没有剥离 libpthread
所以,你的 GDB 或glibc
似乎已经坏了。你可以尝试看看那是什么
- 放置移除
libthread_db
回来,和
(gdb) set debug libthread-db 1
(gdb) run
更新2:
警告:无法设置全局线程事件掩码:一般错误
这意味着 GDB 能够查找td_ta_set_event
libthread_db 中的函数,并调用它,但该函数返回错误。发生这种情况的一种可能是 GDB 无法找到__nptl_threads_events
函数于libpthread.so.0
。该命令会产生什么结果:
nm /lib/libpthread.so.0 | grep __nptl_threads_events
如果该命令产生输出,例如:
000000000021c294 b __nptl_threads_events
然后我不确定还有什么失败了。您可能必须调试 GDB 本身才能弄清楚发生了什么。
如果另一方面grep
上面没有产生输出,那么这是你的工具链的问题:你必须弄清楚为什么该变量没有出现在你的重建中libpthread.so.0
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)