diff options
author | Eugene Zemtsov <ezemtsov@google.com> | 2018-03-13 17:54:29 +0000 |
---|---|---|
committer | Eugene Zemtsov <ezemtsov@google.com> | 2018-03-13 17:54:29 +0000 |
commit | 82d60d6b29808baf25cfd488306a79899b83aa5b (patch) | |
tree | 2a5bcbb587885c76d33aa52805ae8f10bdae213a /llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | |
parent | c6cbbc899b4560d0fa452ebf81fe52fd027efcf6 (diff) | |
download | bcm5719-llvm-82d60d6b29808baf25cfd488306a79899b83aa5b.tar.gz bcm5719-llvm-82d60d6b29808baf25cfd488306a79899b83aa5b.zip |
Handle mixed-OS paths in DWARF reader
Make sure that DWARF line information generated by Windows can be properly read by Posix OS and vice versa.
Differential Revision: https://reviews.llvm.org/D44290
llvm-svn: 327430
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index efc1870fd8c..c91b95cbc11 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -956,6 +956,14 @@ Optional<StringRef> DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileInd return None; } +static bool isPathAbsoluteOnWindowsOrPosix(const Twine &Path) { + // Debug info can contain paths from any OS, not necessarily + // an OS we're currently running on. Moreover different compilation units can + // be compiled on different operating systems and linked together later. + return sys::path::is_absolute(Path, sys::path::Style::posix) || + sys::path::is_absolute(Path, sys::path::Style::windows); +} + bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, const char *CompDir, FileLineInfoKind Kind, @@ -965,7 +973,7 @@ bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, const FileNameEntry &Entry = Prologue.FileNames[FileIndex - 1]; StringRef FileName = Entry.Name.getAsCString().getValue(); if (Kind != FileLineInfoKind::AbsoluteFilePath || - sys::path::is_absolute(FileName)) { + isPathAbsoluteOnWindowsOrPosix(FileName)) { Result = FileName; return true; } @@ -984,7 +992,7 @@ bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, // We know that FileName is not absolute, the only way to have an // absolute path at this point would be if IncludeDir is absolute. if (CompDir && Kind == FileLineInfoKind::AbsoluteFilePath && - sys::path::is_relative(IncludeDir)) + !isPathAbsoluteOnWindowsOrPosix(IncludeDir)) sys::path::append(FilePath, CompDir); // sys::path::append skips empty strings. |