This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Printing thread_local a.k.a. __thread variables
- From: Dmitry Antipov <dantipov at nvidia dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: GDB Development <gdb at sourceware dot org>
- Date: Tue, 13 Feb 2018 10:55:13 +0300
- Subject: Re: Printing thread_local a.k.a. __thread variables
- Authentication-results: sourceware.org; auth=none
- References: <780169f5-fa63-3357-ed78-a3045991c307@nvidia.com> <CAH=s-PP8rg3YxP1uO-PiXa1WJhM4+ks8Z3=TwKJuCmqUBdxULg@mail.gmail.com> <d771ca32-606c-8b27-8914-46a7e9d9cb48@nvidia.com> <CAH=s-PNASvb9R+W56rnodENxi-bJM9sGU_4XRhTLuDYfXx=H=A@mail.gmail.com>
On 02/12/2018 05:54 PM, Yao Qi wrote:
... is it broken in every threads in "thread apply all" or just in some
threads? Can you reproduce it every time or it is intermittent?
If you manually switch threads via command "thread N", can
you examine 'tlocal'?
It seems that 'qGetTLSAddr' fails every time for any thread in question:
(gdb) info threads
Id Target Id Frame
* 1 Thread 19378.19378 "t-thread" 0x00007f62ae10b89d in pthread_join () from target:/lib64/libpthread.so.0
2 Thread 19378.19379 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
3 Thread 19378.19380 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
4 Thread 19378.19381 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
5 Thread 19378.19382 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
6 Thread 19378.19383 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
7 Thread 19378.19384 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
8 Thread 19378.19385 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
9 Thread 19378.19386 "worker" 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
(gdb) print tlocal
Cannot find thread-local storage for Thread 19378.19378, executable file target:/home/dantipov/tmp/t-thread:
Remote target failed to process qGetTLSAddr request
(gdb) thread 2
[Switching to thread 2 (Thread 19378.19379)]
#0 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
(gdb) print tlocal
Cannot find thread-local storage for Thread 19378.19379, executable file target:/home/dantipov/tmp/t-thread:
Remote target failed to process qGetTLSAddr request
(gdb) thread 3
[Switching to thread 3 (Thread 19378.19380)]
#0 0x00007f62ae11499d in nanosleep () from target:/lib64/libpthread.so.0
(gdb) print tlocal
Cannot find thread-local storage for Thread 19378.19380, executable file target:/home/dantipov/tmp/t-thread:
Remote target failed to process qGetTLSAddr request
gdbserver output is:
...
getpkt ("qGetTLSAddr:p4bb2.4bb2,0,7f62aedff330"); [no ack sent]
putpkt ("$E01#a6"); [noack mode]
...
getpkt ("qGetTLSAddr:p4bb2.4bb3,0,7f62aedff330"); [no ack sent]
putpkt ("$E01#a6"); [noack mode]
...
getpkt ("qGetTLSAddr:p4bb2.4bb4,0,7f62aedff330"); [no ack sent]
putpkt ("$E01#a6"); [noack mode]
...
As for the local debugging, the same GDB binary on the same system works as expected:
(gdb) i thr
Id Target Id Frame
* 1 Thread 0x7f62aedd2740 (LWP 19378) "t-thread" 0x00007f62ae10b89d in pthread_join () from /lib64/libpthread.so.0
2 Thread 0x7f62add2d700 (LWP 19379) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
3 Thread 0x7f62ad52c700 (LWP 19380) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
4 Thread 0x7f62acd2b700 (LWP 19381) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
5 Thread 0x7f62ac52a700 (LWP 19382) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
6 Thread 0x7f62abd29700 (LWP 19383) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
7 Thread 0x7f62ab528700 (LWP 19384) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
8 Thread 0x7f62aad27700 (LWP 19385) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
9 Thread 0x7f62aa526700 (LWP 19386) "worker" 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
(gdb) print tlocal
$1 = 100
(gdb) thread 2
[Switching to thread 2 (Thread 0x7f62add2d700 (LWP 19379))]
#0 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
(gdb) print tlocal
$2 = 653
(gdb) thread 3
[Switching to thread 3 (Thread 0x7f62ad52c700 (LWP 19380))]
#0 0x00007f62ae11499d in nanosleep () from /lib64/libpthread.so.0
(gdb) print tlocal
$3 = 1220
Dmitry