llvm.org GIT mirror llvm / 86e9c5d
Revert "[DWARFv5] Dump an MD5 checksum in the line-table header." Unit test fails on some bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320857 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Robinson 2 years ago
7 changed file(s) with 27 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
1414 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
1515 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
1616 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
17 #include "llvm/Support/MD5.h"
1817 #include
1918 #include
2019 #include
3433 uint64_t DirIdx = 0;
3534 uint64_t ModTime = 0;
3635 uint64_t Length = 0;
37 MD5::MD5Result Checksum;
3836 };
3937
4038 struct Prologue {
4745 /// parameters affect interpretation of forms (used in the directory and
4846 /// file tables starting with v5).
4947 DWARFFormParams FormParams;
48 /// In v5, size in bytes of a segment selector.
49 uint8_t SegSelectorSize;
5050 /// The number of bytes following the prologue_length field to the beginning
5151 /// of the first byte of the statement program itself.
5252 uint64_t PrologueLength;
53 /// In v5, size in bytes of a segment selector.
54 uint8_t SegSelectorSize;
5553 /// The size in bytes of the smallest target machine instruction. Statement
5654 /// program opcodes that alter the address register first multiply their
5755 /// operands by this value.
6765 uint8_t LineRange;
6866 /// The number assigned to the first special opcode.
6967 uint8_t OpcodeBase;
70 /// For v5, whether filename entries provide an MD5 checksum.
71 bool HasMD5;
7268 std::vector StandardOpcodeLengths;
7369 std::vector IncludeDirectories;
7470 std::vector FileNames;
776776 case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
777777 case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
778778 case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break;
779 case dwarf::DW_FORM_data16: break;
780779 }
781780
782781 for (const auto &V : values())
791790 case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
792791 case dwarf::DW_FORM_block4: return Size + sizeof(int32_t);
793792 case dwarf::DW_FORM_block: return Size + getULEB128Size(Size);
794 case dwarf::DW_FORM_data16: return 16;
795793 default: llvm_unreachable("Improper form for block");
796794 }
797795 }
4747 MinInstLength = MaxOpsPerInst = DefaultIsStmt = LineBase = LineRange = 0;
4848 OpcodeBase = 0;
4949 FormParams = DWARFFormParams({0, 0, DWARF32});
50 HasMD5 = false;
5150 StandardOpcodeLengths.clear();
5251 IncludeDirectories.clear();
5352 FileNames.clear();
7877 << IncludeDirectories[I] << "'\n";
7978
8079 if (!FileNames.empty()) {
81 if (HasMD5)
82 OS << " Dir MD5 Checksum File Name\n"
83 << " ---- -------------------------------- -----------"
84 "---------------\n";
85 else
86 OS << " Dir Mod Time File Len File Name\n"
87 << " ---- ---------- ---------- -----------"
88 "----------------\n";
80 OS << " Dir Mod Time File Len File Name\n"
81 << " ---- ---------- ---------- -----------"
82 "----------------\n";
8983 for (uint32_t I = 0; I != FileNames.size(); ++I) {
9084 const FileNameEntry &FileEntry = FileNames[I];
91 OS << format("file_names[%3u] %4" PRIu64 " ", I + 1, FileEntry.DirIdx);
92 if (HasMD5)
93 OS << FileEntry.Checksum.digest();
94 else
95 OS << format("0x%8.8" PRIx64 " 0x%8.8" PRIx64, FileEntry.ModTime,
96 FileEntry.Length);
97 OS << ' ' << FileEntry.Name << '\n';
85 OS << format("file_names[%3u] %4" PRIu64 " ", I + 1, FileEntry.DirIdx)
86 << format("0x%8.8" PRIx64 " 0x%8.8" PRIx64 " ", FileEntry.ModTime,
87 FileEntry.Length)
88 << FileEntry.Name << '\n';
9889 }
9990 }
10091 }
130121 // ran off the end of the prologue.
131122 static ContentDescriptors
132123 parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
133 uint64_t EndPrologueOffset, bool *HasMD5) {
124 uint64_t EndPrologueOffset) {
134125 ContentDescriptors Descriptors;
135126 int FormatCount = DebugLineData.getU8(OffsetPtr);
136127 bool HasPath = false;
143134 Descriptor.Form = dwarf::Form(DebugLineData.getULEB128(OffsetPtr));
144135 if (Descriptor.Type == dwarf::DW_LNCT_path)
145136 HasPath = true;
146 else if (Descriptor.Type == dwarf::DW_LNCT_MD5 && HasMD5)
147 *HasMD5 = true;
148137 Descriptors.push_back(Descriptor);
149138 }
150139 return HasPath ? Descriptors : ContentDescriptors();
154143 parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
155144 uint32_t *OffsetPtr, uint64_t EndPrologueOffset,
156145 const DWARFFormParams &FormParams, const DWARFUnit *U,
157 bool &HasMD5, std::vector &IncludeDirectories,
146 std::vector &IncludeDirectories,
158147 std::vector &FileNames) {
159148 // Get the directory entry description.
160149 ContentDescriptors DirDescriptors =
161 parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset, nullptr);
150 parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset);
162151 if (DirDescriptors.empty())
163152 return false;
164153
184173
185174 // Get the file entry description.
186175 ContentDescriptors FileDescriptors =
187 parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset, &HasMD5);
176 parseV5EntryFormat(DebugLineData, OffsetPtr, EndPrologueOffset);
188177 if (FileDescriptors.empty())
189178 return false;
190179
211200 case DW_LNCT_size:
212201 FileEntry.Length = Value.getAsUnsignedConstant().getValue();
213202 break;
214 case DW_LNCT_MD5:
215 assert(Value.getAsBlock().getValue().size() == 16);
216 std::uninitialized_copy_n(Value.getAsBlock().getValue().begin(), 16,
217 FileEntry.Checksum.Bytes.begin());
218 break;
203 // FIXME: Add MD5
219204 default:
220205 break;
221206 }
267252
268253 if (getVersion() >= 5) {
269254 if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
270 getFormParams(), U, HasMD5, IncludeDirectories,
255 getFormParams(), U, IncludeDirectories,
271256 FileNames)) {
272257 fprintf(stderr,
273258 "warning: parsing line table prologue at 0x%8.8" PRIx64
185185 case DW_FORM_data2:
186186 case DW_FORM_data4:
187187 case DW_FORM_data8:
188 case DW_FORM_data16:
189188 case DW_FORM_flag:
190189 case DW_FORM_ref1:
191190 case DW_FORM_ref2:
339338 case DW_FORM_ref_sup8:
340339 Value.uval = Data.getU64(OffsetPtr);
341340 break;
342 case DW_FORM_data16:
343 // Treat this like a 16-byte block.
344 Value.uval = 16;
345 IsBlock = true;
346 break;
347341 case DW_FORM_sdata:
348342 Value.sval = Data.getSLEB128(OffsetPtr);
349343 break;
436430 break;
437431 case DW_FORM_data8:
438432 OS << format("0x%016" PRIx64, UValue);
439 break;
440 case DW_FORM_data16:
441 OS << format_bytes(ArrayRef(Value.data, 16), None, 16, 16);
442433 break;
443434 case DW_FORM_string:
444435 OS << '"';
659650 }
660651
661652 Optional> DWARFFormValue::getAsBlock() const {
662 if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) &&
663 Form != DW_FORM_data16)
653 if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc))
664654 return None;
665655 return makeArrayRef(Value.data, Value.uval);
666656 }
297297 .long str_LT_5a
298298 .long str_LT_5b
299299 # File table format
300 .byte 3 # Three elements per file entry
300 .byte 4 # Four elements per file entry
301301 .byte 1 # DW_LNCT_path
302302 .byte 0x08 # DW_FORM_string
303303 .byte 2 # DW_LNCT_directory_index
304304 .byte 0x0b # DW_FORM_data1
305 .byte 5 # DW_LNCT_MD5
306 .byte 0x1e # DW_FORM_data16
305 .byte 3 # DW_LNCT_timestamp
306 .byte 0x0f # DW_FORM_udata
307 .byte 4 # DW_LNCT_size
308 .byte 0x0f # DW_FORM_udata
307309 # File table entries
308310 .byte 2 # Two files
309311 .asciz "File5a"
310312 .byte 1
311 .quad 0x7766554433221100
312 .quad 0xffeeddccbbaa9988
313 .byte 0x51
314 .byte 0x52
313315 .asciz "File5b"
314316 .byte 2
315 .quad 0x8899aabbccddeeff
316 .quad 0x0011223344556677
317 .byte 0x53
318 .byte 0x54
317319 LH_5_header_end:
318320 # Line number program, which is empty.
319321 LH_5_end:
326328 # CHECK: include_directories[ 1] = 'Directory5a'
327329 # CHECK: include_directories[ 2] = 'Directory5b'
328330 # CHECK-NOT: include_directories
329 # CHECK: MD5 Checksum
330 # CHECK: file_names[ 1] 1 00112233445566778899aabbccddeeff File5a{{$}}
331 # CHECK: file_names[ 2] 2 ffeeddccbbaa99887766554433221100 File5b{{$}}
331 # CHECK: file_names[ 1] 1 0x00000051 0x00000052 File5a{{$}}
332 # CHECK: file_names[ 2] 2 0x00000053 0x00000054 File5b{{$}}
332333 # CHECK-NOT: file_names
333334
334335 .section .debug_line.dwo,"",@progbits
8181 const uint32_t Data4 = 0x6789abcdU;
8282 const uint64_t Data8 = 0x0011223344556677ULL;
8383 const uint64_t Data8_2 = 0xAABBCCDDEEFF0011ULL;
84 const uint8_t Data16[16] = {1, 2, 3, 4, 5, 6, 7, 8,
85 9, 10, 11, 12, 13, 14, 15, 16};
8684 const int64_t SData = INT64_MIN;
8785 const int64_t ICSData = INT64_MAX; // DW_FORM_implicit_const SData
8886 const uint64_t UData[] = {UINT64_MAX - 1, UINT64_MAX - 2, UINT64_MAX - 3,
120118
121119 const auto Attr_DW_FORM_block4 = static_cast(Attr++);
122120 CUDie.addAttribute(Attr_DW_FORM_block4, DW_FORM_block4, BlockData, BlockSize);
123
124 // We handle data16 as a block form.
125 const auto Attr_DW_FORM_data16 = static_cast(Attr++);
126 if (Version >= 5)
127 CUDie.addAttribute(Attr_DW_FORM_data16, DW_FORM_data16, Data16, 16);
128121
129122 //----------------------------------------------------------------------
130123 // Test data forms
281274 ExtractedBlockData = BlockDataOpt.getValue();
282275 EXPECT_EQ(ExtractedBlockData.size(), BlockSize);
283276 EXPECT_TRUE(memcmp(ExtractedBlockData.data(), BlockData, BlockSize) == 0);
284
285 // Data16 is handled like a block.
286 if (Version >= 5) {
287 FormValue = DieDG.find(Attr_DW_FORM_data16);
288 EXPECT_TRUE((bool)FormValue);
289 BlockDataOpt = FormValue->getAsBlock();
290 EXPECT_TRUE(BlockDataOpt.hasValue());
291 ExtractedBlockData = BlockDataOpt.getValue();
292 EXPECT_EQ(ExtractedBlockData.size(), 16u);
293 EXPECT_TRUE(memcmp(ExtractedBlockData.data(), Data16, 16) == 0);
294 }
295277
296278 //----------------------------------------------------------------------
297279 // Test data forms
159159 EXPECT_EQ(LEBMax.getAsSignedConstant().getValue(), LLONG_MAX);
160160 EXPECT_EQ(LEB1.getAsSignedConstant().getValue(), -42);
161161 EXPECT_EQ(LEB2.getAsSignedConstant().getValue(), 42);
162
163 // Data16 is a little tricky.
164 using uint128_t = std::array;
165 uint128_t Item16({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
166 auto Data16 = createDataXFormValue(DW_FORM_data16, Item16);
167 SmallString<32> Str;
168 raw_svector_ostream Res(Str);
169 Data16.dump(Res, DIDumpOptions());
170 EXPECT_EQ(memcmp(Str.data(), "000102030405060708090a0b0c0d0e0f", 32), 0);
171162 }
172163
173164 } // end anonymous namespace