Index: src/debug/debug.cc |
diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
index 2c763915bd451bc9f55f9dbc9d07b805fb4971a8..e950a045f94c4d3584bc7c04437cdd2af3bbd8cf 100644 |
--- a/src/debug/debug.cc |
+++ b/src/debug/debug.cc |
@@ -843,7 +843,8 @@ void Debug::FloodWithOneShot(Handle<JSFunction> function, |
// Debug utility functions are not subject to debugging. |
if (function->native_context() == *debug_context()) return; |
- if (!function->shared()->IsSubjectToDebugging()) { |
+ if (!function->shared()->IsSubjectToDebugging() || |
+ function->shared()->DebugIsBlackboxed()) { |
// Builtin functions are not subject to stepping, but need to be |
// deoptimized, because optimized code does not check for debug |
// step in at call sites. |
@@ -962,7 +963,8 @@ void Debug::PrepareStepOnThrow() { |
// Find the closest Javascript frame we can flood with one-shots. |
while (!it.done() && |
- !it.frame()->function()->shared()->IsSubjectToDebugging()) { |
+ (!it.frame()->function()->shared()->IsSubjectToDebugging() || |
+ it.frame()->function()->shared()->DebugIsBlackboxed())) { |
it.Advance(); |
} |
@@ -1022,6 +1024,10 @@ void Debug::PrepareStep(StepAction step_action) { |
if (location.IsReturn()) step_action = StepOut; |
// A step-next at a tail call is a step-out. |
if (location.IsTailCall() && step_action == StepNext) step_action = StepOut; |
+ // A step-next in blackboxed function is a step-out. |
+ if (step_action == StepNext && shared->DebugIsBlackboxed()) { |
+ step_action = StepOut; |
+ } |
thread_local_.last_statement_position_ = |
summary.abstract_code()->SourceStatementPosition(summary.code_offset()); |
@@ -1037,8 +1043,10 @@ void Debug::PrepareStep(StepAction step_action) { |
// Advance to caller frame. |
frames_it.Advance(); |
// Skip native and extension functions on the stack. |
- while (!frames_it.done() && |
- !frames_it.frame()->function()->shared()->IsSubjectToDebugging()) { |
+ while ( |
+ !frames_it.done() && |
+ (!frames_it.frame()->function()->shared()->IsSubjectToDebugging() || |
+ frames_it.frame()->function()->shared()->DebugIsBlackboxed())) { |
// Builtin functions are not subject to stepping, but need to be |
// deoptimized to include checks for step-in at call sites. |
Deoptimizer::DeoptimizeFunction(frames_it.frame()->function()); |
@@ -1754,15 +1762,18 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
} |
{ |
- // Check whether the break location is muted. |
JavaScriptFrameIterator it(isolate_); |
- if (!it.done() && IsMutedAtCurrentLocation(it.frame())) return; |
+ // Check whether the top frame is blackboxed or the break location is muted. |
+ if (!it.done() && (it.frame()->function()->shared()->DebugIsBlackboxed() || |
+ IsMutedAtCurrentLocation(it.frame()))) { |
+ return; |
+ } |
} |
DebugScope debug_scope(this); |
if (debug_scope.failed()) return; |
- if (debug_event_listener_) { |
+ if (debug_delegate_) { |
HandleScope scope(isolate_); |
// Create the execution state. |
@@ -1770,7 +1781,7 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
// Bail out and don't call debugger if exception. |
if (!MakeExecutionState().ToHandle(&exec_state)) return; |
- debug_event_listener_->ExceptionThrown( |
+ debug_delegate_->ExceptionThrown( |
GetDebugEventContext(isolate_), |
v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)), |
v8::Utils::ToLocal(exception), promise->IsJSObject(), uncaught); |
@@ -1800,7 +1811,7 @@ void Debug::OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue) { |
PrintBreakLocation(); |
#endif // DEBUG |
- if (debug_event_listener_) { |
+ if (debug_delegate_) { |
HandleScope scope(isolate_); |
// Create the execution state. |
@@ -1810,7 +1821,7 @@ void Debug::OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue) { |
bool previous = in_debug_event_listener_; |
in_debug_event_listener_ = true; |
- debug_event_listener_->BreakProgramRequested( |
+ debug_delegate_->BreakProgramRequested( |
GetDebugEventContext(isolate_), |
v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)), |
v8::Utils::ToLocal(break_points_hit)); |
@@ -1895,11 +1906,30 @@ int Debug::NextAsyncTaskId(Handle<JSObject> promise) { |
return async_id->value(); |
} |
+namespace { |
+debug::Location GetDebugLocation(Handle<Script> script, int source_position) { |
+ Script::PositionInfo info; |
+ Script::GetPositionInfo(script, source_position, &info, Script::WITH_OFFSET); |
+ return debug::Location(info.line, info.column); |
+} |
+} // namespace |
+ |
+bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) { |
+ if (!debug_delegate_) return false; |
+ if (!shared->script()->IsScript()) return false; |
+ Handle<Script> script(Script::cast(shared->script())); |
+ if (script->type() != i::Script::TYPE_NORMAL) return false; |
+ debug::Location start = GetDebugLocation(script, shared->start_position()); |
+ debug::Location end = GetDebugLocation(script, shared->end_position()); |
+ return debug_delegate_->IsBlackboxed(ToApiHandle<debug::Script>(script), |
+ start, end); |
+} |
+ |
void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) { |
if (in_debug_scope() || ignore_events()) return; |
- if (debug_event_listener_) { |
- debug_event_listener_->PromiseEventOccurred(type, id); |
+ if (debug_delegate_) { |
+ debug_delegate_->PromiseEventOccurred(type, id); |
if (!non_inspector_listener_exists()) return; |
} |
@@ -1990,9 +2020,9 @@ void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { |
DebugScope debug_scope(this); |
if (debug_scope.failed()) return; |
- if (debug_event_listener_) { |
- debug_event_listener_->ScriptCompiled(ToApiHandle<debug::Script>(script), |
- event != v8::AfterCompile); |
+ if (debug_delegate_) { |
+ debug_delegate_->ScriptCompiled(ToApiHandle<debug::Script>(script), |
+ event != v8::AfterCompile); |
if (!non_inspector_listener_exists()) return; |
} |
@@ -2188,14 +2218,14 @@ void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) { |
} |
} |
-void Debug::SetDebugEventListener(debug::DebugEventListener* listener) { |
- debug_event_listener_ = listener; |
+void Debug::SetDebugDelegate(debug::DebugDelegate* delegate) { |
+ debug_delegate_ = delegate; |
UpdateState(); |
} |
void Debug::UpdateState() { |
bool is_active = message_handler_ != nullptr || !event_listener_.is_null() || |
- debug_event_listener_ != nullptr; |
+ debug_delegate_ != nullptr; |
if (is_active || in_debug_scope()) { |
// Note that the debug context could have already been loaded to |
// bootstrap test cases. |
@@ -2277,6 +2307,11 @@ void Debug::HandleDebugBreak() { |
if (fun && fun->IsJSFunction()) { |
// Don't stop in builtin functions. |
if (!JSFunction::cast(fun)->shared()->IsSubjectToDebugging()) return; |
+ if (isolate_->stack_guard()->CheckDebugBreak() && |
+ JSFunction::cast(fun)->shared()->DebugIsBlackboxed()) { |
+ Deoptimizer::DeoptimizeFunction(JSFunction::cast(fun)); |
+ return; |
+ } |
JSGlobalObject* global = |
JSFunction::cast(fun)->context()->global_object(); |
// Don't stop in debugger functions. |