This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Examining thread-local storage with GDB
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb at sourceware dot org
- Date: Sat, 27 Feb 2016 19:08:58 +0100
- Subject: Re: Examining thread-local storage with GDB
- Authentication-results: sourceware.org; auth=none
- References: <83wppqba6m dot fsf at gnu dot org>
On Sat, 2016-02-27 at 14:38 +0200, Eli Zaretskii wrote:
> How does one display variables in TLS? I see nothing about this in
> the manual.
>
> What happened to me was that an attempt to display the value of a
> thread-local variable was responded with some confusing message like
> "No global value for this variable" (or something, I don't remember
> the exact wording and couldn't find it in the sources), and it took a
> long time (including looking at disassembly) to figure out this has
> something to do with TLS. Once I had that figured out, I still cannot
> find any way of displaying the value, though.
If gdb properly supports TLS variables on your platform, then
there is nothing special to do.
For example, here is the way you can look at the addresses and values
of a TLS variable called "global" in all threads:
(gdb) thread apply all printf "%d %p", global, &global
Thread 15 (Thread 0xb15e0b40 (LWP 6294)):
1 0xb15e0b38
Thread 14 (Thread 0xb1de1b40 (LWP 6293)):
1 0xb1de1b38
Thread 13 (Thread 0xb25e2b40 (LWP 6292)):
0 0xb25e2b38
Thread 12 (Thread 0xb2de3b40 (LWP 6291)):
0 0xb2de3b38
...
If you are remotely debugging, the gdbserver must support the packet
qGetTLSAddr.
For local debugging, I think this is the target method target_translate_tls_address
which on linux might be implemented via the thread debugging library.
Philippe