Commit a573a21f authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #1147 from palmtenor/moduleopt

Small improvements to symboling availiability
parents 2e38eeda 552f4c69
...@@ -33,6 +33,11 @@ ino_t ProcStat::getinode_() { ...@@ -33,6 +33,11 @@ ino_t ProcStat::getinode_() {
return (!stat(procfs_.c_str(), &s)) ? s.st_ino : -1; return (!stat(procfs_.c_str(), &s)) ? s.st_ino : -1;
} }
bool ProcStat::is_stale() {
ino_t cur_inode = getinode_();
return (cur_inode > 0) && (cur_inode != inode_);
}
ProcStat::ProcStat(int pid) ProcStat::ProcStat(int pid)
: procfs_(tfm::format("/proc/%d/exe", pid)), inode_(getinode_()) {} : procfs_(tfm::format("/proc/%d/exe", pid)), inode_(getinode_()) {}
...@@ -190,7 +195,7 @@ bool ProcSyms::resolve_name(const char *module, const char *name, ...@@ -190,7 +195,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 +218,9 @@ bool ProcSyms::Module::is_perf_map() const { ...@@ -213,8 +218,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_)
......
...@@ -30,7 +30,7 @@ class ProcStat { ...@@ -30,7 +30,7 @@ class ProcStat {
public: public:
ProcStat(int pid); ProcStat(int pid);
bool is_stale() { return inode_ != getinode_(); } bool is_stale();
void reset() { inode_ = getinode_(); } void reset() { inode_ = getinode_(); }
}; };
...@@ -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