This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch] fine_nearest_line: find the most nested inline function
- From: Tristan Gingold <gingold at adacore dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: "binutils at sourceware dot org Development" <binutils at sourceware dot org>
- Date: Tue, 27 May 2014 17:32:04 +0200
- Subject: Re: [Patch] fine_nearest_line: find the most nested inline function
- Authentication-results: sourceware.org; auth=none
- References: <B45AC4A3-39C6-46C9-B9A2-01FABBD07DDD at adacore dot com> <20140527140027 dot GB6679 at bubble dot grove dot modra dot org>
On 27 May 2014, at 16:00, Alan Modra <amodra@gmail.com> wrote:
> On Tue, May 27, 2014 at 02:11:48PM +0200, Tristan Gingold wrote:
>> * dwarf2.c (lookup_address_in_function_table): Add best_fit_len
>> to keep the length of the best fit range.
>
> OK. Please apply a similar fix to lookup_symbol_in_function_table
> and info_hash_lookup_funcinfo.
Well spotted. Wider view from a global maintainer :-)
How about this ?
No regressions for i386-linux.
Tristan.
2014-05-27 Tristan Gingold <gingold@adacore.com>
* dwarf2.c (lookup_address_in_function_table): Add best_fit_len
to keep the length of the best fit range.
(lookup_symbol_in_function_table, info_hash_lookup_funcinfo):
Likewise.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index e5579d8..5e322ce 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1994,6 +1994,7 @@ lookup_address_in_function_table (struct comp_unit *unit,
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
+ bfd_vma best_fit_len = 0;
struct arange *arange;
for (each_func = unit->function_table;
@@ -2007,9 +2008,11 @@ lookup_address_in_function_table (struct comp_unit *unit,
if (addr >= arange->low && addr < arange->high)
{
if (!best_fit
- || (arange->high - arange->low
- < best_fit->arange.high - best_fit->arange.low))
- best_fit = each_func;
+ || arange->high - arange->low < best_fit_len)
+ {
+ best_fit = each_func;
+ best_fit_len = arange->high - arange->low;
+ }
}
}
}
@@ -2038,6 +2041,7 @@ lookup_symbol_in_function_table (struct comp_unit *unit,
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
+ bfd_vma best_fit_len = 0;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
@@ -2056,9 +2060,11 @@ lookup_symbol_in_function_table (struct comp_unit *unit,
&& each_func->name
&& strcmp (name, each_func->name) == 0
&& (!best_fit
- || (arange->high - arange->low
- < best_fit->arange.high - best_fit->arange.low)))
- best_fit = each_func;
+ || arange->high - arange->low < best_fit_len))
+ {
+ best_fit = each_func;
+ best_fit_len = arange->high - arange->low;
+ }
}
}
@@ -3173,6 +3179,7 @@ info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
+ bfd_vma best_fit_len = 0;
struct info_list_node *node;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
@@ -3191,9 +3198,11 @@ info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
&& addr >= arange->low
&& addr < arange->high
&& (!best_fit
- || (arange->high - arange->low
- < best_fit->arange.high - best_fit->arange.low)))
- best_fit = each_func;
+ || arange->high - arange->low < best_fit_len))
+ {
+ best_fit = each_func;
+ best_fit_len = arange->high - arange->low;
+ }
}
}