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 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 } | 1722 } |
1723 } // anonymous namespace | 1723 } // anonymous namespace |
1724 | 1724 |
1725 bool Debug::IsExceptionBlackboxed(bool uncaught) { | 1725 bool Debug::IsExceptionBlackboxed(bool uncaught) { |
1726 JavaScriptFrameIterator it(isolate_); | 1726 JavaScriptFrameIterator it(isolate_); |
1727 if (it.done()) return false; | 1727 if (it.done()) return false; |
1728 // Uncaught exception is blackboxed if all current frames are blackboxed, | 1728 // Uncaught exception is blackboxed if all current frames are blackboxed, |
1729 // caught exception if top frame is blackboxed. | 1729 // caught exception if top frame is blackboxed. |
1730 bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame()); | 1730 bool is_top_frame_blackboxed = IsFrameBlackboxed(it.frame()); |
1731 if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed; | 1731 if (!uncaught || !is_top_frame_blackboxed) return is_top_frame_blackboxed; |
1732 it.Advance(); | 1732 return AllFramesOnStackAreBlackboxed(); |
1733 while (!it.done()) { | |
1734 if (!IsFrameBlackboxed(it.frame())) return false; | |
1735 it.Advance(); | |
1736 } | |
1737 return true; | |
1738 } | 1733 } |
1739 | 1734 |
1740 bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { | 1735 bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { |
1741 HandleScope scope(isolate_); | 1736 HandleScope scope(isolate_); |
1742 if (!frame->HasInlinedFrames()) { | 1737 if (!frame->HasInlinedFrames()) { |
1743 Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_); | 1738 Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_); |
1744 return IsBlackboxed(shared); | 1739 return IsBlackboxed(shared); |
1745 } | 1740 } |
1746 List<Handle<SharedFunctionInfo>> infos; | 1741 List<Handle<SharedFunctionInfo>> infos; |
1747 frame->GetFunctions(&infos); | 1742 frame->GetFunctions(&infos); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 is_blackboxed = debug_delegate_->IsFunctionBlackboxed( | 1977 is_blackboxed = debug_delegate_->IsFunctionBlackboxed( |
1983 ToApiHandle<debug::Script>(script), start, end); | 1978 ToApiHandle<debug::Script>(script), start, end); |
1984 } | 1979 } |
1985 } | 1980 } |
1986 shared->set_debug_is_blackboxed(is_blackboxed); | 1981 shared->set_debug_is_blackboxed(is_blackboxed); |
1987 shared->set_computed_debug_is_blackboxed(true); | 1982 shared->set_computed_debug_is_blackboxed(true); |
1988 } | 1983 } |
1989 return shared->debug_is_blackboxed(); | 1984 return shared->debug_is_blackboxed(); |
1990 } | 1985 } |
1991 | 1986 |
| 1987 bool Debug::AllFramesOnStackAreBlackboxed() { |
| 1988 HandleScope scope(isolate_); |
| 1989 for (StackTraceFrameIterator it(isolate_); !it.done(); it.Advance()) { |
| 1990 if (!it.is_javascript()) continue; |
| 1991 if (!IsFrameBlackboxed(it.javascript_frame())) return false; |
| 1992 } |
| 1993 return true; |
| 1994 } |
| 1995 |
1992 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, | 1996 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, |
1993 int parent_id) { | 1997 int parent_id) { |
1994 if (in_debug_scope() || ignore_events()) return; | 1998 if (in_debug_scope() || ignore_events()) return; |
1995 if (!debug_delegate_) return; | 1999 if (!debug_delegate_) return; |
1996 SuppressDebug while_processing(this); | 2000 SuppressDebug while_processing(this); |
1997 DebugScope debug_scope(isolate_->debug()); | 2001 DebugScope debug_scope(isolate_->debug()); |
1998 if (debug_scope.failed()) return; | 2002 if (debug_scope.failed()) return; |
1999 HandleScope scope(isolate_); | 2003 HandleScope scope(isolate_); |
2000 PostponeInterruptsScope no_interrupts(isolate_); | 2004 PostponeInterruptsScope no_interrupts(isolate_); |
2001 DisableBreak no_recursive_break(this); | 2005 DisableBreak no_recursive_break(this); |
2002 debug_delegate_->PromiseEventOccurred(type, id, parent_id); | 2006 bool created_by_user = false; |
| 2007 if (type == debug::kDebugPromiseCreated) { |
| 2008 JavaScriptFrameIterator it(isolate_); |
| 2009 // We need to skip top frame which contains instrumentation. |
| 2010 it.Advance(); |
| 2011 created_by_user = |
| 2012 !it.done() && |
| 2013 it.frame()->function()->shared()->IsSubjectToDebugging() && |
| 2014 !IsFrameBlackboxed(it.frame()); |
| 2015 } |
| 2016 debug_delegate_->PromiseEventOccurred( |
| 2017 Utils::ToLocal(debug_scope.GetContext()), type, id, parent_id, |
| 2018 created_by_user); |
2003 } | 2019 } |
2004 | 2020 |
2005 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { | 2021 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { |
2006 if (ignore_events()) return; | 2022 if (ignore_events()) return; |
2007 if (script->type() != i::Script::TYPE_NORMAL && | 2023 if (script->type() != i::Script::TYPE_NORMAL && |
2008 script->type() != i::Script::TYPE_WASM) { | 2024 script->type() != i::Script::TYPE_WASM) { |
2009 return; | 2025 return; |
2010 } | 2026 } |
2011 if (!debug_delegate_) return; | 2027 if (!debug_delegate_) return; |
2012 SuppressDebug while_processing(this); | 2028 SuppressDebug while_processing(this); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 DCHECK(isolate_->needs_side_effect_check()); | 2288 DCHECK(isolate_->needs_side_effect_check()); |
2273 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true; | 2289 if (DebugEvaluate::CallbackHasNoSideEffect(function)) return true; |
2274 side_effect_check_failed_ = true; | 2290 side_effect_check_failed_ = true; |
2275 // Throw an uncatchable termination exception. | 2291 // Throw an uncatchable termination exception. |
2276 isolate_->TerminateExecution(); | 2292 isolate_->TerminateExecution(); |
2277 isolate_->OptionalRescheduleException(false); | 2293 isolate_->OptionalRescheduleException(false); |
2278 return false; | 2294 return false; |
2279 } | 2295 } |
2280 | 2296 |
2281 void LegacyDebugDelegate::PromiseEventOccurred( | 2297 void LegacyDebugDelegate::PromiseEventOccurred( |
2282 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 created_by_user) { |
2283 Handle<Object> event_data; | 2300 Handle<Object> event_data; |
2284 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { | 2301 if (isolate_->debug()->MakeAsyncTaskEvent(type, id).ToHandle(&event_data)) { |
2285 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); | 2302 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data)); |
2286 } | 2303 } |
2287 } | 2304 } |
2288 | 2305 |
2289 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script, | 2306 void LegacyDebugDelegate::ScriptCompiled(v8::Local<v8::debug::Script> script, |
2290 bool is_compile_error) { | 2307 bool is_compile_error) { |
2291 Handle<Object> event_data; | 2308 Handle<Object> event_data; |
2292 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 Loading... |
2426 isolate_->Throw(*isolate_->factory()->NewEvalError( | 2443 isolate_->Throw(*isolate_->factory()->NewEvalError( |
2427 MessageTemplate::kNoSideEffectDebugEvaluate)); | 2444 MessageTemplate::kNoSideEffectDebugEvaluate)); |
2428 } | 2445 } |
2429 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); | 2446 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); |
2430 isolate_->debug()->UpdateHookOnFunctionCall(); | 2447 isolate_->debug()->UpdateHookOnFunctionCall(); |
2431 isolate_->debug()->side_effect_check_failed_ = false; | 2448 isolate_->debug()->side_effect_check_failed_ = false; |
2432 } | 2449 } |
2433 | 2450 |
2434 } // namespace internal | 2451 } // namespace internal |
2435 } // namespace v8 | 2452 } // namespace v8 |
OLD | NEW |