Index: src/debug/debug.cc |
diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
index 32d1e8f1131903f7dd8062c704d211223e7536bd..ddf2daa84a6bcfc0bc91eae2a73968362a6bacba 100644 |
--- a/src/debug/debug.cc |
+++ b/src/debug/debug.cc |
@@ -1724,12 +1724,7 @@ bool Debug::IsExceptionBlackboxed(bool uncaught) { |
// caught exception if top frame is blackboxed. |
bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame()); |
if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed; |
- it.Advance(); |
- while (!it.done()) { |
- if (!IsFrameBlackboxed(it.frame())) return false; |
- it.Advance(); |
- } |
- return true; |
+ return !HasNonBlackboxedFrameOnStack(); |
} |
bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { |
@@ -1984,6 +1979,26 @@ bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) { |
return shared->debug_is_blackboxed(); |
} |
+bool Debug::HasPromiseBuiltinOnStack() { |
+ for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) { |
+ List<SharedFunctionInfo*> raw_shareds; |
+ it.frame()->GetFunctions(&raw_shareds); |
+ for (int i = 0; i < raw_shareds.length(); ++i) { |
+ if (raw_shareds[i]->is_promise_builtin()) return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
+bool Debug::HasNonBlackboxedFrameOnStack() { |
+ HandleScope scope(isolate_); |
+ for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) { |
+ if (!it.is_javascript()) continue; |
+ if (!IsFrameBlackboxed(it.javascript_frame())) return true; |
+ } |
+ return false; |
+} |
+ |
void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, |
int parent_id) { |
if (in_debug_scope() || ignore_events()) return; |
@@ -1994,7 +2009,13 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, |
HandleScope scope(isolate_); |
PostponeInterruptsScope no_interrupts(isolate_); |
DisableBreak no_recursive_break(this); |
- debug_delegate_->PromiseEventOccurred(type, id, parent_id); |
+ // Promise.all and Promise.race implementations use .then internally, |
+ // we don't allow to break on these calls. |
+ bool breakable = type == debug::kDebugPromiseCreated && |
+ !HasPromiseBuiltinOnStack() && |
+ HasNonBlackboxedFrameOnStack(); |
+ debug_delegate_->PromiseEventOccurred( |
+ Utils::ToLocal(debug_scope.GetContext()), type, id, parent_id, breakable); |
} |
void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { |
@@ -2274,7 +2295,8 @@ bool Debug::PerformSideEffectCheckForCallback(Address function) { |
} |
void LegacyDebugDelegate::PromiseEventOccurred( |
- v8::debug::PromiseDebugActionType type, int id, int parent_id) { |
+ v8::Local<v8::Context> context, v8::debug::PromiseDebugActionType type, |
+ int id, int parent_id, bool breakable) { |
Handle<Object> event_data; |
if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { |
ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); |