| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) | 463 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) |
| 464 { | 464 { |
| 465 v8::DebugEvent event = eventDetails.GetEvent(); | 465 v8::DebugEvent event = eventDetails.GetEvent(); |
| 466 | 466 |
| 467 if (event == v8::BreakForCommand) { | 467 if (event == v8::BreakForCommand) { |
| 468 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); | 468 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); |
| 469 data->task()->run(); | 469 data->task()->run(); |
| 470 return; | 470 return; |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile) | 473 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError) |
| 474 return; | 474 return; |
| 475 | 475 |
| 476 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); | 476 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); |
| 477 ASSERT(!eventContext.IsEmpty()); | 477 ASSERT(!eventContext.IsEmpty()); |
| 478 | 478 |
| 479 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); | 479 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); |
| 480 if (listener) { | 480 if (listener) { |
| 481 v8::HandleScope scope(m_isolate); | 481 v8::HandleScope scope(m_isolate); |
| 482 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); | 482 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); |
| 483 if (event == v8::BeforeCompile) { | 483 if (event == v8::BeforeCompile) { |
| 484 preprocessBeforeCompile(eventDetails); | 484 preprocessBeforeCompile(eventDetails); |
| 485 } else if (event == v8::AfterCompile) { | 485 } else if (event == v8::AfterCompile || event == v8::CompileError) { |
| 486 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 486 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| 487 v8::Handle<v8::Function> getAfterCompileScript = v8::Local<v8::Funct
ion>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getAfterCompileScript"
))); | 487 v8::Handle<v8::Function> getAfterCompileScript = v8::Local<v8::Funct
ion>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getAfterCompileScript"
))); |
| 488 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 488 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| 489 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(g
etAfterCompileScript, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate); | 489 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(g
etAfterCompileScript, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate); |
| 490 ASSERT(value->IsObject()); | 490 ASSERT(value->IsObject()); |
| 491 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 491 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
| 492 dispatchDidParseSource(listener, object); | 492 dispatchDidParseSource(listener, object, event != v8::AfterCompile ?
CompileError : CompileSuccess); |
| 493 } else if (event == v8::Exception) { | 493 } else if (event == v8::Exception) { |
| 494 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT
race(m_isolate, 1); | 494 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT
race(m_isolate, 1); |
| 495 // Stack trace is empty in case of syntax error. Silently continue e
xecution in such cases. | 495 // Stack trace is empty in case of syntax error. Silently continue e
xecution in such cases. |
| 496 if (!stackTrace->GetFrameCount()) | 496 if (!stackTrace->GetFrameCount()) |
| 497 return; | 497 return; |
| 498 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); | 498 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); |
| 499 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); | 499 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); |
| 500 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); | 500 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); |
| 501 } else if (event == v8::Break) { | 501 } else if (event == v8::Break) { |
| 502 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); | 502 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 522 else if (name == "Promise.Rejected") | 522 else if (name == "Promise.Rejected") |
| 523 name = "Promise.reject"; | 523 name = "Promise.reject"; |
| 524 | 524 |
| 525 m_pausedScriptState = pausedScriptState; | 525 m_pausedScriptState = pausedScriptState; |
| 526 m_executionState = executionState; | 526 m_executionState = executionState; |
| 527 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); | 527 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); |
| 528 m_pausedScriptState.clear(); | 528 m_pausedScriptState.clear(); |
| 529 m_executionState.Clear(); | 529 m_executionState.Clear(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object) | 532 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object, CompileResult compileResult) |
| 533 { | 533 { |
| 534 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); | 534 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); |
| 535 ASSERT(!id.IsEmpty() && id->IsInt32()); | 535 ASSERT(!id.IsEmpty() && id->IsInt32()); |
| 536 String sourceID = String::number(id->Int32Value()); | 536 String sourceID = String::number(id->Int32Value()); |
| 537 | 537 |
| 538 ScriptDebugListener::Script script; | 538 ScriptDebugListener::Script script; |
| 539 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); | 539 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); |
| 540 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr
ing(m_isolate, "source"))); | 540 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr
ing(m_isolate, "source"))); |
| 541 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); | 541 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); |
| 542 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn
teger()->Value(); | 542 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn
teger()->Value(); |
| 543 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))->
ToInteger()->Value(); | 543 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))->
ToInteger()->Value(); |
| 544 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege
r()->Value(); | 544 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege
r()->Value(); |
| 545 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn
teger()->Value(); | 545 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn
teger()->Value(); |
| 546 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr
ipt"))->ToBoolean()->Value(); | 546 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr
ipt"))->ToBoolean()->Value(); |
| 547 | 547 |
| 548 listener->didParseSource(sourceID, script); | 548 listener->didParseSource(sourceID, script, compileResult); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 551 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
| 552 { | 552 { |
| 553 if (!m_debuggerScript.isEmpty()) | 553 if (!m_debuggerScript.isEmpty()) |
| 554 return; | 554 return; |
| 555 | 555 |
| 556 v8::HandleScope scope(m_isolate); | 556 v8::HandleScope scope(m_isolate); |
| 557 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 557 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| 558 v8::Handle<v8::String> source = v8String(m_isolate, String(reinterpret_cast<
const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js))); | 558 v8::Handle<v8::String> source = v8String(m_isolate, String(reinterpret_cast<
const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js))); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 { | 673 { |
| 674 return PassOwnPtr<ScriptSourceCode>(); | 674 return PassOwnPtr<ScriptSourceCode>(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) | 677 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) |
| 678 { | 678 { |
| 679 return source; | 679 return source; |
| 680 } | 680 } |
| 681 | 681 |
| 682 } // namespace WebCore | 682 } // namespace WebCore |
| OLD | NEW |