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