From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100723 invoked by alias); 27 Feb 2016 18:06:08 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 100704 invoked by uid 89); 27 Feb 2016 18:06:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=BAYES_40,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*F:D*be, HCc:U*gdb, eli, zaretskii X-HELO: mailsec104.isp.belgacom.be Received: from mailsec104.isp.belgacom.be (HELO mailsec104.isp.belgacom.be) (195.238.20.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 27 Feb 2016 18:06:05 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CEAgBt5NFW/93is1tegzq8EgENgWaGEwKBKzkUAQEBAQEBAWQnhEIBAQQjMyMQCAMYAgImAgI5HgaINq94jjgBAQgCHhhjhReEOoQfgxaBOgWXDIFCjCCOdI5KHgEBQoNlO4ccgToBAQE Received: from 221.226-179-91.adsl-dyn.isp.belgacom.be (HELO soleil) ([91.179.226.221]) by relay.skynet.be with ESMTP/TLS/AES128-GCM-SHA256; 27 Feb 2016 19:06:01 +0100 Message-ID: <1456596538.6069.9.camel@skynet.be> Subject: Re: Examining thread-local storage with GDB From: Philippe Waroquiers To: Eli Zaretskii Cc: gdb@sourceware.org Date: Sat, 27 Feb 2016 18:06:00 -0000 In-Reply-To: <83wppqba6m.fsf@gnu.org> References: <83wppqba6m.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00034.txt.bz2 On Sat, 2016-02-27 at 14:38 +0200, Eli Zaretskii wrote: > How does one display variables in TLS? I see nothing about this in > the manual. > > What happened to me was that an attempt to display the value of a > thread-local variable was responded with some confusing message like > "No global value for this variable" (or something, I don't remember > the exact wording and couldn't find it in the sources), and it took a > long time (including looking at disassembly) to figure out this has > something to do with TLS. Once I had that figured out, I still cannot > find any way of displaying the value, though. If gdb properly supports TLS variables on your platform, then there is nothing special to do. For example, here is the way you can look at the addresses and values of a TLS variable called "global" in all threads: (gdb) thread apply all printf "%d %p", global, &global Thread 15 (Thread 0xb15e0b40 (LWP 6294)): 1 0xb15e0b38 Thread 14 (Thread 0xb1de1b40 (LWP 6293)): 1 0xb1de1b38 Thread 13 (Thread 0xb25e2b40 (LWP 6292)): 0 0xb25e2b38 Thread 12 (Thread 0xb2de3b40 (LWP 6291)): 0 0xb2de3b38 ... If you are remotely debugging, the gdbserver must support the packet qGetTLSAddr. For local debugging, I think this is the target method target_translate_tls_address which on linux might be implemented via the thread debugging library. Philippe