Index: lld/COFF/PDB.cpp =================================================================== --- lld/COFF/PDB.cpp +++ lld/COFF/PDB.cpp @@ -222,7 +222,7 @@ // 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 &FileName) { - if (sys::path::is_absolute(FileName, sys::path::Style::windows)) + if (sys::path::is_absolute(FileName)) return; if (Config->PDBSourcePath.empty()) { // Debuggers generally want that PDB files contain absolute, Windows-style @@ -238,10 +238,9 @@ // 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 +443,7 @@ 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 EC) -> Error { @@ -1027,7 +1025,7 @@ 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 +1310,7 @@ 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); Index: lldb/lit/SymbolFile/NativePDB/source-list.cpp =================================================================== --- lldb/lit/SymbolFile/NativePDB/source-list.cpp +++ lldb/lit/SymbolFile/NativePDB/source-list.cpp @@ -25,7 +25,7 @@ // 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. Index: lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -42,11 +42,8 @@ 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 @@ // 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); Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -530,7 +530,9 @@ 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); } Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ 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 @@ // 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 += '/';