Index: Source/bindings/dart/DartScriptDebugServer.cpp |
diff --git a/Source/bindings/dart/DartScriptDebugServer.cpp b/Source/bindings/dart/DartScriptDebugServer.cpp |
index 1a574b0c9f0045486950749f7ad87f446beb93ec..39f6ac0d5b486d38ccf4ea25490f498e4322969b 100644 |
--- a/Source/bindings/dart/DartScriptDebugServer.cpp |
+++ b/Source/bindings/dart/DartScriptDebugServer.cpp |
@@ -461,6 +461,7 @@ DartScriptDebugServer::DartScriptDebugServer() |
, m_breakpointsActivated(true) |
, m_runningNestedMessageLoop(false) |
, m_executionState(0) |
+ , m_isPaused(false) |
, m_pausedIsolate(0) |
, m_pausedPage(0) |
, m_clientMessageLoop(0) |
@@ -633,6 +634,7 @@ void DartScriptDebugServer::continueProgram() |
if (isPaused()) |
quitMessageLoopOnPause(); |
m_executionState = 0; |
+ m_isPaused = false; |
m_pausedIsolate = 0; |
} |
@@ -657,7 +659,7 @@ void DartScriptDebugServer::stepOutOfFunction() |
continueProgram(); |
} |
-bool DartScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorData, StackTrace* newCallFrames, RefPtr<JSONObject>* result) |
+bool DartScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorData, StackTraces* newCallFrames, RefPtr<JSONObject>* result) |
{ |
*error = "Dart does not support live editing source code yet."; |
return false; |
@@ -687,20 +689,39 @@ int DartScriptDebugServer::frameCount() |
return length; |
} |
-StackTrace DartScriptDebugServer::currentCallFrames() |
+StackTraces DartScriptDebugServer::currentCallFrames() |
{ |
- return StackTrace(m_executionState); |
+ if (!m_executionState) { |
+ if (!Dart_CurrentIsolate()) |
+ return StackTraces(); |
+ ASSERT(!m_isPaused); |
+ // We are not paused at a Dart breakpoint but there may be Dart frames |
+ // on the call stack. |
+ |
+ Dart_Handle ALLOW_UNUSED result = Dart_GetStackTrace(&m_executionState); |
+ ASSERT(!Dart_IsError(result)); |
+ if (!m_executionState) |
+ return StackTraces(); |
+ intptr_t length = 0; |
+ Dart_StackTraceLength(m_executionState, &length); |
+ if (!length) { |
+ ASSERT_NOT_REACHED(); |
+ m_executionState = 0; |
+ return StackTraces(); |
+ } |
+ } |
+ return StackTraces(StackTrace(m_executionState), DartUtilities::currentScriptState()); |
} |
-StackTrace DartScriptDebugServer::currentCallFramesForAsyncStack() |
+StackTraces DartScriptDebugServer::currentCallFramesForAsyncStack() |
{ |
// FIXMEDART: implement propertly. These are the regular not Async call frames. |
- return StackTrace(m_executionState); |
+ return currentCallFrames(); |
} |
bool DartScriptDebugServer::isPaused() |
{ |
- return !!m_executionState; |
+ return m_isPaused; |
} |
void DartScriptDebugServer::clearCompiledScripts() |
@@ -961,6 +982,7 @@ DartPageDebug* DartScriptDebugServer::lookupPageDebugForCurrentIsolate() |
void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackTrace stackTrace, intptr_t dartBreakpointId, Dart_Handle exception, const Dart_CodeLocation& location) |
{ |
ASSERT(isolate == Dart_CurrentIsolate()); |
+ |
// Don't allow nested breaks. |
if (isAnyScriptPaused()) |
return; |
@@ -980,9 +1002,10 @@ void DartScriptDebugServer::handleProgramBreak(Dart_Isolate isolate, Dart_StackT |
Vector<String> breakpointIds; |
breakpointIds.append(pageDebug->lookupBreakpointId(dartBreakpointId)); |
m_executionState = stackTrace; |
+ m_isPaused = true; |
m_pausedIsolate = isolate; |
DartScriptState* scriptState = DartUtilities::currentScriptState(); |
- ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptState, currentCallFrames(), exception ? DartUtilities::dartToScriptValue(exception) : ScriptValue(), breakpointIds); |
+ ScriptDebugListener::SkipPauseRequest result = listener->didPause(scriptState, exception ? DartUtilities::dartToScriptValue(exception) : ScriptValue(), breakpointIds); |
if (result == ScriptDebugListener::NoSkip) { |
m_runningNestedMessageLoop = true; |
@@ -1161,9 +1184,8 @@ void UnifiedScriptDebugServer::setPauseOnExceptionsState(ScriptDebugServer::Paus |
void UnifiedScriptDebugServer::setPauseOnNextStatement(bool pause) |
{ |
- if (isPaused()) { |
+ if (isPaused()) |
return; |
- } |
m_v8->setPauseOnNextStatement(pause); |
m_dart->setPauseOnNextStatement(pause); |
} |
@@ -1223,7 +1245,7 @@ bool UnifiedScriptDebugServer::isDartBreakpointId(const String& breakpointId) |
return breakpointId.startsWith(String("{\"dartBreakpoint")); |
} |
-bool UnifiedScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorBuilder, StackTrace* newCallFrames, RefPtr<JSONObject>* result) |
+bool UnifiedScriptDebugServer::setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>& errorBuilder, StackTraces* newCallFrames, RefPtr<JSONObject>* result) |
{ |
if (isDartSourceID(sourceID)) |
return m_dart->setScriptSource(sourceID, newContent, preview, error, errorBuilder, newCallFrames, result); |
@@ -1239,26 +1261,20 @@ int UnifiedScriptDebugServer::frameCount() |
return m_dart->frameCount(); |
} |
- |
-StackTrace UnifiedScriptDebugServer::currentCallFrames() |
+StackTraces UnifiedScriptDebugServer::currentCallFrames() |
{ |
- // FIXMEDART: we need to figure out how to interleave stack traces where possible. |
- StackTrace v8StackTrace = m_v8->currentCallFrames(); |
- if (!v8StackTrace.isNull()) |
- return v8StackTrace; |
- return m_dart->currentCallFrames(); |
+ StackTraces traces = m_v8->currentCallFrames(); |
+ traces.add(m_dart->currentCallFrames()); |
+ return traces; |
} |
-StackTrace UnifiedScriptDebugServer::currentCallFramesForAsyncStack() |
+StackTraces UnifiedScriptDebugServer::currentCallFramesForAsyncStack() |
{ |
- // FIXMEDART: we need to figure out how to interleave stack traces where possible. |
- StackTrace v8StackTrace = m_v8->currentCallFramesForAsyncStack(); |
- if (!v8StackTrace.isNull()) |
- return v8StackTrace; |
- return m_dart->currentCallFramesForAsyncStack(); |
+ StackTraces traces = m_v8->currentCallFramesForAsyncStack(); |
+ traces.add(m_dart->currentCallFramesForAsyncStack()); |
+ return traces; |
} |
- |
bool UnifiedScriptDebugServer::isPaused() |
{ |
return m_v8->isPaused() || m_dart->isPaused(); |