OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 foo->Call(env->Global(), kArgc, args); | 2230 foo->Call(env->Global(), kArgc, args); |
2231 | 2231 |
2232 // With stepping all break locations are hit. | 2232 // With stepping all break locations are hit. |
2233 CHECK_EQ(22, break_point_hit_count); | 2233 CHECK_EQ(22, break_point_hit_count); |
2234 | 2234 |
2235 v8::Debug::SetDebugEventListener(NULL); | 2235 v8::Debug::SetDebugEventListener(NULL); |
2236 CheckDebuggerUnloaded(); | 2236 CheckDebuggerUnloaded(); |
2237 } | 2237 } |
2238 | 2238 |
2239 | 2239 |
| 2240 // Test of the stepping mechanism for keyed store in a loop. |
| 2241 TEST(DebugStepKeyedStoreLoop) { |
| 2242 v8::HandleScope scope; |
| 2243 DebugLocalContext env; |
| 2244 |
| 2245 // Create a function for testing stepping of keyed store. The statement 'y=1' |
| 2246 // is there to have more than one breakable statement in the loop, TODO(315). |
| 2247 v8::Local<v8::Function> foo = CompileFunction( |
| 2248 &env, |
| 2249 "function foo(a) {\n" |
| 2250 " var len = a.length;\n" |
| 2251 " for (var i = 0; i < len; i++) {\n" |
| 2252 " y = 1;\n" |
| 2253 " a[i] = 42;\n" |
| 2254 " }\n" |
| 2255 "}\n", |
| 2256 "foo"); |
| 2257 |
| 2258 // Create array [0,1,2,3,4,5,6,7,8,9] |
| 2259 v8::Local<v8::Array> a = v8::Array::New(10); |
| 2260 for (int i = 0; i < 10; i++) { |
| 2261 a->Set(v8::Number::New(i), v8::Number::New(i)); |
| 2262 } |
| 2263 |
| 2264 // Call function without any break points to ensure inlining is in place. |
| 2265 const int kArgc = 1; |
| 2266 v8::Handle<v8::Value> args[kArgc] = { a }; |
| 2267 foo->Call(env->Global(), kArgc, args); |
| 2268 |
| 2269 // Register a debug event listener which steps and counts. |
| 2270 v8::Debug::SetDebugEventListener(DebugEventStep); |
| 2271 |
| 2272 // Setup break point and step through the function. |
| 2273 SetBreakPoint(foo, 3); |
| 2274 step_action = StepNext; |
| 2275 break_point_hit_count = 0; |
| 2276 foo->Call(env->Global(), kArgc, args); |
| 2277 |
| 2278 // With stepping all break locations are hit. |
| 2279 CHECK_EQ(22, break_point_hit_count); |
| 2280 |
| 2281 v8::Debug::SetDebugEventListener(NULL); |
| 2282 CheckDebuggerUnloaded(); |
| 2283 } |
| 2284 |
| 2285 |
2240 // Test the stepping mechanism with different ICs. | 2286 // Test the stepping mechanism with different ICs. |
2241 TEST(DebugStepLinearMixedICs) { | 2287 TEST(DebugStepLinearMixedICs) { |
2242 v8::HandleScope scope; | 2288 v8::HandleScope scope; |
2243 DebugLocalContext env; | 2289 DebugLocalContext env; |
2244 | 2290 |
2245 // Create a function for testing stepping. | 2291 // Create a function for testing stepping. |
2246 v8::Local<v8::Function> foo = CompileFunction(&env, | 2292 v8::Local<v8::Function> foo = CompileFunction(&env, |
2247 "function bar() {};" | 2293 "function bar() {};" |
2248 "function foo() {" | 2294 "function foo() {" |
2249 " var x;" | 2295 " var x;" |
(...skipping 2928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5178 v8::Local<v8::Function> f = | 5224 v8::Local<v8::Function> f = |
5179 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 5225 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
5180 f->Call(env->Global(), 0, NULL); | 5226 f->Call(env->Global(), 0, NULL); |
5181 | 5227 |
5182 // Setting message handler to NULL should cause debugger unload. | 5228 // Setting message handler to NULL should cause debugger unload. |
5183 v8::Debug::SetMessageHandler2(NULL); | 5229 v8::Debug::SetMessageHandler2(NULL); |
5184 CheckDebuggerUnloaded(); | 5230 CheckDebuggerUnloaded(); |
5185 | 5231 |
5186 CHECK_EQ(1, exception_event_count); | 5232 CHECK_EQ(1, exception_event_count); |
5187 } | 5233 } |
OLD | NEW |