This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dwarf2out.c patch for signed 64-bit enum values on 64-bit host


Gcc emits incorrect debug info for signed 64-bit enum values.  The problem is
that gcc assumes that such values are always 4 bytes, and this is wrong on
64-bit hosts.  Rather than always use 8 byte values on 64-bit hosts, I chose
to use sleb128 values.  Enum values are usually small, so this should result
in smaller debug info on average.

It would be nice to use the same scheme as is used for unsigned values,
emit them as 1, 2, 4, or 8 byte values.  Unfortunately, this does not work,
because gdb before Oct 1999 does not sign extend, and gdb after Oct 1999 does
sign extend.  I think the current gdb behaviour is correct (it matches what
SGI's debugger does), but I don't want to break support for gdb 4.x, so we
can't rely on it.

As before, this doesn't actually fix the 64-bit debugging problem unless you
also have my soon to be submitted gdb patch.

This was tested against the gdb testsuite on an ia64-linux system.

2000-06-08  James E. Wilson  <wilson@bletchleypark.cygnus.com>

	* dwarf2out.c (size_of_die, case dw_val_class_const): Use
	size_of_sleb128.
	(value_format, case dw_val_class_const): Use sdata format.
	(output_die): Call output_sleb128.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.176
diff -p -r1.176 dwarf2out.c
*** dwarf2out.c	2000/06/08 17:25:22	1.176
--- dwarf2out.c	2000/06/08 22:30:54
*************** size_of_die (die)
*** 4644,4650 ****
  	  }
  	  break;
  	case dw_val_class_const:
! 	  size += 4;
  	  break;
  	case dw_val_class_unsigned_const:
  	  size += constant_size (AT_unsigned (a));
--- 4644,4650 ----
  	  }
  	  break;
  	case dw_val_class_const:
! 	  size += size_of_sleb128 (AT_int (a));
  	  break;
  	case dw_val_class_unsigned_const:
  	  size += constant_size (AT_unsigned (a));
*************** value_format (a)
*** 4801,4807 ****
  	  abort ();
  	}
      case dw_val_class_const:
!       return DW_FORM_data4;
      case dw_val_class_unsigned_const:
        switch (constant_size (AT_unsigned (a)))
  	{
--- 4801,4807 ----
  	  abort ();
  	}
      case dw_val_class_const:
!       return DW_FORM_sdata;
      case dw_val_class_unsigned_const:
        switch (constant_size (AT_unsigned (a)))
  	{
*************** output_die (die)
*** 5089,5095 ****
  	  break;
  
  	case dw_val_class_const:
! 	  ASM_OUTPUT_DWARF_DATA4 (asm_out_file, AT_int (a));
  	  break;
  
  	case dw_val_class_unsigned_const:
--- 5089,5098 ----
  	  break;
  
  	case dw_val_class_const:
! 	  /* ??? It would be slightly more efficient to use a scheme like is
! 	     used for unsigned constants below, but gdb 4.x does not sign
! 	     extend.  Gdb 5.x does sign extend.  */
! 	  output_sleb128 (AT_int (a));
  	  break;
  
  	case dw_val_class_unsigned_const:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]