From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12811 invoked by alias); 13 Dec 2012 14:13:05 -0000 Received: (qmail 12784 invoked by uid 22791); 13 Dec 2012 14:13:02 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_BJ,TW_FN X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Dec 2012 14:12:51 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Tj9Ws-0002DK-Jn from Yao_Qi@mentor.com ; Thu, 13 Dec 2012 06:12:50 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 13 Dec 2012 06:12:50 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Thu, 13 Dec 2012 06:12:49 -0800 Message-ID: <50C9E23B.7010504@codesourcery.com> Date: Thu, 13 Dec 2012 14:13:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: Joel Brobecker CC: Pedro Alves , Subject: Re: crash/regression with ia64 targets References: <1353404184-22073-1-git-send-email-yao@codesourcery.com> <50AFD573.1090601@gmail.com> <50B0ABF9.1080606@codesourcery.com> <20121213120528.GA19986@adacore.com> In-Reply-To: <20121213120528.GA19986@adacore.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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: 2012-12/txt/msg00443.txt.bz2 On 12/13/2012 08:05 PM, Joel Brobecker wrote: > But the other worrisome element is that most calls to > init_entry_point_info are made from routines used as > the "sym_init" struct sym_fns hook, and this hook is > in fact called, in syms_from_objfile, before the section_offsets > table is allocated. > > Since syms_from_objfile is calling init_entry_point_info, > it seems to me that the call to init_entry_point_info in > the "sym_init" hooks are redundant, and could be removed, > clearing one hurdle. The change here looks straightforward to me, but I agree that we need test to double-check. > > The other hurdle is making sure that init_entry_point_info > is called*after* the section offsets have been allocated. > Which means we need to make sure that we always allocate > some, including in the case where no symbols are found. > This must also become a documented invariant. How about add an assert in init_entry_point_info? gdb_assert (objfile->section_offsets != NULL); > > Attached is a prototype that seems to work on ia64-linux. > I've only tested it against our testsuite for now, but it will > need to be tested with the official testsuite on GNU/Linux, > as well as on Darwin, AiX, and maybe Windows (although, I tested this patch (with conflict resolved, this patch can't be applied cleanly to FSF GDB trunk) on x86_64-linux with both board file unix and native-gdbserver respectively. No regression. > I think the changes removing the calls to init_entry_point_info > should be fine). > > Note that there is a second call to init_entry_point_info, > this time inside reread_symbols, but this one should be fine. Yeah, looks 'objfile->section_offsets' has been already set when call init_entry_point_info in reread_symbols. > > This patch also begs the question whether we might want to > move init_entry_point_info to objfiles.c and make it static. > I guess you meant "symfile.c" rather than "objfiles.c". I am not sure, looks init_entry_point_info is not related to "symfile.c" very much, but I am not against this moving. > diff --git a/gdb/symfile.c b/gdb/symfile.c > index bc4f40a..f182617 100644 > --- a/gdb/symfile.c > +++ b/gdb/symfile.c > @@ -929,8 +929,8 @@ read_symbols (struct objfile *objfile, int add_flags) > an extra symbol file such as dynamically loaded code, and wether > breakpoint reset should be deferred. */ > > -void > -syms_from_objfile (struct objfile *objfile, > +static void > +syms_from_objfile_1 (struct objfile *objfile, > struct section_addr_info *addrs, > struct section_offsets *offsets, > int num_offsets, > @@ -943,11 +943,19 @@ syms_from_objfile (struct objfile *objfile, > gdb_assert (! (addrs && offsets)); > > clear_ada_sym_cache (); > - init_entry_point_info (objfile); > objfile->sf = find_sym_fns (objfile->obfd); > > if (objfile->sf == NULL) > - return; /* No symbols. */ > + { > + int num_sections = bfd_count_sections (objfile->obfd); > + size_t size = SIZEOF_N_SECTION_OFFSETS (num_offsets); > + > + objfile->num_sections = num_sections; Can we use 'num_offsets' here, because I see these two lines in some lines below here, /* Just copy in the offset table directly as given to us. */ objfile->num_sections = num_offsets; in this way, we don't call 'bfd_count_sections'. > + objfile->section_offsets > + = obstack_alloc (&objfile->objfile_obstack, size); > + memset (objfile->section_offsets, 0, size); > + return; /* No symbols. */ > + } > > /* Make sure that partially constructed symbol tables will be cleaned up > if an error occurs during symbol reading. */ > @@ -1028,6 +1036,17 @@ syms_from_objfile (struct objfile *objfile, > xfree (local_addr); > } > > +void > +syms_from_objfile (struct objfile *objfile, > + struct section_addr_info *addrs, > + struct section_offsets *offsets, > + int num_offsets, > + int add_flags) > +{ > + syms_from_objfile_1 (objfile, addrs, offsets, num_offsets, add_flags); > + init_entry_point_info (objfile); > +} > + > /* Perform required actions after either reading in the initial > symbols for a new objfile, or mapping in the symbols from a reusable > objfile. ADD_FLAGS is a bitmask of enum symfile_add_flags. */ -- Yao (齐尧)