[英]gdb: thread debugging will not be available?
I'm using gdb-7.11.1 and I get this message on my embedded powerpc system.我正在使用 gdb-7.11.1 并且在我的嵌入式 powerpc 系统上收到此消息。 Some more background, the libpthread I use has been stripped off all the non-dynamic symbols, including
nptl_version
, which libthread_db uses to make sure it is compatible with libpthread.更多的背景知识,我使用的 libpthread 已经被剥离了所有非动态符号,包括
nptl_version
, libthread_db 使用它来确保它与 libpthread 兼容。
Coming to my problem, gdb says it won't be able to debug threads, but it seemingly can as evidenced below.谈到我的问题,gdb 说它无法调试线程,但它似乎可以如下所示。 Am I simply misunderstanding what 'thread debugging' means?
我只是误解了“线程调试”的含义吗? (The ?? you see are naturally due to the missing symbol table in libpthread)
(你看到的 ?? 自然是因为 libpthread 中缺少符号表)
(gdb) break fn2
Breakpoint 1 at 0x1000052c: file test.c, line 7.
(gdb) run
Starting program: /tmp/test
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[New LWP 21312]
[New LWP 21313]
[New LWP 21314]
[New LWP 21315]
[New LWP 21316]
[New LWP 21317]
[Switching to LWP 21315]
Thread 5 hit Breakpoint 1, fn2 () at test.c:7
7 test.c: No such file or directory.
(gdb) thread apply all bt
Thread 7 (LWP 21317):
#0 0x0fdcf030 in ?? () from /lib/libpthread.so.0
#1 0x0fdc892c in pthread_mutex_lock () from /lib/libpthread.so.0
#2 0x00000000 in ?? ()
Thread 6 (LWP 21316):
#0 0x0fdcf030 in ?? () from /lib/libpthread.so.0
#1 0x0fdc892c in pthread_mutex_lock () from /lib/libpthread.so.0
#2 0x00000000 in ?? ()
Thread 5 (LWP 21315):
#0 fn2 () at test.c:7
#1 0x0fdc6d8c in ?? () from /lib/libpthread.so.0
#2 0x0fd26074 in clone () from /lib/libc.so.6
Thread 4 (LWP 21314):
#0 0x0fdcf030 in ?? () from /lib/libpthread.so.0
#1 0x0fdc892c in pthread_mutex_lock () from /lib/libpthread.so.0
#2 0x00000000 in ?? ()
Thread 3 (LWP 21313):
#0 0x0fdcf030 in ?? () from /lib/libpthread.so.0
#1 0x0fdc892c in pthread_mutex_lock () from /lib/libpthread.so.0
#2 0x00000000 in ?? ()
Thread 2 (LWP 21312):
#0 0x0fdcefdc in ?? () from /lib/libpthread.so.0
#1 0x0fdc892c in pthread_mutex_lock () from /lib/libpthread.so.0
#2 0x00000000 in ?? ()
Thread 1 (LWP 21309):
#0 0x0fd26038 in clone () from /lib/libc.so.6
#1 0x0fdc5f2c in ?? () from /lib/libpthread.so.0
#2 0x0fde6150 in ?? () from /lib/libpthread.so.0
#3 0x0fdc6424 in pthread_create () from /lib/libpthread.so.0
#4 0x100006a4 in main () at test.c:23
(gdb)
The common cause for this error message:此错误消息的常见原因:
Unable to find libthread_db matching inferior's thread library, ...
is having libpthread.so.0
that is fully stripped.具有完全剥离的
libpthread.so.0
。 Don't do that.不要那样做。
In particular, libthread_db.so
needs nptl_version
(local) symbol.特别是
libthread_db.so
需要nptl_version
(local) 符号。 You can verify whether your libpthread.so.0
has it with:你可以验证你的
libpthread.so.0
是否有它:
nm /path/to/libpthread.so.0 | grep version
which should produce something like:这应该产生类似的东西:
0000000000012cc6 r nptl_version
On Linux (at least, and others), an important part of the threading library is implemented in the kernel: that the "kernel-thread", called LWPs (for light-weight process).在 Linux(至少和其他)上,线程库的一个重要部分是在内核中实现的:即“内核线程”,称为 LWP(用于轻量级进程)。
GDB doesn't need libthread_db
help to track them, as the OS itself can give the information the key information about them: their CPU registers (mainly IP, SP, FP). GDB 不需要
libthread_db
帮助来跟踪它们,因为操作系统本身可以提供有关它们的关键信息:它们的 CPU 寄存器(主要是 IP、SP、FP)。
I'm not sure what libthread_db
provides in that context.我不确定
libthread_db
在该上下文中提供了什么。 The only thing I can think of is the LWP <-> Thread id mapping:我唯一能想到的是 LWP <-> Thread id 映射:
* 3 Thread 0x7ffff6d19700 (LWP 21571) "erato" primes_computer_runner2 (param=0x7fffffffca50) at erato.c:46
1 Thread 0x7ffff7fad700 (LWP 21565) "erato" 0x00007ffff7bc568d in pthread_join () from /usr/lib/libpthread.so.0
(gdb) print/x thread_handle
$1 = 0x7ffff6d19700
See, Thread 0x7ffff7fad700
maps to LWP 21565
.请参阅,
Thread 0x7ffff7fad700
映射到LWP 21565
。
In comparison, without libthread_db
it just gives the LWP id (in another run):相比之下,如果没有
libthread_db
它只会给出 LWP id(在另一次运行中):
* 3 LWP 22060 "erato" primes_computer_runner2 (param=0x7fffffffca50) at erato.c:46
1 LWP 22058 "erato" 0x00007ffff76037b1 in clone () from /usr/lib/libc.so.6
If you want further details about pthread_db purpose, and why it's mandatory (or something equivalent) for user and hybrid threading libraries, you can take a look at this article I wrote several years ago:如果您想了解有关 pthread_db 用途的更多详细信息,以及为什么它对用户和混合线程库是强制性的(或等效的),您可以查看我几年前写的这篇文章:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.