Index: include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFContext.h +++ include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -34,6 +34,7 @@ #include #include #include +#include #include namespace llvm { @@ -191,6 +192,10 @@ /// Get a pointer to a parsed line table corresponding to a compile unit. const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu); + /// Get a set of all addresses that appear in the line tables of the compile + /// units in this DWARF context. + std::set getAllLineAddresses(); + DILineInfo getLineInfoForAddress(uint64_t Address, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; DILineInfoTable getLineInfoForAddressRange(uint64_t Address, uint64_t Size, Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -432,6 +432,19 @@ return Line->getOrParseLineTable(lineData, stmtOffset); } +std::set DWARFContext::getAllLineAddresses() { + parseCompileUnits(); + + std::set Result; + for (const auto &CU : CUs) { + const DWARFLineTable* table = getLineTableForUnit(CU.get()); + for (const DWARFDebugLine::Row &row : table->Rows) { + Result.insert(row.Address); + } + } + return Result; +} + void DWARFContext::parseCompileUnits() { CUs.parse(*this, getInfoSection()); }