Commit 879bff25 authored by Teng Qin's avatar Teng Qin Committed by Sasha Goldshtein

Avoid walking all symbols for unknown address

parent fbd91e2d
......@@ -284,12 +284,20 @@ bool ProcSyms::Module::find_addr(uint64_t addr, struct bcc_symbol *sym) {
// brings us to bar, which does not contain offset 0x12 and is nested inside
// foo. Going back one more symbol brings us to foo, which contains 0x12
// and is a match.
for (--it; offset >= it->start; --it) {
// However, we also don't want to walk through the entire symbol list for
// unknown / missing symbols. So we will break if we reach a function that
// doesn't cover the function immediately before 'it', which means it is
// not possibly a nested function containing the address we're looking for.
--it;
uint64_t limit = it->start;
for (; offset >= it->start; --it) {
if (offset < it->start + it->size) {
sym->name = it->name->c_str();
sym->offset = (offset - it->start);
return true;
}
if (limit > it->start + it->size)
break;
// But don't step beyond begin()!
if (it == syms_.begin())
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment