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: Printing thread_local a.k.a. __thread variables


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 (齐尧)


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