OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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::HasNonBlackboxedFrameOnStack() { | |
1983 HandleScope scope(isolate_); | |
1984 for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) { | |
1985 if (!it.is_javascript()) continue; | |
1986 if (!IsFrameBlackboxed(it.javascript_frame())) return true; | |
1987 } | |
1988 return false; | |
1989 } | |
1990 | |
1987 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, | 1991 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, |
1988 int parent_id) { | 1992 int parent_id) { |
1989 if (in_debug_scope() || ignore_events()) return; | 1993 if (in_debug_scope() || ignore_events()) return; |
1990 if (!debug_delegate_) return; | 1994 if (!debug_delegate_) return; |
1991 SuppressDebug while_processing(this); | 1995 SuppressDebug while_processing(this); |
1992 DebugScope debug_scope(isolate_->debug()); | 1996 DebugScope debug_scope(isolate_->debug()); |
1993 if (debug_scope.failed()) return; | 1997 if (debug_scope.failed()) return; |
1994 HandleScope scope(isolate_); | 1998 HandleScope scope(isolate_); |
1995 PostponeInterruptsScope no_interrupts(isolate_); | 1999 PostponeInterruptsScope no_interrupts(isolate_); |
1996 DisableBreak no_recursive_break(this); | 2000 DisableBreak no_recursive_break(this); |
1997 debug_delegate_->PromiseEventOccurred(type, id, parent_id); | 2001 bool created_by_user = false; |
2002 if (type == debug::kDebugPromiseCreated) { | |
2003 JavaScriptFrameIterator it(isolate_); | |
2004 // We need to skip top frame which contains instrumentation. | |
dgozman
2017/03/03 19:47:06
Looks a bit sketchy, as it heavily relies on the i
kozy
2017/03/03 20:17:02
We skip not a Promise.all or Promise.race here, we
| |
2005 it.Advance(); | |
2006 created_by_user = | |
2007 !it.done() && | |
2008 it.frame()->function()->shared()->IsSubjectToDebugging() && | |
2009 !IsFrameBlackboxed(it.frame()); | |
2010 } | |
2011 debug_delegate_->PromiseEventOccurred( | |
2012 Utils::ToLocal(debug_scope.GetContext()), type, id, parent_id, | |
2013 created_by_user); | |
1998 } | 2014 } |
1999 | 2015 |
2000 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { | 2016 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { |
2001 if (ignore_events()) return; | 2017 if (ignore_events()) return; |
2002 if (script->type() != i::Script::TYPE_NORMAL && | 2018 if (script->type() != i::Script::TYPE_NORMAL && |
2003 script->type() != i::Script::TYPE_WASM) { | 2019 script->type() != i::Script::TYPE_WASM) { |
2004 return; | 2020 return; |
2005 } | 2021 } |
2006 if (!debug_delegate_) return; | 2022 if (!debug_delegate_) return; |
2007 SuppressDebug while_processing(this); | 2023 SuppressDebug while_processing(this); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2267 DCHECK(isolate_->needs_side_effect_check()); | 2283 DCHECK(isolate_->needs_side_effect_check()); |
2268 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true; | 2284 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true; |
2269 side_effect_check_failed_ = true; | 2285 side_effect_check_failed_ = true; |
2270 // Throw an uncatchable termination exception. | 2286 // Throw an uncatchable termination exception. |
2271 isolate_->TerminateExecution(); | 2287 isolate_->TerminateExecution(); |
2272 isolate_->OptionalRescheduleException(false); | 2288 isolate_->OptionalRescheduleException(false); |
2273 return false; | 2289 return false; |
2274 } | 2290 } |
2275 | 2291 |
2276 void LegacyDebugDelegate::PromiseEventOccurred( | 2292 void LegacyDebugDelegate::PromiseEventOccurred( |
2277 v8::debug::PromiseDebugActionType type, int id, int parent_id) { | 2293 v8::Local<v8::Context> context, v8::debug::PromiseDebugActionType type, |
2294 int id, int parent_id, bool created_by_user) { | |
2278 Handle<Object> event_data; | 2295 Handle<Object> event_data; |
2279 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { | 2296 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { |
2280 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); | 2297 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); |
2281 } | 2298 } |
2282 } | 2299 } |
2283 | 2300 |
2284 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script, | 2301 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script, |
2285 bool is_compile_error) { | 2302 bool is_compile_error) { |
2286 Handle<Object> event_data; | 2303 Handle<Object> event_data; |
2287 v8::DebugEvent event = is_compile_error ? v8::CompileError : v8::AfterCompile; | 2304 v8::DebugEvent event = is_compile_error ? v8::CompileError : v8::AfterCompile; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2421 isolate_->Throw(*isolate_->factory()->NewEvalError( | 2438 isolate_->Throw(*isolate_->factory()->NewEvalError( |
2422 MessageTemplate::kNoSideEffectDebugEvaluate)); | 2439 MessageTemplate::kNoSideEffectDebugEvaluate)); |
2423 } | 2440 } |
2424 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); | 2441 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); |
2425 isolate_->debug()->UpdateHookOnFunctionCall(); | 2442 isolate_->debug()->UpdateHookOnFunctionCall(); |
2426 isolate_->debug()->side_effect_check_failed_ = false; | 2443 isolate_->debug()->side_effect_check_failed_ = false; |
2427 } | 2444 } |
2428 | 2445 |
2429 } // namespace internal | 2446 } // namespace internal |
2430 } // namespace v8 | 2447 } // namespace v8 |
OLD | NEW |