OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 | 342 |
343 // Prepare to step to next break location. | 343 // Prepare to step to next break location. |
344 static void PrepareStep(StepAction step_action) { | 344 static void PrepareStep(StepAction step_action) { |
345 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 345 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
346 debug->PrepareStep(step_action, 1, StackFrame::NO_ID); | 346 debug->PrepareStep(step_action, 1, StackFrame::NO_ID); |
347 } | 347 } |
348 | 348 |
349 | 349 |
| 350 static void ClearStepping() { CcTest::i_isolate()->debug()->ClearStepping(); } |
| 351 |
| 352 |
350 // This function is in namespace v8::internal to be friend with class | 353 // This function is in namespace v8::internal to be friend with class |
351 // v8::internal::Debug. | 354 // v8::internal::Debug. |
352 namespace v8 { | 355 namespace v8 { |
353 namespace internal { | 356 namespace internal { |
354 | 357 |
355 // Collect the currently debugged functions. | 358 // Collect the currently debugged functions. |
356 Handle<FixedArray> GetDebuggedFunctions() { | 359 Handle<FixedArray> GetDebuggedFunctions() { |
357 Debug* debug = CcTest::i_isolate()->debug(); | 360 Debug* debug = CcTest::i_isolate()->debug(); |
358 | 361 |
359 v8::internal::DebugInfoListNode* node = debug->debug_info_list_; | 362 v8::internal::DebugInfoListNode* node = debug->debug_info_list_; |
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3831 "[Function.call, bar]);" | 3834 "[Function.call, bar]);" |
3832 "}", | 3835 "}", |
3833 "foo"); | 3836 "foo"); |
3834 | 3837 |
3835 // Register a debug event listener which steps and counts. | 3838 // Register a debug event listener which steps and counts. |
3836 v8::Debug::SetDebugEventListener(DebugEventStep); | 3839 v8::Debug::SetDebugEventListener(DebugEventStep); |
3837 step_action = StepIn; | 3840 step_action = StepIn; |
3838 | 3841 |
3839 break_point_hit_count = 0; | 3842 break_point_hit_count = 0; |
3840 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3843 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
3841 CHECK_EQ(5, break_point_hit_count); | 3844 CHECK_EQ(6, break_point_hit_count); |
3842 | 3845 |
3843 v8::Debug::SetDebugEventListener(NULL); | 3846 v8::Debug::SetDebugEventListener(NULL); |
3844 CheckDebuggerUnloaded(); | 3847 CheckDebuggerUnloaded(); |
3845 | 3848 |
3846 // Register a debug event listener which just counts. | 3849 // Register a debug event listener which just counts. |
3847 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); | 3850 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); |
3848 | 3851 |
3849 break_point_hit_count = 0; | 3852 break_point_hit_count = 0; |
3850 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3853 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
3851 | 3854 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4204 const char* src = "function a() { n(); }; " | 4207 const char* src = "function a() { n(); }; " |
4205 "function b() { c(); }; " | 4208 "function b() { c(); }; " |
4206 "function c() { n(); }; " | 4209 "function c() { n(); }; " |
4207 "function d() { x = 1; try { e(); } catch(x) { x = 2; } }; " | 4210 "function d() { x = 1; try { e(); } catch(x) { x = 2; } }; " |
4208 "function e() { n(); }; " | 4211 "function e() { n(); }; " |
4209 "function f() { x = 1; try { g(); } catch(x) { x = 2; } }; " | 4212 "function f() { x = 1; try { g(); } catch(x) { x = 2; } }; " |
4210 "function g() { h(); }; " | 4213 "function g() { h(); }; " |
4211 "function h() { x = 1; throw 1; }; "; | 4214 "function h() { x = 1; throw 1; }; "; |
4212 | 4215 |
4213 // Step through invocation of a. | 4216 // Step through invocation of a. |
| 4217 ClearStepping(); |
4214 v8::Local<v8::Function> a = CompileFunction(&env, src, "a"); | 4218 v8::Local<v8::Function> a = CompileFunction(&env, src, "a"); |
4215 SetBreakPoint(a, 0); | 4219 SetBreakPoint(a, 0); |
4216 step_action = StepIn; | 4220 step_action = StepIn; |
4217 break_point_hit_count = 0; | 4221 break_point_hit_count = 0; |
4218 expected_step_sequence = "aa"; | 4222 expected_step_sequence = "aa"; |
4219 CHECK(a->Call(context, env->Global(), 0, NULL).IsEmpty()); | 4223 CHECK(a->Call(context, env->Global(), 0, NULL).IsEmpty()); |
4220 CHECK_EQ(StrLength(expected_step_sequence), | 4224 CHECK_EQ(StrLength(expected_step_sequence), |
4221 break_point_hit_count); | 4225 break_point_hit_count); |
4222 | 4226 |
4223 // Step through invocation of b + c. | 4227 // Step through invocation of b + c. |
| 4228 ClearStepping(); |
4224 v8::Local<v8::Function> b = CompileFunction(&env, src, "b"); | 4229 v8::Local<v8::Function> b = CompileFunction(&env, src, "b"); |
4225 SetBreakPoint(b, 0); | 4230 SetBreakPoint(b, 0); |
4226 step_action = StepIn; | 4231 step_action = StepIn; |
4227 break_point_hit_count = 0; | 4232 break_point_hit_count = 0; |
4228 expected_step_sequence = "bcc"; | 4233 expected_step_sequence = "bcc"; |
4229 CHECK(b->Call(context, env->Global(), 0, NULL).IsEmpty()); | 4234 CHECK(b->Call(context, env->Global(), 0, NULL).IsEmpty()); |
4230 CHECK_EQ(StrLength(expected_step_sequence), | 4235 CHECK_EQ(StrLength(expected_step_sequence), |
4231 break_point_hit_count); | 4236 break_point_hit_count); |
| 4237 |
4232 // Step through invocation of d + e. | 4238 // Step through invocation of d + e. |
| 4239 ClearStepping(); |
4233 v8::Local<v8::Function> d = CompileFunction(&env, src, "d"); | 4240 v8::Local<v8::Function> d = CompileFunction(&env, src, "d"); |
4234 SetBreakPoint(d, 0); | 4241 SetBreakPoint(d, 0); |
4235 ChangeBreakOnException(false, true); | 4242 ChangeBreakOnException(false, true); |
4236 step_action = StepIn; | 4243 step_action = StepIn; |
4237 break_point_hit_count = 0; | 4244 break_point_hit_count = 0; |
4238 expected_step_sequence = "ddedd"; | 4245 expected_step_sequence = "ddedd"; |
4239 d->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 4246 d->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
4240 CHECK_EQ(StrLength(expected_step_sequence), | 4247 CHECK_EQ(StrLength(expected_step_sequence), |
4241 break_point_hit_count); | 4248 break_point_hit_count); |
4242 | 4249 |
4243 // Step through invocation of d + e now with break on caught exceptions. | 4250 // Step through invocation of d + e now with break on caught exceptions. |
4244 ChangeBreakOnException(true, true); | 4251 ChangeBreakOnException(true, true); |
4245 step_action = StepIn; | 4252 step_action = StepIn; |
4246 break_point_hit_count = 0; | 4253 break_point_hit_count = 0; |
4247 expected_step_sequence = "ddeedd"; | 4254 expected_step_sequence = "ddeedd"; |
4248 d->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 4255 d->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
4249 CHECK_EQ(StrLength(expected_step_sequence), | 4256 CHECK_EQ(StrLength(expected_step_sequence), |
4250 break_point_hit_count); | 4257 break_point_hit_count); |
4251 | 4258 |
4252 // Step through invocation of f + g + h. | 4259 // Step through invocation of f + g + h. |
| 4260 ClearStepping(); |
4253 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); | 4261 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); |
4254 SetBreakPoint(f, 0); | 4262 SetBreakPoint(f, 0); |
4255 ChangeBreakOnException(false, true); | 4263 ChangeBreakOnException(false, true); |
4256 step_action = StepIn; | 4264 step_action = StepIn; |
4257 break_point_hit_count = 0; | 4265 break_point_hit_count = 0; |
4258 expected_step_sequence = "ffghhff"; | 4266 expected_step_sequence = "ffghhff"; |
4259 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 4267 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
4260 CHECK_EQ(StrLength(expected_step_sequence), | 4268 CHECK_EQ(StrLength(expected_step_sequence), |
4261 break_point_hit_count); | 4269 break_point_hit_count); |
4262 | 4270 |
(...skipping 3759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8022 CompileRun("function foo() {}; foo();"); | 8030 CompileRun("function foo() {}; foo();"); |
8023 --after_compile_handler_depth; | 8031 --after_compile_handler_depth; |
8024 } | 8032 } |
8025 | 8033 |
8026 | 8034 |
8027 TEST(NoInterruptsInDebugListener) { | 8035 TEST(NoInterruptsInDebugListener) { |
8028 DebugLocalContext env; | 8036 DebugLocalContext env; |
8029 v8::Debug::SetDebugEventListener(NoInterruptsOnDebugEvent); | 8037 v8::Debug::SetDebugEventListener(NoInterruptsOnDebugEvent); |
8030 CompileRun("void(0);"); | 8038 CompileRun("void(0);"); |
8031 } | 8039 } |
OLD | NEW |