summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-07-07 18:46:14 +0000
committerZachary Turner <zturner@google.com>2017-07-07 18:46:14 +0000
commit448dea419c6cf01e5d692b58ebc36ad5453d2d8f (patch)
treee2cfdafe17fa76fb7ccebe2caec8d193613ef7f2
parentc1e93e5fa46772c959a9f5d74dfeb95d3cde4ce3 (diff)
downloadbcm5719-llvm-448dea419c6cf01e5d692b58ebc36ad5453d2d8f.tar.gz
bcm5719-llvm-448dea419c6cf01e5d692b58ebc36ad5453d2d8f.zip
Use windows path syntax when writing PDB module name.
Without this we would just append whatever the user wrote on the command line, so if we're in C:\foo and we run lld-link bar/baz.obj, we would write C:\foo\bar/baz.obj in various places in the PDB. MSVC linker does not do this, so we shouldn't either. This fixes some differences in the diff test, so we update the test as well. Differential Revision: https://reviews.llvm.org/D35092 llvm-svn: 307423
-rw-r--r--lld/COFF/PDB.cpp4
-rw-r--r--lld/test/COFF/pdb-diff.test26
-rw-r--r--llvm/tools/llvm-pdbutil/Diff.cpp88
-rw-r--r--llvm/tools/llvm-pdbutil/DiffPrinter.cpp2
4 files changed, 74 insertions, 46 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index e0dc58b2a18..02cb1f51e3d 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -315,7 +315,9 @@ static void addObjectsToPDB(BumpPtrAllocator &Alloc, SymbolTable *Symtab,
bool InArchive = !File->ParentName.empty();
SmallString<128> Path = InArchive ? File->ParentName : File->getName();
sys::fs::make_absolute(Path);
+ sys::path::native(Path, llvm::sys::path::Style::windows);
StringRef Name = InArchive ? File->getName() : StringRef(Path);
+
File->ModuleDBI = &ExitOnErr(Builder.getDbiBuilder().addModuleInfo(Name));
File->ModuleDBI->setObjFileName(Path);
@@ -414,7 +416,7 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
llvm::SmallString<128> NativePath(Path.begin(), Path.end());
llvm::sys::fs::make_absolute(NativePath);
- llvm::sys::path::native(NativePath);
+ llvm::sys::path::native(NativePath, llvm::sys::path::Style::windows);
pdb::PDB_UniqueId uuid{};
if (DI)
diff --git a/lld/test/COFF/pdb-diff.test b/lld/test/COFF/pdb-diff.test
index a6352ab4ef5..93fd5e83b21 100644
--- a/lld/test/COFF/pdb-diff.test
+++ b/lld/test/COFF/pdb-diff.test
@@ -45,7 +45,7 @@ CHECK-NEXT: | Named Stream "/LinkInfo" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Named Stream "/src/heade..." | D |
CHECK-NEXT: |------------------------------+---|
-CHECK-NEXT: | Module "{{.*}}pdb-diff.obj" | D |
+CHECK-NEXT: | Module "{{.*}}\pdb-diff.obj" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Module "* Linker *" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
@@ -59,8 +59,6 @@ CHECK-NEXT: | Public Symbol Hash | D |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Public Symbol Records | D |
CHECK-NEXT: |------------------------------+---|
-CHECK-NEXT: | Module "{{.*}}pdb-diff.obj" | D |
-CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | New FPO Data | D |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: ------------------------------------
@@ -174,9 +172,25 @@ CHECK-NEXT: | Module Count | I |
CHECK-NEXT: |----------------------------------------+---|
CHECK-NEXT: | Source File Count | I |
CHECK-NEXT: |----------------------------------------+---|
-CHECK-NEXT: |Module "{{.*}}Inputs/pdb-diff.obj"|
+CHECK-NEXT: |Module "{{.*}}\pdb-diff.obj"|
+CHECK-NEXT: |----------------------------------------+---|
+CHECK-NEXT: | - Modi | I |
CHECK-NEXT: |----------------------------------------+---|
-CHECK-NEXT: | - Modi | D |
+CHECK-NEXT: | - Obj File Name | {{[EI]}} |
+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: | - Source File Name Index | {{[EI]}} |
CHECK-NEXT: |----------------------------------------+---|
CHECK-NEXT: | - Symbol Byte Size | D |
CHECK-NEXT: |----------------------------------------+---|
+
+
diff --git a/llvm/tools/llvm-pdbutil/Diff.cpp b/llvm/tools/llvm-pdbutil/Diff.cpp
index fc374ad3a4c..9e520470790 100644
--- a/llvm/tools/llvm-pdbutil/Diff.cpp
+++ b/llvm/tools/llvm-pdbutil/Diff.cpp
@@ -348,6 +348,52 @@ getModuleDescriptors(const DbiModuleList &ML) {
return List;
}
+static void diffOneModule(
+ DiffPrinter &D, const std::pair<uint32_t, DbiModuleDescriptor> Item,
+ std::vector<std::pair<uint32_t, DbiModuleDescriptor>> &Other, bool Invert) {
+ D.printFullRow(
+ truncateQuotedNameFront("Module", Item.second.getModuleName(), 70));
+
+ auto Iter = llvm::find_if(
+ Other, [&Item](const std::pair<uint32_t, DbiModuleDescriptor> &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<ModiProvider>("- 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<ModiProvider>("- Modi", L->first, R->first);
+ D.print<StringProvider>("- Obj File Name",
+ shortFilePath(L->second.getObjFileName(), 28),
+ shortFilePath(R->second.getObjFileName(), 28));
+ D.print<StreamNumberProvider>("- 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 @@ Error DiffStyle::diffDbiStream() {
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<uint32_t, DbiModuleDescriptor> &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<ModiProvider>("- Modi", L.first, None);
- continue;
- }
-
- // We did find this module. Go through and compare each field.
- const auto &R = *Iter;
- D.print<ModiProvider>("- Modi", L.first, R.first);
- D.print<StringProvider>("- Obj File Name",
- shortFilePath(L.second.getObjFileName(), 28),
- shortFilePath(R.second.getObjFileName(), 28));
- D.print<StreamNumberProvider>("- 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();
}
diff --git a/llvm/tools/llvm-pdbutil/DiffPrinter.cpp b/llvm/tools/llvm-pdbutil/DiffPrinter.cpp
index 8deb69309b0..45641e2e4b0 100644
--- a/llvm/tools/llvm-pdbutil/DiffPrinter.cpp
+++ b/llvm/tools/llvm-pdbutil/DiffPrinter.cpp
@@ -110,8 +110,6 @@ void DiffPrinter::printResult(DiffResult Result) {
case DiffResult::UNSPECIFIED:
printValue(" ", Result, AlignStyle::Center, 3, true);
break;
- default:
- llvm_unreachable("unreachable!");
}
}
OpenPOWER on IntegriCloud