-static bool getFileNameForCompileUnit(DWARFCompileUnit *CU,
- const DWARFLineTable *LineTable,
- uint64_t FileIndex,
- bool NeedsAbsoluteFilePath,
- std::string &FileName) {
- if (!CU || !LineTable ||
- !LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath,
- FileName))
- return false;
- if (NeedsAbsoluteFilePath && sys::path::is_relative(FileName)) {
- // We may still need to append compilation directory of compile unit.
- SmallString<16> AbsolutePath;
- if (const char *CompilationDir = CU->getCompilationDir()) {
- sys::path::append(AbsolutePath, CompilationDir);
- }
- sys::path::append(AbsolutePath, FileName);
- FileName = AbsolutePath.str();
- }
- return true;
-}
-
-static bool getFileLineInfoForCompileUnit(DWARFCompileUnit *CU,
- const DWARFLineTable *LineTable,
- uint64_t Address,
- bool NeedsAbsoluteFilePath,
- DILineInfo &Result) {
- if (!CU || !LineTable)
- return false;
- // Get the index of row we're looking for in the line table.
- uint32_t RowIndex = LineTable->lookupAddress(Address);
- if (RowIndex == -1U)
- return false;
- // Take file number and line/column from the row.
- const DWARFDebugLine::Row &Row = LineTable->Rows[RowIndex];
- if (!getFileNameForCompileUnit(CU, LineTable, Row.File, NeedsAbsoluteFilePath,
- Result.FileName))
- return false;
- Result.Line = Row.Line;
- Result.Column = Row.Column;
- return true;
-}
-