Loading lld/COFF/PDB.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -1791,8 +1791,8 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr, // Use CodeView line tables to resolve a file and line number for the given // offset into the given chunk and return them, or {"", 0} if a line table was // not found. std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t addr) { Optional<std::pair<StringRef, uint32_t>> getFileLineCodeView(const SectionChunk *c, uint32_t addr) { ExitOnError exitOnErr; DebugStringTableSubsectionRef cVStrTab; Loading @@ -1801,7 +1801,7 @@ std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t offsetInLinetable; if (!findLineTable(c, addr, cVStrTab, checksums, lines, offsetInLinetable)) return {"", 0}; return None; Optional<uint32_t> nameIndex; Optional<uint32_t> lineNumber; Loading @@ -1815,16 +1815,16 @@ std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, } StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex)); return {filename, *lineNumber}; return std::make_pair(filename, *lineNumber); } nameIndex = entry.NameIndex; lineNumber = li.getStartLine(); } } if (!nameIndex) return {"", 0}; return None; StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex)); return {filename, *lineNumber}; return std::make_pair(filename, *lineNumber); } } // namespace coff Loading lld/COFF/PDB.h +5 −4 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ #define LLD_COFF_PDB_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" namespace llvm { Loading @@ -29,9 +30,9 @@ void createPDB(SymbolTable *symtab, llvm::ArrayRef<uint8_t> sectionTable, llvm::codeview::DebugInfo *buildId); std::pair<llvm::StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t addr); } } llvm::Optional<std::pair<llvm::StringRef, uint32_t>> getFileLineCodeView(const SectionChunk *c, uint32_t addr); } // namespace coff } // namespace lld #endif lld/COFF/SymbolTable.cpp +15 −12 Original line number Diff line number Diff line Loading @@ -108,26 +108,27 @@ static std::vector<std::string> getSymbolLocations(BitcodeFile *file) { return {res}; } static std::pair<StringRef, uint32_t> getFileLineDwarf(const SectionChunk *c, uint32_t addr) { static Optional<std::pair<StringRef, uint32_t>> getFileLineDwarf(const SectionChunk *c, uint32_t addr) { if (!config->symbolizer) config->symbolizer = make<symbolize::LLVMSymbolizer>(); Expected<DILineInfo> expectedLineInfo = config->symbolizer->symbolizeCode( *c->file->getCOFFObj(), {addr, c->getSectionNumber() - 1}); if (!expectedLineInfo) return {"", 0}; return None; const DILineInfo &lineInfo = *expectedLineInfo; if (lineInfo.FileName == DILineInfo::BadString) return {"", 0}; return {saver.save(lineInfo.FileName), lineInfo.Line}; return None; return std::make_pair(saver.save(lineInfo.FileName), lineInfo.Line); } static std::pair<StringRef, uint32_t> getFileLine(const SectionChunk *c, uint32_t addr) { static Optional<std::pair<StringRef, uint32_t>> getFileLine(const SectionChunk *c, uint32_t addr) { // MinGW can optionally use codeview, even if the default is dwarf. std::pair<StringRef, uint32_t> fileLine = getFileLineCodeView(c, addr); Optional<std::pair<StringRef, uint32_t>> fileLine = getFileLineCodeView(c, addr); // If codeview didn't yield any result, check dwarf in MinGW mode. if (fileLine.first.empty() && config->mingw) if (!fileLine && config->mingw) fileLine = getFileLineDwarf(c, addr); return fileLine; } Loading @@ -150,11 +151,13 @@ std::vector<std::string> getSymbolLocations(ObjFile *file, uint32_t symIndex) { for (const coff_relocation &r : sc->getRelocs()) { if (r.SymbolTableIndex != symIndex) continue; std::pair<StringRef, uint32_t> fileLine = Optional<std::pair<StringRef, uint32_t>> fileLine = getFileLine(sc, r.VirtualAddress); Symbol *sym = getSymbol(sc, r.VirtualAddress); if (!fileLine.first.empty() || sym) locations.push_back({sym, fileLine}); if (fileLine) locations.push_back({sym, *fileLine}); else if (sym) locations.push_back({sym}); } } Loading Loading
lld/COFF/PDB.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -1791,8 +1791,8 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr, // Use CodeView line tables to resolve a file and line number for the given // offset into the given chunk and return them, or {"", 0} if a line table was // not found. std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t addr) { Optional<std::pair<StringRef, uint32_t>> getFileLineCodeView(const SectionChunk *c, uint32_t addr) { ExitOnError exitOnErr; DebugStringTableSubsectionRef cVStrTab; Loading @@ -1801,7 +1801,7 @@ std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t offsetInLinetable; if (!findLineTable(c, addr, cVStrTab, checksums, lines, offsetInLinetable)) return {"", 0}; return None; Optional<uint32_t> nameIndex; Optional<uint32_t> lineNumber; Loading @@ -1815,16 +1815,16 @@ std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, } StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex)); return {filename, *lineNumber}; return std::make_pair(filename, *lineNumber); } nameIndex = entry.NameIndex; lineNumber = li.getStartLine(); } } if (!nameIndex) return {"", 0}; return None; StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex)); return {filename, *lineNumber}; return std::make_pair(filename, *lineNumber); } } // namespace coff Loading
lld/COFF/PDB.h +5 −4 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ #define LLD_COFF_PDB_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" namespace llvm { Loading @@ -29,9 +30,9 @@ void createPDB(SymbolTable *symtab, llvm::ArrayRef<uint8_t> sectionTable, llvm::codeview::DebugInfo *buildId); std::pair<llvm::StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c, uint32_t addr); } } llvm::Optional<std::pair<llvm::StringRef, uint32_t>> getFileLineCodeView(const SectionChunk *c, uint32_t addr); } // namespace coff } // namespace lld #endif
lld/COFF/SymbolTable.cpp +15 −12 Original line number Diff line number Diff line Loading @@ -108,26 +108,27 @@ static std::vector<std::string> getSymbolLocations(BitcodeFile *file) { return {res}; } static std::pair<StringRef, uint32_t> getFileLineDwarf(const SectionChunk *c, uint32_t addr) { static Optional<std::pair<StringRef, uint32_t>> getFileLineDwarf(const SectionChunk *c, uint32_t addr) { if (!config->symbolizer) config->symbolizer = make<symbolize::LLVMSymbolizer>(); Expected<DILineInfo> expectedLineInfo = config->symbolizer->symbolizeCode( *c->file->getCOFFObj(), {addr, c->getSectionNumber() - 1}); if (!expectedLineInfo) return {"", 0}; return None; const DILineInfo &lineInfo = *expectedLineInfo; if (lineInfo.FileName == DILineInfo::BadString) return {"", 0}; return {saver.save(lineInfo.FileName), lineInfo.Line}; return None; return std::make_pair(saver.save(lineInfo.FileName), lineInfo.Line); } static std::pair<StringRef, uint32_t> getFileLine(const SectionChunk *c, uint32_t addr) { static Optional<std::pair<StringRef, uint32_t>> getFileLine(const SectionChunk *c, uint32_t addr) { // MinGW can optionally use codeview, even if the default is dwarf. std::pair<StringRef, uint32_t> fileLine = getFileLineCodeView(c, addr); Optional<std::pair<StringRef, uint32_t>> fileLine = getFileLineCodeView(c, addr); // If codeview didn't yield any result, check dwarf in MinGW mode. if (fileLine.first.empty() && config->mingw) if (!fileLine && config->mingw) fileLine = getFileLineDwarf(c, addr); return fileLine; } Loading @@ -150,11 +151,13 @@ std::vector<std::string> getSymbolLocations(ObjFile *file, uint32_t symIndex) { for (const coff_relocation &r : sc->getRelocs()) { if (r.SymbolTableIndex != symIndex) continue; std::pair<StringRef, uint32_t> fileLine = Optional<std::pair<StringRef, uint32_t>> fileLine = getFileLine(sc, r.VirtualAddress); Symbol *sym = getSymbol(sc, r.VirtualAddress); if (!fileLine.first.empty() || sym) locations.push_back({sym, fileLine}); if (fileLine) locations.push_back({sym, *fileLine}); else if (sym) locations.push_back({sym}); } } Loading