Fixed step in handling for function.call.

For function.call debug step in did not work as execution did not break in the function called. This has now been fixed using the same means as for function.apply in CL http://codereview.chromium.org/63055.
Review URL: http://codereview.chromium.org/63058

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1684 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sgjesse@chromium.org 2009-04-07 12:11:43 +00:00
parent a74fcf458c
commit 835b89b727
2 changed files with 63 additions and 9 deletions

View File

@ -1161,15 +1161,18 @@ void Debug::HandleStepIn(Handle<JSFunction> function,
// Don't allow step into functions in the native context.
if (function->context()->global() != Top::context()->builtins()) {
if (function->shared()->code() ==
Builtins::builtin(Builtins::FunctionApply)) {
// Handle function.apply separately to flood the function to be called
// and not the code for Builtins::FunctionApply. At the point of the
// call IC to call Builtins::FunctionApply the expression stack has the
// following content:
// symbol "apply"
// function apply was called on
// receiver for apply (first parameter to apply)
// arguments array for apply (second parameter to apply)
Builtins::builtin(Builtins::FunctionApply) ||
function->shared()->code() ==
Builtins::builtin(Builtins::FunctionCall)) {
// Handle function.apply and function.call separately to flood the
// function to be called and not the code for Builtins::FunctionApply or
// Builtins::FunctionCall. At the point of the call IC to call either
// Builtins::FunctionApply or Builtins::FunctionCall the expression
// stack has the following content:
// symbol "apply" or "call"
// function apply or call was called on
// receiver for apply or call (first parameter to apply or call)
// ... further arguments to apply or call.
JavaScriptFrameIterator it;
ASSERT(it.frame()->fp() == fp);
ASSERT(it.frame()->GetExpression(1)->IsJSFunction());

View File

@ -2445,6 +2445,57 @@ TEST(DebugStepFunctionApply) {
}
// Test that step in works with function.call.
TEST(DebugStepFunctionCall) {
v8::HandleScope scope;
DebugLocalContext env;
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(
&env,
"function bar(x, y, z) { if (x == 1) { a = y; b = z; } }"
"function foo(a){ debugger;"
" if (a) {"
" bar.call(this, 1, 2, 3);"
" } else {"
" bar.call(this, 0);"
" }"
"}",
"foo");
// Register a debug event listener which steps and counts.
v8::Debug::SetDebugEventListener(DebugEventStep);
step_action = StepIn;
// Check stepping where the if condition in bar is false.
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
CHECK_EQ(4, break_point_hit_count);
// Check stepping where the if condition in bar is true.
break_point_hit_count = 0;
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { v8::True() };
foo->Call(env->Global(), argc, argv);
CHECK_EQ(6, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
// Register a debug event listener which just counts.
v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
// Without stepping only the debugger statement is hit.
CHECK_EQ(1, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
// Test break on exceptions. For each exception break combination the number
// of debug event exception callbacks and message callbacks are collected. The
// number of debug event exception callbacks are used to check that the