Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py @@ -116,6 +116,38 @@ self.expect("expr/x (packed.c)", VARIABLES_DISPLAYED_CORRECTLY, substrs=['uint32_t', "7112233"]) + for bit in range(1,18): + expected = "1" if bit in [1, 5, 7, 13] else "0" + self.expect("expr even_more_bits.b" + str(bit), VARIABLES_DISPLAYED_CORRECTLY, + substrs=['uint8_t', expected]) + + for bit in [3, 10, 14]: + self.expect("expr even_more_bits.b" + str(bit) + " = 1", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['uint8_t', "1"]) + + self.expect( + "frame variable --show-types even_more_bits", + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + '(uint8_t:1) b1 = \'\\x01\'', + '(uint8_t:1) b2 = \'\\0\'', + '(uint8_t:1) b3 = \'\\x01\'', + '(uint8_t:1) b4 = \'\\0\'', + '(uint8_t:1) b5 = \'\\x01\'', + '(uint8_t:1) b6 = \'\\0\'', + '(uint8_t:1) b7 = \'\\x01\'', + '(uint8_t:1) b8 = \'\\0\'', + '(uint8_t:1) b9 = \'\\0\'', + '(uint8_t:1) b10 = \'\\x01\'', + '(uint8_t:1) b12 = \'\\0\'', + '(uint8_t:1) b13 = \'\\x01\'', + '(uint8_t:1) b14 = \'\\x01\'', + '(uint8_t:1) b15 = \'\\0\'', + '(uint8_t:1) b16 = \'\\0\'', + '(uint8_t:1) b17 = \'\\0\'', + ]) + + @add_test_categories(['pyapi']) # BitFields exhibit crashes in record layout on Windows # (http://llvm.org/pr21800) Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/main.c =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/main.c +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/main.c @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include #include +#include int main (int argc, char const *argv[]) { @@ -63,6 +64,20 @@ more_bits.c = 1; more_bits.d = 0; + struct EvenMoreBits + { + uint8_t b1 : 1, b2 : 1, b3 : 1, b4 : 1, b5 : 1, b6 : 1, + b7 : 1, b8 : 1, b9 : 1, b10 : 1, b11 : 1, b12 : 1, + b13 : 1, b14 : 1, b15 : 1, b16 : 1, b17 : 1; + }; + + struct EvenMoreBits even_more_bits; + memset(&even_more_bits, 0, sizeof(even_more_bits)); + even_more_bits.b1 = 1; + even_more_bits.b5 = 1; + even_more_bits.b7 = 1; + even_more_bits.b13 = 1; + #pragma pack(1) struct PackedBits { Index: lldb/trunk/source/Expression/IRInterpreter.cpp =================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp +++ lldb/trunk/source/Expression/IRInterpreter.cpp @@ -152,17 +152,13 @@ Type *type) { size_t type_size = m_target_data.getTypeStoreSize(type); - switch (type_size) { - case 1: - case 2: - case 4: - case 8: - scalar = llvm::APInt(type_size*8, u64value); - break; - default: + if (type_size > 8) return false; - } + if (type_size != 1) + type_size = PowerOf2Ceil(type_size); + + scalar = llvm::APInt(type_size*8, u64value); return true; } @@ -192,8 +188,7 @@ return false; lldb::offset_t offset = 0; - if (value_size == 1 || value_size == 2 || value_size == 4 || - value_size == 8) { + if (value_size <= 8) { uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size); return AssignToMatchType(scalar, u64value, value->getType()); }