Index: lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py +++ lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py @@ -148,6 +148,9 @@ '(uint8_t:1) b17 = \'\\0\'', ]) + self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY, + substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"]) + @add_test_categories(['pyapi']) # BitFields exhibit crashes in record layout on Windows Index: lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c =================================================================== --- lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c +++ lldb/packages/Python/lldbsuite/test/lang/c/bitfields/main.c @@ -90,6 +90,14 @@ packed.b = 10; packed.c = 0x7112233; + struct LargePackedBits { + unsigned long a: 36; + unsigned long b: 36; + } __attribute__((packed)); + + struct LargePackedBits large_packed = + (struct LargePackedBits){ 0xcbbbbaaaa, 0xdffffeeee }; + return 0; //// Set break point at this line. } Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ lldb/source/Core/ValueObject.cpp @@ -618,6 +618,18 @@ if (!child_name_str.empty()) child_name.SetCString(child_name_str.c_str()); + // If a bitfield doesn't fit into the child_byte_size'd window at + // child_byte_offset, move the window (= child_byte_offset) + // forward until it fits. + uint32_t child_bit_size = child_byte_size * 8; + if (child_bitfield_bit_size + child_bitfield_bit_offset > child_bit_size) { + uint32_t overhang_bits = + (child_bitfield_bit_size + child_bitfield_bit_offset) - child_bit_size; + uint32_t overhang_bytes = (overhang_bits + 7) / 8; + child_byte_offset += overhang_bytes; + child_bitfield_bit_offset -= overhang_bytes * 8; + } + valobj = new ValueObjectChild( *this, child_compiler_type, child_name, child_byte_size, child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,