diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h | 2 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 17 | ||||
| -rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 13 |
3 files changed, 21 insertions, 11 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index 760950b726b..ca9a6c82287 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -188,6 +188,8 @@ public: bool lookupAddressRange(uint64_t address, uint64_t size, std::vector<uint32_t> &result) const; + bool hasFileAtIndex(uint64_t FileIndex) const; + // Extracts filename by its index in filename table in prologue. // Returns true on success. bool getFileNameByIndex(uint64_t FileIndex, const char *CompDir, diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 30cb83398dd..63d22d84121 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -624,12 +624,17 @@ bool DWARFDebugLine::LineTable::lookupAddressRange( return true; } -bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, - const char *CompDir, - FileLineInfoKind Kind, - std::string &Result) const { - if (FileIndex == 0 || FileIndex > Prologue.FileNames.size() || - Kind == FileLineInfoKind::None) +bool +DWARFDebugLine::LineTable::hasFileAtIndex(uint64_t FileIndex) const { + return FileIndex != 0 && FileIndex <= Prologue.FileNames.size(); +} + +bool +DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, + const char *CompDir, + FileLineInfoKind Kind, + std::string &Result) const { + if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex)) return false; const FileNameEntry &Entry = Prologue.FileNames[FileIndex - 1]; const char *FileName = Entry.Name; diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index bea30ded591..0421040b3d6 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -1633,11 +1633,7 @@ PointerIntPair<DeclContext *, 1> DeclContextTree::getChildDeclContext( // FIXME: Passing U.getOrigUnit().getCompilationDir() // instead of "" would allow more uniquing, but for now, do // it this way to match dsymutil-classic. - std::string File; - if (LT->getFileNameByIndex( - FileNum, "", - DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, - File)) { + if (LT->hasFileAtIndex(FileNum)) { Line = DIE->getAttributeValueAsUnsignedConstant( &U.getOrigUnit(), dwarf::DW_AT_decl_line, 0); // Cache the resolved paths, because calling realpath is expansive. @@ -1646,6 +1642,13 @@ PointerIntPair<DeclContext *, 1> DeclContextTree::getChildDeclContext( FileRef = ResolvedPath; } else { #ifdef HAVE_REALPATH + std::string File; + bool gotFileName = + LT->getFileNameByIndex(FileNum, "", + DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, + File); + (void)gotFileName; + assert(gotFileName && "Must get file name from line table"); char RealPath[PATH_MAX + 1]; RealPath[PATH_MAX] = 0; if (::realpath(File.c_str(), RealPath)) |

