From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25675 invoked by alias); 23 Jul 2010 22:33:02 -0000 Received: (qmail 25639 invoked by uid 22791); 23 Jul 2010 22:33:02 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_FD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Jul 2010 22:32:56 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6NMWtpN028164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Jul 2010 18:32:55 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6NMWs5J014243; Fri, 23 Jul 2010 18:32:55 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o6NMWs57007130; Fri, 23 Jul 2010 18:32:54 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id D3ABF3797F4; Fri, 23 Jul 2010 16:32:53 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: change needs_frame_tls_address Date: Fri, 23 Jul 2010 22:33:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00374.txt.bz2 I am curious to get reactions on this patch. This fixes PR 11803, a gdb assertion resulting from trying to print the TLS variable in this program: class A { public: static __thread int num; }; __thread int A::num = 1; int main() { return 0; } For this we get a warning from value_static_field, then things go downhill and we hit an internal_error. From the PR: (gdb) print A::num warning: static field's value depends on the current frame - bad debug info? findvar.c:427: internal-error: read_var_value: Assertion `frame' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) After tracing through the TLS code for a bit, I have concluded that TLS does not really need a frame, at least not in the gdb sense. Instead, I think it only needs registers -- a funny sort of distinction to make, but nevertheless... With this patch the behavior seems ok: (gdb) p A::num $1 = 1 (gdb) kill Kill the program being debugged? (y or n) y (gdb) p A::num Cannot access memory at address 0xb7fdb6d8 If this seems acceptable I will write up a real test case. If it is not acceptable, I would appreciate some enlightenment as to what other approach I should take. This built & regtested ok on x86-64 (compile farm). Tom 2010-07-23 Tom Tromey PR exp/11803: * dwarf2loc.c (needs_frame_tls_address): Don't require a frame. Index: dwarf2loc.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2loc.c,v retrieving revision 1.95 diff -u -r1.95 dwarf2loc.c --- dwarf2loc.c 13 Jul 2010 15:09:03 -0000 1.95 +++ dwarf2loc.c 23 Jul 2010 22:25:56 -0000 @@ -1053,13 +1053,15 @@ return 1; } -/* Thread-local accesses do require a frame. */ static CORE_ADDR needs_frame_tls_address (void *baton, CORE_ADDR offset) { struct needs_frame_baton *nf_baton = baton; - nf_baton->needs_frame = 1; + /* Thread-local accesses require registers, but not an actual + frame. This is a funny sort of distinction to make, but it lets + us avoid assertions elsewhere in gdb. */ + nf_baton->needs_frame = 0; return 1; }