Пример #1
0
bool DepositLightCore::prepare() {
  DYSECTVERBOSE(true, "Preparing deposit light core action");
#ifdef CALLPATH_ENABLED
  prepared = true;
  findAggregates();

  string libraryPath;
  char *envValue;
  Domain *domain = owner->getDomain();
  bool boolRet;
  vector<Process::ptr>::iterator procIter;
  ProcessSet::ptr procs;
  WalkerSet *allWalkers;
  Process::ptr *proc;
  ProcDebug *pDebug;

  if(domain == NULL)
    return DYSECTWARN(false, "Domain not found when preparing DepositLightCore action");

  allWalkers = domain->getAllWalkers();
  DYSECTVERBOSE(true, "Preparing deposit light core action %d", allWalkers->size());

  envValue = getenv("STAT_PREFIX");
  if (envValue != NULL)
    libraryPath = envValue;
  else
    libraryPath = STAT_PREFIX;
  libraryPath += "/lib/libcallpathwrap.so";
  for (WalkerSet::iterator i = allWalkers->begin(); i != allWalkers->end(); i++) {
    pDebug = dynamic_cast<ProcDebug *>((*i)->getProcessState());
    proc = &(pDebug->getProc());
    DYSECTVERBOSE(true, "loading library %s", libraryPath.c_str());
    // This will fail in launch mode since process hasn't been started yet. We will also try loading the library on finishBE
    // This will also be called multiple times if multiple probes use this action, but this won't result in any errors
    if (Backend::loadLibrary(*proc, libraryPath) != OK) {
      return DYSECTWARN(false, "Failed to load library %s: %s", libraryPath.c_str(), Stackwalker::getLastErrorMsg());
    }
  }

  DYSECTVERBOSE(true, "Prepared deposit light core action");
#endif //ifdef CALLPATH_ENABLED
  return true;
}