http://sourceware.org/ml/gdb-patches/2011-06/msg00136.html
authorAndrew Burgess <aburgess@broadcom.com>
Thu, 23 Jun 2011 09:51:57 +0000 (09:51 +0000)
committerAndrew Burgess <aburgess@broadcom.com>
Thu, 23 Jun 2011 09:51:57 +0000 (09:51 +0000)
2011-06-23  Andrew Burgess  <aburgess@broadcom.com>

* gdbtypes.c (append_composite_type_field_aligned): Fix
calculation of bit position based on alignment.

gdb/ChangeLog
gdb/gdbtypes.c

index fb4c664797f6edf7dc4613dba68ee28a869277d2..b2ff7ffdf6d49ebd574b4831cc0822c21573ca65 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-23  Andrew Burgess  <aburgess@broadcom.com>
+
+       * gdbtypes.c (append_composite_type_field_aligned): Fix
+       calculation of bit position based on alignment.
+
 2011-06-22  Pedro Alves  <pedro@codesourcery.com>
 
        * breakpoint.c (bpstat_stop_status): Call the check_status
index 2bdb4ebe72df0b75941dd438b3488f1d4e334d9e..2572046e39cffdd5938ceac065fe4298db95dca1 100644 (file)
@@ -3654,12 +3654,15 @@ append_composite_type_field_aligned (struct type *t, char *name,
 
          if (alignment)
            {
-             int left = FIELD_BITPOS (f[0]) % (alignment * TARGET_CHAR_BIT);
+             int left;
+
+             alignment *= TARGET_CHAR_BIT;
+             left = FIELD_BITPOS (f[0]) % alignment;
 
              if (left)
                {
-                 FIELD_BITPOS (f[0]) += left;
-                 TYPE_LENGTH (t) += left / TARGET_CHAR_BIT;
+                 FIELD_BITPOS (f[0]) += (alignment - left);
+                 TYPE_LENGTH (t) += (alignment - left) / TARGET_CHAR_BIT;
                }
            }
        }