Exemplo n.º 1
0
bool PCLibraryState::getAOut(LibAddrPair &ao)
{
   Process::ptr proc = pdebug->getProc();
   CHECK_PROC_LIVE;

   Library::ptr lib = proc->libraries().getExecutable();
   if (!lib) {
      sw_printf("[%s:%u] - Could not get executable\n", FILE__, __LINE__);
      return false;
   }
   ao = LibAddrPair(lib->getName(), lib->getLoadAddress());
   return true;
}
Exemplo n.º 2
0
bool PCLibraryState::updateLibraries()
{
   Process::ptr proc = pdebug->getProc();
   CHECK_PROC_LIVE;

   LibraryPool::iterator i;
   for (i = proc->libraries().begin(); i != proc->libraries().end(); i++)
   {
      checkForNewLib(*i);
   }

   return true;
}
Exemplo n.º 3
0
bool PCLibraryState::getLibraryAtAddr(Address addr, LibAddrPair &lib)
{
   Process::ptr proc = pdebug->getProc();
   CHECK_PROC_LIVE;

   /**
    * An OS can have a list of platform-special libs (currently only the
    * vsyscall DSO on Linux).  Those don't appear in the normal link_map
    * and thus won't have dynamic addresses.  Check their library range
    * manually.
    **/

   vector<pair<LibAddrPair, unsigned int> > arch_libs;
   updateLibsArch(arch_libs);
   vector<pair<LibAddrPair, unsigned int> >::iterator j;
   for (j = arch_libs.begin(); j != arch_libs.end(); j++) {
      string name = (*j).first.first;
      Address start = (*j).first.second;
      Address size = (*j).second;
      if (addr >= start && addr < start + size) {
         lib.first = name;
         lib.second = start;
         return true;
      }
   }

   /**
    * Look up the address in our cache of libraries
    **/

   bool ret = findInCache(proc, addr, lib);
   if (ret) {
      return true;
   }

   /**
    * Cache lookup failed. Instead of iterating over every library,
    * look at the link map in memory. This allows us to avoid opening
    * files.
    **/

   // Do a fast in-memory scan
   ret = memoryScan(proc, addr, lib);
   if (ret) {
      return true;
   }

   return false;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
bool PCLibraryState::getLibraries(std::vector<LibAddrPair> &libs, bool allow_refresh)
{
   Process::ptr proc = pdebug->getProc();
   CHECK_PROC_LIVE;

   LibraryPool::iterator i;
   for (i = proc->libraries().begin(); i != proc->libraries().end(); i++)
   {
      if (allow_refresh)
         checkForNewLib(*i);
      libs.push_back(LibAddrPair((*i)->getName(), (*i)->getLoadAddress()));
   }

   vector<pair<LibAddrPair, unsigned int> > arch_libs;
   vector<pair<LibAddrPair, unsigned int> >::iterator j;
   updateLibsArch(arch_libs);
   for (j = arch_libs.begin(); j != arch_libs.end(); j++) {
      libs.push_back(j->first);
   }

   return true;
}