multithreading 无法使用 gdb 调试多线程应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11585472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to Debug Multi-Threaded Application with gdb
提问by Samuel
I am debugging a multi-threaded application with gdb, but when I start the program in gdb I get the warning:
我正在使用 gdb 调试多线程应用程序,但是当我在 gdb 中启动程序时,我收到警告:
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
警告:无法找到匹配下级线程库的libthread_db,线程调试将不可用。
I can still debug, but I can't debug anything other than the main thread. I have read forums that suggest installing the packages libthread-db1 and glibc-dbg, but this does not correct the problem for me.
我仍然可以调试,但除了主线程我不能调试任何东西。我已经阅读了建议安装软件包 libthread-db1 和 glibc-dbg 的论坛,但这并不能解决我的问题。
On my machine I have the 3 files /lib/libthread_db.so.1
, /lib/.debug/libthread_db-1.0.so
, and /lib/libthread_db-1.0.so
. I tried creating symbolic links in /lib
with the name libthread_db.so
, one time pointing at the /lib/libthread_db.so.1
file, and another time pointing at the /lib/libthread_db-1.0.so
file, and also I created the symbolic link /lib/.debug/libthread_db.so
pointing to /lib/.debug/libthread_db-1.0.so
, all with no luck.
在我的机器我有3个文件/lib/libthread_db.so.1
,/lib/.debug/libthread_db-1.0.so
和/lib/libthread_db-1.0.so
。我尝试/lib
使用 name创建符号链接libthread_db.so
,一次指向/lib/libthread_db.so.1
文件,另一次指向/lib/libthread_db-1.0.so
文件,并且我还创建了/lib/.debug/libthread_db.so
指向的符号链接/lib/.debug/libthread_db-1.0.so
,但都没有运气。
In gdb I have tried setting libthread-db-search-path
to /lib
(with the symlink once set to libthread_db.so.1
, and once to libthread_db-1.0.so
, and also set to /lib/.debug
.
在 gdb 中,我尝试设置libthread-db-search-path
为/lib
(符号链接一次设置为libthread_db.so.1
,一次设置为,libthread_db-1.0.so
还设置为/lib/.debug
.
Any suggestions? I am using Angstrom Linux v2.6.39 for the BeagleBoard-xm.
有什么建议?我为 BeagleBoard-xm 使用 Angstrom Linux v2.6.39。
回答by Employed Russian
warning: Unable to find libthread_db matching inferior's thread library
警告:无法找到与下级线程库匹配的 libthread_db
This means that your /lib/libthread_db.so.1
does not match your /lib/libpthread.so.0
. Such mismatch could be the result of you installing different versions of libc
and libthread_db
packages, or updating one or the other outside of the package management system. It could also be an error in your packages (i.e. they may not be built correctly).
这意味着/lib/libthread_db.so.1
您的/lib/libpthread.so.0
. 这种不匹配可能是由于您安装了不同版本的libc
和libthread_db
软件包,或者在软件包管理系统之外更新了一个或另一个。它也可能是您的包中的错误(即它们可能没有正确构建)。
You should ignore/lib/.debug/*
-- that is notthe library you are looking for.
你应该忽略/lib/.debug/*
——那不是你要找的图书馆。
回答by Tony K.
You are correct in trying to use
您尝试使用是正确的
set libthread-db-search-path [path]
however, it seems you have still not pointed it at a version of libthread_db that is compatible with the pthreads library you're using.
但是,您似乎仍未将其指向与您正在使用的 pthreads 库兼容的 libthread_db 版本。
First, check which pthread library you're linked to using ldd:
首先,使用 ldd 检查您链接到的 pthread 库:
ldd your_executable
then make sure the libthread-db-search-path points to a location that has a compatible version of libthread_db with whatever libpthread you're getting. It could be that you're dynamic linker path is getting a different pthread library than you expect.
然后确保 libthread-db-search-path 指向一个位置,该位置具有与您获得的任何 libpthread 兼容的 libthread_db 版本。可能是您的动态链接器路径获得了与您预期不同的 pthread 库。