Beispiel #1
0
// Cleanup any proxies in our retired proxy queue. We'll pull a proxy
// out of the queue, ask it to cleanup which will wait for threads it
// owns to exit, then drop our shared reference to it. That may
// destroy the proxy here, or it may remain alive if there is a thread
// still processing an interrupt with it since such threads have their
// own shared reference.
void Debugger::cleanupRetiredProxies() {
  TRACE(7, "Debugger::cleanupRetiredProxies\n");
  DebuggerProxyPtr proxy;
  while (m_retiredProxyQueue.try_pop(proxy)) {
    try {
      // We give the proxy a short period of time to wait for any
      // threads it owns. If it doesn't succeed, we put it back and
      // try again later.
      TRACE(2, "Cleanup proxy %p\n", proxy.get());
      if (!proxy->cleanup(1)) {
        TRACE(2, "Proxy %p has not stopped yet\n", proxy.get());
        m_retiredProxyQueue.push(proxy);
      }
    } catch (Exception &e) {
      Logger::Error("Exception during proxy %p retirement: %s",
                    proxy.get(), e.getMessage().c_str());
    }
  }
}
Beispiel #2
0
bool Debugger::switchSandbox(DebuggerProxyPtr proxy,
                             const std::string &newId,
                             bool force) {
  const StringData* newSid = StringData::GetStaticString(newId);
  // Lock the proxy during the switch
  Lock l(proxy.get());
  if (proxy->getSandboxId() != newId) {
    if (!switchSandboxImpl(proxy, newSid, force)) {
      // failed to switch
      return false;
    }
  }

  updateProxySandbox(proxy, newSid);
  return true;
}
Beispiel #3
0
void Debugger::registerSandbox(const DSandboxInfo &sandbox) {
  // update sandbox first
  updateSandbox(sandbox);

  // add thread do m_sandboxThreadInfoMap
  const StringData* sid = StringData::GetStaticString(sandbox.id());
  ThreadInfo* ti = ThreadInfo::s_threadInfo.getNoCheck();
  {
    SandboxThreadInfoMap::accessor acc;
    m_sandboxThreadInfoMap.insert(acc, sid);
    ThreadInfoSet& set = acc->second;
    set.insert(ti);
  }

  // find out whether this sandbox is being debugged
  DebuggerProxyPtr proxy = findProxy(sid);
  if (proxy) {
    ti->m_reqInjectionData.debugger = true;
    if (hhvm) {
      DebuggerProxyVM* proxyVM = (DebuggerProxyVM*)proxy.get();
      proxyVM->writeInjTablesToThread();
    }
  }
}
Beispiel #4
0
// Place the proxy onto the retired proxy queue. It will be cleaned up
// and destroyed later by another thread.
void Debugger::retireProxy(DebuggerProxyPtr proxy) {
  TRACE(2, "Debugger::retireProxy %p\n", proxy.get());
  m_retiredProxyQueue.push(proxy);
}