[Patch] fine_nearest_line: find the most nested inline function

Tristan Gingold gingold@adacore.com
Tue May 27 12:11:00 GMT 2014


Hi,

there is a small thinko in dwarf2.c:lookup_address_in_function_table.
As a consequence, the result may not be the most nested inlined function.

In order to find inlined functions, we find the function that has the
smallest range that contains the address.  But we compare ranges with
the first range of the best function instead of the best range of the
best function.

No regressions on i386-linux.

Ok for trunk ?

Tristan.

bfd/
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.


diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index e5579d8..6c2a651 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1995,6 +1995,7 @@ lookup_address_in_function_table (struct comp_unit *unit,
   struct funcinfo* each_func;
   struct funcinfo* best_fit = NULL;
   struct arange *arange;
+  bfd_vma best_fit_len = 0;
 
   for (each_func = unit->function_table;
        each_func;
@@ -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;
+		}
 	    }
 	}
     }

 


More information about the Binutils mailing list