summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2017-12-18 19:08:35 +0000
committerPaul Robinson <paul.robinson@sony.com>2017-12-18 19:08:35 +0000
commita06f8dcca63fea724d60cbd9b776c43be849bf2b (patch)
tree20b5b5940612f864da3227a72f46dca5f19bb045 /llvm/unittests/DebugInfo
parentf4cc67acb66c33f006be1e05686eafe5e76f2b36 (diff)
downloadbcm5719-llvm-a06f8dcca63fea724d60cbd9b776c43be849bf2b.tar.gz
bcm5719-llvm-a06f8dcca63fea724d60cbd9b776c43be849bf2b.zip
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 llvm-svn: 321011
Diffstat (limited to 'llvm/unittests/DebugInfo')
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp18
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp12
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 953c5c57d20..cb7bf82d86f 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/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/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
index 14550b9082b..c552623a786 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud