Chromium Code Reviews| Index: Source/bindings/v8/ScriptDebugServer.cpp |
| diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp |
| index 2faae44528f8b5617aafd6eb5c00fb9c300dce99..7aaa8257e428f9813dcb502649df5eced3bbaf22 100644 |
| --- a/Source/bindings/v8/ScriptDebugServer.cpp |
| +++ b/Source/bindings/v8/ScriptDebugServer.cpp |
| @@ -201,6 +201,29 @@ void ScriptDebugServer::breakProgram() |
| m_pausedContext.Clear(); |
| } |
| +bool ScriptDebugServer::requestAsyncCallFrames() |
| +{ |
| + if (isPaused()) { |
| + ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); |
| + ASSERT(listener); |
| + if (!listener) |
| + return false; |
| + listener->didRequestAsyncCallFrames(currentCallFrame()); |
|
yurys
2013/12/03 13:41:08
I believe we can implement this synchronously by p
aandrey
2013/12/04 12:45:47
Done.
|
| + return true; |
| + } |
| + |
| + v8::HandleScope scope(m_isolate); |
| + if (m_asyncCallFramesCallbackTemplate.isEmpty()) { |
| + v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| + templ->SetCallHandler(&ScriptDebugServer::asyncCallFramesCallback, v8::External::New(this)); |
| + m_asyncCallFramesCallbackTemplate.set(m_isolate, templ); |
| + } |
| + |
| + v8::Handle<v8::Function> asyncCallFramesFunction = m_asyncCallFramesCallbackTemplate.newLocal(m_isolate)->GetFunction(); |
| + v8::Debug::Call(asyncCallFramesFunction); |
| + return true; |
| +} |
| + |
| void ScriptDebugServer::continueProgram() |
| { |
| if (isPaused()) |
| @@ -335,12 +358,17 @@ PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::wrapCallFrames(v8::Handle<v8: |
| ScriptValue ScriptDebugServer::currentCallFrame() |
| { |
| ASSERT(isPaused()); |
| + return currentCallFrame(m_executionState.newLocal(m_isolate), m_pausedContext); |
| +} |
| + |
| +ScriptValue ScriptDebugServer::currentCallFrame(v8::Handle<v8::Object> executionState, v8::Handle<v8::Context> pausedContext) |
| +{ |
| v8::HandleScope handleScope(m_isolate); |
| - RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(m_executionState.newLocal(m_isolate), -1); |
| + RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(executionState, -1); |
| if (!currentCallFrame) |
| return ScriptValue(v8::Null(m_isolate), m_isolate); |
| - v8::Context::Scope contextScope(m_pausedContext); |
| - return ScriptValue(toV8(currentCallFrame.release(), v8::Handle<v8::Object>(), m_pausedContext->GetIsolate()), m_pausedContext->GetIsolate()); |
| + v8::Context::Scope contextScope(pausedContext); |
| + return ScriptValue(toV8(currentCallFrame.release(), v8::Handle<v8::Object>(), pausedContext->GetIsolate()), pausedContext->GetIsolate()); |
| } |
| void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task, v8::Isolate* isolate) |
| @@ -359,10 +387,29 @@ static ScriptDebugServer* toScriptDebugServer(v8::Handle<v8::Value> data) |
| return static_cast<ScriptDebugServer*>(p); |
| } |
| -void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +void ScriptDebugServer::asyncCallFramesCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| { |
| ASSERT(2 == info.Length()); |
| + ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); |
| + thisPtr->handleAsyncCallFrames(v8::Handle<v8::Object>::Cast(info[0])); |
| +} |
| + |
| +void ScriptDebugServer::handleAsyncCallFrames(v8::Handle<v8::Object> executionState) |
| +{ |
| + if (m_isolate->GetCurrentContext().IsEmpty()) |
| + return; |
| + ScriptDebugListener* listener = getDebugListenerForContext(m_isolate->GetCurrentContext()); |
| + if (!listener) |
| + return; |
| + if (isPaused()) |
|
yurys
2013/12/03 13:41:08
How can we get here not being paused?
|
| + listener->didRequestAsyncCallFrames(currentCallFrame()); |
| + else |
| + listener->didRequestAsyncCallFrames(currentCallFrame(executionState, m_isolate->GetCurrentContext())); |
| +} |
| +void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ASSERT(2 == info.Length()); |
| ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); |
| v8::Handle<v8::Value> exception; |
| v8::Handle<v8::Array> hitBreakpoints; |