From: Dave Marchevsky Date: Sat, 19 Jun 2021 02:34:55 +0000 (-0700) Subject: ProcSyms should treat the executable like any other mapped file when X-Git-Tag: v0.21.0~7^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=649cb3e3d1870a1514238ab63b9167a1a402fdd2;p=platform%2Fupstream%2Fbcc.git ProcSyms should treat the executable like any other mapped file when symbolizing As reported in #3487, when `/proc/PID/exe`'s symlink points to a mountns-relative path from a different mountns than the tracing process, we can fail to open it as we don't prepend `/proc/PID/root` . A few potential solutions were discussed in that issue, we settled on treating the main exe like any other map in `/proc/PID/maps`. Since it's always the first map we can reuse existing code and get rid of exe-specific helpers. --- diff --git a/src/cc/bcc_syms.cc b/src/cc/bcc_syms.cc index b3a10167..24f4277b 100644 --- a/src/cc/bcc_syms.cc +++ b/src/cc/bcc_syms.cc @@ -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(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); } diff --git a/src/cc/syms.h b/src/cc/syms.h index 021b28aa..cf2cd35b 100644 --- a/src/cc/syms.h +++ b/src/cc/syms.h @@ -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: