From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sourceware.org
Subject: Re: Examining thread-local storage with GDB
Date: Sat, 27 Feb 2016 18:06:00 -0000 [thread overview]
Message-ID: <1456596538.6069.9.camel@skynet.be> (raw)
In-Reply-To: <83wppqba6m.fsf@gnu.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
prev parent reply other threads:[~2016-02-27 18:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-27 12:38 Eli Zaretskii
2016-02-27 18:06 ` Philippe Waroquiers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456596538.6069.9.camel@skynet.be \
--to=philippe.waroquiers@skynet.be \
--cc=eliz@gnu.org \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox