Esempio n. 1
0
void DebuggerAgentManager::onV8DebugMessage(const v8::Debug::Message& message)
{
    v8::HandleScope scope;
    v8::String::Value value(message.GetJSON());
    WTF::String out(reinterpret_cast<const UChar*>(*value), value.length());

    // If callerData is not 0 the message is a response to a debugger command.
    if (v8::Debug::ClientData* callerData = message.GetClientData()) {
        CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(callerData);
        if (wrapper->callerIsMananager()) {
            // Just ignore messages sent by this manager.
            return;
        }
        DebuggerAgentImpl* debuggerAgent = debuggerAgentForHostId(wrapper->callerId());
        if (debuggerAgent)
            debuggerAgent->debuggerOutput(out);
        else if (!message.WillStartRunning()) {
            // Autocontinue execution if there is no handler.
            sendContinueCommandToV8();
        }
        return;
    } // Otherwise it's an event message.
    ASSERT(message.IsEvent());

    // Ignore unsupported event types.
    if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception)
        return;

    v8::Handle<v8::Context> context = message.GetEventContext();
    // If the context is from one of the inpected tabs it should have its context
    // data.
    if (context.IsEmpty()) {
        // Unknown context, skip the event.
        return;
    }

    // If the context is from one of the inpected tabs or injected extension
    // scripts it must have hostId in the data field.
    int hostId = WebCore::V8Proxy::contextDebugId(context);
    if (hostId != -1) {
        DebuggerAgentImpl* agent = debuggerAgentForHostId(hostId);
        if (agent) {
            if (agent->autoContinueOnException()
                && message.GetEvent() == v8::Exception) {
                sendContinueCommandToV8();
                return;
            }

            agent->debuggerOutput(out);
            return;
        }
    }

    if (!message.WillStartRunning()) {
        // Autocontinue execution on break and exception  events if there is no
        // handler.
        sendContinueCommandToV8();
    }
}
Esempio n. 2
0
/* *
 * private method that takes debug message as json from v8
 * after it gets the message the message handler passes it to enqueueMessage method in java
 */
void JsDebugger::MyMessageHandler(const v8::Debug::Message& message)
{
	if (s_jsDebugger == nullptr)
	{
		return;
	}

	auto json = message.GetJSON();
	auto str = ConvertToString(json);

	JEnv env;
	JniLocalRef s(env.NewStringUTF(str.c_str()));
	env.CallVoidMethod(s_jsDebugger, s_EnqueueMessage, (jstring) s);
}
Esempio n. 3
0
void JSDebugger::MessageHandler(const v8::Debug::Message& message)
{
	if (debugger__ == nullptr)
	{
		return;
	}

	JNIEnv *env = JNIUtil::getJNIEnv();
	ASSERT(env != NULL);

	auto json = message.GetJSON();
	jstring s = TypeConverter::jsStringToJavaString(env, json);
	env->CallVoidMethod(debugger__, handleMessage__, s);
	env->DeleteLocalRef(s);
}