diff options
author | Paul Robinson <paul.robinson@sony.com> | 2017-12-15 22:57:17 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2017-12-15 22:57:17 +0000 |
commit | bee91d76343aa0fd5d616ec0e74b74e6de2bb545 (patch) | |
tree | 8296976798a627e4e3ca58af292cef0e6f5222fa /unittests | |
parent | 35877056519fc2d23eb09527d204738234b908a9 (diff) |
Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header."
Adds missing support for DW_FORM_data16.
Update of r320852, fixing the unittest to use a hand-coded struct
instead of std::array to guarantee data layout.
Differential Revision: https://reviews.llvm.org/D41090
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320886 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 | 11 |
2 files changed, 29 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..8d9edb3e9aa 100644 --- a/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp +++ b/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp @@ -160,6 +160,17 @@ 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. + struct uint128_t { + uint8_t Bytes[16]; + }; + uint128_t Item16({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}); + auto Data16 = createDataXFormValue<uint128_t>(DW_FORM_data16, Item16); + SmallString<32> Str; + raw_svector_ostream Res(Str); + Data16.dump(Res, DIDumpOptions()); + EXPECT_EQ(memcmp(Str.data(), "000102030405060708090a0b0c0d0e0f", 32), 0); } } // end anonymous namespace |