Symbol *Symtab::FindSymbolContainingFileAddress(addr_t file_addr) { std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_file_addr_to_index_computed) InitAddressIndexes(); const FileRangeToIndexMap::Entry *entry = m_file_addr_to_index.FindEntryThatContains(file_addr); if (entry) { Symbol *symbol = SymbolAtIndex(entry->data); if (symbol->ContainsFileAddress(file_addr)) return symbol; } return nullptr; }
void Symtab::ForEachSymbolContainingFileAddress( addr_t file_addr, std::function<bool(Symbol *)> const &callback) { std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_file_addr_to_index_computed) InitAddressIndexes(); std::vector<uint32_t> all_addr_indexes; // Get all symbols with file_addr const size_t addr_match_count = m_file_addr_to_index.FindEntryIndexesThatContain(file_addr, all_addr_indexes); for (size_t i = 0; i < addr_match_count; ++i) { Symbol *symbol = SymbolAtIndex(all_addr_indexes[i]); if (symbol->ContainsFileAddress(file_addr)) { if (!callback(symbol)) break; } } }