void Debug::Unload() {
ClearAllBreakPoints();
+ ClearStepping();
// Match unmatched PromiseHandlePrologue calls.
while (thread_local_.promise_on_stack_) PromiseHandleEpilogue();
isolate_);
if (!bindee.is_null() && bindee->IsJSFunction() &&
- !JSFunction::cast(*bindee)->IsBuiltin()) {
+ !JSFunction::cast(*bindee)->IsNative()) {
Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
Debug::FloodWithOneShot(bindee_function);
}
frames_it.Advance();
}
// Skip builtin functions on the stack.
- while (!frames_it.done() && frames_it.frame()->function()->IsBuiltin()) {
+ while (!frames_it.done() && frames_it.frame()->function()->IsNative()) {
frames_it.Advance();
}
// Step out: If there is a JavaScript caller frame, we need to
Handle<JSFunction> js_function(JSFunction::cast(fun));
if (js_function->shared()->bound()) {
Debug::FloodBoundFunctionWithOneShot(js_function);
- } else if (!js_function->IsBuiltin()) {
+ } else if (!js_function->IsNative()) {
// Don't step into builtins.
// It will also compile target function if it's not compiled yet.
FloodWithOneShot(js_function);
if (function->shared()->bound()) {
// Handle Function.prototype.bind
Debug::FloodBoundFunctionWithOneShot(function);
- } else if (!function->IsBuiltin()) {
+ } else if (!function->IsNative()) {
// Don't allow step into functions in the native context.
if (function->shared()->code() ==
isolate->builtins()->builtin(Builtins::kFunctionApply) ||
// function.
if (!holder.is_null() && holder->IsJSFunction()) {
Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder);
- if (!js_function->IsBuiltin()) {
+ if (!js_function->IsNative()) {
Debug::FloodWithOneShot(js_function);
} else if (js_function->shared()->bound()) {
// Handle Function.prototype.bind
if (!shared->allows_lazy_compilation()) continue;
if (!shared->script()->IsScript()) continue;
- if (function->IsBuiltin()) continue;
+ if (function->IsNative()) continue;
if (shared->code()->gc_metadata() == active_code_marker) continue;
if (shared->is_generator()) {
}
+bool JSFunction::IsNative() {
+ Object* script = shared()->script();
+ bool native = script->IsScript() &&
+ Script::cast(script)->type()->value() == Script::TYPE_NATIVE;
+ ASSERT(!IsBuiltin() || native); // All builtins are also native.
+ return native;
+}
+
+
bool JSFunction::NeedsArgumentsAdaption() {
return shared()->formal_parameter_count() !=
SharedFunctionInfo::kDontAdaptArgumentsSentinel;
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug
+
+Debug = debug.Debug
+var exception = null;
+
+function breakListener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ exec_state.prepareStep(Debug.StepAction.StepIn, 1);
+ // Assert that the break happens at an intended location.
+ assertTrue(exec_state.frame(0).sourceLineText().indexOf("// break") > 0);
+ } catch (e) {
+ exception = e;
+ }
+}
+
+Debug.setListener(breakListener);
+
+debugger; // break
+
+function f(x) {
+ return x; // break
+} // break
+
+Debug.setBreakPoint(f, 0, 0); // break
+Debug.scripts(); // break
+debug.MakeMirror(f); // break
+
+new Error("123").stack; // break
+Math.sin(0); // break
+
+f("this should break"); // break
+
+Debug.setListener(null); // break
+
+f("this should not break");
+
+assertNull(exception);