From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15362 invoked by alias); 5 May 2004 00:45:54 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15324 invoked from network); 5 May 2004 00:45:53 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 May 2004 00:45:53 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i450jrkG011648 for ; Tue, 4 May 2004 20:45:53 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i450jqv28482 for ; Tue, 4 May 2004 20:45:52 -0400 Received: from [172.16.14.98] (tool.toronto.redhat.com [172.16.14.98]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id i450jqcU003474 for ; Tue, 4 May 2004 20:45:52 -0400 Message-ID: <40983940.3050003@redhat.com> Date: Wed, 05 May 2004 00:45:00 -0000 From: Bryce McKinlay User-Agent: Mozilla Thunderbird 0.5 (X11/20040502) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Patch: DWARF2 location lists vs. shared libraries Content-Type: multipart/mixed; boundary="------------000505010305030302060309" X-SW-Source: 2004-05/txt/msg00126.txt.bz2 This is a multi-part message in MIME format. --------------000505010305030302060309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1288 GDB has been having problems debugging shared libraries built with CVS gcc @ -O2. For example, libgcj backtraces look like this: (gdb) bt #0 _Jv_FindClass (name=0x83ebfe0, loader=Variable "loader" is not available. ) at ../../../libjava/java/lang/natClassLoader.cc:375 #1 0x01442a99 in _Jv_FindClassFromSignature (sig=Variable "sig" is not available. ) at ../../../libjava/prims.cc:753 #2 0x01442acb in _Jv_FindClassFromSignature (sig=Variable "sig" is not available. ) at ../../../libjava/prims.cc:757 #3 0x01467d61 in _Jv_PrepareCompiledClass (klass=0x18f3500) at ../../../libjava/java/lang/natClassLoader.cc:107 #4 0x014670b8 in java::lang::Class::initializeClass (this=Variable "this" is not available. ) at ../../../libjava/java/lang/natClass.cc:733 The problem seems to be that dwarf2read.c does not offset dwarf2_loclist_baton's base_address for shared library load addresses. This means that find_location_expression() fails, since the unrelocated base_address in the baton does not match up with the PC being searched for. Please review and commit. Since this bug means debugging of -O2 shared libraries with cvs GCC is basically broken, perhaps the fix should go on the stable branch as well? Thanks to Daniel Berlin for helping to track this down! Bryce --------------000505010305030302060309 Content-Type: text/x-patch; name="gdb-loclist.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-loclist.patch" Content-length: 1363 2004-05-04 Bryce McKinlay * dwarf2read.c (dwarf2_symbol_mark_computed): Use ANOFFSET to adjust baton's base_address for shared libraries. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.150 diff -u -r1.150 dwarf2read.c --- dwarf2read.c 4 May 2004 00:11:25 -0000 1.150 +++ dwarf2read.c 5 May 2004 00:41:00 -0000 @@ -8662,6 +8662,7 @@ if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) { struct dwarf2_loclist_baton *baton; + CORE_ADDR base_offset; baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (struct dwarf2_loclist_baton)); @@ -8671,7 +8672,10 @@ don't run off the edge of the section. */ baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr); baton->data = dwarf2_per_objfile->loc_buffer + DW_UNSND (attr); - baton->base_address = cu->header.base_address; + /* Set base_address, adjusting for shared libraries. */ + base_offset = ANOFFSET (cu->objfile->section_offsets, + SECT_OFF_TEXT (cu->objfile)); + baton->base_address = cu->header.base_address + base_offset; if (cu->header.base_known == 0) complaint (&symfile_complaints, "Location list used without specifying the CU base address."); --------------000505010305030302060309--