Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcSyms should treat the executable like any other mapped file when symbolizing #3498

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/cc/bcc_syms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,7 @@ ProcSyms::ProcSyms(int pid, struct bcc_symbol_option *option)
load_modules();
}

int ProcSyms::_add_load_sections(uint64_t v_addr, uint64_t mem_sz,
uint64_t file_offset, void *payload) {
auto module = static_cast<Module *>(payload);
module->ranges_.emplace_back(v_addr, v_addr + mem_sz, file_offset);
return 0;
}

void ProcSyms::load_exe() {
std::string exe = ebpf::get_pid_exe(pid_);
Module module(exe.c_str(), exe.c_str(), &symbol_option_);

if (module.type_ != ModuleType::EXEC)
return;


bcc_elf_foreach_load_section(exe.c_str(), &_add_load_sections, &module);

if (!module.ranges_.empty())
modules_.emplace_back(std::move(module));
}

void ProcSyms::load_modules() {
load_exe();
bcc_procutils_each_module(pid_, _add_module, this);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code needs to be added in this PR because the _add_module callback passed to the /proc/PID/maps iterator compares module 'name's of /proc/PID/maps lines - the file path - with already-added Module objects. Since load_exe was adding to modules_ a Module with name = result of get_pid_exe, if the /proc/PID/maps entry is the same path, it'll just get ignored.

}

Expand Down
3 changes: 0 additions & 3 deletions src/cc/syms.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ class ProcSyms : SymbolCache {
ProcStat procstat_;
bcc_symbol_option symbol_option_;

static int _add_load_sections(uint64_t v_addr, uint64_t mem_sz,
uint64_t file_offset, void *payload);
static int _add_module(mod_info *, int, void *);
void load_exe();
void load_modules();

public:
Expand Down