Commit 7efd2dc8 authored by Teng Qin's avatar Teng Qin

Don't always reload empty Modules

Currently we think the Module's symbol table is not loaed as long as its
empty. But some times we were just not able to read the symbols from the
binary / perf map, or didn't get symbol from the read. This commit makes
so that we don't end up trying to do a read on each lookup.
parent 2e38eeda
...@@ -190,7 +190,7 @@ bool ProcSyms::resolve_name(const char *module, const char *name, ...@@ -190,7 +190,7 @@ bool ProcSyms::resolve_name(const char *module, const char *name,
} }
ProcSyms::Module::Module(const char *name, int pid, bool in_ns) ProcSyms::Module::Module(const char *name, int pid, bool in_ns)
: name_(name), pid_(pid), in_ns_(in_ns) { : name_(name), pid_(pid), in_ns_(in_ns), loaded_(false) {
struct ns_cookie nsc; struct ns_cookie nsc;
bcc_procutils_enter_mountns(pid_, &nsc); bcc_procutils_enter_mountns(pid_, &nsc);
...@@ -213,8 +213,9 @@ bool ProcSyms::Module::is_perf_map() const { ...@@ -213,8 +213,9 @@ bool ProcSyms::Module::is_perf_map() const {
void ProcSyms::Module::load_sym_table() { void ProcSyms::Module::load_sym_table() {
struct ns_cookie nsc = {-1, -1}; struct ns_cookie nsc = {-1, -1};
if (syms_.size()) if (loaded_)
return; return;
loaded_ = true;
if (is_perf_map()) { if (is_perf_map()) {
if (in_ns_) if (in_ns_)
......
...@@ -91,6 +91,7 @@ class ProcSyms : SymbolCache { ...@@ -91,6 +91,7 @@ class ProcSyms : SymbolCache {
bool is_so_; bool is_so_;
int pid_; int pid_;
bool in_ns_; bool in_ns_;
bool loaded_;
std::unordered_set<std::string> symnames_; std::unordered_set<std::string> symnames_;
std::vector<Symbol> syms_; std::vector<Symbol> syms_;
......
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