From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3682 invoked by alias); 19 Feb 2004 19:01:26 -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 3673 invoked from network); 19 Feb 2004 19:01:24 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 19 Feb 2004 19:01:24 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id 099C11A448A; Thu, 19 Feb 2004 13:56:56 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16437.1784.909435.173166@localhost.redhat.com> Date: Thu, 19 Feb 2004 19:01:00 -0000 To: Joel Brobecker Cc: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] find_pc_sect_psymtab(): symbol table not always complete In-Reply-To: <20031120002359.GB504@gnat.com> References: <20031119181910.GD1067@gnat.com> <20031119182634.GA1423@nevyn.them.org> <20031120002359.GB504@gnat.com> X-SW-Source: 2004-02/txt/msg00541.txt.bz2 Joel Brobecker writes: Joel, I committed an updated version of your patch. By updated I mean with new/more comments. Now let's keep an eye on any apparently unrelated breakage :-) elena 2004-02-19 Joel Brobecker Committed by Elena Zannoni * symtab.c (find_pc_sect_psymtab): Return the psymtab that contains a symbol wich is the best, non-exact match for the given pc. Update comments. Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.127 diff -u -p -r1.127 symtab.c --- symtab.c 17 Feb 2004 15:21:22 -0000 1.127 +++ symtab.c 19 Feb 2004 17:13:11 -0000 @@ -672,8 +672,10 @@ init_sal (struct symtab_and_line *sal) -/* Find which partial symtab on contains PC and SECTION. Return 0 if none. */- +/* Find which partial symtab contains PC and SECTION. Return 0 if + none. We return the psymtab that contains a symbol whose address + exactly matches PC, or, if we cannot find an exact match, the + psymtab that contains a symbol whose address is closest to PC. */ struct partial_symtab * find_pc_sect_psymtab (CORE_ADDR pc, asection *section) { @@ -698,6 +700,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 +714,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, asec if (msymbol == NULL) return (pst); + /* The code range of partial symtabs sometimes overlap, so, in + the loop below, 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 whose + address is closest to the PC address. By closest we mean + that find_pc_sect_symbol returns the symbol with address + that is closest and still less than the given PC. */ for (tpst = pst; tpst != NULL; tpst = tpst->next) { if (pc >= tpst->textlow && pc < tpst->texthigh) @@ -721,9 +732,33 @@ 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 (or is closest to) 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. */ + /* This way we return the psymtab which contains + such best match symbol. This can help in cases + where the symbol information/debuginfo is not + complete, like for instance on IRIX6 with gcc, + where no debug info is emitted for + statics. (See also the nodebug.exp + testcase.) */ + 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);