llvm.org GIT mirror llvm / 364e3e0
Revert "[DebugInfo] Move function from line table to the prologue (NFC)" This broke LLD, which I didn't have enabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366160 91177308-0d34-0410-b5e6-96231b3b80d8 Jonas Devlieghere 3 months ago
2 changed file(s) with 42 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
119119 int32_t getMaxLineIncrementForSpecialOpcode() const {
120120 return LineBase + (int8_t)LineRange - 1;
121121 }
122
123 /// Get DWARF-version aware access to the file name entry at the provided
124 /// index.
125 const llvm::DWARFDebugLine::FileNameEntry &
126 getFileNameEntry(uint64_t Index) const;
127
128 bool hasFileAtIndex(uint64_t FileIndex) const;
129
130 bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir,
131 DILineInfoSpecifier::FileLineInfoKind Kind,
132 std::string &Result) const;
133122
134123 void clear();
135124 void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const;
250239 bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size,
251240 std::vector &Result) const;
252241
253 bool hasFileAtIndex(uint64_t FileIndex) const {
254 return Prologue.hasFileAtIndex(FileIndex);
255 }
242 bool hasFileAtIndex(uint64_t FileIndex) const;
256243
257244 /// Extracts filename by its index in filename table in prologue.
258245 /// In Dwarf 4, the files are 1-indexed and the current compilation file
259246 /// name is not represented in the list. In DWARF v5, the files are
260247 /// 0-indexed and the primary source file has the index 0.
261248 /// Returns true on success.
262 bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir,
249 bool getFileNameByIndex(uint64_t FileIndex, const char *CompDir,
263250 DILineInfoSpecifier::FileLineInfoKind Kind,
264 std::string &Result) const {
265 return Prologue.getFileNameByIndex(FileIndex, CompDir, Kind, Result);
266 }
251 std::string &Result) const;
267252
268253 /// Fills the Result argument with the file and line information
269254 /// corresponding to Address. Returns true on success.
281266 const DWARFContext &Ctx, const DWARFUnit *U,
282267 std::function RecoverableErrorCallback,
283268 raw_ostream *OS = nullptr);
269
270 /// Get DWARF-version aware access to the file name entry at the provided
271 /// index.
272 const llvm::DWARFDebugLine::FileNameEntry &
273 getFileNameEntry(uint64_t Index) const;
284274
285275 using RowVector = std::vector;
286276 using RowIter = RowVector::const_iterator;
6464 }
6565
6666 DWARFDebugLine::Prologue::Prologue() { clear(); }
67
68 bool DWARFDebugLine::Prologue::hasFileAtIndex(uint64_t FileIndex) const {
69 uint16_t DwarfVersion = getVersion();
70 assert(DwarfVersion != 0 &&
71 "line table prologue has no dwarf version information");
72 if (DwarfVersion >= 5)
73 return FileIndex < FileNames.size();
74 return FileIndex != 0 && FileIndex <= FileNames.size();
75 }
76
77 const llvm::DWARFDebugLine::FileNameEntry &
78 DWARFDebugLine::Prologue::getFileNameEntry(uint64_t Index) const {
79 uint16_t DwarfVersion = getVersion();
80 assert(DwarfVersion != 0 &&
81 "line table prologue has no dwarf version information");
82 // In DWARF v5 the file names are 0-indexed.
83 if (DwarfVersion >= 5)
84 return FileNames[Index];
85 return FileNames[Index - 1];
86 }
8767
8868 void DWARFDebugLine::Prologue::clear() {
8969 TotalLength = PrologueLength = 0;
987967 return true;
988968 }
989969
970 bool DWARFDebugLine::LineTable::hasFileAtIndex(uint64_t FileIndex) const {
971 uint16_t DwarfVersion = Prologue.getVersion();
972 assert(DwarfVersion != 0 && "LineTable has no dwarf version information");
973 if (DwarfVersion >= 5)
974 return FileIndex < Prologue.FileNames.size();
975 return FileIndex != 0 && FileIndex <= Prologue.FileNames.size();
976 }
977
978 const llvm::DWARFDebugLine::FileNameEntry &
979 DWARFDebugLine::LineTable::getFileNameEntry(uint64_t Index) const {
980 uint16_t DwarfVersion = Prologue.getVersion();
981 assert(DwarfVersion != 0 && "LineTable has no dwarf version information");
982 // In DWARF v5 the file names are 0-indexed.
983 if (DwarfVersion >= 5)
984 return Prologue.FileNames[Index];
985 else
986 return Prologue.FileNames[Index - 1];
987 }
988
990989 Optional DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex,
991990 FileLineInfoKind Kind) const {
992 if (Kind == FileLineInfoKind::None || !Prologue.hasFileAtIndex(FileIndex))
991 if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))
993992 return None;
994 const FileNameEntry &Entry = Prologue.getFileNameEntry(FileIndex);
993 const FileNameEntry &Entry = getFileNameEntry(FileIndex);
995994 if (Optional source = Entry.Source.getAsCString())
996995 return StringRef(*source);
997996 return None;
10051004 sys::path::is_absolute(Path, sys::path::Style::windows);
10061005 }
10071006
1008 bool DWARFDebugLine::Prologue::getFileNameByIndex(uint64_t FileIndex,
1009 StringRef CompDir,
1010 FileLineInfoKind Kind,
1011 std::string &Result) const {
1007 bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex,
1008 const char *CompDir,
1009 FileLineInfoKind Kind,
1010 std::string &Result) const {
10121011 if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))
10131012 return false;
10141013 const FileNameEntry &Entry = getFileNameEntry(FileIndex);
10221021 SmallString<16> FilePath;
10231022 StringRef IncludeDir;
10241023 // Be defensive about the contents of Entry.
1025 if (getVersion() >= 5) {
1026 if (Entry.DirIdx < IncludeDirectories.size())
1027 IncludeDir = IncludeDirectories[Entry.DirIdx].getAsCString().getValue();
1024 if (Prologue.getVersion() >= 5) {
1025 if (Entry.DirIdx < Prologue.IncludeDirectories.size())
1026 IncludeDir =
1027 Prologue.IncludeDirectories[Entry.DirIdx].getAsCString().getValue();
10281028 } else {
1029 if (0 < Entry.DirIdx && Entry.DirIdx <= IncludeDirectories.size())
1030 IncludeDir =
1031 IncludeDirectories[Entry.DirIdx - 1].getAsCString().getValue();
1029 if (0 < Entry.DirIdx && Entry.DirIdx <= Prologue.IncludeDirectories.size())
1030 IncludeDir = Prologue.IncludeDirectories[Entry.DirIdx - 1]
1031 .getAsCString()
1032 .getValue();
10321033
10331034 // We may still need to append compilation directory of compile unit.
10341035 // We know that FileName is not absolute, the only way to have an
10351036 // absolute path at this point would be if IncludeDir is absolute.
1036 if (!CompDir.empty() && !isPathAbsoluteOnWindowsOrPosix(IncludeDir))
1037 if (CompDir && !isPathAbsoluteOnWindowsOrPosix(IncludeDir))
10371038 sys::path::append(FilePath, CompDir);
10381039 }
10391040