diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -36,10 +36,13 @@ EXPECT_FALSE(Unrecoverable); } + Triple getGeneratorTriple(uint8_t AddrSize = 8) { + return getDefaultTargetTripleForAddrSize(AddrSize == 0 ? 8 : AddrSize); + } + bool setupGenerator(uint16_t Version = 4, uint8_t AddrSize = 8) { AddressSize = AddrSize; - Triple T = - getDefaultTargetTripleForAddrSize(AddressSize == 0 ? 8 : AddressSize); + Triple T = getGeneratorTriple(AddressSize); if (!isConfigurationSupported(T)) return false; auto ExpectedGenerator = Generator::create(T, Version); @@ -1437,27 +1440,16 @@ }; struct TruncatedExtendedOpcodeFixture - : public TestWithParam>, + : public TestWithParam< + std::tuple, StringRef>>, public TruncatedOpcodeFixtureBase { void SetUp() { + Optional ExpectedOutputBigEndian; std::tie(BodyLength, OpcodeLength, Opcode, Operands, ExpectedOutput, - ExpectedErr) = GetParam(); - // Swap the byte order of the operands on big endian hosts, so that the raw - // bytes are always in the same order. ValLen.Value is a uint64_t, so make - // sure to shift the value back to the actually used bits for the - // appropriate type. - if (sys::IsBigEndianHost) - for (LineTable::ValueAndLength &ValLen : Operands) - if (ValLen.Length != LineTable::SLEB && - ValLen.Length != LineTable::ULEB && - ValLen.Length != LineTable::Byte) { - sys::swapByteOrder(ValLen.Value); - if (ValLen.Length == LineTable::Long) - ValLen.Value >>= 32; - if (ValLen.Length == LineTable::Half) - ValLen.Value >>= 48; - } + ExpectedOutputBigEndian, ExpectedErr) = GetParam(); + if (!getGeneratorTriple().isLittleEndian() && ExpectedOutputBigEndian) + ExpectedOutput = ExpectedOutputBigEndian.getValue(); } uint64_t OpcodeLength; @@ -1478,22 +1470,24 @@ Values( // Truncated length: std::make_tuple(1, 1, /*ArbitraryOpcode=*/0x7f, ValueAndLengths(), "", + None, "unable to decode LEB128 at offset 0x00000030: " "malformed uleb128, extends past end"), // Truncated opcode: std::make_tuple( - 2, 9, /*ArbitraryOpcode=*/0x7f, ValueAndLengths(), "", + 2, 9, /*ArbitraryOpcode=*/0x7f, ValueAndLengths(), "", None, "unexpected end of data at offset 0x31 while reading [0x31, 0x32)"), // Truncated operands: std::make_tuple( 3, 9, DW_LNE_set_address, ValueAndLengths{{0x1234567890abcdef, LineTable::Quad}}, - "DW_LNE_set_address", + "DW_LNE_set_address", None, "unexpected end of data at offset 0x32 while reading [0x32, 0x3a)"), std::make_tuple( 10, 9, DW_LNE_set_address, ValueAndLengths{{0x1234567890abcdef, LineTable::Quad}}, "DW_LNE_set_address ( ef cd ab 90 78 56 34)", + "DW_LNE_set_address ( 12 34 56 78 90 ab cd)", "unexpected end of data at offset 0x39 while reading [0x32, 0x3a)"), std::make_tuple(3, 6, DW_LNE_define_file, ValueAndLengths{{'a', LineTable::Byte}, @@ -1501,7 +1495,7 @@ {1, LineTable::ULEB}, {1, LineTable::ULEB}, {1, LineTable::ULEB}}, - "DW_LNE_define_file", + "DW_LNE_define_file", None, "no null terminated string at offset 0x32"), std::make_tuple(5, 6, DW_LNE_define_file, ValueAndLengths{{'a', LineTable::Byte}, @@ -1509,7 +1503,7 @@ {1, LineTable::ULEB}, {1, LineTable::ULEB}, {1, LineTable::ULEB}}, - "DW_LNE_define_file ( 61 00)", + "DW_LNE_define_file ( 61 00)", None, "unable to decode LEB128 at offset 0x00000034: " "malformed uleb128, extends past end"), std::make_tuple(6, 6, DW_LNE_define_file, @@ -1518,7 +1512,7 @@ {1, LineTable::ULEB}, {1, LineTable::ULEB}, {1, LineTable::ULEB}}, - "DW_LNE_define_file ( 61 00 01)", + "DW_LNE_define_file ( 61 00 01)", None, "unable to decode LEB128 at offset 0x00000035: " "malformed uleb128, extends past end"), std::make_tuple(7, 6, DW_LNE_define_file, @@ -1528,17 +1522,19 @@ {1, LineTable::ULEB}, {1, LineTable::ULEB}}, "DW_LNE_define_file ( 61 00 01 01)", + None, "unable to decode LEB128 at offset 0x00000036: " "malformed uleb128, extends past end"), std::make_tuple(3, 2, DW_LNE_set_discriminator, ValueAndLengths{{1, LineTable::ULEB}}, - "DW_LNE_set_discriminator", + "DW_LNE_set_discriminator", None, "unable to decode LEB128 at offset 0x00000032: " "malformed uleb128, extends past end"), std::make_tuple( 6, 5, /*Unknown=*/0x7f, ValueAndLengths{{0x12345678, LineTable::Long}}, "Unrecognized extended op 0x7f length 5 ( 78 56 34)", + "Unrecognized extended op 0x7f length 5 ( 12 34 56)", "unexpected end of data at offset 0x35 while reading [0x32, " "0x36)")), );