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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 // Create function and set the break point. | 503 // Create function and set the break point. |
504 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( | 504 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( |
505 *CompileFunction(env, source, name)); | 505 *CompileFunction(env, source, name)); |
506 int bp = SetBreakPoint(fun, position); | 506 int bp = SetBreakPoint(fun, position); |
507 | 507 |
508 // Check that the debug break function is as expected. | 508 // Check that the debug break function is as expected. |
509 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); | 509 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); |
510 CHECK(Debug::HasDebugInfo(shared)); | 510 CHECK(Debug::HasDebugInfo(shared)); |
511 TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); | 511 TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); |
512 it1.FindBreakLocationFromPosition(position); | 512 it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); |
513 v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode(); | 513 v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode(); |
514 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { | 514 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { |
515 actual_mode = v8::internal::RelocInfo::CODE_TARGET; | 515 actual_mode = v8::internal::RelocInfo::CODE_TARGET; |
516 } | 516 } |
517 CHECK_EQ(mode, actual_mode); | 517 CHECK_EQ(mode, actual_mode); |
518 if (mode != v8::internal::RelocInfo::JS_RETURN) { | 518 if (mode != v8::internal::RelocInfo::JS_RETURN) { |
519 CHECK_EQ(debug_break, | 519 CHECK_EQ(debug_break, |
520 Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address())); | 520 Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address())); |
521 } else { | 521 } else { |
522 CHECK(Debug::IsDebugBreakAtReturn(it1.it()->rinfo())); | 522 CHECK(Debug::IsDebugBreakAtReturn(it1.it()->rinfo())); |
523 } | 523 } |
524 | 524 |
525 // Clear the break point and check that the debug break function is no longer | 525 // Clear the break point and check that the debug break function is no longer |
526 // there | 526 // there |
527 ClearBreakPoint(bp); | 527 ClearBreakPoint(bp); |
528 CHECK(!debug->HasDebugInfo(shared)); | 528 CHECK(!debug->HasDebugInfo(shared)); |
529 CHECK(debug->EnsureDebugInfo(shared, fun)); | 529 CHECK(debug->EnsureDebugInfo(shared, fun)); |
530 TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); | 530 TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); |
531 it2.FindBreakLocationFromPosition(position); | 531 it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); |
532 actual_mode = it2.it()->rinfo()->rmode(); | 532 actual_mode = it2.it()->rinfo()->rmode(); |
533 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { | 533 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { |
534 actual_mode = v8::internal::RelocInfo::CODE_TARGET; | 534 actual_mode = v8::internal::RelocInfo::CODE_TARGET; |
535 } | 535 } |
536 CHECK_EQ(mode, actual_mode); | 536 CHECK_EQ(mode, actual_mode); |
537 if (mode == v8::internal::RelocInfo::JS_RETURN) { | 537 if (mode == v8::internal::RelocInfo::JS_RETURN) { |
538 CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo())); | 538 CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo())); |
539 } | 539 } |
540 } | 540 } |
541 | 541 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 // For this debug event handler to work the following two global varaibles | 813 // For this debug event handler to work the following two global varaibles |
814 // must be initialized. | 814 // must be initialized. |
815 // checks: An array of expressions and expected results | 815 // checks: An array of expressions and expected results |
816 // evaluate_check_function: A JavaScript function (see below) | 816 // evaluate_check_function: A JavaScript function (see below) |
817 | 817 |
818 // Structure for holding checks to do. | 818 // Structure for holding checks to do. |
819 struct EvaluateCheck { | 819 struct EvaluateCheck { |
820 const char* expr; // An expression to evaluate when a break point is hit. | 820 const char* expr; // An expression to evaluate when a break point is hit. |
821 v8::Handle<v8::Value> expected; // The expected result. | 821 v8::Handle<v8::Value> expected; // The expected result. |
822 }; | 822 }; |
| 823 |
| 824 |
823 // Array of checks to do. | 825 // Array of checks to do. |
824 struct EvaluateCheck* checks = NULL; | 826 struct EvaluateCheck* checks = NULL; |
825 // Source for The JavaScript function which can do the evaluation when a break | 827 // Source for The JavaScript function which can do the evaluation when a break |
826 // point is hit. | 828 // point is hit. |
827 const char* evaluate_check_source = | 829 const char* evaluate_check_source = |
828 "function evaluate_check(exec_state, expr, expected) {" | 830 "function evaluate_check(exec_state, expr, expected) {" |
829 " return exec_state.frame(0).evaluate(expr).value() === expected;" | 831 " return exec_state.frame(0).evaluate(expr).value() === expected;" |
830 "}"; | 832 "}"; |
831 v8::Local<v8::Function> evaluate_check_function; | 833 v8::Local<v8::Function> evaluate_check_function; |
832 | 834 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 v8::Local<v8::Function> f, | 1388 v8::Local<v8::Function> f, |
1387 int break_point_count, | 1389 int break_point_count, |
1388 int call_count) { | 1390 int call_count) { |
1389 break_point_hit_count = 0; | 1391 break_point_hit_count = 0; |
1390 for (int i = 0; i < call_count; i++) { | 1392 for (int i = 0; i < call_count; i++) { |
1391 f->Call(recv, 0, NULL); | 1393 f->Call(recv, 0, NULL); |
1392 CHECK_EQ((i + 1) * break_point_count, break_point_hit_count); | 1394 CHECK_EQ((i + 1) * break_point_count, break_point_hit_count); |
1393 } | 1395 } |
1394 } | 1396 } |
1395 | 1397 |
| 1398 |
1396 // Test GC during break point processing. | 1399 // Test GC during break point processing. |
1397 TEST(GCDuringBreakPointProcessing) { | 1400 TEST(GCDuringBreakPointProcessing) { |
1398 break_point_hit_count = 0; | 1401 break_point_hit_count = 0; |
1399 DebugLocalContext env; | 1402 DebugLocalContext env; |
1400 v8::HandleScope scope(env->GetIsolate()); | 1403 v8::HandleScope scope(env->GetIsolate()); |
1401 | 1404 |
1402 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage, | 1405 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage, |
1403 v8::Undefined()); | 1406 v8::Undefined()); |
1404 v8::Local<v8::Function> foo; | 1407 v8::Local<v8::Function> foo; |
1405 | 1408 |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 v8::Debug::SetDebugEventListener(NULL); | 2522 v8::Debug::SetDebugEventListener(NULL); |
2520 CheckDebuggerUnloaded(); | 2523 CheckDebuggerUnloaded(); |
2521 } | 2524 } |
2522 | 2525 |
2523 | 2526 |
2524 int debugEventCount = 0; | 2527 int debugEventCount = 0; |
2525 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { | 2528 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { |
2526 if (eventDetails.GetEvent() == v8::Break) ++debugEventCount; | 2529 if (eventDetails.GetEvent() == v8::Break) ++debugEventCount; |
2527 } | 2530 } |
2528 | 2531 |
| 2532 |
2529 // Test that the conditional breakpoints work event if code generation from | 2533 // Test that the conditional breakpoints work event if code generation from |
2530 // strings is prohibited in the debugee context. | 2534 // strings is prohibited in the debugee context. |
2531 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) { | 2535 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) { |
2532 DebugLocalContext env; | 2536 DebugLocalContext env; |
2533 v8::HandleScope scope(env->GetIsolate()); | 2537 v8::HandleScope scope(env->GetIsolate()); |
2534 env.ExposeDebug(); | 2538 env.ExposeDebug(); |
2535 | 2539 |
2536 v8::Debug::SetDebugEventListener2(CheckDebugEvent); | 2540 v8::Debug::SetDebugEventListener2(CheckDebugEvent); |
2537 | 2541 |
2538 v8::Local<v8::Function> foo = CompileFunction(&env, | 2542 v8::Local<v8::Function> foo = CompileFunction(&env, |
(...skipping 25 matching lines...) Expand all Loading... |
2564 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 2568 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
2565 | 2569 |
2566 v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() }; | 2570 v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() }; |
2567 CHECK(checkGlobalEvalFunction->Call( | 2571 CHECK(checkGlobalEvalFunction->Call( |
2568 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); | 2572 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); |
2569 CHECK(checkFrameEvalFunction->Call( | 2573 CHECK(checkFrameEvalFunction->Call( |
2570 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); | 2574 eventDetails.GetEventContext()->Global(), 1, args)->IsTrue()); |
2571 } | 2575 } |
2572 } | 2576 } |
2573 | 2577 |
| 2578 |
2574 // Test that the evaluation of expressions when a break point is hit generates | 2579 // Test that the evaluation of expressions when a break point is hit generates |
2575 // the correct results in case code generation from strings is disallowed in the | 2580 // the correct results in case code generation from strings is disallowed in the |
2576 // debugee context. | 2581 // debugee context. |
2577 TEST(DebugEvaluateWithCodeGenerationDisallowed) { | 2582 TEST(DebugEvaluateWithCodeGenerationDisallowed) { |
2578 DebugLocalContext env; | 2583 DebugLocalContext env; |
2579 v8::HandleScope scope(env->GetIsolate()); | 2584 v8::HandleScope scope(env->GetIsolate()); |
2580 env.ExposeDebug(); | 2585 env.ExposeDebug(); |
2581 | 2586 |
2582 v8::Debug::SetDebugEventListener2(CheckDebugEval); | 2587 v8::Debug::SetDebugEventListener2(CheckDebugEval); |
2583 | 2588 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2618 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { | 2623 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { |
2619 int i; | 2624 int i; |
2620 for (i = 0; input_buffer[i] != '\0'; ++i) { | 2625 for (i = 0; input_buffer[i] != '\0'; ++i) { |
2621 // ASCII does not use chars > 127, but be careful anyway. | 2626 // ASCII does not use chars > 127, but be careful anyway. |
2622 output_buffer[i] = static_cast<unsigned char>(input_buffer[i]); | 2627 output_buffer[i] = static_cast<unsigned char>(input_buffer[i]); |
2623 } | 2628 } |
2624 output_buffer[i] = 0; | 2629 output_buffer[i] = 0; |
2625 return i; | 2630 return i; |
2626 } | 2631 } |
2627 | 2632 |
| 2633 |
2628 // Copies a 16-bit string to a C string by dropping the high byte of | 2634 // Copies a 16-bit string to a C string by dropping the high byte of |
2629 // each character. Does not check for buffer overflow. | 2635 // each character. Does not check for buffer overflow. |
2630 // Can be used in any thread. Requires string length as an input. | 2636 // Can be used in any thread. Requires string length as an input. |
2631 int Utf16ToAscii(const uint16_t* input_buffer, int length, | 2637 int Utf16ToAscii(const uint16_t* input_buffer, int length, |
2632 char* output_buffer, int output_len = -1) { | 2638 char* output_buffer, int output_len = -1) { |
2633 if (output_len >= 0) { | 2639 if (output_len >= 0) { |
2634 if (length > output_len - 1) { | 2640 if (length > output_len - 1) { |
2635 length = output_len - 1; | 2641 length = output_len - 1; |
2636 } | 2642 } |
2637 } | 2643 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 EvaluateResult* array_item = process_debug_messages_data.current(); | 2711 EvaluateResult* array_item = process_debug_messages_data.current(); |
2706 | 2712 |
2707 bool res = GetEvaluateStringResult(print_buffer, | 2713 bool res = GetEvaluateStringResult(print_buffer, |
2708 array_item->buffer, | 2714 array_item->buffer, |
2709 EvaluateResult::kBufferSize); | 2715 EvaluateResult::kBufferSize); |
2710 if (res) { | 2716 if (res) { |
2711 process_debug_messages_data.next(); | 2717 process_debug_messages_data.next(); |
2712 } | 2718 } |
2713 } | 2719 } |
2714 | 2720 |
| 2721 |
2715 // Test that the evaluation of expressions works even from ProcessDebugMessages | 2722 // Test that the evaluation of expressions works even from ProcessDebugMessages |
2716 // i.e. with empty stack. | 2723 // i.e. with empty stack. |
2717 TEST(DebugEvaluateWithoutStack) { | 2724 TEST(DebugEvaluateWithoutStack) { |
2718 v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler); | 2725 v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler); |
2719 | 2726 |
2720 DebugLocalContext env; | 2727 DebugLocalContext env; |
2721 v8::HandleScope scope(env->GetIsolate()); | 2728 v8::HandleScope scope(env->GetIsolate()); |
2722 | 2729 |
2723 const char* source = | 2730 const char* source = |
2724 "var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }"; | 2731 "var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }"; |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4134 CHECK_EQ(StrLength(expected_step_sequence), | 4141 CHECK_EQ(StrLength(expected_step_sequence), |
4135 break_point_hit_count); | 4142 break_point_hit_count); |
4136 | 4143 |
4137 // Get rid of the debug event listener. | 4144 // Get rid of the debug event listener. |
4138 v8::Debug::SetDebugEventListener(NULL); | 4145 v8::Debug::SetDebugEventListener(NULL); |
4139 CheckDebuggerUnloaded(); | 4146 CheckDebuggerUnloaded(); |
4140 } | 4147 } |
4141 | 4148 |
4142 | 4149 |
4143 TEST(DebugBreak) { | 4150 TEST(DebugBreak) { |
| 4151 i::FLAG_stress_compaction = false; |
4144 #ifdef VERIFY_HEAP | 4152 #ifdef VERIFY_HEAP |
4145 i::FLAG_verify_heap = true; | 4153 i::FLAG_verify_heap = true; |
4146 #endif | 4154 #endif |
4147 DebugLocalContext env; | 4155 DebugLocalContext env; |
4148 v8::HandleScope scope(env->GetIsolate()); | 4156 v8::HandleScope scope(env->GetIsolate()); |
4149 | 4157 |
4150 // Register a debug event listener which sets the break flag and counts. | 4158 // Register a debug event listener which sets the break flag and counts. |
4151 v8::Debug::SetDebugEventListener(DebugEventBreak); | 4159 v8::Debug::SetDebugEventListener(DebugEventBreak); |
4152 | 4160 |
4153 // Create a function for testing stepping. | 4161 // Create a function for testing stepping. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 v8::Context::New(isolate, &extensions); | 4265 v8::Context::New(isolate, &extensions); |
4258 } | 4266 } |
4259 // Check that no DebugBreak events occured during the context creation. | 4267 // Check that no DebugBreak events occured during the context creation. |
4260 CHECK_EQ(0, break_point_hit_count); | 4268 CHECK_EQ(0, break_point_hit_count); |
4261 | 4269 |
4262 // Get rid of the debug event listener. | 4270 // Get rid of the debug event listener. |
4263 v8::Debug::SetDebugEventListener(NULL); | 4271 v8::Debug::SetDebugEventListener(NULL); |
4264 CheckDebuggerUnloaded(); | 4272 CheckDebuggerUnloaded(); |
4265 } | 4273 } |
4266 | 4274 |
| 4275 |
4267 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 4276 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
4268 v8::Handle<v8::Array> result = v8::Array::New(3); | 4277 v8::Handle<v8::Array> result = v8::Array::New(3); |
4269 result->Set(v8::Integer::New(0), v8::String::New("a")); | 4278 result->Set(v8::Integer::New(0), v8::String::New("a")); |
4270 result->Set(v8::Integer::New(1), v8::String::New("b")); | 4279 result->Set(v8::Integer::New(1), v8::String::New("b")); |
4271 result->Set(v8::Integer::New(2), v8::String::New("c")); | 4280 result->Set(v8::Integer::New(2), v8::String::New("c")); |
4272 info.GetReturnValue().Set(result); | 4281 info.GetReturnValue().Set(result); |
4273 } | 4282 } |
4274 | 4283 |
4275 | 4284 |
4276 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 4285 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4701 bool invalid_; | 4710 bool invalid_; |
4702 }; | 4711 }; |
4703 | 4712 |
4704 ThreadBarrier::ThreadBarrier(int num_threads) | 4713 ThreadBarrier::ThreadBarrier(int num_threads) |
4705 : num_threads_(num_threads), num_blocked_(0) { | 4714 : num_threads_(num_threads), num_blocked_(0) { |
4706 lock_ = OS::CreateMutex(); | 4715 lock_ = OS::CreateMutex(); |
4707 sem_ = OS::CreateSemaphore(0); | 4716 sem_ = OS::CreateSemaphore(0); |
4708 invalid_ = false; // A barrier may only be used once. Then it is invalid. | 4717 invalid_ = false; // A barrier may only be used once. Then it is invalid. |
4709 } | 4718 } |
4710 | 4719 |
| 4720 |
4711 // Do not call, due to race condition with Wait(). | 4721 // Do not call, due to race condition with Wait(). |
4712 // Could be resolved with Pthread condition variables. | 4722 // Could be resolved with Pthread condition variables. |
4713 ThreadBarrier::~ThreadBarrier() { | 4723 ThreadBarrier::~ThreadBarrier() { |
4714 lock_->Lock(); | 4724 lock_->Lock(); |
4715 delete lock_; | 4725 delete lock_; |
4716 delete sem_; | 4726 delete sem_; |
4717 } | 4727 } |
4718 | 4728 |
| 4729 |
4719 void ThreadBarrier::Wait() { | 4730 void ThreadBarrier::Wait() { |
4720 lock_->Lock(); | 4731 lock_->Lock(); |
4721 CHECK(!invalid_); | 4732 CHECK(!invalid_); |
4722 if (num_blocked_ == num_threads_ - 1) { | 4733 if (num_blocked_ == num_threads_ - 1) { |
4723 // Signal and unblock all waiting threads. | 4734 // Signal and unblock all waiting threads. |
4724 for (int i = 0; i < num_threads_ - 1; ++i) { | 4735 for (int i = 0; i < num_threads_ - 1; ++i) { |
4725 sem_->Signal(); | 4736 sem_->Signal(); |
4726 } | 4737 } |
4727 invalid_ = true; | 4738 invalid_ = true; |
4728 printf("BARRIER\n\n"); | 4739 printf("BARRIER\n\n"); |
4729 fflush(stdout); | 4740 fflush(stdout); |
4730 lock_->Unlock(); | 4741 lock_->Unlock(); |
4731 } else { // Wait for the semaphore. | 4742 } else { // Wait for the semaphore. |
4732 ++num_blocked_; | 4743 ++num_blocked_; |
4733 lock_->Unlock(); // Potential race condition with destructor because | 4744 lock_->Unlock(); // Potential race condition with destructor because |
4734 sem_->Wait(); // these two lines are not atomic. | 4745 sem_->Wait(); // these two lines are not atomic. |
4735 } | 4746 } |
4736 } | 4747 } |
4737 | 4748 |
| 4749 |
4738 // A set containing enough barriers and semaphores for any of the tests. | 4750 // A set containing enough barriers and semaphores for any of the tests. |
4739 class Barriers { | 4751 class Barriers { |
4740 public: | 4752 public: |
4741 Barriers(); | 4753 Barriers(); |
4742 void Initialize(); | 4754 void Initialize(); |
4743 ThreadBarrier barrier_1; | 4755 ThreadBarrier barrier_1; |
4744 ThreadBarrier barrier_2; | 4756 ThreadBarrier barrier_2; |
4745 ThreadBarrier barrier_3; | 4757 ThreadBarrier barrier_3; |
4746 ThreadBarrier barrier_4; | 4758 ThreadBarrier barrier_4; |
4747 ThreadBarrier barrier_5; | 4759 ThreadBarrier barrier_5; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 const char* source_line = "\"sourceLine\":"; | 4849 const char* source_line = "\"sourceLine\":"; |
4838 char* pos = strstr(message, source_line); | 4850 char* pos = strstr(message, source_line); |
4839 if (pos == NULL) { | 4851 if (pos == NULL) { |
4840 return -1; | 4852 return -1; |
4841 } | 4853 } |
4842 int res = -1; | 4854 int res = -1; |
4843 res = StringToInt(pos + strlen(source_line)); | 4855 res = StringToInt(pos + strlen(source_line)); |
4844 return res; | 4856 return res; |
4845 } | 4857 } |
4846 | 4858 |
| 4859 |
4847 /* Test MessageQueues */ | 4860 /* Test MessageQueues */ |
4848 /* Tests the message queues that hold debugger commands and | 4861 /* Tests the message queues that hold debugger commands and |
4849 * response messages to the debugger. Fills queues and makes | 4862 * response messages to the debugger. Fills queues and makes |
4850 * them grow. | 4863 * them grow. |
4851 */ | 4864 */ |
4852 Barriers message_queue_barriers; | 4865 Barriers message_queue_barriers; |
4853 | 4866 |
4854 // This is the debugger thread, that executes no v8 calls except | 4867 // This is the debugger thread, that executes no v8 calls except |
4855 // placing JSON debugger commands in the queue. | 4868 // placing JSON debugger commands in the queue. |
4856 class MessageQueueDebuggerThread : public v8::internal::Thread { | 4869 class MessageQueueDebuggerThread : public v8::internal::Thread { |
(...skipping 11 matching lines...) Expand all Loading... |
4868 // Lets test script wait until break occurs to send commands. | 4881 // Lets test script wait until break occurs to send commands. |
4869 // Signals when a break is reported. | 4882 // Signals when a break is reported. |
4870 message_queue_barriers.semaphore_2->Signal(); | 4883 message_queue_barriers.semaphore_2->Signal(); |
4871 } | 4884 } |
4872 | 4885 |
4873 // Allow message handler to block on a semaphore, to test queueing of | 4886 // Allow message handler to block on a semaphore, to test queueing of |
4874 // messages while blocked. | 4887 // messages while blocked. |
4875 message_queue_barriers.semaphore_1->Wait(); | 4888 message_queue_barriers.semaphore_1->Wait(); |
4876 } | 4889 } |
4877 | 4890 |
| 4891 |
4878 void MessageQueueDebuggerThread::Run() { | 4892 void MessageQueueDebuggerThread::Run() { |
4879 const int kBufferSize = 1000; | 4893 const int kBufferSize = 1000; |
4880 uint16_t buffer_1[kBufferSize]; | 4894 uint16_t buffer_1[kBufferSize]; |
4881 uint16_t buffer_2[kBufferSize]; | 4895 uint16_t buffer_2[kBufferSize]; |
4882 const char* command_1 = | 4896 const char* command_1 = |
4883 "{\"seq\":117," | 4897 "{\"seq\":117," |
4884 "\"type\":\"request\"," | 4898 "\"type\":\"request\"," |
4885 "\"command\":\"evaluate\"," | 4899 "\"command\":\"evaluate\"," |
4886 "\"arguments\":{\"expression\":\"1+2\"}}"; | 4900 "\"arguments\":{\"expression\":\"1+2\"}}"; |
4887 const char* command_2 = | 4901 const char* command_2 = |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5167 global_template->Set(v8::String::New("ThreadedAtBarrier1"), | 5181 global_template->Set(v8::String::New("ThreadedAtBarrier1"), |
5168 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5182 v8::FunctionTemplate::New(ThreadedAtBarrier1)); |
5169 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(), | 5183 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(), |
5170 NULL, | 5184 NULL, |
5171 global_template); | 5185 global_template); |
5172 v8::Context::Scope context_scope(context); | 5186 v8::Context::Scope context_scope(context); |
5173 | 5187 |
5174 CompileRun(source); | 5188 CompileRun(source); |
5175 } | 5189 } |
5176 | 5190 |
| 5191 |
5177 void DebuggerThread::Run() { | 5192 void DebuggerThread::Run() { |
5178 const int kBufSize = 1000; | 5193 const int kBufSize = 1000; |
5179 uint16_t buffer[kBufSize]; | 5194 uint16_t buffer[kBufSize]; |
5180 | 5195 |
5181 const char* command_1 = "{\"seq\":102," | 5196 const char* command_1 = "{\"seq\":102," |
5182 "\"type\":\"request\"," | 5197 "\"type\":\"request\"," |
5183 "\"command\":\"evaluate\"," | 5198 "\"command\":\"evaluate\"," |
5184 "\"arguments\":{\"expression\":\"bar(false)\"}}"; | 5199 "\"arguments\":{\"expression\":\"bar(false)\"}}"; |
5185 const char* command_2 = "{\"seq\":103," | 5200 const char* command_2 = "{\"seq\":103," |
5186 "\"type\":\"request\"," | 5201 "\"type\":\"request\"," |
(...skipping 14 matching lines...) Expand all Loading... |
5201 // Create a V8 environment | 5216 // Create a V8 environment |
5202 threaded_debugging_barriers.Initialize(); | 5217 threaded_debugging_barriers.Initialize(); |
5203 | 5218 |
5204 v8_thread.Start(); | 5219 v8_thread.Start(); |
5205 debugger_thread.Start(); | 5220 debugger_thread.Start(); |
5206 | 5221 |
5207 v8_thread.Join(); | 5222 v8_thread.Join(); |
5208 debugger_thread.Join(); | 5223 debugger_thread.Join(); |
5209 } | 5224 } |
5210 | 5225 |
| 5226 |
5211 /* Test RecursiveBreakpoints */ | 5227 /* Test RecursiveBreakpoints */ |
5212 /* In this test, the debugger evaluates a function with a breakpoint, after | 5228 /* In this test, the debugger evaluates a function with a breakpoint, after |
5213 * hitting a breakpoint in another function. We do this with both values | 5229 * hitting a breakpoint in another function. We do this with both values |
5214 * of the flag enabling recursive breakpoints, and verify that the second | 5230 * of the flag enabling recursive breakpoints, and verify that the second |
5215 * breakpoint is hit when enabled, and missed when disabled. | 5231 * breakpoint is hit when enabled, and missed when disabled. |
5216 */ | 5232 */ |
5217 | 5233 |
5218 class BreakpointsV8Thread : public v8::internal::Thread { | 5234 class BreakpointsV8Thread : public v8::internal::Thread { |
5219 public: | 5235 public: |
5220 BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { } | 5236 BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5392 // 8: Evaluate dog() with breaks disabled. | 5408 // 8: Evaluate dog() with breaks disabled. |
5393 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer)); | 5409 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer)); |
5394 // Evaluate dog() finishes. | 5410 // Evaluate dog() finishes. |
5395 breakpoints_barriers->semaphore_1->Wait(); | 5411 breakpoints_barriers->semaphore_1->Wait(); |
5396 // Must have result 116. | 5412 // Must have result 116. |
5397 CHECK_EQ(116, evaluate_int_result); | 5413 CHECK_EQ(116, evaluate_int_result); |
5398 // 9: Continue evaluation of source2, reach end. | 5414 // 9: Continue evaluation of source2, reach end. |
5399 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer)); | 5415 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer)); |
5400 } | 5416 } |
5401 | 5417 |
| 5418 |
5402 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { | 5419 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { |
5403 i::FLAG_debugger_auto_break = true; | 5420 i::FLAG_debugger_auto_break = true; |
5404 | 5421 |
5405 BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); | 5422 BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); |
5406 BreakpointsV8Thread breakpoints_v8_thread; | 5423 BreakpointsV8Thread breakpoints_v8_thread; |
5407 | 5424 |
5408 // Create a V8 environment | 5425 // Create a V8 environment |
5409 Barriers stack_allocated_breakpoints_barriers; | 5426 Barriers stack_allocated_breakpoints_barriers; |
5410 stack_allocated_breakpoints_barriers.Initialize(); | 5427 stack_allocated_breakpoints_barriers.Initialize(); |
5411 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 5428 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
5412 | 5429 |
5413 breakpoints_v8_thread.Start(); | 5430 breakpoints_v8_thread.Start(); |
5414 breakpoints_debugger_thread.Start(); | 5431 breakpoints_debugger_thread.Start(); |
5415 | 5432 |
5416 breakpoints_v8_thread.Join(); | 5433 breakpoints_v8_thread.Join(); |
5417 breakpoints_debugger_thread.Join(); | 5434 breakpoints_debugger_thread.Join(); |
5418 } | 5435 } |
5419 | 5436 |
| 5437 |
5420 TEST(RecursiveBreakpoints) { | 5438 TEST(RecursiveBreakpoints) { |
5421 TestRecursiveBreakpointsGeneric(false); | 5439 TestRecursiveBreakpointsGeneric(false); |
5422 } | 5440 } |
5423 | 5441 |
| 5442 |
5424 TEST(RecursiveBreakpointsGlobal) { | 5443 TEST(RecursiveBreakpointsGlobal) { |
5425 TestRecursiveBreakpointsGeneric(true); | 5444 TestRecursiveBreakpointsGeneric(true); |
5426 } | 5445 } |
5427 | 5446 |
5428 | 5447 |
5429 static void DummyDebugEventListener(v8::DebugEvent event, | 5448 static void DummyDebugEventListener(v8::DebugEvent event, |
5430 v8::Handle<v8::Object> exec_state, | 5449 v8::Handle<v8::Object> exec_state, |
5431 v8::Handle<v8::Object> event_data, | 5450 v8::Handle<v8::Object> event_data, |
5432 v8::Handle<v8::Value> data) { | 5451 v8::Handle<v8::Value> data) { |
5433 } | 5452 } |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6262 } | 6281 } |
6263 | 6282 |
6264 | 6283 |
6265 // Test which creates two contexts and sets different embedder data on each. | 6284 // Test which creates two contexts and sets different embedder data on each. |
6266 // Checks that this data is set correctly and that when the debug message | 6285 // Checks that this data is set correctly and that when the debug message |
6267 // handler is called the expected context is the one active. | 6286 // handler is called the expected context is the one active. |
6268 TEST(ContextData) { | 6287 TEST(ContextData) { |
6269 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6288 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
6270 v8::HandleScope scope(isolate); | 6289 v8::HandleScope scope(isolate); |
6271 | 6290 |
6272 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler); | |
6273 | |
6274 // Create two contexts. | 6291 // Create two contexts. |
6275 v8::Handle<v8::Context> context_1; | 6292 v8::Handle<v8::Context> context_1; |
6276 v8::Handle<v8::Context> context_2; | 6293 v8::Handle<v8::Context> context_2; |
6277 v8::Handle<v8::ObjectTemplate> global_template = | 6294 v8::Handle<v8::ObjectTemplate> global_template = |
6278 v8::Handle<v8::ObjectTemplate>(); | 6295 v8::Handle<v8::ObjectTemplate>(); |
6279 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); | 6296 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); |
6280 context_1 = v8::Context::New(isolate, NULL, global_template, global_object); | 6297 context_1 = v8::Context::New(isolate, NULL, global_template, global_object); |
6281 context_2 = v8::Context::New(isolate, NULL, global_template, global_object); | 6298 context_2 = v8::Context::New(isolate, NULL, global_template, global_object); |
6282 | 6299 |
| 6300 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler); |
| 6301 |
6283 // Default data value is undefined. | 6302 // Default data value is undefined. |
6284 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); | 6303 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6285 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); | 6304 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); |
6286 | 6305 |
6287 // Set and check different data values. | 6306 // Set and check different data values. |
6288 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6307 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
6289 v8::Handle<v8::String> data_2 = v8::String::New("2"); | 6308 v8::Handle<v8::String> data_2 = v8::String::New("2"); |
6290 context_1->SetEmbedderData(0, data_1); | 6309 context_1->SetEmbedderData(0, data_1); |
6291 context_2->SetEmbedderData(0, data_2); | 6310 context_2->SetEmbedderData(0, data_2); |
6292 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); | 6311 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6430 | 6449 |
6431 // Check that there was only one break event. Matching RegExp should not | 6450 // Check that there was only one break event. Matching RegExp should not |
6432 // cause Break events. | 6451 // cause Break events. |
6433 CHECK_EQ(1, break_point_hit_count); | 6452 CHECK_EQ(1, break_point_hit_count); |
6434 CHECK_EQ("f", last_function_hit); | 6453 CHECK_EQ("f", last_function_hit); |
6435 } | 6454 } |
6436 #endif // V8_INTERPRETED_REGEXP | 6455 #endif // V8_INTERPRETED_REGEXP |
6437 | 6456 |
6438 | 6457 |
6439 // Common part of EvalContextData and NestedBreakEventContextData tests. | 6458 // Common part of EvalContextData and NestedBreakEventContextData tests. |
6440 static void ExecuteScriptForContextCheck() { | 6459 static void ExecuteScriptForContextCheck( |
| 6460 v8::Debug::MessageHandler2 message_handler) { |
6441 // Create a context. | 6461 // Create a context. |
6442 v8::Handle<v8::Context> context_1; | 6462 v8::Handle<v8::Context> context_1; |
6443 v8::Handle<v8::ObjectTemplate> global_template = | 6463 v8::Handle<v8::ObjectTemplate> global_template = |
6444 v8::Handle<v8::ObjectTemplate>(); | 6464 v8::Handle<v8::ObjectTemplate>(); |
6445 context_1 = | 6465 context_1 = |
6446 v8::Context::New(v8::Isolate::GetCurrent(), NULL, global_template); | 6466 v8::Context::New(v8::Isolate::GetCurrent(), NULL, global_template); |
6447 | 6467 |
| 6468 v8::Debug::SetMessageHandler2(message_handler); |
| 6469 |
6448 // Default data value is undefined. | 6470 // Default data value is undefined. |
6449 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); | 6471 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6450 | 6472 |
6451 // Set and check a data value. | 6473 // Set and check a data value. |
6452 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6474 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
6453 context_1->SetEmbedderData(0, data_1); | 6475 context_1->SetEmbedderData(0, data_1); |
6454 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); | 6476 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
6455 | 6477 |
6456 // Simple test function with eval that causes a break. | 6478 // Simple test function with eval that causes a break. |
6457 const char* source = "function f() { eval('debugger;'); }"; | 6479 const char* source = "function f() { eval('debugger;'); }"; |
6458 | 6480 |
6459 // Enter and run function in the context. | 6481 // Enter and run function in the context. |
6460 { | 6482 { |
6461 v8::Context::Scope context_scope(context_1); | 6483 v8::Context::Scope context_scope(context_1); |
6462 expected_context = context_1; | 6484 expected_context = context_1; |
6463 expected_context_data = data_1; | 6485 expected_context_data = data_1; |
6464 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6486 v8::Local<v8::Function> f = CompileFunction(source, "f"); |
6465 f->Call(context_1->Global(), 0, NULL); | 6487 f->Call(context_1->Global(), 0, NULL); |
6466 } | 6488 } |
| 6489 |
| 6490 v8::Debug::SetMessageHandler2(NULL); |
6467 } | 6491 } |
6468 | 6492 |
6469 | 6493 |
6470 // Test which creates a context and sets embedder data on it. Checks that this | 6494 // Test which creates a context and sets embedder data on it. Checks that this |
6471 // data is set correctly and that when the debug message handler is called for | 6495 // data is set correctly and that when the debug message handler is called for |
6472 // break event in an eval statement the expected context is the one returned by | 6496 // break event in an eval statement the expected context is the one returned by |
6473 // Message.GetEventContext. | 6497 // Message.GetEventContext. |
6474 TEST(EvalContextData) { | 6498 TEST(EvalContextData) { |
6475 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6499 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
6476 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler); | |
6477 | 6500 |
6478 ExecuteScriptForContextCheck(); | 6501 ExecuteScriptForContextCheck(ContextCheckMessageHandler); |
6479 | 6502 |
6480 // One time compile event and one time break event. | 6503 // One time compile event and one time break event. |
6481 CHECK_GT(message_handler_hit_count, 2); | 6504 CHECK_GT(message_handler_hit_count, 2); |
6482 v8::Debug::SetMessageHandler2(NULL); | |
6483 CheckDebuggerUnloaded(); | 6505 CheckDebuggerUnloaded(); |
6484 } | 6506 } |
6485 | 6507 |
6486 | 6508 |
6487 static bool sent_eval = false; | 6509 static bool sent_eval = false; |
6488 static int break_count = 0; | 6510 static int break_count = 0; |
6489 static int continue_command_send_count = 0; | 6511 static int continue_command_send_count = 0; |
6490 // Check that the expected context is the one generating the debug event | 6512 // Check that the expected context is the one generating the debug event |
6491 // including the case of nested break event. | 6513 // including the case of nested break event. |
6492 static void DebugEvalContextCheckMessageHandler( | 6514 static void DebugEvalContextCheckMessageHandler( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6531 } | 6553 } |
6532 } | 6554 } |
6533 | 6555 |
6534 | 6556 |
6535 // Tests that context returned for break event is correct when the event occurs | 6557 // Tests that context returned for break event is correct when the event occurs |
6536 // in 'evaluate' debugger request. | 6558 // in 'evaluate' debugger request. |
6537 TEST(NestedBreakEventContextData) { | 6559 TEST(NestedBreakEventContextData) { |
6538 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6560 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
6539 break_count = 0; | 6561 break_count = 0; |
6540 message_handler_hit_count = 0; | 6562 message_handler_hit_count = 0; |
6541 v8::Debug::SetMessageHandler2(DebugEvalContextCheckMessageHandler); | |
6542 | 6563 |
6543 ExecuteScriptForContextCheck(); | 6564 ExecuteScriptForContextCheck(DebugEvalContextCheckMessageHandler); |
6544 | 6565 |
6545 // One time compile event and two times break event. | 6566 // One time compile event and two times break event. |
6546 CHECK_GT(message_handler_hit_count, 3); | 6567 CHECK_GT(message_handler_hit_count, 3); |
6547 | 6568 |
6548 // One break from the source and another from the evaluate request. | 6569 // One break from the source and another from the evaluate request. |
6549 CHECK_EQ(break_count, 2); | 6570 CHECK_EQ(break_count, 2); |
6550 v8::Debug::SetMessageHandler2(NULL); | |
6551 CheckDebuggerUnloaded(); | 6571 CheckDebuggerUnloaded(); |
6552 } | 6572 } |
6553 | 6573 |
6554 | 6574 |
6555 // Debug event listener which counts the script collected events. | 6575 // Debug event listener which counts the script collected events. |
6556 int script_collected_count = 0; | 6576 int script_collected_count = 0; |
6557 static void DebugEventScriptCollectedEvent(v8::DebugEvent event, | 6577 static void DebugEventScriptCollectedEvent(v8::DebugEvent event, |
6558 v8::Handle<v8::Object> exec_state, | 6578 v8::Handle<v8::Object> exec_state, |
6559 v8::Handle<v8::Object> event_data, | 6579 v8::Handle<v8::Object> event_data, |
6560 v8::Handle<v8::Value> data) { | 6580 v8::Handle<v8::Value> data) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6607 script_collected_message_count++; | 6627 script_collected_message_count++; |
6608 v8::Handle<v8::Context> context = message.GetEventContext(); | 6628 v8::Handle<v8::Context> context = message.GetEventContext(); |
6609 CHECK(context.IsEmpty()); | 6629 CHECK(context.IsEmpty()); |
6610 } | 6630 } |
6611 } | 6631 } |
6612 | 6632 |
6613 | 6633 |
6614 // Test that GetEventContext doesn't fail and return empty handle for | 6634 // Test that GetEventContext doesn't fail and return empty handle for |
6615 // ScriptCollected events. | 6635 // ScriptCollected events. |
6616 TEST(ScriptCollectedEventContext) { | 6636 TEST(ScriptCollectedEventContext) { |
| 6637 i::FLAG_stress_compaction = false; |
6617 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6638 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
6618 v8::internal::Debug* debug = | 6639 v8::internal::Debug* debug = |
6619 reinterpret_cast<v8::internal::Isolate*>(isolate)->debug(); | 6640 reinterpret_cast<v8::internal::Isolate*>(isolate)->debug(); |
6620 script_collected_message_count = 0; | 6641 script_collected_message_count = 0; |
6621 v8::HandleScope scope(isolate); | 6642 v8::HandleScope scope(isolate); |
6622 | 6643 |
6623 v8::Persistent<v8::Context> context; | 6644 v8::Persistent<v8::Context> context; |
6624 { | 6645 { |
6625 v8::HandleScope scope(isolate); | 6646 v8::HandleScope scope(isolate); |
6626 context.Reset(isolate, v8::Context::New(isolate)); | 6647 context.Reset(isolate, v8::Context::New(isolate)); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6864 CheckDebuggerUnloaded(); | 6885 CheckDebuggerUnloaded(); |
6865 } | 6886 } |
6866 | 6887 |
6867 | 6888 |
6868 static int counting_message_handler_counter; | 6889 static int counting_message_handler_counter; |
6869 | 6890 |
6870 static void CountingMessageHandler(const v8::Debug::Message& message) { | 6891 static void CountingMessageHandler(const v8::Debug::Message& message) { |
6871 counting_message_handler_counter++; | 6892 counting_message_handler_counter++; |
6872 } | 6893 } |
6873 | 6894 |
| 6895 |
6874 // Test that debug messages get processed when ProcessDebugMessages is called. | 6896 // Test that debug messages get processed when ProcessDebugMessages is called. |
6875 TEST(ProcessDebugMessages) { | 6897 TEST(ProcessDebugMessages) { |
6876 DebugLocalContext env; | 6898 DebugLocalContext env; |
6877 v8::HandleScope scope(env->GetIsolate()); | 6899 v8::HandleScope scope(env->GetIsolate()); |
6878 | 6900 |
6879 counting_message_handler_counter = 0; | 6901 counting_message_handler_counter = 0; |
6880 | 6902 |
6881 v8::Debug::SetMessageHandler2(CountingMessageHandler); | 6903 v8::Debug::SetMessageHandler2(CountingMessageHandler); |
6882 | 6904 |
6883 const int kBufferSize = 1000; | 6905 const int kBufferSize = 1000; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7103 CHECK_EQ(*context1, *context2); | 7125 CHECK_EQ(*context1, *context2); |
7104 } | 7126 } |
7105 | 7127 |
7106 | 7128 |
7107 static v8::Handle<v8::Value> expected_callback_data; | 7129 static v8::Handle<v8::Value> expected_callback_data; |
7108 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { | 7130 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { |
7109 CHECK(details.GetEventContext() == expected_context); | 7131 CHECK(details.GetEventContext() == expected_context); |
7110 CHECK_EQ(expected_callback_data, details.GetCallbackData()); | 7132 CHECK_EQ(expected_callback_data, details.GetCallbackData()); |
7111 } | 7133 } |
7112 | 7134 |
| 7135 |
7113 // Check that event details contain context where debug event occured. | 7136 // Check that event details contain context where debug event occured. |
7114 TEST(DebugEventContext) { | 7137 TEST(DebugEventContext) { |
7115 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 7138 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
7116 v8::HandleScope scope(isolate); | 7139 v8::HandleScope scope(isolate); |
7117 expected_callback_data = v8::Int32::New(2010); | 7140 expected_callback_data = v8::Int32::New(2010); |
| 7141 expected_context = v8::Context::New(isolate); |
7118 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, | 7142 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, |
7119 expected_callback_data); | 7143 expected_callback_data); |
7120 expected_context = v8::Context::New(isolate); | |
7121 v8::Context::Scope context_scope(expected_context); | 7144 v8::Context::Scope context_scope(expected_context); |
7122 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); | 7145 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); |
7123 expected_context.Clear(); | 7146 expected_context.Clear(); |
7124 v8::Debug::SetDebugEventListener(NULL); | 7147 v8::Debug::SetDebugEventListener(NULL); |
7125 expected_context_data = v8::Handle<v8::Value>(); | 7148 expected_context_data = v8::Handle<v8::Value>(); |
7126 CheckDebuggerUnloaded(); | 7149 CheckDebuggerUnloaded(); |
7127 } | 7150 } |
7128 | 7151 |
7129 | 7152 |
7130 static void* expected_break_data; | 7153 static void* expected_break_data; |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7572 TEST(LiveEditDisabled) { | 7595 TEST(LiveEditDisabled) { |
7573 v8::internal::FLAG_allow_natives_syntax = true; | 7596 v8::internal::FLAG_allow_natives_syntax = true; |
7574 LocalContext env; | 7597 LocalContext env; |
7575 v8::HandleScope scope(env->GetIsolate()); | 7598 v8::HandleScope scope(env->GetIsolate()); |
7576 v8::Debug::SetLiveEditEnabled(false); | 7599 v8::Debug::SetLiveEditEnabled(false); |
7577 CompileRun("%LiveEditCompareStrings('', '')"); | 7600 CompileRun("%LiveEditCompareStrings('', '')"); |
7578 } | 7601 } |
7579 | 7602 |
7580 | 7603 |
7581 #endif // ENABLE_DEBUGGER_SUPPORT | 7604 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |