mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
introduce minimal_symbol_upper_bound
This introduces minimal_symbol_upper_bound and changes various bits of code to use it. Since this function is intimately tied to the implementation of minimal symbol tables, I believe it belongs in minsyms.c. The new function is extracted from find_pc_partial_function_gnu_ifunc. This isn't a "clean" move because the old function interleaved the caching and the computation; but this doesn't make sense for the new code. 2014-02-26 Tom Tromey <tromey@redhat.com> * blockframe.c (find_pc_partial_function_gnu_ifunc): Use bound minimal symbols. Move code that knows about minsym table layout... * minsyms.c (minimal_symbol_upper_bound): ... here. New function. * minsyms.h (minimal_symbol_upper_bound): Declare. * objc-lang.c (find_objc_msgsend): Use bound minimal symbols, minimal_symbol_upper_bound.
This commit is contained in:
parent
1b58801583
commit
50e65b1713
@ -1,3 +1,14 @@
|
||||
2014-02-26 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* blockframe.c (find_pc_partial_function_gnu_ifunc): Use
|
||||
bound minimal symbols. Move code that knows about minsym
|
||||
table layout...
|
||||
* minsyms.c (minimal_symbol_upper_bound): ... here. New
|
||||
function.
|
||||
* minsyms.h (minimal_symbol_upper_bound): Declare.
|
||||
* objc-lang.c (find_objc_msgsend): Use bound minimal symbols,
|
||||
minimal_symbol_upper_bound.
|
||||
|
||||
2014-02-27 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* python/lib/gdb/printing.py (RegexpCollectionPrettyPrinter):
|
||||
|
@ -195,7 +195,7 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
|
||||
{
|
||||
struct obj_section *section;
|
||||
struct symbol *f;
|
||||
struct minimal_symbol *msymbol;
|
||||
struct bound_minimal_symbol msymbol;
|
||||
struct symtab *symtab = NULL;
|
||||
struct objfile *objfile;
|
||||
int i;
|
||||
@ -217,11 +217,11 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
|
||||
&& section == cache_pc_function_section)
|
||||
goto return_cached_value;
|
||||
|
||||
msymbol = lookup_minimal_symbol_by_pc_section (mapped_pc, section).minsym;
|
||||
msymbol = lookup_minimal_symbol_by_pc_section (mapped_pc, section);
|
||||
ALL_OBJFILES (objfile)
|
||||
{
|
||||
if (objfile->sf)
|
||||
symtab = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
|
||||
symtab = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol.minsym,
|
||||
mapped_pc, section, 0);
|
||||
if (symtab)
|
||||
break;
|
||||
@ -233,9 +233,9 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
|
||||
"pathological" case mentioned in print_frame_info. */
|
||||
f = find_pc_sect_function (mapped_pc, section);
|
||||
if (f != NULL
|
||||
&& (msymbol == NULL
|
||||
&& (msymbol.minsym == NULL
|
||||
|| (BLOCK_START (SYMBOL_BLOCK_VALUE (f))
|
||||
>= SYMBOL_VALUE_ADDRESS (msymbol))))
|
||||
>= SYMBOL_VALUE_ADDRESS (msymbol.minsym))))
|
||||
{
|
||||
cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f));
|
||||
cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f));
|
||||
@ -252,10 +252,10 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
|
||||
last function in the text segment. */
|
||||
|
||||
if (!section)
|
||||
msymbol = NULL;
|
||||
msymbol.minsym = NULL;
|
||||
|
||||
/* Must be in the minimal symbol table. */
|
||||
if (msymbol == NULL)
|
||||
if (msymbol.minsym == NULL)
|
||||
{
|
||||
/* No available symbol. */
|
||||
if (name != NULL)
|
||||
@ -269,42 +269,12 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol);
|
||||
cache_pc_function_name = SYMBOL_LINKAGE_NAME (msymbol);
|
||||
cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol.minsym);
|
||||
cache_pc_function_name = SYMBOL_LINKAGE_NAME (msymbol.minsym);
|
||||
cache_pc_function_section = section;
|
||||
cache_pc_function_is_gnu_ifunc = MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc;
|
||||
|
||||
/* If the minimal symbol has a size, use it for the cache.
|
||||
Otherwise use the lesser of the next minimal symbol in the same
|
||||
section, or the end of the section, as the end of the
|
||||
function. */
|
||||
|
||||
if (MSYMBOL_SIZE (msymbol) != 0)
|
||||
cache_pc_function_high = cache_pc_function_low + MSYMBOL_SIZE (msymbol);
|
||||
else
|
||||
{
|
||||
/* Step over other symbols at this same address, and symbols in
|
||||
other sections, to find the next symbol in this section with
|
||||
a different address. */
|
||||
|
||||
for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
|
||||
{
|
||||
if (SYMBOL_VALUE_ADDRESS (msymbol + i)
|
||||
!= SYMBOL_VALUE_ADDRESS (msymbol)
|
||||
&& SYMBOL_SECTION (msymbol + i)
|
||||
== SYMBOL_SECTION (msymbol))
|
||||
break;
|
||||
}
|
||||
|
||||
if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL
|
||||
&& SYMBOL_VALUE_ADDRESS (msymbol + i)
|
||||
< obj_section_endaddr (section))
|
||||
cache_pc_function_high = SYMBOL_VALUE_ADDRESS (msymbol + i);
|
||||
else
|
||||
/* We got the start address from the last msymbol in the objfile.
|
||||
So the end address is the end of the section. */
|
||||
cache_pc_function_high = obj_section_endaddr (section);
|
||||
}
|
||||
cache_pc_function_is_gnu_ifunc = (MSYMBOL_TYPE (msymbol.minsym)
|
||||
== mst_text_gnu_ifunc);
|
||||
cache_pc_function_high = minimal_symbol_upper_bound (msymbol);
|
||||
|
||||
return_cached_value:
|
||||
|
||||
|
@ -1358,3 +1358,48 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* See minsyms.h. */
|
||||
|
||||
CORE_ADDR
|
||||
minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
|
||||
{
|
||||
int i;
|
||||
short section;
|
||||
struct obj_section *obj_section;
|
||||
CORE_ADDR result;
|
||||
struct minimal_symbol *msymbol;
|
||||
|
||||
gdb_assert (minsym.minsym != NULL);
|
||||
|
||||
/* If the minimal symbol has a size, use it. Otherwise use the
|
||||
lesser of the next minimal symbol in the same section, or the end
|
||||
of the section, as the end of the function. */
|
||||
|
||||
if (MSYMBOL_SIZE (minsym.minsym) != 0)
|
||||
return SYMBOL_VALUE_ADDRESS (minsym.minsym) + MSYMBOL_SIZE (minsym.minsym);
|
||||
|
||||
/* Step over other symbols at this same address, and symbols in
|
||||
other sections, to find the next symbol in this section with a
|
||||
different address. */
|
||||
|
||||
msymbol = minsym.minsym;
|
||||
section = SYMBOL_SECTION (msymbol);
|
||||
for (i = 1; SYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
|
||||
{
|
||||
if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol)
|
||||
&& SYMBOL_SECTION (msymbol + i) == section)
|
||||
break;
|
||||
}
|
||||
|
||||
obj_section = SYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
|
||||
if (SYMBOL_LINKAGE_NAME (msymbol + i) != NULL
|
||||
&& SYMBOL_VALUE_ADDRESS (msymbol + i) < obj_section_endaddr (obj_section))
|
||||
result = SYMBOL_VALUE_ADDRESS (msymbol + i);
|
||||
else
|
||||
/* We got the start address from the last msymbol in the objfile.
|
||||
So the end address is the end of the section. */
|
||||
result = obj_section_endaddr (obj_section);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -249,4 +249,12 @@ void iterate_over_minimal_symbols (struct objfile *objf,
|
||||
void *),
|
||||
void *user_data);
|
||||
|
||||
/* Compute the upper bound of MINSYM. The upper bound is the last
|
||||
address thought to be part of the symbol. If the symbol has a
|
||||
size, it is used. Otherwise use the lesser of the next minimal
|
||||
symbol in the same section, or the end of the section, as the end
|
||||
of the function. */
|
||||
|
||||
CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
|
||||
|
||||
#endif /* MINSYMS_H */
|
||||
|
@ -1260,25 +1260,23 @@ find_objc_msgsend (void)
|
||||
|
||||
for (i = 0; i < nmethcalls; i++)
|
||||
{
|
||||
struct minimal_symbol *func;
|
||||
struct bound_minimal_symbol func;
|
||||
|
||||
/* Try both with and without underscore. */
|
||||
func = lookup_minimal_symbol (methcalls[i].name, NULL, NULL);
|
||||
if ((func == NULL) && (methcalls[i].name[0] == '_'))
|
||||
func = lookup_bound_minimal_symbol (methcalls[i].name);
|
||||
if ((func.minsym == NULL) && (methcalls[i].name[0] == '_'))
|
||||
{
|
||||
func = lookup_minimal_symbol (methcalls[i].name + 1, NULL, NULL);
|
||||
func = lookup_bound_minimal_symbol (methcalls[i].name + 1);
|
||||
}
|
||||
if (func == NULL)
|
||||
if (func.minsym == NULL)
|
||||
{
|
||||
methcalls[i].begin = 0;
|
||||
methcalls[i].end = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func);
|
||||
do {
|
||||
methcalls[i].end = SYMBOL_VALUE_ADDRESS (++func);
|
||||
} while (methcalls[i].begin == methcalls[i].end);
|
||||
methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func.minsym);
|
||||
methcalls[i].end = minimal_symbol_upper_bound (func);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user