Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Dmitry Antipov <dantipov@nvidia.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: GDB Development <gdb@sourceware.org>
Subject: Re: Printing thread_local a.k.a. __thread variables
Date: Tue, 13 Feb 2018 07:55:00 -0000	[thread overview]
Message-ID: <469e1280-3581-0305-6c9a-2693a765ab7a@nvidia.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2018-02-13  7:55 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
2018-02-12 14:15   ` Dmitry Antipov
2018-02-12 14:54     ` Yao Qi
2018-02-13  7:55       ` Dmitry Antipov [this message]
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=469e1280-3581-0305-6c9a-2693a765ab7a@nvidia.com \
    --to=dantipov@nvidia.com \
    --cc=gdb@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /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