Chromium Code Reviews| Index: Source/bindings/v8/ScriptDebugServer.cpp |
| diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp |
| index 3e092646ef2422cdd0e4aec1af69edae2c18403b..553b206d3130bf0a1312bccce5244e942c328c73 100644 |
| --- a/Source/bindings/v8/ScriptDebugServer.cpp |
| +++ b/Source/bindings/v8/ScriptDebugServer.cpp |
| @@ -406,11 +406,12 @@ v8::Handle<v8::Value> ScriptDebugServer::breakProgramCallback(const v8::Argument |
| ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data()); |
| v8::Handle<v8::Value> exception; |
| - thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception); |
| + v8::Handle<v8::Array> hitBreakPoints; |
| + thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception, hitBreakPoints); |
| return v8::Undefined(); |
| } |
| -void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8::Handle<v8::Value> exception) |
| +void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) |
| { |
| // Don't allow nested breaks. |
| if (isPaused()) |
| @@ -420,9 +421,16 @@ void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8:: |
| if (!listener) |
| return; |
| + Vector<String> breakpointIDs; |
| + if (!hitBreakpointNumbers.IsEmpty()) { |
| + breakpointIDs.resize(hitBreakpointNumbers->Length()); |
| + for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) |
| + breakpointIDs[i] = toWebCoreStringWithUndefinedOrNullCheck(hitBreakpointNumbers->Get(i)); |
| + } |
| + |
| m_executionState.set(executionState); |
| ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext); |
| - listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(exception)); |
| + listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(exception), breakpointIDs); |
| m_runningNestedMessageLoop = true; |
| runMessageLoopOnPause(m_pausedContext); |
| @@ -478,29 +486,38 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD |
| m_scriptPreprocessor = preprocessor.release(); |
| } else if (event == v8::AfterCompile) { |
| v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| - v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileScript"))); |
| + v8::Handle<v8::Function> getAfterCompileFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileScript"))); |
| v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| - v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debuggerScript.get(), 1, argv); |
| + v8::Handle<v8::Value> value = getAfterCompileFunction->Call(m_debuggerScript.get(), 1, argv); |
| ASSERT(value->IsObject()); |
| v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
| dispatchDidParseSource(listener, object); |
| - } else if (event == v8::Break || event == v8::Exception) { |
| - v8::Handle<v8::Value> exception; |
| - if (event == v8::Exception) { |
| - v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1); |
| - // Stack trace is empty in case of syntax error. Silently continue execution in such cases. |
| - if (!stackTrace->GetFrameCount()) |
| - return; |
| - v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); |
| - v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8::String::NewSymbol("exception")); |
| - ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFunction()); |
| - v8::Handle<v8::Value> argv[] = { v8Undefined() }; |
| - V8RecursionScope::MicrotaskSuppression scope; |
| - exception = v8::Handle<v8::Function>::Cast(exceptionGetterValue)->Call(eventData, 0, argv); |
| - } |
|
yurys
2013/05/16 19:52:53
Can you put breakpoint ids retrieval into else if
SeRya
2013/05/30 07:45:57
The code looks more clear for me without such an i
|
| + } else if (event == v8::Exception) { |
| + v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1); |
| + // Stack trace is empty in case of syntax error. Silently continue execution in such cases. |
| + if (!stackTrace->GetFrameCount()) |
| + return; |
| + v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); |
| + v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8::String::NewSymbol("exception")); |
| + ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFunction()); |
| + v8::Handle<v8::Value> argv[] = { v8Undefined() }; |
| + V8RecursionScope::MicrotaskSuppression scope; |
| + v8::Handle<v8::Value> exception = v8::Handle<v8::Function>::Cast(exceptionGetterValue)->Call(eventData, 0, argv); |
| + |
| + v8::Handle<v8::Array> hitBreakpoints; |
| + m_pausedContext = *eventContext; |
| + breakProgram(eventDetails.GetExecutionState(), exception, hitBreakpoints); |
| + m_pausedContext.Clear(); |
| + } else if (event == v8::Break) { |
| + // v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| + v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getBreakpointNumbers"))); |
| + v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| + v8::Handle<v8::Value> hitBreakpoints = getBreakpointNumbersFunction->Call(m_debuggerScript.get(), 1, argv); |
| + ASSERT(hitBreakpoints.IsArray()); |
| + v8::Handle<v8::Value> exception; |
| m_pausedContext = *eventContext; |
| - breakProgram(eventDetails.GetExecutionState(), exception); |
| + breakProgram(eventDetails.GetExecutionState(), exception, hitBreakpoints.As<v8::Array>()); |
| m_pausedContext.Clear(); |
| } |
| } |