Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: Source/bindings/v8/ScriptDebugServer.cpp

Issue 74063002: DevTools: Support asynchronous call stacks on backend. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Async call stacks are off by default, added Debugger.enableAsyncCallStacks protocol command Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/ScriptDebugServer.cpp
diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp
index b94fadf396ba83af4b46c387cb8327638f76a40f..5a86e8951a10a83a54ece9d1b17bcba124261918 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());
+ return true;
+ }
+
+ v8::HandleScope scope(m_isolate);
loislo 2013/11/20 01:39:18 it is not clear for me why do you need this async
aandrey 2013/11/20 15:20:02 There are two kind of stacks: console stack (Conso
+ 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())
+ 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;

Powered by Google App Engine
This is Rietveld 408576698