From: Teng Qin Date: Wed, 3 May 2017 09:16:21 +0000 (-0700) Subject: Avoid walking all symbols for unknown address X-Git-Tag: submit/tizen_4.0/20171018.110122~126 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=879bff25b593b5fa8cfa13b4c92cc52f0950ce39;p=platform%2Fupstream%2Fbcc.git Avoid walking all symbols for unknown address --- diff --git a/src/cc/bcc_syms.cc b/src/cc/bcc_syms.cc index ff88c669..f2dc36de 100644 --- a/src/cc/bcc_syms.cc +++ b/src/cc/bcc_syms.cc @@ -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;