void BacktracePrinter::printbtgoal(std::ostream& os, Goal goal){
  // identify hanging threads factorized by their intensions
  IntenMap hanging;
  addThreads(hanging, goal->threads);
  Choice c = goal->choices.ptr();
  while (c != 0){
    addThreads(hanging, c->enriched);
    c = c->parent;
  }
  if (hanging.empty()) return;
  os << " {" << ind << ind;
  // print the threads along the variable instantiation order
  VarRecord v = goal->vars.ptr();
  while (v != 0){
    Choice c = goal->choices.ptr();
    while (c != 0 && c->varmark != v->index){
      c = c->parent;
    }
    IntenMap::iterator i = hanging.find(v->inten);
    if (i != hanging.end()){
      os << iendl << "resolving " << v->inten->schema->name;
      if (c != 0){
	os << iendl << "as a choice of " << c->thread->constr->name;
      }
      if (v->inten->schema->paramcount > 0){
	os << iendl << "with parameters:" << ind;
	printbtparams(os, v->inten->schema->paramcount,
		      v->inten->schema->paramnames,
		      v->inten->params);
	os << unind;
      }
      if (v->inten->schema->varcount > 0){
	os << iendl << "with variables:" << ind;
	printbtvars(os, v->inten->schema->varcount, v->vars);
	os << unind;
      }
      printbtthreads(os, "unresolved constraints:", i->second);
    }
    v = v->parent;
  }
  /*
  if (goal->parent != 0){
    os << iendl << "this was a subresolution invoked from " 
       << goal->parent->constr->name;
  }
  */
  os << unind << unind << iendl << "}";
}
IOThreadPoolExecutor::IOThreadPoolExecutor(
    size_t numThreads,
    std::shared_ptr<ThreadFactory> threadFactory)
  : ThreadPoolExecutor(numThreads, std::move(threadFactory)),
    nextThread_(0) {
  addThreads(numThreads);
  CHECK(threadList_.get().size() == numThreads);
}
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
    size_t numThreads,
    std::unique_ptr<BlockingQueue<Task>> taskQueue,
    std::unique_ptr<ThreadFactory> threadFactory)
    : ThreadPoolExecutor(numThreads, std::move(threadFactory)),
      taskQueue_(std::move(taskQueue)) {
  addThreads(numThreads);
  CHECK(threadList_.get().size() == numThreads);
}
Exemple #4
0
/*
 * Class:     sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
 * Method:    attach0
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal_attach0__I
  (JNIEnv *env, jobject obj, jint pid) {

  if (getWindbgInterfaces(env, obj) == false) {
     return;
  }

  if (attachToProcess(env, obj, pid) == false) {
     return;
  }

  if (addLoadObjects(env, obj) == false) {
     return;
  }

  if (addThreads(env, obj) == false) {
     return;
  }
}
Exemple #5
0
/*
 * Class:     sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
 * Method:    attach0
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
  (JNIEnv *env, jobject obj, jstring execName, jstring coreFileName) {

  if (getWindbgInterfaces(env, obj) == false) {
     return;
  }

  if (openDumpFile(env, obj, coreFileName) == false) {
     return;
  }

  if (addLoadObjects(env, obj) == false) {
     return;
  }

  if (addThreads(env, obj) == false) {
     return;
  }
}
Exemple #6
0
int main(int argc, char *argv[])
{
    Application app(argc, argv);
    QApplication::setOrganizationName(Common::ORG_NAME);
    QApplication::setOrganizationDomain(Common::ORG_DOMAIN);
    QApplication::setApplicationName(Common::APP_NAME);
    QApplication::setWindowIcon( QIcon(":/res/ico/anonymous.png") );
    QSettings settings;
    NetworkAccessManager::instance()->setCache(0);
    LocalServer localServer;
    //LocalServer::removeServer(Common::APP_NAME);
    bool serverStarted = localServer.listen(Common::APP_NAME);
    QStringList argList;
    QStringList urlList;
    bool fillingUrlList = false;

    for (int i = 0; i < argc; ++i)
    {
        QString arg(argv[i]);

        if ( arg.at(0) == LocalServer::PREFIX.at(0) )
        {
            argList << arg;

            if (fillingUrlList)
                fillingUrlList = false;
            else if (LocalServer::ARG_URLS == arg)
                fillingUrlList = true;
        }
        else if (fillingUrlList)
        {
            urlList << QUrl::fromUserInput(arg).toString();
        }
    }

    if ( !serverStarted && !argList.contains(LocalServer::ARG_MULTIPLE) )
    {
        if ( argList.contains(LocalServer::ARG_URLS) )
        {
            QLocalSocket socket;
            socket.connectToServer(Common::APP_NAME, QIODevice::WriteOnly);

            if ( !socket.waitForConnected() )
                return 1;

            QByteArray data;

            for (int i = 0; i < argc; ++i)
            {
                data.append(argv[i]).append('\0');
            }

            if ( -1 == socket.write(data) )
                return 2;

            if ( !socket.waitForBytesWritten() )
                return 3;

            socket.disconnectFromServer();
        }

        return 0;
    }

    qRegisterMetaType<ParceTask::Result>("ParceTask::Result");
    qRegisterMetaType<SaveTask::Result>("SaveTask::Result");
    qRegisterMetaType<SavePageTask::Result>("SavePageTask::Result");
    qRegisterMetaType<RmdirTask::Result>("RmdirTask::Result");
    qRegisterMetaType<ImageboardThread*>("ImageboardThread*");
    qRegisterMetaType<InfoWidget*>("InfoWidget*");
    qRegisterMetaType<QModelIndex>("QModelIndex");
    qRegisterMetaType<ImageboardThread::Modifiable>("ImageboardThread::Modifiable");
    QThreadPool::globalInstance()->setMaxThreadCount(10);
    ThreadManager threadManager(0);
    QObject::connect( &localServer,
             SIGNAL( addThreadSilent(ImageboardThread::Parameters, bool) ),
             &threadManager,
             SLOT( requestAddThread(ImageboardThread::Parameters, bool) ) );

    if ( argList.contains(LocalServer::ARG_DEFAULT) && !urlList.isEmpty() )
    {
        bool start = argList.contains(LocalServer::ARG_START);
        settings.beginGroup(ParametersDialog::GROUP_PARAMETERS);
          settings.beginGroup(ThreadManager::SUB_GROUP_DEFAULT);
            ImageboardThread::Parameters param =
                    ImageboardThread::readParameters(settings);
          settings.endGroup();
        settings.endGroup();

        for (int i = 0; i < urlList.count(); ++i)
        {
            param.url = urlList.at(i);
            param.added = QDateTime::currentDateTime();
            threadManager.requestAddThread(param, start);
        }
    }

    MainWindow *mainWindow = new MainWindow(threadManager.threadModel(),
                                            threadManager.categoryModel(), 0);
    QObject::connect(&app, SIGNAL( requestWriteSettings() ),
                     mainWindow, SLOT( writeSettings() ),
                     Qt::DirectConnection);
    QObject::connect(
                mainWindow,
                SIGNAL( requestAddThread(ImageboardThread::Parameters, bool) ),
                &threadManager,
                SLOT( requestAddThread(ImageboardThread::Parameters, bool) ) );
    QObject::connect( mainWindow, SIGNAL( requestBackup(QString) ),
                      &threadManager, SLOT( requestBackup(QString) ) );
    QObject::connect( mainWindow,
                      SIGNAL( requestRemoveThread(QList<int>, bool) ),
                      &threadManager,
                      SLOT( requestRemoveThread(QList<int>, bool) ) );
    QObject::connect( mainWindow, SIGNAL( requestStartThread(int) ),
                      &threadManager, SLOT( requestStartThread(int) ) );
    QObject::connect( mainWindow, SIGNAL( requestStopThread(int) ),
                      &threadManager, SLOT( requestStopThread(int) ) );
    QObject::connect( mainWindow, SIGNAL( requestOpenDir(int) ),
                      &threadManager, SLOT( requestOpenDir(int) ) );
    QObject::connect( mainWindow, SIGNAL( requestOpenUrl(int) ),
                      &threadManager, SLOT( requestOpenUrl(int) ) );
    QObject::connect( mainWindow, SIGNAL( requestOpenLocal(int) ),
                      &threadManager, SLOT( requestOpenLocal(int) ) );
    QObject::connect( mainWindow,
                      SIGNAL(requestSetObservedThread(int, InfoWidget*) ),
                      &threadManager,
                      SLOT( requestSetObservedThread(int, InfoWidget*) ) );
    QObject::connect( mainWindow,
                      SIGNAL( requestModifyParameters(
                                 QList<int>, ImageboardThread::Modifiable) ),
                      &threadManager,
                      SLOT( requestModifyParameters(
                               QList<int>, ImageboardThread::Modifiable) ) );
    QObject::connect( mainWindow, SIGNAL( requestRetranslate() ),
                      &threadManager, SLOT( requestRetranslate() ) );
    QObject::connect( mainWindow, SIGNAL( requestWriteSettings() ),
                      &threadManager, SLOT( requestWriteSettings() ) );
    QObject::connect( &localServer, SIGNAL( addThreads(QStringList) ),
                      mainWindow, SLOT( callAddThreadDialog(QStringList) ) );
    ParametersDialog::CommonParameters commonParam =
            ParametersDialog::readCommonParameters(settings);
    mainWindow->setVisibility(!commonParam.startMinimized);

    if ( !argList.contains(LocalServer::ARG_DEFAULT) && !urlList.isEmpty() )
        mainWindow->callAddThreadDialog(urlList);

    int err = app.exec();
    //LocalServer::removeServer(Common::APP_NAME);
    localServer.close();
    return err;
}