public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Examining thread-local storage with GDB
@ 2016-02-27 12:38 Eli Zaretskii
  2016-02-27 18:06 ` Philippe Waroquiers
  0 siblings, 1 reply; 2+ messages in thread
From: Eli Zaretskii @ 2016-02-27 12:38 UTC (permalink / raw)
  To: gdb

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.

What am I missing?

TIA

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Examining thread-local storage with GDB
  2016-02-27 12:38 Examining thread-local storage with GDB Eli Zaretskii
@ 2016-02-27 18:06 ` Philippe Waroquiers
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Waroquiers @ 2016-02-27 18:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-27 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-27 12:38 Examining thread-local storage with GDB Eli Zaretskii
2016-02-27 18:06 ` Philippe Waroquiers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).