Index: src/debug/debug.cc |
diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
index 35f9a7350f9091c36e45214878eed7a451cf5ec8..b6e17a31b6096a53bed0c601320184ec3edc6efb 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())) { |
dgozman
2017/01/19 21:49:14
Should we make IsSubjectToDebugging() to check for
kozy
2017/01/20 02:32:37
Acknowledged.
Yang
2017/01/20 09:30:48
I think the reason we don't is because we want bla
|
it.Advance(); |
} |
@@ -1037,8 +1039,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,9 +1758,12 @@ 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); |
@@ -1895,6 +1902,33 @@ 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); |
dgozman
2017/01/19 22:34:20
GetPositionInfo
kozy
2017/01/20 02:32:37
Done.
|
+ int column = Script::GetColumnNumber(script, source_position); |
+ return debug::Location(line, column); |
+} |
+} // namespace |
+ |
+bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) { |
+ if (!is_blackboxed_callback_) 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 is_blackboxed_callback_(ToApiHandle<debug::Script>(script), start, end, |
+ is_blackboxed_callback_data_); |
+} |
+ |
void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) { |
if (in_debug_scope() || ignore_events()) return; |
@@ -2277,6 +2311,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()->DebugIsBlackboxed()) |
+ return; |
JSGlobalObject* global = |
JSFunction::cast(fun)->context()->global_object(); |
// Don't stop in debugger functions. |