public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* COFF line information
@ 1999-07-25  2:18 Eli Zaretskii
  0 siblings, 0 replies; only message in thread
From: Eli Zaretskii @ 1999-07-25  2:18 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils, djgpp-workers, DJ Delorie

The following changes correct some minor problems in reporting file
names and line numbers for a given address.


1999-07-24  Eli Zaretskii  <eliz@is.elta.co.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 = &section->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.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-07-25  2:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-25  2:18 COFF line information Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).