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]

dwarf1 bugfix



This fixes the negative bit offset problem shown by bf-pack-1.c on a little
endian target.

In a nutshell we detected a case where we have a bitfield which crosses
an alignment boundary.

The code tries to recompute the offset of the byte which contains the first
bit in the bitfield we want.  However, the code only worked for big endian
targets.  In fact, no recomputation is necessary for little endian targets.

I have verified that not only does the debug info no longer contain a negative
bit offset, but that the debugger can actually find the bitfield in
question and correctly print its value (previously the debugger would print
random data because it read from the wrong memory location).



	* dwarfout.c (field_byte_offset): Correctly compute the object's
	byte offset for the first bit of a field which crosses an alignment
	boundary on a !BYTES_BIG_ENDIAN target.

Index: dwarfout.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/dwarfout.c,v
retrieving revision 1.35.4.1
diff -c -3 -p -r1.35.4.1 dwarfout.c
*** dwarfout.c	1999/06/16 10:38:19	1.35.4.1
--- dwarfout.c	1999/07/02 08:58:13
*************** field_byte_offset (decl)
*** 2106,2113 ****
       negative.  Gdb fails when given negative bit offsets.  We avoid this
       by recomputing using the first bit of the bitfield.  This will give
       us an object which does not completely contain the bitfield, but it
!      will be aligned, and it will contain the first bit of the bitfield.  */
!   if (object_offset_in_bits > bitpos_int)
      {
        deepest_bitpos = bitpos_int + 1;
        object_offset_in_bits
--- 2106,2121 ----
       negative.  Gdb fails when given negative bit offsets.  We avoid this
       by recomputing using the first bit of the bitfield.  This will give
       us an object which does not completely contain the bitfield, but it
!      will be aligned, and it will contain the first bit of the bitfield.
! 
!      However, only do this for a BYTES_BIG_ENDIAN target.  For a
!      ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
!      first bit of the bitfield.  If we recompute using bitpos_int + 1 below,
!      then we end up computing the object byte offset for the wrong word of 
the
!      desired bitfield, which in turn causes the field offset to be negative
!      in bit_offset_attribute.  */
!   if (BYTES_BIG_ENDIAN
!       && object_offset_in_bits > bitpos_int)
      {
        deepest_bitpos = bitpos_int + 1;
        object_offset_in_bits





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