gdb:找不到新线程:系统更新后出现一般错误

gdb:找不到新线程:系统更新后出现一般错误,gdb,pthreads,arm,Gdb,Pthreads,Arm,我正在ARM板上运行一个基于OpenEmbedded的Linux,我的应用程序就是在这个板上运行的。我曾经运行内核2.6.35、GDB6.8和GCC4.3。最近,我将系统更新为内核2.6.37、GDB7.4(也尝试了7.3)和GCC4.6 现在,我的应用程序无法再调试(在ARM板上),每次我尝试在gdb中运行它时,都会出现错误“gdb:找不到新线程:通用错误”。该应用程序使用pthread并与pthread进行链接(readelf将libpthread.so.0列为依赖项)。到目前为止,我找到的

我正在ARM板上运行一个基于OpenEmbedded的Linux,我的应用程序就是在这个板上运行的。我曾经运行内核2.6.35、GDB6.8和GCC4.3。最近,我将系统更新为内核2.6.37、GDB7.4(也尝试了7.3)和GCC4.6

现在,我的应用程序无法再调试(在ARM板上),每次我尝试在gdb中运行它时,都会出现错误“gdb:找不到新线程:通用错误”。该应用程序使用pthread并与pthread进行链接(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),动态链接(使用共享libs),用于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
    libthread\u db.so.1
  • 您已经剥离了
    libpthread.so.0
  • 您的信息并不完全清楚:

  • 您是否使用cross GDB从x86主机调试在ARM上运行的应用程序
  • 除了更新内核等,您是否更新(或重建)了glibc
  • 如果剥离了
    libpthread.so.0
    ,则不要这样做--
    libthread\u db
    需要不剥离它

    如果要进行交叉调试,请确保在主机上重建
    libthread\u db.so.1
    ,以匹配目标上的
    glibc

    更新:

    不交叉调试
    没有剥离libpthread

    因此,您的GDB或
    glibc
    中的某些内容似乎已被破坏。你可以试着看看那是什么

  • 将删除的
    libthread\u db
    放回,然后
  • (gdb)设置调试libthread db 1
  • (gdb)运行
  • 更新2:

    警告:无法设置全局线程事件掩码:一般错误

    这意味着GDB能够在libthread_db中查找
    td_ta_set_event
    函数并调用它,但该函数返回了一个错误。如果GDB在
    libpthread.so.0
    中找不到
    \u nptl\u threads\u events
    函数,就会出现这种情况。此命令生成什么:

    nm /lib/libpthread.so.0 | grep __nptl_threads_events
    
    如果该命令产生输出,例如:

    000000000021c294 b __nptl_threads_events
    
    那么,我不确定还有什么失败的地方。您可能需要调试GDB本身以了解发生了什么


    另一方面,如果上面的
    grep
    没有输出,那么这就是你的工具链的问题:你必须弄清楚为什么这个变量没有出现在你重建的
    libpthread中。那么.0

    你有匹配的libthread数据库吗?@Guy:我重新编译了整个图像,这应该都匹配。否则,我如何检查它是否匹配?我不知道错误匹配是如何发生的,整个系统(包括glibc停留在2.9版)是从头开始重新编译的,应该匹配。我也没有剥离libpthread,也没有交叉调试。@dseifert This:
    /lib/libpthread-2.9.so:ELF 32位LSB共享对象,ARM,版本1(SYSV),动态链接(使用共享libs),对于GNU/Linux 2.6.16,未剥离
    并不一定意味着未剥离
    libpthread
    nm/lib/libpthread-2.9.so | grep _version$
    的输出是什么?这表示000118c r nptl_version尝试了您的建议,但不确定如何利用输出。我已经在问题中添加了输出。事实上,nm/grep不会产生输出。谢谢你的指点!我得检查一下这是怎么回事。