patch for binutils bfd/dwarf2.c

Nathan Tallent eraxxon@alumni.rice.edu
Fri Sep 20 07:46:00 GMT 2002


What follows is a(nother) patch for binutils bfd/dwarf2.c.
-Nathan Tallent

Description:
------------
This fix updates 'decode_line_info' to correctly decode the
(non-standard DWARF2) out-of-order address sequences generated by the 
Intel C++ 6.0 compiler for ia64-Linux.  Fortunately, the fix is simple 
and therefore (IMO) not especially ugly or clunky.


Testing and testcases:
----------------------
I have run the binutils regression tests with and without my changes and
the results are the same.

Our tests: We are using bintuils as the binary reader for a program
that performs source code structure recovery on binaries from a number 
of different platforms.  (We esp. focus on loop recovery for scientific
programs.) This program is also a cross-tool and we have successfully
tested these changes (and a number of others to follow eventually) on a
number of different binaries (from GNU and non-GNU compilers) and
platforms.

hosts (all of which are enabled on each platform)
   mips64-sgi-irix6
   alpha-*-linux-gnu, alpha-*-osf
   sparc32-*-elf, sparc64-*-solaris2
   i386-*-linux-gnu
   ia64-*-linux-gnu

ChangeLog:
----------

2002-09-20  Nathan Tallent  <eraxxon@alumni.rice.edu>

	* dwarf2.c (decode_line_info): Update to correctly decode
	the (non-standard DWARF2) out-of-order address sequences
	generated by the Intel C++ 6.0 compiler for ia64-Linux.


Patch: bfd/dwarf2.c
(created with 'cvs diff -c3p' against cvs repository on 9/20/02)
------

Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 dwarf2.c
*** dwarf2.c	20 Sep 2002 07:28:54 -0000	1.34
--- dwarf2.c	20 Sep 2002 13:12:22 -0000
*************** decode_line_info (unit, stash)
*** 1089,1096 ****
         unsigned int column = 0;
         int is_stmt = lh.default_is_stmt;
         int basic_block = 0;
!       int end_sequence = 0, need_low_pc = 1;
!       bfd_vma low_pc = 0;

         /* Decode the table.  */
         while (! end_sequence)
--- 1089,1102 ----
         unsigned int column = 0;
         int is_stmt = lh.default_is_stmt;
         int basic_block = 0;
!       int end_sequence = 0;
!
!       /* eraxxon@alumni.rice.edu: Against the DWARF2 specs, some
!          compilers generate address sequences that are wildly out of
!          order using DW_LNE_set_address (e.g. Intel C++ 6.0 compiler
!          for ia64-Linux).  Thus, to determine the low and high
!          address, we must compare on every DW_LNS_copy, etc. */
!       bfd_vma low_pc = 0, high_pc = 0;

         /* Decode the table.  */
         while (! end_sequence)
*************** decode_line_info (unit, stash)
*** 1107,1117 ****
   	      /* Append row to matrix using current values.  */
   	      add_line_info (table, address, filename, line, column, 0);
   	      basic_block = 1;
! 	      if (need_low_pc)
! 		{
! 		  need_low_pc = 0;
! 		  low_pc = address;
! 		}
   	    }
   	  else switch (op_code)
   	    {
--- 1113,1122 ----
   	      /* Append row to matrix using current values.  */
   	      add_line_info (table, address, filename, line, column, 0);
   	      basic_block = 1;
! 	      if (low_pc == 0 || address < low_pc) /* eraxxon */
! 		low_pc = address;
! 	      if (high_pc == 0 || address > high_pc)
! 		high_pc = address;
   	    }
   	  else switch (op_code)
   	    {
*************** decode_line_info (unit, stash)
*** 1125,1136 ****
   		  end_sequence = 1;
   		  add_line_info (table, address, filename, line, column,
   				 end_sequence);
! 		  if (need_low_pc)
! 		    {
! 		      need_low_pc = 0;
! 		      low_pc = address;
! 		    }
! 		  arange_add (unit, low_pc, address);
   		  break;
   		case DW_LNE_set_address:
   		  address = read_address (unit, line_ptr);
--- 1130,1140 ----
   		  end_sequence = 1;
   		  add_line_info (table, address, filename, line, column,
   				 end_sequence);
! 		  if (low_pc == 0 || address < low_pc) /* eraxxon */
! 		    low_pc = address;
! 		  if (high_pc == 0 || address > high_pc)
! 		    high_pc = address;
! 		  arange_add (unit, low_pc, high_pc);
   		  break;
   		case DW_LNE_set_address:
   		  address = read_address (unit, line_ptr);
*************** decode_line_info (unit, stash)
*** 1169,1179 ****
   	    case DW_LNS_copy:
   	      add_line_info (table, address, filename, line, column, 0);
   	      basic_block = 0;
! 	      if (need_low_pc)
! 		{
! 		  need_low_pc = 0;
! 		  low_pc = address;
! 		}
   	      break;
   	    case DW_LNS_advance_pc:
   	      address += lh.minimum_instruction_length
--- 1173,1182 ----
   	    case DW_LNS_copy:
   	      add_line_info (table, address, filename, line, column, 0);
   	      basic_block = 0;
! 	      if (low_pc == 0 || address < low_pc) /* eraxxon */
! 		low_pc = address;
! 	      if (high_pc == 0 || address > high_pc)
! 		high_pc = address;
   	      break;
   	    case DW_LNS_advance_pc:
   	      address += lh.minimum_instruction_length



More information about the Binutils mailing list