Selecting the correct thread debugging library¶
libthread_db.so
is a library used to extract thread information from
programs by parsing the memory of libpthread.so
which is linked into
multithreaded programs. This is needed when reading from thread-local storage,
such as the errno
variable.
The Linux thread debugging API requires that, when debugging a program using pthreads,
the debugger has a compatible libthread_db.so that is able to inspect the pthread
library’s internal data structures. When loading a recording on a machine with an
incompatible libthread_db.so
, errors may be seen when attempting to view
thread-local variables:
12% 12,345> p errno
Cannot find thread-local storage for Thread 7615.7615, shared library /lib/x86_64-linux-gnu/libc.so.6:
Remote target failed to process qGetTLSAddr request
UDB incorporates two mechanisms to ensure that a libthread_db.so
that is compatible with
a given recording is available.
Automatic use of libthread_db from recordings¶
An Undo recording includes the libthread_db.so
library (if any) from
the system on which the recording was made. When UDB loads the recording, it
extracts the library, and calls its functions when it needs to analyze
thread-local storage in the recorded program.
Warning
The functions from the loaded libthread_db.so
are executed directly, and not
via UDB’s replay engine, as if UDB had been executed on the machine where the
recording was made.
To prevent UDB from executing the libthread_db.so
from the recording, and to
execute the libthread_db.so
on the machine where the recording is being
replayed, use the --thread-db
option with the special value
local
, or set the UNDO_thread_db
environment variable to this value.
For example:
$ udb --thread-db local my_recording.undo
New in version 8.0.
Explicit libthread_db selection¶
When replaying a recording, UDB uses the libthread_db.so
from the
recording, if any. If the recording does not contain a copy of libthread_db.so
(either because the recording is too old to contain one, or because
libthread_db.so
was not found at record time), then UDB uses the
libthread_db.so
found on the machine where the recording is being replayed.
However, the local libthread_db.so
may not be compatible with the recording.
If there is an incompatibility, UDB will produce error messages when
attempting to inspect thread-local state:
Remote target failed to process qGetTLSAddr request
To use an alternative libthread_db.so
, use the
--thread-db
option or set the environment
variable UNDO_thread_db
.
For example, using the command-line parameter:
$ udb --thread-db $SDK/lib/libthread_db.so my_recording.undo