diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -140,11 +140,6 @@ // for the length. if (arangeDescriptor.Address == 0 && *offset_ptr == end_offset) return ErrorSuccess(); - return createStringError( - errc::invalid_argument, - "address range table at offset 0x%" PRIx64 - " has an invalid tuple (length = 0) at offset 0x%" PRIx64, - Offset, *offset_ptr - tuple_size); } ArangeDescriptors.push_back(arangeDescriptor); diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h" +#include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" using namespace llvm; @@ -168,7 +169,7 @@ TEST(DWARFDebugArangeSet, ZeroLengthEntry) { static const char DebugArangesSecRaw[] = - "\x24\x00\x00\x00" // Length + "\x2c\x00\x00\x00" // Length "\x02\x00" // Version "\x00\x00\x00\x00" // Debug Info Offset "\x04" // Address Size @@ -177,13 +178,29 @@ "\x00\x00\x00\x00" // Entry1: Address "\x01\x00\x00\x00" // Length "\x01\x00\x00\x00" // Entry2: Address - "\x00\x00\x00\x00" // Length (invalid) + "\x00\x00\x00\x00" // Length + "\x00\x00\x00\x00" // Entry3: Address + "\x00\x00\x00\x00" // Length "\x00\x00\x00\x00" // Termination tuple "\x00\x00\x00\x00"; - ExpectExtractError( - DebugArangesSecRaw, - "address range table at offset 0x0 has an invalid tuple (length = 0) " - "at offset 0x18"); + DWARFDataExtractor Extractor( + StringRef(DebugArangesSecRaw, sizeof(DebugArangesSecRaw) - 1), + /*IsLittleEndian=*/true, + /*AddressSize=*/4); + DWARFDebugArangeSet Set; + uint64_t Offset = 0; + ASSERT_THAT_ERROR(Set.extract(Extractor, &Offset), Succeeded()); + auto Range = Set.descriptors(); + auto Iter = Range.begin(); + ASSERT_EQ(std::distance(Iter, Range.end()), 3u); + EXPECT_EQ(Iter->Address, 0u); + EXPECT_EQ(Iter->Length, 1u); + ++Iter; + EXPECT_EQ(Iter->Address, 1u); + EXPECT_EQ(Iter->Length, 0u); + ++Iter; + EXPECT_EQ(Iter->Address, 0u); + EXPECT_EQ(Iter->Length, 0u); } } // end anonymous namespace