GDB does not see any threads besides the one in which crash occurred; or SIGTRAP kills my program when 开发者_高级运维I set a breakpoint.
This frequently happen on Linux, especially on embedded targets. There are two common causes:
- you are using glibc, and you have stripped
libpthread.so.0
- mismatch between
libpthread.so.0
andlibthread_db.so.1
GDB itself does not know how to decode "thread control blocks" maintained by glibc and considered to be glibc private implementation detail. It uses libthread_db.so.1
(part of glibc) to help it do so. Therefore, libthread_db.so.1
and libpthread.so.0
must match in version and compilation flags. In addition, libthread_db.so.1
requires certain non-global symbols to be present in libpthread.so.0
.
Solution: use strip --strip-debug libpthread.so.0
instead of strip libpthread.so.0
.
If you are doing remote debugging, make sure libpthread.so.0
on target and libthread_db.so.1
on host match.
精彩评论