Index: lld/COFF/PDB.cpp =================================================================== --- lld/COFF/PDB.cpp +++ lld/COFF/PDB.cpp @@ -245,8 +245,10 @@ // absolute. bool InArchive = !File->ParentName.empty(); SmallString<128> Path = InArchive ? File->ParentName : File->getName(); + sys::path::native(Path); sys::fs::make_absolute(Path); StringRef Name = InArchive ? File->getName() : StringRef(Path); + File->ModuleDBI = &ExitOnErr(Builder.getDbiBuilder().addModuleInfo(Name)); File->ModuleDBI->setObjFileName(Path); Index: lld/test/COFF/pdb-diff.test =================================================================== --- lld/test/COFF/pdb-diff.test +++ lld/test/COFF/pdb-diff.test @@ -45,7 +45,7 @@ CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | Named Stream "/src/heade..." | D | CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Module "...uts/pdb-diff.obj" | D | +CHECK-NEXT: | Module "...uts\pdb-diff.obj" | {{[EI]}} | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | Module "* Linker *" | {{[EI]}} | CHECK-NEXT: |------------------------------+---| @@ -59,8 +59,6 @@ CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | Public Symbol Records | D | CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Module "...uts\pdb-diff.obj" | D | -CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | New FPO Data | D | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: ------------------------------------ @@ -174,9 +172,25 @@ CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | Source File Count | I | CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: |Module "D:\src\llvm-mono\lld\test\COFF/Inputs/pdb-diff.obj"| +CHECK-NEXT: |Module "D:\src\llvm-mono\lld\test\coff\Inputs\pdb-diff.obj"| +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - Modi | I | CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Modi | D | +CHECK-NEXT: | - Obj File Name | D | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - Debug Stream | {{[EI]}} | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - C11 Byte Size | I | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - C13 Byte Size | I | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - # of files | I | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - Pdb File Path Index | I | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - Source File Name Index | I | +CHECK-NEXT: |----------------------------------------+---| +CHECK-NEXT: | - Symbol Byte Size | D | CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | Module "* Linker *" | CHECK-NEXT: |----------------------------------------+---| @@ -198,3 +212,5 @@ CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | - Symbol Byte Size | D | CHECK-NEXT: |----------------------------------------+---| + + Index: llvm/tools/llvm-pdbutil/Diff.cpp =================================================================== --- llvm/tools/llvm-pdbutil/Diff.cpp +++ llvm/tools/llvm-pdbutil/Diff.cpp @@ -348,6 +348,52 @@ return List; } +static void diffOneModule( + DiffPrinter &D, const std::pair Item, + std::vector> &Other, bool Invert) { + D.printFullRow( + truncateQuotedNameFront("Module", Item.second.getModuleName(), 70)); + + auto Iter = llvm::find_if( + Other, [&Item](const std::pair &Other) { + return Other.second.getModuleName().equals_lower( + Item.second.getModuleName()); + }); + if (Iter == Other.end()) { + // We didn't find this module at all on the other side. Just print one row + // and continue. + D.print("- Modi", Item.first, None); + return; + } + + // We did find this module. Go through and compare each field. + const auto *L = &Item; + const auto *R = &*Iter; + if (Invert) + std::swap(L, R); + + D.print("- Modi", L->first, R->first); + D.print("- Obj File Name", + shortFilePath(L->second.getObjFileName(), 28), + shortFilePath(R->second.getObjFileName(), 28)); + D.print("- Debug Stream", + L->second.getModuleStreamIndex(), + R->second.getModuleStreamIndex()); + D.print("- C11 Byte Size", L->second.getC11LineInfoByteSize(), + R->second.getC11LineInfoByteSize()); + D.print("- C13 Byte Size", L->second.getC13LineInfoByteSize(), + R->second.getC13LineInfoByteSize()); + D.print("- # of files", L->second.getNumberOfFiles(), + R->second.getNumberOfFiles()); + D.print("- Pdb File Path Index", L->second.getPdbFilePathNameIndex(), + R->second.getPdbFilePathNameIndex()); + D.print("- Source File Name Index", L->second.getSourceFileNameIndex(), + R->second.getSourceFileNameIndex()); + D.print("- Symbol Byte Size", L->second.getSymbolDebugInfoByteSize(), + R->second.getSymbolDebugInfoByteSize()); + Other.erase(Iter); +} + Error DiffStyle::diffDbiStream() { DiffPrinter D(2, "DBI Stream", 40, 30, opts::diff::PrintResultColumn, opts::diff::PrintValueColumns, outs()); @@ -439,45 +485,11 @@ auto MDR = getModuleDescriptors(MR); // Scan all module descriptors from the left, and look for corresponding // module descriptors on the right. - for (const auto &L : MDL) { - D.printFullRow( - truncateQuotedNameFront("Module", L.second.getModuleName(), 70)); + for (const auto &L : MDL) + diffOneModule(D, L, MDR, false); - auto Iter = llvm::find_if( - MDR, [&L](const std::pair &R) { - return R.second.getModuleName().equals_lower( - L.second.getModuleName()); - }); - if (Iter == MDR.end()) { - // We didn't find this module at all on the right. Just print one row - // and continue. - D.print("- Modi", L.first, None); - continue; - } - - // We did find this module. Go through and compare each field. - const auto &R = *Iter; - D.print("- Modi", L.first, R.first); - D.print("- Obj File Name", - shortFilePath(L.second.getObjFileName(), 28), - shortFilePath(R.second.getObjFileName(), 28)); - D.print("- Debug Stream", - L.second.getModuleStreamIndex(), - R.second.getModuleStreamIndex()); - D.print("- C11 Byte Size", L.second.getC11LineInfoByteSize(), - R.second.getC11LineInfoByteSize()); - D.print("- C13 Byte Size", L.second.getC13LineInfoByteSize(), - R.second.getC13LineInfoByteSize()); - D.print("- # of files", L.second.getNumberOfFiles(), - R.second.getNumberOfFiles()); - D.print("- Pdb File Path Index", L.second.getPdbFilePathNameIndex(), - R.second.getPdbFilePathNameIndex()); - D.print("- Source File Name Index", L.second.getSourceFileNameIndex(), - R.second.getSourceFileNameIndex()); - D.print("- Symbol Byte Size", L.second.getSymbolDebugInfoByteSize(), - R.second.getSymbolDebugInfoByteSize()); - MDR.erase(Iter); - } + for (const auto &R : MDR) + diffOneModule(D, R, MDL, true); return Error::success(); }