Mail Archives: djgpp-workers/1999/07/25/05:19:33
The following changes correct some minor problems in reporting file
names and line numbers for a given address.
1999-07-24 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* coffgen.c (coff_find_nearest_line): Update filename_ptr even if
the current address difference is *equal* to maxdiff; this avoids
returning a wrong file name when some source files have zero
symbols. If the offset is beyond the last line number record,
don't return the last values as if they were valid info.
*** bfd/coffgen.c~1 Mon Dec 7 02:47:22 1998
--- bfd/coffgen.c Sat Jul 24 18:06:08 1999
*************** coff_find_nearest_line (abfd, section, s
*** 2192,2198 ****
if (p2 < pend
&& offset + sec_vma >= (bfd_vma) p2->u.syment.n_value
! && offset + sec_vma - (bfd_vma) p2->u.syment.n_value < maxdiff)
{
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
maxdiff = offset + sec_vma - p2->u.syment.n_value;
--- 2192,2198 ----
if (p2 < pend
&& offset + sec_vma >= (bfd_vma) p2->u.syment.n_value
! && offset + sec_vma - (bfd_vma) p2->u.syment.n_value <= maxdiff)
{
*filename_ptr = (char *) p->u.syment._n._n_n._n_offset;
maxdiff = offset + sec_vma - p2->u.syment.n_value;
*************** coff_find_nearest_line (abfd, section, s
*** 2229,2234 ****
--- 2229,2236 ----
if (section->lineno != NULL)
{
+ bfd_vma last_value = 0;
+
l = §ion->lineno[i];
for (; i < section->lineno_count; i++)
*************** coff_find_nearest_line (abfd, section, s
*** 2240,2245 ****
--- 2242,2248 ----
if (coff->symbol.value > offset)
break;
*functionname_ptr = coff->symbol.name;
+ last_value = coff->symbol.value;
if (coff->native)
{
combined_entry_type *s = coff->native;
*************** coff_find_nearest_line (abfd, section, s
*** 2268,2273 ****
--- 2271,2293 ----
}
l++;
}
+ /* If we fell off the end of the loop, assume this symbol
+ doesn't have a line number info. Otherwise, symbols
+ that don't have line number info get reported with the
+ line number of the last line of the last symbol which
+ does have line number info.
+
+ Here's the problem: a naive implementation of this test
+ breaks the (rare but possible) cases where the last line
+ has some executable code in it. The following heuristics
+ assumes no such line generates more than 0x100 bytes of
+ code. */
+ if (i == section->lineno_count
+ && last_value && offset - last_value > 0x100)
+ {
+ *functionname_ptr = 0;
+ *line_ptr = 0;
+ }
}
/* Cache the results for the next call. */
- Raw text -