This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC/RFA] find_pc_sect_psymtab(): symbol table not always complete


On Wed, Nov 19, 2003 at 04:23:59PM -0800, Joel Brobecker wrote:
> 2003-11-19  J. Brobecker  <brobecker@gnat.com>
> 
>         * 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.

ping?

(DanielJ gave a positive feedback on this patch early december)

> 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);


-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]