|
|
@ -1231,6 +1231,11 @@ TEST(GCDuringBreakPointProcessing) { |
|
|
|
SetBreakPoint(foo, 0); |
|
|
|
CallWithBreakPoints(env->Global(), foo, 1, 25); |
|
|
|
|
|
|
|
// Test debug break slot break point with garbage collection.
|
|
|
|
foo = CompileFunction(&env, "function foo(){var a;}", "foo"); |
|
|
|
SetBreakPoint(foo, 0); |
|
|
|
CallWithBreakPoints(env->Global(), foo, 1, 25); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
@ -1660,7 +1665,7 @@ TEST(ConditionalScriptBreakPoint) { |
|
|
|
f->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(1, break_point_hit_count); |
|
|
|
|
|
|
|
ChangeScriptBreakPointConditionFromJS(sbp1, "a % 2 == 0"); |
|
|
|
ChangeScriptBreakPointConditionFromJS(sbp1, "x % 2 == 0"); |
|
|
|
break_point_hit_count = 0; |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
f->Call(env->Global(), 0, NULL); |
|
|
@ -2144,17 +2149,19 @@ TEST(DebugEvaluate) { |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, |
|
|
|
"function foo(x) {" |
|
|
|
" var a;" |
|
|
|
" y=0; /* To ensure break location.*/" |
|
|
|
" y=0;" // To ensure break location 1.
|
|
|
|
" a=x;" |
|
|
|
" y=0;" // To ensure break location 2.
|
|
|
|
"}", |
|
|
|
"foo"); |
|
|
|
const int foo_break_position = 15; |
|
|
|
const int foo_break_position_1 = 15; |
|
|
|
const int foo_break_position_2 = 29; |
|
|
|
|
|
|
|
// Arguments with one parameter "Hello, world!"
|
|
|
|
v8::Handle<v8::Value> argv_foo[1] = { v8::String::New("Hello, world!") }; |
|
|
|
|
|
|
|
// Call foo with breakpoint set before a=x and undefined as parameter.
|
|
|
|
int bp = SetBreakPoint(foo, foo_break_position); |
|
|
|
int bp = SetBreakPoint(foo, foo_break_position_1); |
|
|
|
checks = checks_uu; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
|
|
|
@ -2164,7 +2171,7 @@ TEST(DebugEvaluate) { |
|
|
|
|
|
|
|
// Call foo with breakpoint set after a=x and parameter "Hello, world!".
|
|
|
|
ClearBreakPoint(bp); |
|
|
|
SetBreakPoint(foo, foo_break_position + 1); |
|
|
|
SetBreakPoint(foo, foo_break_position_2); |
|
|
|
checks = checks_hh; |
|
|
|
foo->Call(env->Global(), 1, argv_foo); |
|
|
|
|
|
|
@ -2426,6 +2433,9 @@ TEST(DebugStepKeyedLoadLoop) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping of keyed load. The statement 'y=1'
|
|
|
|
// is there to have more than one breakable statement in the loop, TODO(315).
|
|
|
|
v8::Local<v8::Function> foo = CompileFunction( |
|
|
@ -2451,9 +2461,6 @@ TEST(DebugStepKeyedLoadLoop) { |
|
|
|
v8::Handle<v8::Value> args[kArgc] = { a }; |
|
|
|
foo->Call(env->Global(), kArgc, args); |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Setup break point and step through the function.
|
|
|
|
SetBreakPoint(foo, 3); |
|
|
|
step_action = StepNext; |
|
|
@ -2461,7 +2468,7 @@ TEST(DebugStepKeyedLoadLoop) { |
|
|
|
foo->Call(env->Global(), kArgc, args); |
|
|
|
|
|
|
|
// With stepping all break locations are hit.
|
|
|
|
CHECK_EQ(22, break_point_hit_count); |
|
|
|
CHECK_EQ(33, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -2473,6 +2480,9 @@ TEST(DebugStepKeyedStoreLoop) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping of keyed store. The statement 'y=1'
|
|
|
|
// is there to have more than one breakable statement in the loop, TODO(315).
|
|
|
|
v8::Local<v8::Function> foo = CompileFunction( |
|
|
@ -2497,9 +2507,6 @@ TEST(DebugStepKeyedStoreLoop) { |
|
|
|
v8::Handle<v8::Value> args[kArgc] = { a }; |
|
|
|
foo->Call(env->Global(), kArgc, args); |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Setup break point and step through the function.
|
|
|
|
SetBreakPoint(foo, 3); |
|
|
|
step_action = StepNext; |
|
|
@ -2507,7 +2514,7 @@ TEST(DebugStepKeyedStoreLoop) { |
|
|
|
foo->Call(env->Global(), kArgc, args); |
|
|
|
|
|
|
|
// With stepping all break locations are hit.
|
|
|
|
CHECK_EQ(22, break_point_hit_count); |
|
|
|
CHECK_EQ(32, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -2519,6 +2526,9 @@ TEST(DebugStepNamedLoadLoop) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping of named load.
|
|
|
|
v8::Local<v8::Function> foo = CompileFunction( |
|
|
|
&env, |
|
|
@ -2541,9 +2551,6 @@ TEST(DebugStepNamedLoadLoop) { |
|
|
|
// Call function without any break points to ensure inlining is in place.
|
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Setup break point and step through the function.
|
|
|
|
SetBreakPoint(foo, 4); |
|
|
|
step_action = StepNext; |
|
|
@ -2551,7 +2558,7 @@ TEST(DebugStepNamedLoadLoop) { |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
|
|
|
|
// With stepping all break locations are hit.
|
|
|
|
CHECK_EQ(41, break_point_hit_count); |
|
|
|
CHECK_EQ(53, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -2563,6 +2570,9 @@ TEST(DebugStepLinearMixedICs) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, |
|
|
|
"function bar() {};" |
|
|
@ -2573,15 +2583,12 @@ TEST(DebugStepLinearMixedICs) { |
|
|
|
" a=1;b=2;x=a;y[index]=3;x=y[index];bar();}", "foo"); |
|
|
|
SetBreakPoint(foo, 0); |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
|
|
|
|
// With stepping all break locations are hit.
|
|
|
|
CHECK_EQ(8, break_point_hit_count); |
|
|
|
CHECK_EQ(11, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -2601,6 +2608,66 @@ TEST(DebugStepLinearMixedICs) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepDeclarations) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const char* src = "function foo() { " |
|
|
|
" var a;" |
|
|
|
" var b = 1;" |
|
|
|
" var c = foo;" |
|
|
|
" var d = Math.floor;" |
|
|
|
" var e = b + d(1.2);" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
SetBreakPoint(foo, 0); |
|
|
|
|
|
|
|
// Stepping through the declarations.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(6, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepLocals) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const char* src = "function foo() { " |
|
|
|
" var a,b;" |
|
|
|
" a = 1;" |
|
|
|
" b = a + 2;" |
|
|
|
" b = 1 + 2 + 3;" |
|
|
|
" a = Math.floor(b);" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
SetBreakPoint(foo, 0); |
|
|
|
|
|
|
|
// Stepping through the declarations.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(6, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepIf) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
@ -2627,14 +2694,14 @@ TEST(DebugStepIf) { |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_true[argc] = { v8::True() }; |
|
|
|
foo->Call(env->Global(), argc, argv_true); |
|
|
|
CHECK_EQ(3, break_point_hit_count); |
|
|
|
CHECK_EQ(4, break_point_hit_count); |
|
|
|
|
|
|
|
// Stepping through the false part.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_false[argc] = { v8::False() }; |
|
|
|
foo->Call(env->Global(), argc, argv_false); |
|
|
|
CHECK_EQ(4, break_point_hit_count); |
|
|
|
CHECK_EQ(5, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
@ -2662,6 +2729,7 @@ TEST(DebugStepSwitch) { |
|
|
|
" case 3:" |
|
|
|
" d = 1;" |
|
|
|
" e = 1;" |
|
|
|
" f = 1;" |
|
|
|
" break;" |
|
|
|
" }" |
|
|
|
"}"; |
|
|
@ -2673,21 +2741,97 @@ TEST(DebugStepSwitch) { |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(1) }; |
|
|
|
foo->Call(env->Global(), argc, argv_1); |
|
|
|
CHECK_EQ(4, break_point_hit_count); |
|
|
|
CHECK_EQ(6, break_point_hit_count); |
|
|
|
|
|
|
|
// Another case.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(2) }; |
|
|
|
foo->Call(env->Global(), argc, argv_2); |
|
|
|
CHECK_EQ(3, break_point_hit_count); |
|
|
|
CHECK_EQ(5, break_point_hit_count); |
|
|
|
|
|
|
|
// Last case.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(3) }; |
|
|
|
foo->Call(env->Global(), argc, argv_3); |
|
|
|
CHECK_EQ(4, break_point_hit_count); |
|
|
|
CHECK_EQ(7, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepWhile) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const int argc = 1; |
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a = 0;" |
|
|
|
" while (a < x) {" |
|
|
|
" a++;" |
|
|
|
" }" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
SetBreakPoint(foo, 8); // "var a = 0;"
|
|
|
|
|
|
|
|
// Looping 10 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; |
|
|
|
foo->Call(env->Global(), argc, argv_10); |
|
|
|
CHECK_EQ(23, break_point_hit_count); |
|
|
|
|
|
|
|
// Looping 100 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; |
|
|
|
foo->Call(env->Global(), argc, argv_100); |
|
|
|
CHECK_EQ(203, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepDoWhile) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const int argc = 1; |
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a = 0;" |
|
|
|
" do {" |
|
|
|
" a++;" |
|
|
|
" } while (a < x)" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
SetBreakPoint(foo, 8); // "var a = 0;"
|
|
|
|
|
|
|
|
// Looping 10 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; |
|
|
|
foo->Call(env->Global(), argc, argv_10); |
|
|
|
CHECK_EQ(22, break_point_hit_count); |
|
|
|
|
|
|
|
// Looping 100 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; |
|
|
|
foo->Call(env->Global(), argc, argv_100); |
|
|
|
CHECK_EQ(202, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
@ -2733,6 +2877,210 @@ TEST(DebugStepFor) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepForContinue) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const int argc = 1; |
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a = 0;" |
|
|
|
" var b = 0;" |
|
|
|
" var c = 0;" |
|
|
|
" for (var i = 0; i < x; i++) {" |
|
|
|
" a++;" |
|
|
|
" if (a % 2 == 0) continue;" |
|
|
|
" b++;" |
|
|
|
" c++;" |
|
|
|
" }" |
|
|
|
" return b;" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
v8::Handle<v8::Value> result; |
|
|
|
SetBreakPoint(foo, 8); // "var a = 0;"
|
|
|
|
|
|
|
|
// Each loop generates 4 or 5 steps depending on whether a is equal.
|
|
|
|
|
|
|
|
// Looping 10 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; |
|
|
|
result = foo->Call(env->Global(), argc, argv_10); |
|
|
|
CHECK_EQ(5, result->Int32Value()); |
|
|
|
CHECK_EQ(50, break_point_hit_count); |
|
|
|
|
|
|
|
// Looping 100 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; |
|
|
|
result = foo->Call(env->Global(), argc, argv_100); |
|
|
|
CHECK_EQ(50, result->Int32Value()); |
|
|
|
CHECK_EQ(455, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepForBreak) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const int argc = 1; |
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a = 0;" |
|
|
|
" var b = 0;" |
|
|
|
" var c = 0;" |
|
|
|
" for (var i = 0; i < 1000; i++) {" |
|
|
|
" a++;" |
|
|
|
" if (a == x) break;" |
|
|
|
" b++;" |
|
|
|
" c++;" |
|
|
|
" }" |
|
|
|
" return b;" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
v8::Handle<v8::Value> result; |
|
|
|
SetBreakPoint(foo, 8); // "var a = 0;"
|
|
|
|
|
|
|
|
// Each loop generates 5 steps except for the last (when break is executed)
|
|
|
|
// which only generates 4.
|
|
|
|
|
|
|
|
// Looping 10 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; |
|
|
|
result = foo->Call(env->Global(), argc, argv_10); |
|
|
|
CHECK_EQ(9, result->Int32Value()); |
|
|
|
CHECK_EQ(53, break_point_hit_count); |
|
|
|
|
|
|
|
// Looping 100 times.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; |
|
|
|
result = foo->Call(env->Global(), argc, argv_100); |
|
|
|
CHECK_EQ(99, result->Int32Value()); |
|
|
|
CHECK_EQ(503, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepForIn) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
v8::Local<v8::Function> foo; |
|
|
|
const char* src_1 = "function foo() { " |
|
|
|
" var a = [1, 2];" |
|
|
|
" for (x in a) {" |
|
|
|
" b = 0;" |
|
|
|
" }" |
|
|
|
"}"; |
|
|
|
foo = CompileFunction(&env, src_1, "foo"); |
|
|
|
SetBreakPoint(foo, 0); // "var a = ..."
|
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(6, break_point_hit_count); |
|
|
|
|
|
|
|
const char* src_2 = "function foo() { " |
|
|
|
" var a = {a:[1, 2, 3]};" |
|
|
|
" for (x in a.a) {" |
|
|
|
" b = 0;" |
|
|
|
" }" |
|
|
|
"}"; |
|
|
|
foo = CompileFunction(&env, src_2, "foo"); |
|
|
|
SetBreakPoint(foo, 0); // "var a = ..."
|
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(8, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugStepWith) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a = {};" |
|
|
|
" with (a) {}" |
|
|
|
" with (b) {}" |
|
|
|
"}"; |
|
|
|
env->Global()->Set(v8::String::New("b"), v8::Object::New()); |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
v8::Handle<v8::Value> result; |
|
|
|
SetBreakPoint(foo, 8); // "var a = {};"
|
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(4, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(DebugConditional) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
|
|
|
|
|
// Register a debug event listener which steps and counts.
|
|
|
|
v8::Debug::SetDebugEventListener(DebugEventStep); |
|
|
|
|
|
|
|
// Create a function for testing stepping.
|
|
|
|
const char* src = "function foo(x) { " |
|
|
|
" var a;" |
|
|
|
" a = x ? 1 : 2;" |
|
|
|
" return a;" |
|
|
|
"}"; |
|
|
|
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
|
|
|
SetBreakPoint(foo, 0); // "var a;"
|
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(5, break_point_hit_count); |
|
|
|
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
const int argc = 1; |
|
|
|
v8::Handle<v8::Value> argv_true[argc] = { v8::True() }; |
|
|
|
foo->Call(env->Global(), argc, argv_true); |
|
|
|
CHECK_EQ(5, break_point_hit_count); |
|
|
|
|
|
|
|
// Get rid of the debug event listener.
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(StepInOutSimple) { |
|
|
|
v8::HandleScope scope; |
|
|
|
DebugLocalContext env; |
|
|
@ -2854,7 +3202,7 @@ TEST(StepInOutBranch) { |
|
|
|
// Step through invocation of a.
|
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
expected_step_sequence = "abaca"; |
|
|
|
expected_step_sequence = "abbaca"; |
|
|
|
a->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
@ -2923,7 +3271,7 @@ TEST(DebugStepFunctionApply) { |
|
|
|
foo->Call(env->Global(), 0, NULL); |
|
|
|
|
|
|
|
// With stepping all break locations are hit.
|
|
|
|
CHECK_EQ(6, break_point_hit_count); |
|
|
|
CHECK_EQ(7, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -2967,14 +3315,14 @@ TEST(DebugStepFunctionCall) { |
|
|
|
// 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_EQ(6, 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); |
|
|
|
CHECK_EQ(8, break_point_hit_count); |
|
|
|
|
|
|
|
v8::Debug::SetDebugEventListener(NULL); |
|
|
|
CheckDebuggerUnloaded(); |
|
|
@ -3267,14 +3615,13 @@ TEST(StepWithException) { |
|
|
|
b->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
|
|
|
|
|
// Step through invocation of d + e.
|
|
|
|
v8::Local<v8::Function> d = CompileFunction(&env, src, "d"); |
|
|
|
SetBreakPoint(d, 0); |
|
|
|
ChangeBreakOnException(false, true); |
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
expected_step_sequence = "dded"; |
|
|
|
expected_step_sequence = "ddedd"; |
|
|
|
d->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
@ -3283,7 +3630,7 @@ TEST(StepWithException) { |
|
|
|
ChangeBreakOnException(true, true); |
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
expected_step_sequence = "ddeed"; |
|
|
|
expected_step_sequence = "ddeedd"; |
|
|
|
d->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
@ -3294,7 +3641,7 @@ TEST(StepWithException) { |
|
|
|
ChangeBreakOnException(false, true); |
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
expected_step_sequence = "ffghf"; |
|
|
|
expected_step_sequence = "ffghhff"; |
|
|
|
f->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
@ -3303,7 +3650,7 @@ TEST(StepWithException) { |
|
|
|
ChangeBreakOnException(true, true); |
|
|
|
step_action = StepIn; |
|
|
|
break_point_hit_count = 0; |
|
|
|
expected_step_sequence = "ffghhf"; |
|
|
|
expected_step_sequence = "ffghhhff"; |
|
|
|
f->Call(env->Global(), 0, NULL); |
|
|
|
CHECK_EQ(StrLength(expected_step_sequence), |
|
|
|
break_point_hit_count); |
|
|
|