From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4040 invoked by alias); 6 Jan 2010 11:18:32 -0000 Received: (qmail 4029 invoked by uid 22791); 6 Jan 2010 11:18:31 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jan 2010 11:18:27 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3CA34CB01DE for ; Wed, 6 Jan 2010 12:18:25 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jEm1nUUR1ajI for ; Wed, 6 Jan 2010 12:18:25 +0100 (CET) Received: from chinon.act-europe.fr (chinon.act-europe.fr [10.10.0.182]) by mel.act-europe.fr (Postfix) with ESMTP id 2B3F5CB01DD for ; Wed, 6 Jan 2010 12:18:25 +0100 (CET) Received: by chinon.act-europe.fr (Postfix, from userid 1038) id 5D327D8B89; Wed, 6 Jan 2010 12:18:23 +0100 (CET) Date: Wed, 06 Jan 2010 11:18:00 -0000 From: Tristan Gingold To: gdb-patches@sourceware.org Subject: [RFA] Always use addr info to add a separate debug file Message-ID: <20100106111823.GA15402@chinon.act-europe.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i 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-01/txt/msg00110.txt.bz2 Hi, as explained by Jan, it is necessary to use addr_info while loading a separate debug file. No regressions on GNU Linux i386. Tristan. 2010-01-04 Tristan Gingold * symfile.c (build_section_addr_info_from_objfile): New function. (symbol_file_add_separate): Don't use offsets from objfile but built an addr info. --- gdb/symfile.c | 36 ++++++++++++++++++++++++++++++++++-- 1 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index 91b7870..511d426 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -384,6 +384,29 @@ build_section_addr_info_from_section_table (const struct target_section *start, return sap; } +/* Create a section_addr_info from section offsets in OBJFILE. */ + +static struct section_addr_info * +build_section_addr_info_from_objfile (const struct objfile *objfile) +{ + struct section_addr_info *sap; + int i; + struct bfd_section *sec; + + sap = alloc_section_addr_info (objfile->num_sections); + for (i = 0, sec = objfile->obfd->sections; + i < objfile->num_sections; + i++, sec = sec->next) + { + gdb_assert (sec != NULL); + sap->other[i].addr = bfd_get_section_vma (objfile->obfd, sec) + + objfile->section_offsets->offsets[i]; + sap->other[i].name = xstrdup (bfd_get_section_name (objfile->obfd, sec)); + sap->other[i].sectindex = sec->index; + } + return sap; +} + /* Free all memory allocated by build_section_addr_info_from_section_table. */ @@ -1043,14 +1066,23 @@ void symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile) { struct objfile *new_objfile; + struct section_addr_info *sap; + struct cleanup *my_cleanup; + + /* Create section_addr_info. We can't directly use offsets from OBJFILE + because sections of BFD may not match sections of OBJFILE and because + vma may have been modified by tools such as prelink. */ + sap = build_section_addr_info_from_objfile (objfile); + my_cleanup = make_cleanup_free_section_addr_info (sap); new_objfile = symbol_file_add_with_addrs_or_offsets (bfd, symfile_flags, - 0, /* No addr table. */ - objfile->section_offsets, objfile->num_sections, + sap, NULL, 0, objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW | OBJF_USERLOADED)); + do_cleanups (my_cleanup); + add_separate_debug_objfile (new_objfile, objfile); } -- 1.6.5.rc2