From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22752 invoked by alias); 20 Nov 2003 00:24:02 -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 22742 invoked from network); 20 Nov 2003 00:24:00 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 20 Nov 2003 00:24:00 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 0DCF6482A3; Wed, 19 Nov 2003 16:23:59 -0800 (PST) Date: Thu, 20 Nov 2003 00:24:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] find_pc_sect_psymtab(): symbol table not always complete Message-ID: <20031120002359.GB504@gnat.com> References: <20031119181910.GD1067@gnat.com> <20031119182634.GA1423@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline In-Reply-To: <20031119182634.GA1423@nevyn.them.org> User-Agent: Mutt/1.4i X-SW-Source: 2003-11/txt/msg00413.txt.bz2 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 684 > > 2003-11-19 J. Brobecker > > > > * symtab.c (find_pc_sect_psymtab): Refine the search for the > > partial symtab corresponding to the given PC address, taking > > into account the fact that the symbol table might be incomplete. > > FWIW, this looks good to me, but I'd like another comment on the new > test to the effect of, the find_pc_sect_psymtab call will always return > the closest symbol below pc in tpst. Threw me for a moment how you > were just checking for the highest valued symbol. Thanks for your feedback Daniel. I agree on that a comment is useful. Here is a revised version of the patch. Is it better? -- Joel --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="symtab.c.diff" Content-length: 2152 Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.122 diff -u -p -r1.122 symtab.c --- symtab.c 8 Nov 2003 00:13:03 -0000 1.122 +++ symtab.c 20 Nov 2003 00:21:30 -0000 @@ -698,6 +698,8 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec if (pc >= pst->textlow && pc < pst->texthigh) { struct partial_symtab *tpst; + struct partial_symtab *best_pst = pst; + struct partial_symbol *best_psym = NULL; /* An objfile that has its functions reordered might have many partial symbol tables containing the PC, but @@ -710,6 +712,11 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec if (msymbol == NULL) return (pst); + /* The code range of partial symtabs sometimes overlap, so + we need to check all partial symtabs and find the one that + fits better for the given PC address. We select the partial + symtab that contains a symbol which address is closest to + the PC address. */ for (tpst = pst; tpst != NULL; tpst = tpst->next) { if (pc >= tpst->textlow && pc < tpst->texthigh) @@ -721,9 +728,24 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec && SYMBOL_VALUE_ADDRESS (p) == SYMBOL_VALUE_ADDRESS (msymbol)) return (tpst); + if (p != NULL) + { + /* We found a symbol in this partial symtab which + matches PC, check whether it is closer than our + current BEST_PSYM. Since this symbol address is + necessarily lower or equal to PC, the symbol closer + to PC is the symbol which address is the highest. */ + if (best_psym == NULL + || SYMBOL_VALUE_ADDRESS (p) + > SYMBOL_VALUE_ADDRESS (best_psym)) + { + best_psym = p; + best_pst = tpst; + } + } } } - return (pst); + return best_pst; } } return (NULL); --dDRMvlgZJXvWKvBx--