llvm.org GIT mirror llvm / c5689fd
[pdb] Dump file checksums from pdb codeview line info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271622 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 4 years ago
8 changed file(s) with 82 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
536536 };
537537
538538 enum class TrampolineType { TrampIncremental, BranchIsland };
539
540 // These values correspond to the CV_SourceChksum_t enumeration.
541 enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
542
543 enum LineFlags : uint32_t {
544 HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
545 };
539546 }
540547 }
541548
2626 ArrayRef> getSourceLanguageNames();
2727 ArrayRef> getCompileSym2FlagNames();
2828 ArrayRef> getCompileSym3FlagNames();
29 ArrayRef> getFileChecksumNames();
2930 ArrayRef> getCPUTypeNames();
3031 ArrayRef> getFrameProcSymFlagNames();
3132 ArrayRef> getExportSymFlagNames();
140140 // ulittle32_t Files[];
141141 };
142142
143 enum class FileChecksumKind : uint8_t {
144 None,
145 MD5,
146 SHA1,
147 SHA256
148 };
149
150143 struct FileChecksum {
151144 ulittle32_t FileNameOffset; // Offset of filename in string table substream.
152145 uint8_t ChecksumSize;
154147 // Checksum bytes follow.
155148 };
156149
157 enum LineFlags : uint32_t {
158 HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
159 };
160
161150 } // namespace codeview
162151 } // namespace llvm
163152
2525 FixedStreamArray Columns;
2626 };
2727
28 class FileLineInfoExtractor {
28 template <> class VarStreamArrayExtractor {
2929 public:
30 FileLineInfoExtractor(const LineSubstreamHeader *Header) : Header(Header) {}
30 VarStreamArrayExtractor(const LineSubstreamHeader *Header) : Header(Header) {}
3131
3232 Error operator()(StreamRef Stream, uint32_t &Len,
3333 LineColumnEntry &Item) const {
6363 const LineSubstreamHeader *Header;
6464 };
6565
66 typedef VarStreamArray LineInfoArray;
66 struct FileChecksumEntry {
67 uint32_t FileNameOffset;
68 FileChecksumKind Kind;
69 ArrayRef Checksum;
70 };
71
72 template <> class VarStreamArrayExtractor {
73 public:
74 Error operator()(StreamRef Stream, uint32_t &Len,
75 FileChecksumEntry &Item) const {
76 const FileChecksum *Header;
77 StreamReader Reader(Stream);
78 if (auto EC = Reader.readObject(Header))
79 return EC;
80 Item.FileNameOffset = Header->FileNameOffset;
81 Item.Kind = static_cast(Header->ChecksumKind);
82 if (auto EC = Reader.readBytes(Item.Checksum, Header->ChecksumSize))
83 return EC;
84 Len = sizeof(FileChecksum) + Header->ChecksumSize;
85 return Error::success();
86 }
87 };
88
89 typedef VarStreamArray LineInfoArray;
90 typedef VarStreamArray FileChecksumArray;
6791
6892 class IModuleSubstreamVisitor {
6993 public:
7296 virtual Error visitUnknown(ModuleSubstreamKind Kind, StreamRef Data) = 0;
7397 virtual Error visitSymbols(StreamRef Data);
7498 virtual Error visitLines(StreamRef Data, const LineSubstreamHeader *Header,
75 LineInfoArray Lines);
99 const LineInfoArray &Lines);
76100 virtual Error visitStringTable(StreamRef Data);
77 virtual Error visitFileChecksums(StreamRef Data);
101 virtual Error visitFileChecksums(StreamRef Data,
102 const FileChecksumArray &Checksums);
78103 virtual Error visitFrameData(StreamRef Data);
79104 virtual Error visitInlineeLines(StreamRef Data);
80105 virtual Error visitCrossScopeImports(StreamRef Data);
144144 CV_ENUM_CLASS_ENT(CompileSym3Flags, Sdl),
145145 CV_ENUM_CLASS_ENT(CompileSym3Flags, PGO),
146146 CV_ENUM_CLASS_ENT(CompileSym3Flags, Exp),
147 };
148
149 static const EnumEntry FileChecksumNames[] = {
150 CV_ENUM_CLASS_ENT(FileChecksumKind, None),
151 CV_ENUM_CLASS_ENT(FileChecksumKind, MD5),
152 CV_ENUM_CLASS_ENT(FileChecksumKind, SHA1),
153 CV_ENUM_CLASS_ENT(FileChecksumKind, SHA256),
147154 };
148155
149156 static const EnumEntry CPUTypeNames[] = {
338345 ArrayRef> getCompileSym3FlagNames() {
339346 return makeArrayRef(CompileSym3FlagNames);
340347 }
348 ArrayRef> getFileChecksumNames() {
349 return makeArrayRef(FileChecksumNames);
350 }
341351 ArrayRef> getCPUTypeNames() {
342352 return makeArrayRef(CPUTypeNames);
343353 }
1616 }
1717 Error IModuleSubstreamVisitor::visitLines(StreamRef Data,
1818 const LineSubstreamHeader *Header,
19 LineInfoArray Lines) {
19 const LineInfoArray &Lines) {
2020 return visitUnknown(ModuleSubstreamKind::Lines, Data);
2121 }
2222 Error IModuleSubstreamVisitor::visitStringTable(StreamRef Data) {
2323 return visitUnknown(ModuleSubstreamKind::StringTable, Data);
2424 }
25 Error IModuleSubstreamVisitor::visitFileChecksums(StreamRef Data) {
25 Error IModuleSubstreamVisitor::visitFileChecksums(
26 StreamRef Data, const FileChecksumArray &Checksums) {
2627 return visitUnknown(ModuleSubstreamKind::FileChecksums, Data);
2728 }
2829 Error IModuleSubstreamVisitor::visitFrameData(StreamRef Data) {
6364 const LineSubstreamHeader *Header;
6465 if (auto EC = Reader.readObject(Header))
6566 return EC;
66 FileLineInfoExtractor E(Header);
67 VarStreamArrayExtractor E(Header);
6768 LineInfoArray LineInfos(E);
6869 if (auto EC = Reader.readArray(LineInfos, Reader.bytesRemaining()))
6970 return EC;
7172 }
7273 case ModuleSubstreamKind::StringTable:
7374 return V.visitStringTable(R.getRecordData());
74 case ModuleSubstreamKind::FileChecksums:
75 return V.visitFileChecksums(R.getRecordData());
75 case ModuleSubstreamKind::FileChecksums: {
76 StreamReader Reader(R.getRecordData());
77 FileChecksumArray Checksums;
78 if (auto EC = Reader.readArray(Checksums, Reader.bytesRemaining()))
79 return EC;
80 return V.visitFileChecksums(R.getRecordData(), Checksums);
81 }
7682 case ModuleSubstreamKind::FrameData:
7783 return V.visitFrameData(R.getRecordData());
7884 case ModuleSubstreamKind::InlineeLines:
6969 ; EMPTY-NEXT: Version: 1
7070 ; EMPTY-NEXT: Name Count: 4
7171 ; EMPTY-NEXT: Names [
72 ; EMPTY-NEXT: d:\src\llvm\test\debuginfo\pdb\inputs\predefined c++ attributes (compiler internal)
73 ; EMPTY-NEXT: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
74 ; EMPTY-NEXT: $T0 $ebp = $eip $T0 4 + ^ = $ebp $T0 ^ = $esp $T0 8 + =
72 ; EMPTY-NEXT: 1: d:\src\llvm\test\debuginfo\pdb\inputs\predefined c++ attributes (compiler internal)
73 ; EMPTY-NEXT: 86: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
74 ; EMPTY-NEXT: 134: $T0 $ebp = $eip $T0 4 + ^ = $ebp $T0 ^ = $esp $T0 8 + =
7575 ; EMPTY-NEXT: ]
7676 ; EMPTY-NEXT: }
7777 ; EMPTY-NEXT: Type Info Stream (TPI) {
350350 ; EMPTY-NEXT: EndDelta: 0
351351 ; EMPTY-NEXT: IsStatement: Yes
352352 ; EMPTY-NEXT: }
353 ; EMPTY-NEXT: Data (
354 ; EMPTY-NEXT: 0000: 10000000 01000000 0A000000 00000000 |................|
355 ; EMPTY-NEXT: 0010: 03000000 24000000 00000000 05000080 |....$...........|
356 ; EMPTY-NEXT: 0020: 03000000 06000080 08000000 07000080 |................|
357 ; EMPTY-NEXT: )
358353 ; EMPTY-NEXT: }
359354 ; EMPTY-NEXT: FileChecksums {
360 ; EMPTY-NEXT: Data (
361 ; EMPTY-NEXT: 0000: 56000000 1001A0A5 BD0D3ECD 93FC29D1 |V.........>...).|
362 ; EMPTY-NEXT: 0010: 9DE826FB F4BC0000 |..&.....|
363 ; EMPTY-NEXT: )
355 ; EMPTY-NEXT: Checksum {
356 ; EMPTY-NEXT: FileNameOffset: 86
357 ; EMPTY-NEXT: Kind: MD5 (0x1)
358 ; EMPTY-NEXT: Checksum (
359 ; EMPTY-NEXT: 0000: A0A5BD0D 3ECD93FC 29D19DE8 26FBF4BC |....>...)...&...|
360 ; EMPTY-NEXT: )
361 ; EMPTY-NEXT: }
364362 ; EMPTY-NEXT: }
365363 ; EMPTY-NEXT: ]
366364 ; EMPTY-NEXT: }
426426 for (uint32_t ID : NameTable.name_ids()) {
427427 StringRef Str = NameTable.getStringForID(ID);
428428 if (!Str.empty())
429 P.printString(Str);
429 P.printString(to_string(ID), Str);
430430 }
431431 }
432432 return Error::success();
527527 DictScope DD(P, "Unknown");
528528 return printBinaryData(Data);
529529 }
530 Error visitFileChecksums(StreamRef Data) override {
530 Error
531 visitFileChecksums(StreamRef Data,
532 const FileChecksumArray &Checksums) override {
531533 DictScope DD(P, "FileChecksums");
532 return printBinaryData(Data);
534 for (const auto &C : Checksums) {
535 DictScope DDD(P, "Checksum");
536 P.printNumber("FileNameOffset", C.FileNameOffset);
537 P.printEnum("Kind", uint8_t(C.Kind), getFileChecksumNames());
538 P.printBinaryBlock("Checksum", C.Checksum);
539 }
540 return Error::success();
533541 }
534542
535543 Error visitLines(StreamRef Data, const LineSubstreamHeader *Header,
536 LineInfoArray Lines) override {
544 const LineInfoArray &Lines) override {
537545 DictScope DD(P, "Lines");
538546 for (const auto &L : Lines) {
539547 P.printNumber("FileOffset", L.Offset);
556564 P.printNumber("End", C.EndColumn);
557565 }
558566 }
559 return printBinaryData(Data);
567 return Error::success();
560568 }
561569
562570 private: