This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Examining thread-local storage with GDB


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]