diff options
author | Paul Robinson <paul.robinson@sony.com> | 2017-12-18 19:08:35 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2017-12-18 19:08:35 +0000 |
commit | a6d921ec5bff51da7c7f95340777b4ce75d7f840 (patch) | |
tree | d8902339ecf01eceda72bc4170448ac34917fa20 /unittests | |
parent | 0aa7e5ab503d7bf33113877794f1c86aacb6dc98 (diff) |
Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header."
Adds missing support for DW_FORM_data16.
Update of r320852/r320886, fixing the unittest again, this time use a
raw char string for the test data.
Differential Revision: https://reviews.llvm.org/D41090
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | 18 | ||||
-rw-r--r-- | unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp index 953c5c57d20..cb7bf82d86f 100644 --- a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -82,6 +82,8 @@ void TestAllForms() { const uint32_t Data4 = 0x6789abcdU; const uint64_t Data8 = 0x0011223344556677ULL; const uint64_t Data8_2 = 0xAABBCCDDEEFF0011ULL; + const uint8_t Data16[16] = {1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16}; const int64_t SData = INT64_MIN; const int64_t ICSData = INT64_MAX; // DW_FORM_implicit_const SData const uint64_t UData[] = {UINT64_MAX - 1, UINT64_MAX - 2, UINT64_MAX - 3, @@ -120,6 +122,11 @@ void TestAllForms() { const auto Attr_DW_FORM_block4 = static_cast<dwarf::Attribute>(Attr++); CUDie.addAttribute(Attr_DW_FORM_block4, DW_FORM_block4, BlockData, BlockSize); + // We handle data16 as a block form. + const auto Attr_DW_FORM_data16 = static_cast<dwarf::Attribute>(Attr++); + if (Version >= 5) + CUDie.addAttribute(Attr_DW_FORM_data16, DW_FORM_data16, Data16, 16); + //---------------------------------------------------------------------- // Test data forms //---------------------------------------------------------------------- @@ -276,6 +283,17 @@ void TestAllForms() { EXPECT_EQ(ExtractedBlockData.size(), BlockSize); EXPECT_TRUE(memcmp(ExtractedBlockData.data(), BlockData, BlockSize) == 0); + // Data16 is handled like a block. + if (Version >= 5) { + FormValue = DieDG.find(Attr_DW_FORM_data16); + EXPECT_TRUE((bool)FormValue); + BlockDataOpt = FormValue->getAsBlock(); + EXPECT_TRUE(BlockDataOpt.hasValue()); + ExtractedBlockData = BlockDataOpt.getValue(); + EXPECT_EQ(ExtractedBlockData.size(), 16u); + EXPECT_TRUE(memcmp(ExtractedBlockData.data(), Data16, 16) == 0); + } + //---------------------------------------------------------------------- // Test data forms //---------------------------------------------------------------------- diff --git a/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp index 14550b9082b..c552623a786 100644 --- a/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp +++ b/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp @@ -160,6 +160,18 @@ TEST(DWARFFormValue, SignedConstantForms) { EXPECT_EQ(LEBMax.getAsSignedConstant().getValue(), LLONG_MAX); EXPECT_EQ(LEB1.getAsSignedConstant().getValue(), -42); EXPECT_EQ(LEB2.getAsSignedConstant().getValue(), 42); + + // Data16 is a little tricky. + char Cksum[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + DWARFFormValue Data16(DW_FORM_data16); + DWARFDataExtractor DE16(StringRef(Cksum, 16), sys::IsLittleEndianHost, + sizeof(void *)); + uint32_t Offset = 0; + Data16.extractValue(DE16, &Offset, {0, 0, dwarf::DwarfFormat::DWARF32}); + SmallString<32> Str; + raw_svector_ostream Res(Str); + Data16.dump(Res, DIDumpOptions()); + EXPECT_EQ(memcmp(Str.data(), "000102030405060708090a0b0c0d0e0f", 32), 0); } } // end anonymous namespace |