Chromium Code Reviews| Index: src/debug/debug.cc |
| diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
| index 61e0e0792ef3d538a83cc76c5a0b87738ae44339..25780fdc252ec5a507eb811e2f67a1eb0342b3d4 100644 |
| --- a/src/debug/debug.cc |
| +++ b/src/debug/debug.cc |
| @@ -863,6 +863,7 @@ void Debug::FloodWithOneShot(Handle<JSFunction> function, |
| // Return if we failed to retrieve the debug info. |
| return; |
| } |
| + if (shared->debug_is_blackboxed()) return; |
|
Yang
2017/01/19 13:55:35
Do we need to ensure debug info if it's blackboxed
kozy
2017/01/19 16:08:38
Done.
|
| // Flood the function with break points. |
| Handle<DebugInfo> debug_info(shared->GetDebugInfo()); |
| @@ -969,7 +970,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()->debug_is_blackboxed())) { |
| it.Advance(); |
| } |
| @@ -1043,8 +1045,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()->debug_is_blackboxed())) { |
| // 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()); |
| @@ -1756,8 +1760,11 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
| } |
| { |
| - // Check whether the break location is muted. |
| JavaScriptFrameIterator it(isolate_); |
| + // Check whether the top frame is blackboxed. |
| + if (!it.done() && it.frame()->function()->shared()->debug_is_blackboxed()) |
|
Yang
2017/01/19 13:55:35
please add {} around if-statement body if we have
kozy
2017/01/19 16:08:38
Done.
|
| + return; |
| + // Check whether the break location is muted. |
| if (!it.done() && IsMutedAtCurrentLocation(it.frame())) return; |
|
Yang
2017/01/19 13:55:35
can we merge these two redundant checks?
kozy
2017/01/19 16:08:38
Done.
|
| } |
| @@ -1897,6 +1904,35 @@ int Debug::NextAsyncTaskId(Handle<JSObject> promise) { |
| return async_id->value(); |
| } |
| +void Debug::SetIsBlackboxedCallback(debug::IsBlackboxedCallback callback, |
| + void* data) { |
| + is_blackboxed_callback_ = callback; |
| + is_blackboxed_callback_data_ = data; |
| +} |
| + |
| +namespace { |
| +debug::Location GetDebugLocation(Handle<Script> script, int source_position) { |
| + Script::InitLineEnds(script); |
| + int line = Script::GetLineNumber(script, source_position); |
| + int column = Script::GetColumnNumber(script, source_position); |
| + return debug::Location(line, column); |
| +} |
| +} // namespace |
| + |
| +void Debug::OnNewSharedFunctionInfo(Handle<SharedFunctionInfo> shared) { |
| + if (!is_blackboxed_callback_) return; |
| + Handle<Script> script(Script::cast(shared->script())); |
| + if (script->type() != i::Script::TYPE_NORMAL) return; |
| + |
| + debug::Location start = GetDebugLocation(script, shared->start_position()); |
| + debug::Location end = GetDebugLocation(script, shared->end_position()); |
| + |
| + bool is_blackboxed = |
| + is_blackboxed_callback_(ToApiHandle<debug::Script>(script), start, end, |
| + is_blackboxed_callback_data_); |
| + shared->set_debug_is_blackboxed(is_blackboxed); |
| +} |
| + |
| void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) { |
| if (in_debug_scope() || ignore_events()) return; |
| @@ -2279,6 +2315,9 @@ 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()->debug_is_blackboxed()) |
| + return; |
| JSGlobalObject* global = |
| JSFunction::cast(fun)->context()->global_object(); |
| // Don't stop in debugger functions. |