[llvm] eea9040 - [DebugInfo][test] Fix host endian test issue
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 10 08:24:05 PST 2020
Author: James Henderson
Date: 2020-02-10T16:23:30Z
New Revision: eea9040f42195afb9964665bd8f696484c8eb52e
URL: https://github.com/llvm/llvm-project/commit/eea9040f42195afb9964665bd8f696484c8eb52e
DIFF: https://github.com/llvm/llvm-project/commit/eea9040f42195afb9964665bd8f696484c8eb52e.diff
LOG: [DebugInfo][test] Fix host endian test issue
The test previously assumed that the host was little endian, which broke
the big endian build bots.
Added:
Modified:
llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
index 2af3d4c1c0d6..68b85f7c68cb 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
@@ -158,12 +158,19 @@ struct FormSkipValueFixtureBase : public testing::TestWithParam<ParamType> {
bool ExpectedResult;
};
+template <typename T> static ArrayRef<uint8_t> toBytes(const T &Input) {
+ return ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(&Input),
+ sizeof(Input));
+}
+
const uint8_t LEBData[] = {0x80, 0x1};
ArrayRef<uint8_t> SampleLEB(LEBData, sizeof(LEBData));
-const uint64_t SampleLength = 0x80;
-ArrayRef<uint8_t>
-SampleUnsigned(reinterpret_cast<const uint8_t *>(&SampleLength),
- sizeof(SampleLength));
+const uint8_t SampleLength8 = 0x80;
+const uint16_t SampleLength16 = 0x80;
+const uint32_t SampleLength = 0x80;
+ArrayRef<uint8_t> SampleU8 = toBytes(SampleLength8);
+ArrayRef<uint8_t> SampleU16 = toBytes(SampleLength16);
+ArrayRef<uint8_t> SampleU32 = toBytes(SampleLength);
const uint8_t StringData[] = "abcdef";
ArrayRef<uint8_t> SampleString(StringData, sizeof(StringData));
const uint8_t IndirectData8[] = {DW_FORM_data8};
@@ -188,75 +195,73 @@ INSTANTIATE_TEST_CASE_P(
SampleLength + SampleLEB.size(), true),
ParamType(DW_FORM_block, 0, 0, DWARF32, SampleLEB,
SampleLength + SampleLEB.size(), true),
- ParamType(DW_FORM_block1, 0, 0, DWARF32, SampleUnsigned,
- SampleLength + 1, true),
- ParamType(DW_FORM_block2, 0, 0, DWARF32, SampleUnsigned,
- SampleLength + 2, true),
- ParamType(DW_FORM_block4, 0, 0, DWARF32, SampleUnsigned,
- SampleLength + 4, true),
+ ParamType(DW_FORM_block1, 0, 0, DWARF32, SampleU8, SampleLength8 + 1,
+ true),
+ ParamType(DW_FORM_block2, 0, 0, DWARF32, SampleU16, SampleLength16 + 2,
+ true),
+ ParamType(DW_FORM_block4, 0, 0, DWARF32, SampleU32, SampleLength + 4,
+ true),
ParamType(DW_FORM_string, 0, 0, DWARF32, SampleString,
SampleString.size(), true),
- ParamType(DW_FORM_addr, 0, 42, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_addr, 4, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_addr, 4, 42, DWARF32, SampleUnsigned, 42, true),
- ParamType(DW_FORM_ref_addr, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_ref_addr, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_ref_addr, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_ref_addr, 1, 1, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_ref_addr, 2, 42, DWARF32, SampleUnsigned, 42, true),
- ParamType(DW_FORM_ref_addr, 2, 42, DWARF64, SampleUnsigned, 42, true),
- ParamType(DW_FORM_ref_addr, 3, 3, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_ref_addr, 3, 3, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_flag_present, 4, 4, DWARF32, SampleUnsigned, 0, true),
- ParamType(DW_FORM_data1, 0, 0, DWARF32, SampleUnsigned, 1, true),
- ParamType(DW_FORM_data2, 0, 0, DWARF32, SampleUnsigned, 2, true),
- ParamType(DW_FORM_data4, 0, 0, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_data8, 0, 0, DWARF32, SampleUnsigned, 8, true),
- ParamType(DW_FORM_data16, 0, 0, DWARF32, SampleUnsigned, 16, true),
- ParamType(DW_FORM_flag, 0, 0, DWARF32, SampleUnsigned, 1, true),
- ParamType(DW_FORM_ref1, 0, 0, DWARF32, SampleUnsigned, 1, true),
- ParamType(DW_FORM_ref2, 0, 0, DWARF32, SampleUnsigned, 2, true),
- ParamType(DW_FORM_ref4, 0, 0, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_ref8, 0, 0, DWARF32, SampleUnsigned, 8, true),
- ParamType(DW_FORM_ref_sig8, 0, 0, DWARF32, SampleUnsigned, 8, true),
- ParamType(DW_FORM_ref_sup4, 0, 0, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_ref_sup8, 0, 0, DWARF32, SampleUnsigned, 8, true),
- ParamType(DW_FORM_strx1, 0, 0, DWARF32, SampleUnsigned, 1, true),
- ParamType(DW_FORM_strx2, 0, 0, DWARF32, SampleUnsigned, 2, true),
- ParamType(DW_FORM_strx4, 0, 0, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_addrx1, 0, 0, DWARF32, SampleUnsigned, 1, true),
- ParamType(DW_FORM_addrx2, 0, 0, DWARF32, SampleUnsigned, 2, true),
- ParamType(DW_FORM_addrx4, 0, 0, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_sec_offset, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_sec_offset, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_sec_offset, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_sec_offset, 1, 1, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_strp, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_strp, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_strp, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_strp, 1, 1, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_strp_sup, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_strp_sup, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_strp_sup, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_strp_sup, 1, 1, DWARF64, SampleUnsigned, 8, true)), );
+ ParamType(DW_FORM_addr, 0, 42, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_addr, 4, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_addr, 4, 42, DWARF32, SampleU32, 42, true),
+ ParamType(DW_FORM_ref_addr, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_ref_addr, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_ref_addr, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_ref_addr, 1, 1, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_ref_addr, 2, 42, DWARF32, SampleU32, 42, true),
+ ParamType(DW_FORM_ref_addr, 2, 42, DWARF64, SampleU32, 42, true),
+ ParamType(DW_FORM_ref_addr, 3, 3, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_ref_addr, 3, 3, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_flag_present, 4, 4, DWARF32, SampleU32, 0, true),
+ ParamType(DW_FORM_data1, 0, 0, DWARF32, SampleU32, 1, true),
+ ParamType(DW_FORM_data2, 0, 0, DWARF32, SampleU32, 2, true),
+ ParamType(DW_FORM_data4, 0, 0, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_data8, 0, 0, DWARF32, SampleU32, 8, true),
+ ParamType(DW_FORM_data16, 0, 0, DWARF32, SampleU32, 16, true),
+ ParamType(DW_FORM_flag, 0, 0, DWARF32, SampleU32, 1, true),
+ ParamType(DW_FORM_ref1, 0, 0, DWARF32, SampleU32, 1, true),
+ ParamType(DW_FORM_ref2, 0, 0, DWARF32, SampleU32, 2, true),
+ ParamType(DW_FORM_ref4, 0, 0, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_ref8, 0, 0, DWARF32, SampleU32, 8, true),
+ ParamType(DW_FORM_ref_sig8, 0, 0, DWARF32, SampleU32, 8, true),
+ ParamType(DW_FORM_ref_sup4, 0, 0, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_ref_sup8, 0, 0, DWARF32, SampleU32, 8, true),
+ ParamType(DW_FORM_strx1, 0, 0, DWARF32, SampleU32, 1, true),
+ ParamType(DW_FORM_strx2, 0, 0, DWARF32, SampleU32, 2, true),
+ ParamType(DW_FORM_strx4, 0, 0, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_addrx1, 0, 0, DWARF32, SampleU32, 1, true),
+ ParamType(DW_FORM_addrx2, 0, 0, DWARF32, SampleU32, 2, true),
+ ParamType(DW_FORM_addrx4, 0, 0, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_sec_offset, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_sec_offset, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_sec_offset, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_sec_offset, 1, 1, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_strp, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_strp, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_strp, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_strp, 1, 1, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_strp_sup, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_strp_sup, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_strp_sup, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_strp_sup, 1, 1, DWARF64, SampleU32, 8, true)), );
INSTANTIATE_TEST_CASE_P(
SkipValueTestParams2, FormSkipValueFixture2,
testing::Values(
- ParamType(DW_FORM_line_strp, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_line_strp, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_line_strp, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_line_strp, 1, 1, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_GNU_ref_alt, 0, 1, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_GNU_ref_alt, 1, 0, DWARF32, SampleUnsigned, 0, false),
- ParamType(DW_FORM_GNU_ref_alt, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_GNU_ref_alt, 1, 1, DWARF64, SampleUnsigned, 8, true),
- ParamType(DW_FORM_GNU_strp_alt, 0, 1, DWARF32, SampleUnsigned, 0,
- false),
- ParamType(DW_FORM_GNU_strp_alt, 1, 0, DWARF32, SampleUnsigned, 0,
- false),
- ParamType(DW_FORM_GNU_strp_alt, 1, 1, DWARF32, SampleUnsigned, 4, true),
- ParamType(DW_FORM_GNU_strp_alt, 1, 1, DWARF64, SampleUnsigned, 8, true),
+ ParamType(DW_FORM_line_strp, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_line_strp, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_line_strp, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_line_strp, 1, 1, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_GNU_ref_alt, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_GNU_ref_alt, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_GNU_ref_alt, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_GNU_ref_alt, 1, 1, DWARF64, SampleU32, 8, true),
+ ParamType(DW_FORM_GNU_strp_alt, 0, 1, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_GNU_strp_alt, 1, 0, DWARF32, SampleU32, 0, false),
+ ParamType(DW_FORM_GNU_strp_alt, 1, 1, DWARF32, SampleU32, 4, true),
+ ParamType(DW_FORM_GNU_strp_alt, 1, 1, DWARF64, SampleU32, 8, true),
ParamType(DW_FORM_sdata, 0, 0, DWARF32, SampleLEB, SampleLEB.size(),
true),
ParamType(DW_FORM_udata, 0, 0, DWARF32, SampleLEB, SampleLEB.size(),
@@ -295,7 +300,7 @@ INSTANTIATE_TEST_CASE_P(
ArrayRef<uint8_t>(IndirectIndirectEnd,
sizeof(IndirectIndirectEnd)),
2, false),
- ParamType(/*Unknown=*/Form(0xff), 4, 4, DWARF32, SampleUnsigned, 0,
+ ParamType(/*Unknown=*/Form(0xff), 4, 4, DWARF32, SampleU32, 0,
false)), );
} // end anonymous namespace
More information about the llvm-commits
mailing list