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 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


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