diff options
| -rw-r--r-- | lld/COFF/PDB.cpp | 31 | ||||
| -rw-r--r-- | lldb/lit/SymbolFile/NativePDB/source-list.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 5 |
5 files changed, 24 insertions, 26 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index 6790ae68701..34344dd3f1c 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -222,26 +222,22 @@ public: // PDB to work without additional configuration: // https://docs.microsoft.com/en-us/visualstudio/debugger/debug-source-files-common-properties-solution-property-pages-dialog-box static void pdbMakeAbsolute(SmallVectorImpl<char> &FileName) { - if (sys::path::is_absolute(FileName, sys::path::Style::windows)) + // The default behavior is to produce paths that are valid within the context + // of the machine that you perform the link on. If the linker is running on + // a POSIX system, we will output absolute POSIX paths. If the linker is + // running on a Windows system, we will output absolute Windows paths. If the + // user desires any other kind of behavior, they should explicitly pass + // /pdbsourcepath and/or /pdbaltpath. + if (sys::path::is_absolute(FileName)) return; if (Config->PDBSourcePath.empty()) { - // Debuggers generally want that PDB files contain absolute, Windows-style - // paths. On POSIX hosts, this here will produce an absolute POSIX-style - // path, which is weird -- but it's not clear what else to do. - // People doing cross builds should probably just always pass - // /pbdsourcepath: and make sure paths to input obj files and to lld-link - // itself are relative. sys::fs::make_absolute(FileName); return; } - // Using /pdbsourcepath: with absolute POSIX paths will prepend - // PDBSourcePath to the absolute POSIX path. Since absolute POSIX paths - // don't make sense in PDB files anyways, this is gargabe-in-garbage-out. SmallString<128> AbsoluteFileName = Config->PDBSourcePath; - sys::path::append(AbsoluteFileName, sys::path::Style::windows, FileName); - sys::path::native(AbsoluteFileName, sys::path::Style::windows); - sys::path::remove_dots(AbsoluteFileName, /*remove_dot_dots=*/true, - sys::path::Style::windows); + sys::path::append(AbsoluteFileName, FileName); + sys::path::native(AbsoluteFileName); + sys::path::remove_dots(AbsoluteFileName, /*remove_dot_dots=*/true); FileName = std::move(AbsoluteFileName); } @@ -444,8 +440,7 @@ PDBLinker::maybeMergeTypeServerPDB(ObjFile *File, TypeServer2Record &TS) { StringRef LocalPath = !File->ParentName.empty() ? File->ParentName : File->getName(); SmallString<128> Path = sys::path::parent_path(LocalPath); - sys::path::append( - Path, sys::path::filename(TSPath, sys::path::Style::windows)); + sys::path::append(Path, sys::path::filename(TSPath)); return tryToLoadPDB(TSId, Path); }, [&](std::unique_ptr<ECError> EC) -> Error { @@ -1027,7 +1022,7 @@ void PDBLinker::addObjFile(ObjFile *File) { bool InArchive = !File->ParentName.empty(); SmallString<128> Path = InArchive ? File->ParentName : File->getName(); pdbMakeAbsolute(Path); - sys::path::native(Path, sys::path::Style::windows); + sys::path::native(Path); StringRef Name = InArchive ? File->getName() : StringRef(Path); pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder(); @@ -1312,7 +1307,7 @@ void PDBLinker::addSections(ArrayRef<OutputSection *> OutputSections, pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder(); NativePath = Config->PDBPath; pdbMakeAbsolute(NativePath); - sys::path::native(NativePath, sys::path::Style::windows); + sys::path::native(NativePath); uint32_t PdbFilePathNI = DbiBuilder.addECName(NativePath); auto &LinkerModule = ExitOnErr(DbiBuilder.addModuleInfo("* Linker *")); LinkerModule.setPdbFilePathNI(PdbFilePathNI); diff --git a/lldb/lit/SymbolFile/NativePDB/source-list.cpp b/lldb/lit/SymbolFile/NativePDB/source-list.cpp index d959489f2b6..abd90cde9dd 100644 --- a/lldb/lit/SymbolFile/NativePDB/source-list.cpp +++ b/lldb/lit/SymbolFile/NativePDB/source-list.cpp @@ -25,7 +25,7 @@ int main(int argc, char **argv) { // changing this file. // CHECK: (lldb) source list -n main -// CHECK: File: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\source-list.cpp +// CHECK: File: {{.*}}source-list.cpp // CHECK: 10 // CHECK: 11 // Some context lines before // CHECK: 12 // the function. diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp index 6e6c94330da..b4725e591a4 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -42,11 +42,8 @@ static bool IsMainFile(llvm::StringRef main, llvm::StringRef other) { if (llvm::sys::fs::equivalent(main, other)) return true; - // FIXME: If we ever want to support PDB debug info for non-Windows systems - // the following check will be wrong, but we need a way to store the host - // information in the PDB. llvm::SmallString<64> normalized(other); - llvm::sys::path::native(normalized, llvm::sys::path::Style::windows); + llvm::sys::path::native(normalized); return main.equals_lower(normalized); } @@ -156,7 +153,8 @@ CompileUnitIndex::GetOrCreateCompiland(PdbSymUid compiland_uid) { // name until we find it, and we can cache that one since the memory is backed // by a contiguous chunk inside the mapped PDB. llvm::SmallString<64> main_file = GetMainSourceFile(*cci); - llvm::sys::path::native(main_file, llvm::sys::path::Style::windows); + std::string s = main_file.str(); + llvm::sys::path::native(main_file); uint32_t file_count = modules.getSourceFileCount(modi); cci->m_file_list.reserve(file_count); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 9936c0487c6..a4cf37448be 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -530,7 +530,9 @@ bool SymbolFileNativePDB::ParseCompileUnitSupportFiles( lldbassert(cci); for (llvm::StringRef f : cci->m_file_list) { - FileSpec spec(f, false, FileSpec::Style::windows); + FileSpec::Style style = + f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows; + FileSpec spec(f, false, style); support_files.Append(spec); } diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 4d45a103c5a..8232f076a93 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/Path.h" #include "llvm/Support/SMLoc.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Target/TargetLoweringObjectFile.h" @@ -134,7 +135,9 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) { // If this is a Unix-style path, just use it as is. Don't try to canonicalize // it textually because one of the path components could be a symlink. - if (!Dir.empty() && Dir[0] == '/') { + if (Dir.startswith("/") || Filename.startswith("/")) { + if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix)) + return Filename; Filepath = Dir; if (Dir.back() != '/') Filepath += '/'; |

