From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6731 invoked by alias); 12 Jul 2010 19:34:29 -0000 Received: (qmail 6722 invoked by uid 22791); 12 Jul 2010 19:34:28 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,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; Mon, 12 Jul 2010 19:34:23 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6CJYMIZ026768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Jul 2010 15:34:22 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6CJYLip008101; Mon, 12 Jul 2010 15:34:22 -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 o6CJYLWb020320; Mon, 12 Jul 2010 15:34:21 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id E3BE53782A3; Mon, 12 Jul 2010 13:34:20 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: fix bug when debugging prelink'd library Date: Mon, 12 Jul 2010 19:34:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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/msg00215.txt.bz2 I plan to check this in, but I wanted to ask for comments first, because I think at least Jan disagrees with this direction. Once the discussion is over I plan to commit this, or its replacement, to both the trunk and the 7.2 branch. When debugging a program linked with -lpthread I found that I couldn't print a variable in one of the pthread functions. However, I have full debuginfo installed, and the debuginfo is correct for this particular variable. Jan pointed out a Fedora patch that showed the problem -- dwarf2_per_cu_objfile was returning the master objfile, not the debuginfo objfile. But, at least in the prelink case, the master objfile does not have the same section offsets as the debuginfo objfile. This fixes the problem by changing dwarf2_per_cu_objfile to return the debuginfo objfile. This appears to be correct for all callers except one, which I also updated. Built and regtested on x86-64 (compile farm). I also tried it locally on my prelink test case. Tom 2010-07-12 Tom Tromey * dwarf2read.c (dwarf2_per_cu_objfile): Return the objfile, not the master objfile. * dwarf2loc.c (dwarf_expr_tls_address): Use the master objfile. Index: dwarf2loc.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2loc.c,v retrieving revision 1.94 diff -u -r1.94 dwarf2loc.c --- dwarf2loc.c 7 Jul 2010 17:26:38 -0000 1.94 +++ dwarf2loc.c 12 Jul 2010 19:25:11 -0000 @@ -234,6 +234,10 @@ struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton; struct objfile *objfile = dwarf2_per_cu_objfile (debaton->per_cu); + /* Use the master objfile. */ + if (objfile->separate_debug_objfile_backlink) + objfile = objfile->separate_debug_objfile_backlink; + return target_translate_tls_address (objfile, offset); } Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.411 diff -u -r1.411 dwarf2read.c --- dwarf2read.c 12 Jul 2010 17:07:11 -0000 1.411 +++ dwarf2read.c 12 Jul 2010 19:25:12 -0000 @@ -12054,14 +12054,7 @@ struct objfile * dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu) { - struct objfile *objfile = per_cu->psymtab->objfile; - - /* Return the master objfile, so that we can report and look up the - correct file containing this variable. */ - if (objfile->separate_debug_objfile_backlink) - objfile = objfile->separate_debug_objfile_backlink; - - return objfile; + return per_cu->psymtab->objfile; } /* Return the address size given in the compilation unit header for CU. */