Chromium Code Reviews| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) | 443 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) |
| 444 { | 444 { |
| 445 v8::DebugEvent event = eventDetails.GetEvent(); | 445 v8::DebugEvent event = eventDetails.GetEvent(); |
| 446 | 446 |
| 447 if (event == v8::BreakForCommand) { | 447 if (event == v8::BreakForCommand) { |
| 448 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData()); | 448 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData()); |
| 449 data->task()->run(); | 449 data->task()->run(); |
| 450 return; | 450 return; |
| 451 } | 451 } |
| 452 | 452 |
| 453 if (event != v8::Break && event != v8::Exception && event != v8::AfterCompil e && event != v8::BeforeCompile) | 453 if (event != v8::Break && event != v8::Exception && event != v8::AfterCompil e && event != v8::BeforeCompile && event != v8::CompileError) |
| 454 return; | 454 return; |
| 455 | 455 |
| 456 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); | 456 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); |
| 457 ASSERT(!eventContext.IsEmpty()); | 457 ASSERT(!eventContext.IsEmpty()); |
| 458 | 458 |
| 459 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); | 459 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); |
| 460 if (listener) { | 460 if (listener) { |
| 461 v8::HandleScope scope(m_isolate); | 461 v8::HandleScope scope(m_isolate); |
| 462 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate); | 462 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate); |
| 463 if (event == v8::BeforeCompile) { | 463 if (event == v8::BeforeCompile) { |
| 464 preprocessBeforeCompile(eventDetails); | 464 preprocessBeforeCompile(eventDetails); |
| 465 } else if (event == v8::AfterCompile) { | 465 } else if (event == v8::AfterCompile || event == v8::CompileError) { |
| 466 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 466 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| 467 v8::Handle<v8::Function> getAfterCompileScript = v8::Local<v8::Funct ion>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getAfterCompileScript" ))); | 467 v8::Handle<v8::Function> getAfterCompileScript = v8::Local<v8::Funct ion>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getAfterCompileScript" ))); |
| 468 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 468 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| 469 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(g etAfterCompileScript, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate); | 469 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(g etAfterCompileScript, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate); |
| 470 ASSERT(value->IsObject()); | 470 ASSERT(value->IsObject()); |
| 471 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 471 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
| 472 dispatchDidParseSource(listener, object); | 472 dispatchDidParseSource(listener, object, event == v8::CompileError); |
|
aandrey
2014/07/07 19:44:32
again, an enum name would be more readable, like C
| |
| 473 } else if (event == v8::Exception) { | 473 } else if (event == v8::Exception) { |
| 474 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT race(m_isolate, 1); | 474 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT race(m_isolate, 1); |
| 475 // Stack trace is empty in case of syntax error. Silently continue e xecution in such cases. | 475 // Stack trace is empty in case of syntax error. Silently continue e xecution in such cases. |
| 476 if (!stackTrace->GetFrameCount()) | 476 if (!stackTrace->GetFrameCount()) |
| 477 return; | 477 return; |
| 478 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); | 478 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); |
| 479 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8Atomic String(m_isolate, "exception")); | 479 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8Atomic String(m_isolate, "exception")); |
| 480 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFu nction()); | 480 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFu nction()); |
| 481 v8::Handle<v8::Value> exception = V8ScriptRunner::callInternalFuncti on(v8::Handle<v8::Function>::Cast(exceptionGetterValue), eventData, 0, 0, m_isol ate); | 481 v8::Handle<v8::Value> exception = V8ScriptRunner::callInternalFuncti on(v8::Handle<v8::Function>::Cast(exceptionGetterValue), eventData, 0, 0, m_isol ate); |
| 482 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Handle<v8::Array>()); | 482 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Handle<v8::Array>()); |
| 483 } else if (event == v8::Break) { | 483 } else if (event == v8::Break) { |
| 484 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu mbers"))); | 484 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu mbers"))); |
| 485 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 485 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| 486 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar gv, m_isolate); | 486 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar gv, m_isolate); |
| 487 ASSERT(hitBreakpoints->IsArray()); | 487 ASSERT(hitBreakpoints->IsArray()); |
| 488 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); | 488 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object) | 493 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object, bool hasSyntaxError) |
| 494 { | 494 { |
| 495 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); | 495 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); |
| 496 ASSERT(!id.IsEmpty() && id->IsInt32()); | 496 ASSERT(!id.IsEmpty() && id->IsInt32()); |
| 497 String sourceID = String::number(id->Int32Value()); | 497 String sourceID = String::number(id->Int32Value()); |
| 498 | 498 |
| 499 ScriptDebugListener::Script script; | 499 ScriptDebugListener::Script script; |
| 500 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name"))); | 500 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name"))); |
| 501 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr ing(m_isolate, "source"))); | 501 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr ing(m_isolate, "source"))); |
| 502 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL"))); | 502 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL"))); |
| 503 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn teger()->Value(); | 503 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn teger()->Value(); |
| 504 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))-> ToInteger()->Value(); | 504 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))-> ToInteger()->Value(); |
| 505 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege r()->Value(); | 505 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege r()->Value(); |
| 506 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn teger()->Value(); | 506 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn teger()->Value(); |
| 507 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr ipt"))->ToBoolean()->Value(); | 507 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr ipt"))->ToBoolean()->Value(); |
| 508 | 508 |
| 509 listener->didParseSource(sourceID, script); | 509 listener->didParseSource(sourceID, script, hasSyntaxError); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 512 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
| 513 { | 513 { |
| 514 if (!m_debuggerScript.isEmpty()) | 514 if (!m_debuggerScript.isEmpty()) |
| 515 return; | 515 return; |
| 516 | 516 |
| 517 v8::HandleScope scope(m_isolate); | 517 v8::HandleScope scope(m_isolate); |
| 518 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 518 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| 519 v8::Handle<v8::String> source = v8String(m_isolate, String(reinterpret_cast< const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js))); | 519 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... | |
| 634 { | 634 { |
| 635 return PassOwnPtr<ScriptSourceCode>(); | 635 return PassOwnPtr<ScriptSourceCode>(); |
| 636 } | 636 } |
| 637 | 637 |
| 638 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName) | 638 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName) |
| 639 { | 639 { |
| 640 return source; | 640 return source; |
| 641 } | 641 } |
| 642 | 642 |
| 643 } // namespace WebCore | 643 } // namespace WebCore |
| OLD | NEW |