121
|
1 //===- Diff.cpp - PDB diff utility ------------------------------*- C++ -*-===//
|
|
2 //
|
|
3 // The LLVM Compiler Infrastructure
|
|
4 //
|
|
5 // This file is distributed under the University of Illinois Open Source
|
|
6 // License. See LICENSE.TXT for details.
|
|
7 //
|
|
8 //===----------------------------------------------------------------------===//
|
|
9
|
|
10 #include "Diff.h"
|
|
11
|
|
12 #include "DiffPrinter.h"
|
|
13 #include "FormatUtil.h"
|
|
14 #include "StreamUtil.h"
|
|
15 #include "llvm-pdbutil.h"
|
|
16
|
|
17 #include "llvm/ADT/StringSet.h"
|
|
18
|
|
19 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
|
|
20 #include "llvm/DebugInfo/PDB/Native/Formatters.h"
|
|
21 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
|
|
22 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
|
23 #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
|
|
24 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
|
|
25
|
|
26 #include "llvm/Support/FormatAdapters.h"
|
|
27 #include "llvm/Support/FormatProviders.h"
|
|
28 #include "llvm/Support/FormatVariadic.h"
|
|
29 #include "llvm/Support/Path.h"
|
|
30
|
|
31 using namespace llvm;
|
|
32 using namespace llvm::pdb;
|
|
33
|
|
34 namespace {
|
|
35 // Compare and format two stream numbers. Stream numbers are considered
|
|
36 // identical if they contain the same value, equivalent if they are both
|
|
37 // the invalid stream or neither is the invalid stream, and different if
|
|
38 // one is the invalid stream and another isn't.
|
|
39 struct StreamNumberProvider {
|
|
40 static DiffResult compare(uint16_t L, uint16_t R) {
|
|
41 if (L == R)
|
|
42 return DiffResult::IDENTICAL;
|
|
43 bool LP = L != kInvalidStreamIndex;
|
|
44 bool RP = R != kInvalidStreamIndex;
|
|
45 if (LP != RP)
|
|
46 return DiffResult::DIFFERENT;
|
|
47 return DiffResult::EQUIVALENT;
|
|
48 }
|
|
49
|
|
50 static std::string format(uint16_t SN, bool Right) {
|
|
51 if (SN == kInvalidStreamIndex)
|
|
52 return "(not present)";
|
|
53 return formatv("{0}", SN).str();
|
|
54 }
|
|
55 };
|
|
56
|
|
57 // Compares and formats two module indices. Modis are considered identical
|
|
58 // if they are identical, equivalent if they either both contain a value or
|
|
59 // both don't contain a value, and different if one contains a value and the
|
|
60 // other doesn't.
|
|
61 struct ModiProvider {
|
|
62 DiffResult compare(Optional<uint32_t> L, Optional<uint32_t> R) {
|
|
63 if (L == R)
|
|
64 return DiffResult::IDENTICAL;
|
|
65 if (L.hasValue() != R.hasValue())
|
|
66 return DiffResult::DIFFERENT;
|
|
67 return DiffResult::EQUIVALENT;
|
|
68 }
|
|
69
|
|
70 std::string format(Optional<uint32_t> Modi, bool Right) {
|
|
71 if (!Modi.hasValue())
|
|
72 return "(not present)";
|
|
73 return formatv("{0}", *Modi).str();
|
|
74 }
|
|
75 };
|
|
76
|
|
77 // Compares and formats two paths embedded in the PDB, ignoring the beginning
|
|
78 // of the path if the user specified it as a "root path" on the command line.
|
|
79 struct BinaryPathProvider {
|
|
80 explicit BinaryPathProvider(uint32_t MaxLen) : MaxLen(MaxLen) {}
|
|
81
|
|
82 DiffResult compare(StringRef L, StringRef R) {
|
|
83 if (L == R)
|
|
84 return DiffResult::IDENTICAL;
|
|
85
|
|
86 SmallString<64> LN = removeRoot(L, false);
|
|
87 SmallString<64> RN = removeRoot(R, true);
|
|
88
|
|
89 return (LN.equals_lower(RN)) ? DiffResult::EQUIVALENT
|
|
90 : DiffResult::DIFFERENT;
|
|
91 }
|
|
92
|
|
93 std::string format(StringRef S, bool Right) {
|
|
94 if (S.empty())
|
|
95 return "(empty)";
|
|
96
|
|
97 SmallString<64> Native = removeRoot(S, Right);
|
|
98 return truncateStringFront(Native.str(), MaxLen);
|
|
99 }
|
|
100
|
|
101 SmallString<64> removeRoot(StringRef Path, bool IsRight) const {
|
|
102 SmallString<64> Native(Path);
|
|
103 auto &RootOpt = IsRight ? opts::diff::RightRoot : opts::diff::LeftRoot;
|
|
104 SmallString<64> Root(static_cast<std::string>(RootOpt));
|
|
105 // pdb paths always use windows syntax, convert slashes to backslashes.
|
|
106 sys::path::native(Root, sys::path::Style::windows);
|
|
107 if (sys::path::has_stem(Root, sys::path::Style::windows))
|
|
108 sys::path::append(Root, sys::path::Style::windows,
|
|
109 sys::path::get_separator(sys::path::Style::windows));
|
|
110
|
|
111 sys::path::replace_path_prefix(Native, Root, "", sys::path::Style::windows);
|
|
112 return Native;
|
|
113 }
|
|
114 uint32_t MaxLen;
|
|
115 };
|
|
116
|
|
117 // Compare and format two stream purposes. For general streams, this just
|
|
118 // compares the description. For module streams it uses the path comparison
|
|
119 // algorithm taking into consideration the binary root, described above.
|
|
120 // Formatting stream purposes just prints the stream purpose, except for
|
|
121 // module streams and named streams, where it prefixes the name / module
|
|
122 // with an identifier. Example:
|
|
123 //
|
|
124 // Named Stream "\names"
|
|
125 // Module Stream "foo.obj"
|
|
126 //
|
|
127 // If a named stream is too long to fit in a column, it is truncated at the
|
|
128 // end, and if a module is too long to fit in a column, it is truncated at the
|
|
129 // beginning. Example:
|
|
130 //
|
|
131 // Named Stream "\Really Long Str..."
|
|
132 // Module Stream "...puts\foo.obj"
|
|
133 //
|
|
134 struct StreamPurposeProvider {
|
|
135 explicit StreamPurposeProvider(uint32_t MaxLen) : MaxLen(MaxLen) {}
|
|
136
|
|
137 DiffResult compare(const StreamInfo &L, const StreamInfo &R) {
|
|
138 if (L.getPurpose() != R.getPurpose())
|
|
139 return DiffResult::DIFFERENT;
|
|
140 if (L.getPurpose() == StreamPurpose::ModuleStream) {
|
|
141 BinaryPathProvider PathProvider(MaxLen);
|
|
142 return PathProvider.compare(L.getShortName(), R.getShortName());
|
|
143 }
|
|
144 return (L.getShortName() == R.getShortName()) ? DiffResult::IDENTICAL
|
|
145 : DiffResult::DIFFERENT;
|
|
146 }
|
|
147
|
|
148 std::string format(const StreamInfo &P, bool Right) {
|
|
149 if (P.getPurpose() == StreamPurpose::Other ||
|
|
150 P.getPurpose() == StreamPurpose::Symbols)
|
|
151 return truncateStringBack(P.getShortName(), MaxLen);
|
|
152 if (P.getPurpose() == StreamPurpose::NamedStream)
|
|
153 return truncateQuotedNameBack("Named Stream", P.getShortName(), MaxLen);
|
|
154
|
|
155 assert(P.getPurpose() == StreamPurpose::ModuleStream);
|
|
156 uint32_t ExtraChars = strlen("Module \"\"");
|
|
157 BinaryPathProvider PathProvider(MaxLen - ExtraChars);
|
|
158 std::string Result = PathProvider.format(P.getShortName(), Right);
|
|
159 return formatv("Module \"{0}\"", Result);
|
|
160 }
|
|
161
|
|
162 uint32_t MaxLen;
|
|
163 };
|
|
164 } // namespace
|
|
165
|
|
166 namespace llvm {
|
|
167 template <> struct format_provider<PdbRaw_FeatureSig> {
|
|
168 static void format(const PdbRaw_FeatureSig &Sig, raw_ostream &Stream,
|
|
169 StringRef Style) {
|
|
170 switch (Sig) {
|
|
171 case PdbRaw_FeatureSig::MinimalDebugInfo:
|
|
172 Stream << "MinimalDebugInfo";
|
|
173 break;
|
|
174 case PdbRaw_FeatureSig::NoTypeMerge:
|
|
175 Stream << "NoTypeMerge";
|
|
176 break;
|
|
177 case PdbRaw_FeatureSig::VC110:
|
|
178 Stream << "VC110";
|
|
179 break;
|
|
180 case PdbRaw_FeatureSig::VC140:
|
|
181 Stream << "VC140";
|
|
182 break;
|
|
183 }
|
|
184 }
|
|
185 };
|
|
186 }
|
|
187
|
|
188 template <typename R> using ValueOfRange = llvm::detail::ValueOfRange<R>;
|
|
189
|
|
190 DiffStyle::DiffStyle(PDBFile &File1, PDBFile &File2)
|
|
191 : File1(File1), File2(File2) {}
|
|
192
|
|
193 Error DiffStyle::dump() {
|
|
194 if (auto EC = diffSuperBlock())
|
|
195 return EC;
|
|
196
|
|
197 if (auto EC = diffFreePageMap())
|
|
198 return EC;
|
|
199
|
|
200 if (auto EC = diffStreamDirectory())
|
|
201 return EC;
|
|
202
|
|
203 if (auto EC = diffStringTable())
|
|
204 return EC;
|
|
205
|
|
206 if (auto EC = diffInfoStream())
|
|
207 return EC;
|
|
208
|
|
209 if (auto EC = diffDbiStream())
|
|
210 return EC;
|
|
211
|
|
212 if (auto EC = diffSectionContribs())
|
|
213 return EC;
|
|
214
|
|
215 if (auto EC = diffSectionMap())
|
|
216 return EC;
|
|
217
|
|
218 if (auto EC = diffFpoStream())
|
|
219 return EC;
|
|
220
|
|
221 if (auto EC = diffTpiStream(StreamTPI))
|
|
222 return EC;
|
|
223
|
|
224 if (auto EC = diffTpiStream(StreamIPI))
|
|
225 return EC;
|
|
226
|
|
227 if (auto EC = diffPublics())
|
|
228 return EC;
|
|
229
|
|
230 if (auto EC = diffGlobals())
|
|
231 return EC;
|
|
232
|
|
233 return Error::success();
|
|
234 }
|
|
235
|
|
236 Error DiffStyle::diffSuperBlock() {
|
|
237 DiffPrinter D(2, "MSF Super Block", 16, 20, opts::diff::PrintResultColumn,
|
|
238 opts::diff::PrintValueColumns, outs());
|
|
239 D.printExplicit("File", DiffResult::UNSPECIFIED,
|
|
240 truncateStringFront(File1.getFilePath(), 18),
|
|
241 truncateStringFront(File2.getFilePath(), 18));
|
|
242 D.print("Block Size", File1.getBlockSize(), File2.getBlockSize());
|
|
243 D.print("Block Count", File1.getBlockCount(), File2.getBlockCount());
|
|
244 D.print("Unknown 1", File1.getUnknown1(), File2.getUnknown1());
|
|
245 D.print("Directory Size", File1.getNumDirectoryBytes(),
|
|
246 File2.getNumDirectoryBytes());
|
|
247 return Error::success();
|
|
248 }
|
|
249
|
|
250 Error DiffStyle::diffStreamDirectory() {
|
|
251 DiffPrinter D(2, "Stream Directory", 30, 20, opts::diff::PrintResultColumn,
|
|
252 opts::diff::PrintValueColumns, outs());
|
|
253 D.printExplicit("File", DiffResult::UNSPECIFIED,
|
|
254 truncateStringFront(File1.getFilePath(), 18),
|
|
255 truncateStringFront(File2.getFilePath(), 18));
|
|
256
|
|
257 SmallVector<StreamInfo, 32> P;
|
|
258 SmallVector<StreamInfo, 32> Q;
|
|
259 discoverStreamPurposes(File1, P);
|
|
260 discoverStreamPurposes(File2, Q);
|
|
261 D.print("Stream Count", File1.getNumStreams(), File2.getNumStreams());
|
|
262 auto PI = to_vector<32>(enumerate(P));
|
|
263 auto QI = to_vector<32>(enumerate(Q));
|
|
264
|
|
265 // Scan all streams in the left hand side, looking for ones that are also
|
|
266 // in the right. Each time we find one, remove it. When we're done, Q
|
|
267 // should contain all the streams that are in the right but not in the left.
|
|
268 StreamPurposeProvider StreamProvider(28);
|
|
269 for (const auto &P : PI) {
|
|
270 typedef decltype(PI) ContainerType;
|
|
271 typedef typename ContainerType::value_type value_type;
|
|
272
|
|
273 auto Iter = llvm::find_if(QI, [P, &StreamProvider](const value_type &V) {
|
|
274 DiffResult Result = StreamProvider.compare(P.value(), V.value());
|
|
275 return Result == DiffResult::EQUIVALENT ||
|
|
276 Result == DiffResult::IDENTICAL;
|
|
277 });
|
|
278
|
|
279 if (Iter == QI.end()) {
|
|
280 D.printExplicit(StreamProvider.format(P.value(), false),
|
|
281 DiffResult::DIFFERENT, P.index(), "(not present)");
|
|
282 continue;
|
|
283 }
|
|
284
|
|
285 D.print<EquivalentDiffProvider>(StreamProvider.format(P.value(), false),
|
|
286 P.index(), Iter->index());
|
|
287 QI.erase(Iter);
|
|
288 }
|
|
289
|
|
290 for (const auto &Q : QI) {
|
|
291 D.printExplicit(StreamProvider.format(Q.value(), true),
|
|
292 DiffResult::DIFFERENT, "(not present)", Q.index());
|
|
293 }
|
|
294
|
|
295 return Error::success();
|
|
296 }
|
|
297
|
|
298 Error DiffStyle::diffStringTable() {
|
|
299 DiffPrinter D(2, "String Table", 30, 20, opts::diff::PrintResultColumn,
|
|
300 opts::diff::PrintValueColumns, outs());
|
|
301 D.printExplicit("File", DiffResult::UNSPECIFIED,
|
|
302 truncateStringFront(File1.getFilePath(), 18),
|
|
303 truncateStringFront(File2.getFilePath(), 18));
|
|
304
|
|
305 auto ExpectedST1 = File1.getStringTable();
|
|
306 auto ExpectedST2 = File2.getStringTable();
|
|
307 bool Has1 = !!ExpectedST1;
|
|
308 bool Has2 = !!ExpectedST2;
|
|
309 std::string Count1 = Has1 ? llvm::utostr(ExpectedST1->getNameCount())
|
|
310 : "(string table not present)";
|
|
311 std::string Count2 = Has2 ? llvm::utostr(ExpectedST2->getNameCount())
|
|
312 : "(string table not present)";
|
|
313 D.print("Number of Strings", Count1, Count2);
|
|
314
|
|
315 if (!Has1 || !Has2) {
|
|
316 consumeError(ExpectedST1.takeError());
|
|
317 consumeError(ExpectedST2.takeError());
|
|
318 return Error::success();
|
|
319 }
|
|
320
|
|
321 auto &ST1 = *ExpectedST1;
|
|
322 auto &ST2 = *ExpectedST2;
|
|
323
|
|
324 D.print("Hash Version", ST1.getHashVersion(), ST2.getHashVersion());
|
|
325 D.print("Byte Size", ST1.getByteSize(), ST2.getByteSize());
|
|
326 D.print("Signature", ST1.getSignature(), ST2.getSignature());
|
|
327
|
|
328 // Both have a valid string table, dive in and compare individual strings.
|
|
329
|
|
330 auto IdList1 = ST1.name_ids();
|
|
331 auto IdList2 = ST2.name_ids();
|
|
332 StringSet<> LS;
|
|
333 StringSet<> RS;
|
|
334 uint32_t Empty1 = 0;
|
|
335 uint32_t Empty2 = 0;
|
|
336 for (auto ID : IdList1) {
|
|
337 auto S = ST1.getStringForID(ID);
|
|
338 if (!S)
|
|
339 return S.takeError();
|
|
340 if (S->empty())
|
|
341 ++Empty1;
|
|
342 else
|
|
343 LS.insert(*S);
|
|
344 }
|
|
345 for (auto ID : IdList2) {
|
|
346 auto S = ST2.getStringForID(ID);
|
|
347 if (!S)
|
|
348 return S.takeError();
|
|
349 if (S->empty())
|
|
350 ++Empty2;
|
|
351 else
|
|
352 RS.insert(*S);
|
|
353 }
|
|
354 D.print("Empty Strings", Empty1, Empty2);
|
|
355
|
|
356 for (const auto &S : LS) {
|
|
357 auto R = RS.find(S.getKey());
|
|
358 std::string Truncated = truncateStringMiddle(S.getKey(), 28);
|
|
359 uint32_t I = cantFail(ST1.getIDForString(S.getKey()));
|
|
360 if (R == RS.end()) {
|
|
361 D.printExplicit(Truncated, DiffResult::DIFFERENT, I, "(not present)");
|
|
362 continue;
|
|
363 }
|
|
364
|
|
365 uint32_t J = cantFail(ST2.getIDForString(R->getKey()));
|
|
366 D.print<EquivalentDiffProvider>(Truncated, I, J);
|
|
367 RS.erase(R);
|
|
368 }
|
|
369
|
|
370 for (const auto &S : RS) {
|
|
371 auto L = LS.find(S.getKey());
|
|
372 std::string Truncated = truncateStringMiddle(S.getKey(), 28);
|
|
373 uint32_t J = cantFail(ST2.getIDForString(S.getKey()));
|
|
374 if (L == LS.end()) {
|
|
375 D.printExplicit(Truncated, DiffResult::DIFFERENT, "(not present)", J);
|
|
376 continue;
|
|
377 }
|
|
378
|
|
379 uint32_t I = cantFail(ST1.getIDForString(L->getKey()));
|
|
380 D.print<EquivalentDiffProvider>(Truncated, I, J);
|
|
381 }
|
|
382 return Error::success();
|
|
383 }
|
|
384
|
|
385 Error DiffStyle::diffFreePageMap() { return Error::success(); }
|
|
386
|
|
387 Error DiffStyle::diffInfoStream() {
|
|
388 DiffPrinter D(2, "PDB Stream", 22, 40, opts::diff::PrintResultColumn,
|
|
389 opts::diff::PrintValueColumns, outs());
|
|
390 D.printExplicit("File", DiffResult::UNSPECIFIED,
|
|
391 truncateStringFront(File1.getFilePath(), 38),
|
|
392 truncateStringFront(File2.getFilePath(), 38));
|
|
393
|
|
394 auto ExpectedInfo1 = File1.getPDBInfoStream();
|
|
395 auto ExpectedInfo2 = File2.getPDBInfoStream();
|
|
396
|
|
397 bool Has1 = !!ExpectedInfo1;
|
|
398 bool Has2 = !!ExpectedInfo2;
|
|
399 if (!(Has1 && Has2)) {
|
|
400 std::string L = Has1 ? "(present)" : "(not present)";
|
|
401 std::string R = Has2 ? "(present)" : "(not present)";
|
|
402 D.print("Stream", L, R);
|
|
403
|
|
404 consumeError(ExpectedInfo1.takeError());
|
|
405 consumeError(ExpectedInfo2.takeError());
|
|
406 return Error::success();
|
|
407 }
|
|
408
|
|
409 auto &IS1 = *ExpectedInfo1;
|
|
410 auto &IS2 = *ExpectedInfo2;
|
|
411 D.print("Stream Size", IS1.getStreamSize(), IS2.getStreamSize());
|
|
412 D.print("Age", IS1.getAge(), IS2.getAge());
|
|
413 D.print("Guid", IS1.getGuid(), IS2.getGuid());
|
|
414 D.print("Signature", IS1.getSignature(), IS2.getSignature());
|
|
415 D.print("Version", IS1.getVersion(), IS2.getVersion());
|
|
416 D.diffUnorderedArray("Feature", IS1.getFeatureSignatures(),
|
|
417 IS2.getFeatureSignatures());
|
|
418 D.print("Named Stream Size", IS1.getNamedStreamMapByteSize(),
|
|
419 IS2.getNamedStreamMapByteSize());
|
|
420 StringMap<uint32_t> NSL = IS1.getNamedStreams().getStringMap();
|
|
421 StringMap<uint32_t> NSR = IS2.getNamedStreams().getStringMap();
|
|
422 D.diffUnorderedMap<EquivalentDiffProvider>("Named Stream", NSL, NSR);
|
|
423 return Error::success();
|
|
424 }
|
|
425
|
|
426 typedef std::pair<uint32_t, DbiModuleDescriptor> IndexedModuleDescriptor;
|
|
427 typedef std::vector<IndexedModuleDescriptor> IndexedModuleDescriptorList;
|
|
428
|
|
429 static IndexedModuleDescriptorList
|
|
430 getModuleDescriptors(const DbiModuleList &ML) {
|
|
431 IndexedModuleDescriptorList List;
|
|
432 List.reserve(ML.getModuleCount());
|
|
433 for (uint32_t I = 0; I < ML.getModuleCount(); ++I)
|
|
434 List.emplace_back(I, ML.getModuleDescriptor(I));
|
|
435 return List;
|
|
436 }
|
|
437
|
|
438 static IndexedModuleDescriptorList::iterator
|
|
439 findOverrideEquivalentModule(uint32_t Modi,
|
|
440 IndexedModuleDescriptorList &OtherList) {
|
|
441 auto &EqMap = opts::diff::Equivalences;
|
|
442
|
|
443 auto Iter = EqMap.find(Modi);
|
|
444 if (Iter == EqMap.end())
|
|
445 return OtherList.end();
|
|
446
|
|
447 uint32_t EqValue = Iter->second;
|
|
448
|
|
449 return llvm::find_if(OtherList,
|
|
450 [EqValue](const IndexedModuleDescriptor &Desc) {
|
|
451 return Desc.first == EqValue;
|
|
452 });
|
|
453 }
|
|
454
|
|
455 static IndexedModuleDescriptorList::iterator
|
|
456 findEquivalentModule(const IndexedModuleDescriptor &Item,
|
|
457 IndexedModuleDescriptorList &OtherList, bool ItemIsRight) {
|
|
458
|
|
459 if (!ItemIsRight) {
|
|
460 uint32_t Modi = Item.first;
|
|
461 auto OverrideIter = findOverrideEquivalentModule(Modi, OtherList);
|
|
462 if (OverrideIter != OtherList.end())
|
|
463 return OverrideIter;
|
|
464 }
|
|
465
|
|
466 BinaryPathProvider PathProvider(28);
|
|
467
|
|
468 auto Iter = OtherList.begin();
|
|
469 auto End = OtherList.end();
|
|
470 for (; Iter != End; ++Iter) {
|
|
471 const IndexedModuleDescriptor *Left = &Item;
|
|
472 const IndexedModuleDescriptor *Right = &*Iter;
|
|
473 if (ItemIsRight)
|
|
474 std::swap(Left, Right);
|
|
475 DiffResult Result = PathProvider.compare(Left->second.getModuleName(),
|
|
476 Right->second.getModuleName());
|
|
477 if (Result == DiffResult::EQUIVALENT || Result == DiffResult::IDENTICAL)
|
|
478 return Iter;
|
|
479 }
|
|
480 return OtherList.end();
|
|
481 }
|
|
482
|
|
483 static void diffOneModule(DiffPrinter &D, const IndexedModuleDescriptor &Item,
|
|
484 IndexedModuleDescriptorList &Other,
|
|
485 bool ItemIsRight) {
|
|
486 StreamPurposeProvider HeaderProvider(70);
|
|
487 StreamInfo Info = StreamInfo::createModuleStream(
|
|
488 Item.second.getModuleName(), Item.second.getModuleStreamIndex(),
|
|
489 Item.first);
|
|
490 D.printFullRow(HeaderProvider.format(Info, ItemIsRight));
|
|
491
|
|
492 const auto *L = &Item;
|
|
493
|
|
494 auto Iter = findEquivalentModule(Item, Other, ItemIsRight);
|
|
495 if (Iter == Other.end()) {
|
|
496 // We didn't find this module at all on the other side. Just print one row
|
|
497 // and continue.
|
|
498 if (ItemIsRight)
|
|
499 D.print<ModiProvider>("- Modi", None, Item.first);
|
|
500 else
|
|
501 D.print<ModiProvider>("- Modi", Item.first, None);
|
|
502 return;
|
|
503 }
|
|
504
|
|
505 // We did find this module. Go through and compare each field.
|
|
506 const auto *R = &*Iter;
|
|
507 if (ItemIsRight)
|
|
508 std::swap(L, R);
|
|
509
|
|
510 BinaryPathProvider PathProvider(28);
|
|
511 D.print<ModiProvider>("- Modi", L->first, R->first);
|
|
512 D.print<BinaryPathProvider>("- Obj File Name", L->second.getObjFileName(),
|
|
513 R->second.getObjFileName(), PathProvider);
|
|
514 D.print<StreamNumberProvider>("- Debug Stream",
|
|
515 L->second.getModuleStreamIndex(),
|
|
516 R->second.getModuleStreamIndex());
|
|
517 D.print("- C11 Byte Size", L->second.getC11LineInfoByteSize(),
|
|
518 R->second.getC11LineInfoByteSize());
|
|
519 D.print("- C13 Byte Size", L->second.getC13LineInfoByteSize(),
|
|
520 R->second.getC13LineInfoByteSize());
|
|
521 D.print("- # of files", L->second.getNumberOfFiles(),
|
|
522 R->second.getNumberOfFiles());
|
|
523 D.print("- Pdb File Path Index", L->second.getPdbFilePathNameIndex(),
|
|
524 R->second.getPdbFilePathNameIndex());
|
|
525 D.print("- Source File Name Index", L->second.getSourceFileNameIndex(),
|
|
526 R->second.getSourceFileNameIndex());
|
|
527 D.print("- Symbol Byte Size", L->second.getSymbolDebugInfoByteSize(),
|
|
528 R->second.getSymbolDebugInfoByteSize());
|
|
529 Other.erase(Iter);
|
|
530 }
|
|
531
|
|
532 Error DiffStyle::diffDbiStream() {
|
|
533 DiffPrinter D(2, "DBI Stream", 40, 30, opts::diff::PrintResultColumn,
|
|
534 opts::diff::PrintValueColumns, outs());
|
|
535 D.printExplicit("File", DiffResult::UNSPECIFIED,
|
|
536 truncateStringFront(File1.getFilePath(), 28),
|
|
537 truncateStringFront(File2.getFilePath(), 28));
|
|
538
|
|
539 auto ExpectedDbi1 = File1.getPDBDbiStream();
|
|
540 auto ExpectedDbi2 = File2.getPDBDbiStream();
|
|
541
|
|
542 bool Has1 = !!ExpectedDbi1;
|
|
543 bool Has2 = !!ExpectedDbi2;
|
|
544 if (!(Has1 && Has2)) {
|
|
545 std::string L = Has1 ? "(present)" : "(not present)";
|
|
546 std::string R = Has2 ? "(present)" : "(not present)";
|
|
547 D.print("Stream", L, R);
|
|
548
|
|
549 consumeError(ExpectedDbi1.takeError());
|
|
550 consumeError(ExpectedDbi2.takeError());
|
|
551 return Error::success();
|
|
552 }
|
|
553
|
|
554 auto &DL = *ExpectedDbi1;
|
|
555 auto &DR = *ExpectedDbi2;
|
|
556
|
|
557 D.print("Dbi Version", (uint32_t)DL.getDbiVersion(),
|
|
558 (uint32_t)DR.getDbiVersion());
|
|
559 D.print("Age", DL.getAge(), DR.getAge());
|
|
560 D.print("Machine", (uint16_t)DL.getMachineType(),
|
|
561 (uint16_t)DR.getMachineType());
|
|
562 D.print("Flags", DL.getFlags(), DR.getFlags());
|
|
563 D.print("Build Major", DL.getBuildMajorVersion(), DR.getBuildMajorVersion());
|
|
564 D.print("Build Minor", DL.getBuildMinorVersion(), DR.getBuildMinorVersion());
|
|
565 D.print("Build Number", DL.getBuildNumber(), DR.getBuildNumber());
|
|
566 D.print("PDB DLL Version", DL.getPdbDllVersion(), DR.getPdbDllVersion());
|
|
567 D.print("PDB DLL RBLD", DL.getPdbDllRbld(), DR.getPdbDllRbld());
|
|
568 D.print<StreamNumberProvider>("DBG (FPO)",
|
|
569 DL.getDebugStreamIndex(DbgHeaderType::FPO),
|
|
570 DR.getDebugStreamIndex(DbgHeaderType::FPO));
|
|
571 D.print<StreamNumberProvider>(
|
|
572 "DBG (Exception)", DL.getDebugStreamIndex(DbgHeaderType::Exception),
|
|
573 DR.getDebugStreamIndex(DbgHeaderType::Exception));
|
|
574 D.print<StreamNumberProvider>("DBG (Fixup)",
|
|
575 DL.getDebugStreamIndex(DbgHeaderType::Fixup),
|
|
576 DR.getDebugStreamIndex(DbgHeaderType::Fixup));
|
|
577 D.print<StreamNumberProvider>(
|
|
578 "DBG (OmapToSrc)", DL.getDebugStreamIndex(DbgHeaderType::OmapToSrc),
|
|
579 DR.getDebugStreamIndex(DbgHeaderType::OmapToSrc));
|
|
580 D.print<StreamNumberProvider>(
|
|
581 "DBG (OmapFromSrc)", DL.getDebugStreamIndex(DbgHeaderType::OmapFromSrc),
|
|
582 DR.getDebugStreamIndex(DbgHeaderType::OmapFromSrc));
|
|
583 D.print<StreamNumberProvider>(
|
|
584 "DBG (SectionHdr)", DL.getDebugStreamIndex(DbgHeaderType::SectionHdr),
|
|
585 DR.getDebugStreamIndex(DbgHeaderType::SectionHdr));
|
|
586 D.print<StreamNumberProvider>(
|
|
587 "DBG (TokenRidMap)", DL.getDebugStreamIndex(DbgHeaderType::TokenRidMap),
|
|
588 DR.getDebugStreamIndex(DbgHeaderType::TokenRidMap));
|
|
589 D.print<StreamNumberProvider>("DBG (Xdata)",
|
|
590 DL.getDebugStreamIndex(DbgHeaderType::Xdata),
|
|
591 DR.getDebugStreamIndex(DbgHeaderType::Xdata));
|
|
592 D.print<StreamNumberProvider>("DBG (Pdata)",
|
|
593 DL.getDebugStreamIndex(DbgHeaderType::Pdata),
|
|
594 DR.getDebugStreamIndex(DbgHeaderType::Pdata));
|
|
595 D.print<StreamNumberProvider>("DBG (NewFPO)",
|
|
596 DL.getDebugStreamIndex(DbgHeaderType::NewFPO),
|
|
597 DR.getDebugStreamIndex(DbgHeaderType::NewFPO));
|
|
598 D.print<StreamNumberProvider>(
|
|
599 "DBG (SectionHdrOrig)",
|
|
600 DL.getDebugStreamIndex(DbgHeaderType::SectionHdrOrig),
|
|
601 DR.getDebugStreamIndex(DbgHeaderType::SectionHdrOrig));
|
|
602 D.print<StreamNumberProvider>("Globals Stream",
|
|
603 DL.getGlobalSymbolStreamIndex(),
|
|
604 DR.getGlobalSymbolStreamIndex());
|
|
605 D.print<StreamNumberProvider>("Publics Stream",
|
|
606 DL.getPublicSymbolStreamIndex(),
|
|
607 DR.getPublicSymbolStreamIndex());
|
|
608 D.print<StreamNumberProvider>("Symbol Records", DL.getSymRecordStreamIndex(),
|
|
609 DR.getSymRecordStreamIndex());
|
|
610 D.print("Has CTypes", DL.hasCTypes(), DR.hasCTypes());
|
|
611 D.print("Is Incrementally Linked", DL.isIncrementallyLinked(),
|
|
612 DR.isIncrementallyLinked());
|
|
613 D.print("Is Stripped", DL.isStripped(), DR.isStripped());
|
|
614 const DbiModuleList &ML = DL.modules();
|
|
615 const DbiModuleList &MR = DR.modules();
|
|
616 D.print("Module Count", ML.getModuleCount(), MR.getModuleCount());
|
|
617 D.print("Source File Count", ML.getSourceFileCount(),
|
|
618 MR.getSourceFileCount());
|
|
619 auto MDL = getModuleDescriptors(ML);
|
|
620 auto MDR = getModuleDescriptors(MR);
|
|
621 // Scan all module descriptors from the left, and look for corresponding
|
|
622 // module descriptors on the right.
|
|
623 for (const auto &L : MDL)
|
|
624 diffOneModule(D, L, MDR, false);
|
|
625
|
|
626 for (const auto &R : MDR)
|
|
627 diffOneModule(D, R, MDL, true);
|
|
628
|
|
629 return Error::success();
|
|
630 }
|
|
631
|
|
632 Error DiffStyle::diffSectionContribs() { return Error::success(); }
|
|
633
|
|
634 Error DiffStyle::diffSectionMap() { return Error::success(); }
|
|
635
|
|
636 Error DiffStyle::diffFpoStream() { return Error::success(); }
|
|
637
|
|
638 Error DiffStyle::diffTpiStream(int Index) { return Error::success(); }
|
|
639
|
|
640 Error DiffStyle::diffModuleInfoStream(int Index) { return Error::success(); }
|
|
641
|
|
642 Error DiffStyle::diffPublics() { return Error::success(); }
|
|
643
|
|
644 Error DiffStyle::diffGlobals() { return Error::success(); }
|