Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Dmitry Antipov <dantipov@nvidia.com>
Cc: GDB Development <gdb@sourceware.org>
Subject: Re: Printing thread_local a.k.a. __thread variables
Date: Mon, 12 Feb 2018 14:02:00 -0000	[thread overview]
Message-ID: <CAH=s-PP8rg3YxP1uO-PiXa1WJhM4+ks8Z3=TwKJuCmqUBdxULg@mail.gmail.com> (raw)
In-Reply-To: <780169f5-fa63-3357-ed78-a3045991c307@nvidia.com>

On Mon, Feb 12, 2018 at 1:29 PM, Dmitry Antipov <dantipov@nvidia.com> wrote:
> I just tried the recent git snapshot (on x86 GNU/Linux) and always seeing
> 100 for 'tlocal' variable. Compiled wit GCC 7.3, -O0 -g3, regardless of
> -gdwarf-4 default or -gdwarf-5. Am I doing wrong something?
>

Because you are in thread 1, main thread, in which tlocal is not changed.
If you switch to other threads, you'll see the right value of tlocal.

Thread 1 "2.exe" received signal SIGINT, Interrupt.
0x00007ffff7bc565b in pthread_join () from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) p tlocal
$1 = 100
(gdb) thread 2
[Switching to thread 2 (Thread 0x7ffff6fc6700 (LWP 29726))]
#0  0x00007ffff7bcbb9d in nanosleep () from
/lib/x86_64-linux-gnu/libpthread.so.0
(gdb) p tlocal
$2 = 104
(gdb) thread 4
[Switching to thread 4 (Thread 0x7ffff5fc4700 (LWP 29728))]
#0  0x00007ffff7bcbb9d in nanosleep () from
/lib/x86_64-linux-gnu/libpthread.so.0
(gdb) p tlocal
$4 = 112
(gdb) thread apply all print tlocal

Thread 9 (Thread 0x7ffff37bf700 (LWP 29733)):
$5 = 148

Thread 8 (Thread 0x7ffff3fc0700 (LWP 29732)):
$6 = 121

Thread 7 (Thread 0x7ffff47c1700 (LWP 29731)):
$7 = 124

Thread 6 (Thread 0x7ffff4fc2700 (LWP 29730)):
$8 = 110

Thread 5 (Thread 0x7ffff57c3700 (LWP 29729)):
$9 = 112

Thread 4 (Thread 0x7ffff5fc4700 (LWP 29728)):
$10 = 112

Thread 3 (Thread 0x7ffff67c5700 (LWP 29727)):
$11 = 108

Thread 2 (Thread 0x7ffff6fc6700 (LWP 29726)):
$12 = 104

Thread 1 (Thread 0x7ffff7fca780 (LWP 29722)):
$13 = 100

-- 
Yao (齐尧)


  reply	other threads:[~2018-02-12 14:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 13:30 Dmitry Antipov
2018-02-12 14:02 ` Yao Qi [this message]
2018-02-12 14:15   ` Dmitry Antipov
2018-02-12 14:54     ` Yao Qi
2018-02-13  7:55       ` Dmitry Antipov
2018-02-13  9:19         ` Yao Qi

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='CAH=s-PP8rg3YxP1uO-PiXa1WJhM4+ks8Z3=TwKJuCmqUBdxULg@mail.gmail.com' \
    --to=qiyaoltc@gmail.com \
    --cc=dantipov@nvidia.com \
    --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