MCPcopy Create free account
hub / github.com/bloomberg/pystack / module_callback

Function module_callback

src/pystack/_pystack/unwinder.cpp:353–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351};
352
353static int
354module_callback(
355 Dwfl_Module* mod,
356 void** userdata __attribute__((unused)),
357 const char* name __attribute__((unused)),
358 Dwarf_Addr start __attribute__((unused)),
359 void* arg)
360{
361 auto module_arg = static_cast<ModuleArg*>(arg);
362 // std::cerr << "Searching in " << name << std::endl;
363 if (strstr(module_arg->modulename, name) == nullptr) {
364 LOG(DEBUG) << "Skipping map for symbols " << name << " because doesn't match "
365 << module_arg->modulename;
366 return DWARF_CB_OK;
367 }
368 LOG(INFO) << "Attempting to find symbol '" << module_arg->symbol << "' in " << name;
369 int n_syms = dwfl_module_getsymtab(mod);
370 if (n_syms == -1) {
371 return DWARF_CB_OK;
372 }
373 GElf_Sym sym;
374 GElf_Addr addr;
375 for (int i = 0; i < n_syms; i++) {
376 const char* sname = dwfl_module_getsym_info(mod, i, &sym, &addr, nullptr, nullptr, nullptr);
377 if (strcmp(sname, module_arg->symbol) == 0) {
378 module_arg->addr = addr;
379 LOG(INFO) << "Symbol '" << sname << "' found at address " << std::hex << std::showbase
380 << addr;
381 return DWARF_CB_ABORT;
382 }
383 }
384 return DWARF_CB_OK;
385}
386
387remote_addr_t
388AbstractUnwinder::getAddressforSymbol(const std::string& symbol, const std::string& modulename) const

Callers

nothing calls this directly

Calls 1

LOGClass · 0.85

Tested by

no test coverage detected