From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1806 invoked by alias); 7 Oct 2003 02:14:36 -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 1798 invoked from network); 7 Oct 2003 02:14:33 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 7 Oct 2003 02:14:33 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id E7658D2D29; Mon, 6 Oct 2003 19:14:31 -0700 (PDT) Date: Tue, 07 Oct 2003 02:14:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC] lookup problem in blockframe.c:inside_main_func() Message-ID: <20031007021431.GH933@gnat.com> References: <20031006233728.GB933@gnat.com> <20031007001543.GA16602@nevyn.them.org> <20031007002422.GF933@gnat.com> <20031007014942.GA18589@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="KlAEzMkarCnErv5Q" Content-Disposition: inline In-Reply-To: <20031007014942.GA18589@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2003-10/txt/msg00152.txt.bz2 --KlAEzMkarCnErv5Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1748 > Oh... I see that Ada already has an interface for selecting a list of > symbols. Another bit that doesn't belong anywhere near the > language-specific code, if you'll permit some historical ranting. I agree. My holy grail would be to push all the code doing symbol lookups for Ada, or rather the 90% part of it that's almost a copy/paste of the C code. But this is not something that I have been looking at, because Paul Hilfinger was more familiar with this part and its historical legacy. > > > Or you could > > > just use the minsym version, and then call find_pc_function. > > > > That's a good idea, I think. Lookup the minsym.... Hmmm, let me explore > > this path. Thanks! > > Follow along with the code immediately above in the same function. I don't understand you suggestion, there isn't much code above the part I'd like to change. Maybe below? In any case, attached is the patch that I came up with. I tested it on x86-linux RH9.0 using the stock gcc/g++ there. No regression found. Would it be acceptable for inclusion? I can also add a dated comments explaining why we are doing it that way instead of using lookup_symbol. > Beware, right now that minsym code may find the one which demangles to > main; but that should change. Hmmm, did I do it the right way, or did I open a bad door? In the latter case, is there a way for me to make sure I find the right one? It seems pretty easy to verify that I did find the right own by comparing main_name() against the SYMBOL_LINKAGE_NAME, but that still would not help us find the right symbol :-). 2003-10-06 J. Brobecker * blockframe.c (inside_main_func): No longer use symbol_lookup() to lookup the main function symbol. Thanks, -- Joel --KlAEzMkarCnErv5Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="blockframe.c.diff" Content-length: 1805 Index: blockframe.c =================================================================== RCS file: /cvs/src/src/gdb/blockframe.c,v retrieving revision 1.80 diff -u -p -r1.80 blockframe.c --- blockframe.c 14 Sep 2003 16:32:12 -0000 1.80 +++ blockframe.c 7 Oct 2003 01:56:40 -0000 @@ -83,22 +83,27 @@ deprecated_inside_entry_file (CORE_ADDR int inside_main_func (CORE_ADDR pc) { + struct minimal_symbol *msymbol; + if (pc == 0) return 1; if (symfile_objfile == 0) return 0; + msymbol = lookup_minimal_symbol (main_name (), NULL, symfile_objfile); + /* If the addr range is not set up at symbol reading time, set it up now. This is for DEPRECATED_FRAME_CHAIN_VALID_ALTERNATE. I do this for coff, because it is unable to set it up and symbol reading time. */ - if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC && - symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC) + if (msymbol != NULL + && symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC + && symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC) { - struct symbol *mainsym; + struct symbol *mainsym + = find_pc_function (SYMBOL_VALUE_ADDRESS (msymbol)); - mainsym = lookup_symbol (main_name (), NULL, VAR_DOMAIN, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) { symfile_objfile->ei.main_func_lowpc = @@ -111,8 +116,6 @@ inside_main_func (CORE_ADDR pc) /* Not in the normal symbol tables, see if "main" is in the partial symbol table. If it's not, then give up. */ { - struct minimal_symbol *msymbol - = lookup_minimal_symbol (main_name (), NULL, symfile_objfile); if (msymbol != NULL && MSYMBOL_TYPE (msymbol) == mst_text) { struct obj_section *osect --KlAEzMkarCnErv5Q--