summaryrefslogtreecommitdiffstats
path: root/gcc/dwarfout.c
diff options
context:
space:
mode:
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1997-06-24 19:35:11 +0000
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1997-06-24 19:35:11 +0000
commit30c1e765ddf8a59d1a495f7e95014d2265186124 (patch)
tree950b659c8abdd07a608c5f680262f96250956506 /gcc/dwarfout.c
parenta3540dba5da5506c10933d374018ceff8e870d57 (diff)
downloadppe42-gcc-30c1e765ddf8a59d1a495f7e95014d2265186124.tar.gz
ppe42-gcc-30c1e765ddf8a59d1a495f7e95014d2265186124.zip
(field_byte_offset): Check for object_offset_in_bits
> bitpos_int, and recompute object_offset_in_bytes if true. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@14299 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dwarfout.c')
-rw-r--r--gcc/dwarfout.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c
index f91cccb3420..c9457f56045 100644
--- a/gcc/dwarfout.c
+++ b/gcc/dwarfout.c
@@ -2067,6 +2067,25 @@ field_byte_offset (decl)
/* Compute the offset of the containing object in bytes. */
object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
+ /* The above code assumes that the field does not cross an alignment
+ boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
+ or if the structure is packed. If this happens, then we get an object
+ which starts after the bitfield, which means that the bit offset is
+ 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
+ = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
+ object_offset_in_align_units = (object_offset_in_bits
+ / type_align_in_bits);
+ object_offset_in_bytes = (object_offset_in_align_units
+ * type_align_in_bytes);
+ }
+
return object_offset_in_bytes;
}
OpenPOWER on IntegriCloud