Ejemplo n.º 1
0
void JNICALL
AsyncCommandHandler::StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
{
    JDWP_TRACE_ENTRY("Async::StartExecution(" << jvmti_env << ',' << jni_env << ',' << arg << ')');

    AsyncCommandHandler *handler = reinterpret_cast<AsyncCommandHandler *>(arg);

    try 
    {
        handler->Execute(jni_env);
    }
    catch (const AgentException &e)
    {
        handler->ComposeError(e);
    }

    try {
        if (handler->m_cmdParser->reply.IsPacketInitialized())
        {
            JDWP_TRACE_CMD("send reply");
            handler->m_cmdParser->WriteReply(jni_env);
        }

        JDWP_TRACE_CMD("Removing command handler: "
            << handler->m_cmdParser->command.GetCommandSet() << "/"
            << handler->m_cmdParser->command.GetCommand());

        handler->Destroy();
    
    } catch (const AgentException &e) {
        // cannot report error in async thread, just print warning message
        JDWP_INFO("JDWP error in asynchronous command: " << e.what() << " [" << e.ErrCode() << "]");
    }
}
Ejemplo n.º 2
0
void JNICALL
AsyncCommandHandler::StartExecution(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
{
    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Async::StartExecution(%p,%p,%p)", jvmti_env, jni_env, arg));

    static int count = 0;
    int ret = 0;

    while (true) {
        if (!isWorkerInitialized) {
            continue;
        }
	AsyncCommandHandler* handler = worker->RemoveRequest();

    if (count == 0) {
        GetJniEnv()->PushLocalFrame(100);
    }

    ret = handler->Execute(jni_env);
    if (ret != JDWP_ERROR_NONE) {
        AgentException aex = GetExceptionManager().GetLastException();
        handler->ComposeError(aex);
    }

    if (handler->m_cmdParser->reply.IsPacketInitialized())
    {
        JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "send reply"));
        ret = handler->m_cmdParser->WriteReply(jni_env);
        if (ret != JDWP_ERROR_NONE) {
            // cannot report error in async thread, just print warning message
            AgentException aex = GetExceptionManager().GetLastException();
            JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "JDWP error in asynchronous command: %s", aex.GetExceptionMessage(jni_env)));
        }
    }

    JDWP_TRACE(LOG_RELEASE, (LOG_CMD_FL, "Removing command handler: %d/%d",
           handler->m_cmdParser->command.GetCommandSet(),
           handler->m_cmdParser->command.GetCommand()));

    count++;
    if (count >= 30) {
        GetJniEnv()->PopLocalFrame(NULL);
        count = 0;
    }

    }
}