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

Side by Side Diff: src/debug/debug.cc

Issue 2723273002: [inspector] introduced Debugger.scheduleStepIntoAsync (Closed)
Patch Set: override current scheduled step into async if presented Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 } 1717 }
1718 } // anonymous namespace 1718 } // anonymous namespace
1719 1719
1720 bool Debug::IsExceptionBlackboxed(bool uncaught) { 1720 bool Debug::IsExceptionBlackboxed(bool uncaught) {
1721 JavaScriptFrameIterator it(isolate_); 1721 JavaScriptFrameIterator it(isolate_);
1722 if (it.done()) return false; 1722 if (it.done()) return false;
1723 // Uncaught exception is blackboxed if all current frames are blackboxed, 1723 // Uncaught exception is blackboxed if all current frames are blackboxed,
1724 // caught exception if top frame is blackboxed. 1724 // caught exception if top frame is blackboxed.
1725 bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame()); 1725 bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame());
1726 if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed; 1726 if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed;
1727 it.Advance(); 1727 return !HasNonBlackboxedFrameOnStack();
1728 while (!it.done()) {
1729 if (!IsFrameBlackboxed(it.frame())) return false;
1730 it.Advance();
1731 }
1732 return true;
1733 } 1728 }
1734 1729
1735 bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { 1730 bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) {
1736 HandleScope scope(isolate_); 1731 HandleScope scope(isolate_);
1737 if (!frame->HasInlinedFrames()) { 1732 if (!frame->HasInlinedFrames()) {
1738 Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_); 1733 Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_);
1739 return IsBlackboxed(shared); 1734 return IsBlackboxed(shared);
1740 } 1735 }
1741 List<Handle<SharedFunctionInfo>> infos; 1736 List<Handle<SharedFunctionInfo>> infos;
1742 frame->GetFunctions(&infos); 1737 frame->GetFunctions(&infos);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 is_blackboxed = debug_delegate_->IsFunctionBlackboxed( 1972 is_blackboxed = debug_delegate_->IsFunctionBlackboxed(
1978 ToApiHandle<debug::Script>(script), start, end); 1973 ToApiHandle<debug::Script>(script), start, end);
1979 } 1974 }
1980 } 1975 }
1981 shared->set_debug_is_blackboxed(is_blackboxed); 1976 shared->set_debug_is_blackboxed(is_blackboxed);
1982 shared->set_computed_debug_is_blackboxed(true); 1977 shared->set_computed_debug_is_blackboxed(true);
1983 } 1978 }
1984 return shared->debug_is_blackboxed(); 1979 return shared->debug_is_blackboxed();
1985 } 1980 }
1986 1981
1982 bool Debug::HasPromiseBuiltinOnStack() {
1983 for (JavaScriptFrameIterator it(isolate_); !it.done(); it.Advance()) {
1984 List<SharedFunctionInfo*> raw_shareds;
1985 it.frame()->GetFunctions(&raw_shareds);
1986 for (int i = 0; i < raw_shareds.length(); ++i) {
1987 if (raw_shareds[i]->is_promise_builtin()) return true;
1988 }
1989 }
1990 return false;
1991 }
1992
1993 bool Debug::HasNonBlackboxedFrameOnStack() {
1994 HandleScope scope(isolate_);
1995 for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) {
1996 if (!it.is_javascript()) continue;
1997 if (!IsFrameBlackboxed(it.javascript_frame())) return true;
1998 }
1999 return false;
2000 }
2001
1987 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, 2002 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id,
1988 int parent_id) { 2003 int parent_id) {
1989 if (in_debug_scope() || ignore_events()) return; 2004 if (in_debug_scope() || ignore_events()) return;
1990 if (!debug_delegate_) return; 2005 if (!debug_delegate_) return;
1991 SuppressDebug while_processing(this); 2006 SuppressDebug while_processing(this);
1992 DebugScope debug_scope(isolate_->debug()); 2007 DebugScope debug_scope(isolate_->debug());
1993 if (debug_scope.failed()) return; 2008 if (debug_scope.failed()) return;
1994 HandleScope scope(isolate_); 2009 HandleScope scope(isolate_);
1995 PostponeInterruptsScope no_interrupts(isolate_); 2010 PostponeInterruptsScope no_interrupts(isolate_);
1996 DisableBreak no_recursive_break(this); 2011 DisableBreak no_recursive_break(this);
1997 debug_delegate_->PromiseEventOccurred(type, id, parent_id); 2012 // Promise.all and Promise.race implementations use .then internally,
2013 // we don't allow to break on these calls.
2014 bool breakable = type == debug::kDebugPromiseCreated &&
2015 !HasPromiseBuiltinOnStack() &&
2016 HasNonBlackboxedFrameOnStack();
2017 debug_delegate_->PromiseEventOccurred(
2018 Utils::ToLocal(debug_scope.GetContext()), type, id, parent_id, breakable);
1998 } 2019 }
1999 2020
2000 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { 2021 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
2001 if (ignore_events()) return; 2022 if (ignore_events()) return;
2002 if (script->type() != i::Script::TYPE_NORMAL && 2023 if (script->type() != i::Script::TYPE_NORMAL &&
2003 script->type() != i::Script::TYPE_WASM) { 2024 script->type() != i::Script::TYPE_WASM) {
2004 return; 2025 return;
2005 } 2026 }
2006 if (!debug_delegate_) return; 2027 if (!debug_delegate_) return;
2007 SuppressDebug while_processing(this); 2028 SuppressDebug while_processing(this);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 DCHECK(isolate_->needs_side_effect_check()); 2288 DCHECK(isolate_->needs_side_effect_check());
2268 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true; 2289 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true;
2269 side_effect_check_failed_ = true; 2290 side_effect_check_failed_ = true;
2270 // Throw an uncatchable termination exception. 2291 // Throw an uncatchable termination exception.
2271 isolate_->TerminateExecution(); 2292 isolate_->TerminateExecution();
2272 isolate_->OptionalRescheduleException(false); 2293 isolate_->OptionalRescheduleException(false);
2273 return false; 2294 return false;
2274 } 2295 }
2275 2296
2276 void LegacyDebugDelegate::PromiseEventOccurred( 2297 void LegacyDebugDelegate::PromiseEventOccurred(
2277 v8::debug::PromiseDebugActionType type, int id, int parent_id) { 2298 v8::Local<v8::Context> context, v8::debug::PromiseDebugActionType type,
2299 int id, int parent_id, bool breakable) {
2278 Handle<Object> event_data; 2300 Handle<Object> event_data;
2279 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { 2301 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) {
2280 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); 2302 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data));
2281 } 2303 }
2282 } 2304 }
2283 2305
2284 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script, 2306 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script,
2285 bool is_compile_error) { 2307 bool is_compile_error) {
2286 Handle<Object> event_data; 2308 Handle<Object> event_data;
2287 v8::DebugEvent event = is_compile_error ? v8::CompileError : v8::AfterCompile; 2309 v8::DebugEvent event = is_compile_error ? v8::CompileError : v8::AfterCompile;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 isolate_->Throw(*isolate_->factory()->NewEvalError( 2443 isolate_->Throw(*isolate_->factory()->NewEvalError(
2422 MessageTemplate::kNoSideEffectDebugEvaluate)); 2444 MessageTemplate::kNoSideEffectDebugEvaluate));
2423 } 2445 }
2424 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); 2446 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_);
2425 isolate_->debug()->UpdateHookOnFunctionCall(); 2447 isolate_->debug()->UpdateHookOnFunctionCall();
2426 isolate_->debug()->side_effect_check_failed_ = false; 2448 isolate_->debug()->side_effect_check_failed_ = false;
2427 } 2449 }
2428 2450
2429 } // namespace internal 2451 } // namespace internal
2430 } // namespace v8 2452 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | src/inspector/js_protocol.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698