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 802 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 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 v8::Context::New(isolate, &extensions); | 4265 v8::Context::New(isolate, &extensions); |
4259 } | 4266 } |
4260 // Check that no DebugBreak events occured during the context creation. | 4267 // Check that no DebugBreak events occured during the context creation. |
4261 CHECK_EQ(0, break_point_hit_count); | 4268 CHECK_EQ(0, break_point_hit_count); |
4262 | 4269 |
4263 // Get rid of the debug event listener. | 4270 // Get rid of the debug event listener. |
4264 v8::Debug::SetDebugEventListener(NULL); | 4271 v8::Debug::SetDebugEventListener(NULL); |
4265 CheckDebuggerUnloaded(); | 4272 CheckDebuggerUnloaded(); |
4266 } | 4273 } |
4267 | 4274 |
| 4275 |
4268 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 4276 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
4269 v8::Handle<v8::Array> result = v8::Array::New(3); | 4277 v8::Handle<v8::Array> result = v8::Array::New(3); |
4270 result->Set(v8::Integer::New(0), v8::String::New("a")); | 4278 result->Set(v8::Integer::New(0), v8::String::New("a")); |
4271 result->Set(v8::Integer::New(1), v8::String::New("b")); | 4279 result->Set(v8::Integer::New(1), v8::String::New("b")); |
4272 result->Set(v8::Integer::New(2), v8::String::New("c")); | 4280 result->Set(v8::Integer::New(2), v8::String::New("c")); |
4273 info.GetReturnValue().Set(result); | 4281 info.GetReturnValue().Set(result); |
4274 } | 4282 } |
4275 | 4283 |
4276 | 4284 |
4277 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... |
4702 bool invalid_; | 4710 bool invalid_; |
4703 }; | 4711 }; |
4704 | 4712 |
4705 ThreadBarrier::ThreadBarrier(int num_threads) | 4713 ThreadBarrier::ThreadBarrier(int num_threads) |
4706 : num_threads_(num_threads), num_blocked_(0) { | 4714 : num_threads_(num_threads), num_blocked_(0) { |
4707 lock_ = OS::CreateMutex(); | 4715 lock_ = OS::CreateMutex(); |
4708 sem_ = OS::CreateSemaphore(0); | 4716 sem_ = OS::CreateSemaphore(0); |
4709 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. |
4710 } | 4718 } |
4711 | 4719 |
| 4720 |
4712 // Do not call, due to race condition with Wait(). | 4721 // Do not call, due to race condition with Wait(). |
4713 // Could be resolved with Pthread condition variables. | 4722 // Could be resolved with Pthread condition variables. |
4714 ThreadBarrier::~ThreadBarrier() { | 4723 ThreadBarrier::~ThreadBarrier() { |
4715 lock_->Lock(); | 4724 lock_->Lock(); |
4716 delete lock_; | 4725 delete lock_; |
4717 delete sem_; | 4726 delete sem_; |
4718 } | 4727 } |
4719 | 4728 |
| 4729 |
4720 void ThreadBarrier::Wait() { | 4730 void ThreadBarrier::Wait() { |
4721 lock_->Lock(); | 4731 lock_->Lock(); |
4722 CHECK(!invalid_); | 4732 CHECK(!invalid_); |
4723 if (num_blocked_ == num_threads_ - 1) { | 4733 if (num_blocked_ == num_threads_ - 1) { |
4724 // Signal and unblock all waiting threads. | 4734 // Signal and unblock all waiting threads. |
4725 for (int i = 0; i < num_threads_ - 1; ++i) { | 4735 for (int i = 0; i < num_threads_ - 1; ++i) { |
4726 sem_->Signal(); | 4736 sem_->Signal(); |
4727 } | 4737 } |
4728 invalid_ = true; | 4738 invalid_ = true; |
4729 printf("BARRIER\n\n"); | 4739 printf("BARRIER\n\n"); |
4730 fflush(stdout); | 4740 fflush(stdout); |
4731 lock_->Unlock(); | 4741 lock_->Unlock(); |
4732 } else { // Wait for the semaphore. | 4742 } else { // Wait for the semaphore. |
4733 ++num_blocked_; | 4743 ++num_blocked_; |
4734 lock_->Unlock(); // Potential race condition with destructor because | 4744 lock_->Unlock(); // Potential race condition with destructor because |
4735 sem_->Wait(); // these two lines are not atomic. | 4745 sem_->Wait(); // these two lines are not atomic. |
4736 } | 4746 } |
4737 } | 4747 } |
4738 | 4748 |
| 4749 |
4739 // 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. |
4740 class Barriers { | 4751 class Barriers { |
4741 public: | 4752 public: |
4742 Barriers(); | 4753 Barriers(); |
4743 void Initialize(); | 4754 void Initialize(); |
4744 ThreadBarrier barrier_1; | 4755 ThreadBarrier barrier_1; |
4745 ThreadBarrier barrier_2; | 4756 ThreadBarrier barrier_2; |
4746 ThreadBarrier barrier_3; | 4757 ThreadBarrier barrier_3; |
4747 ThreadBarrier barrier_4; | 4758 ThreadBarrier barrier_4; |
4748 ThreadBarrier barrier_5; | 4759 ThreadBarrier barrier_5; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4838 const char* source_line = "\"sourceLine\":"; | 4849 const char* source_line = "\"sourceLine\":"; |
4839 char* pos = strstr(message, source_line); | 4850 char* pos = strstr(message, source_line); |
4840 if (pos == NULL) { | 4851 if (pos == NULL) { |
4841 return -1; | 4852 return -1; |
4842 } | 4853 } |
4843 int res = -1; | 4854 int res = -1; |
4844 res = StringToInt(pos + strlen(source_line)); | 4855 res = StringToInt(pos + strlen(source_line)); |
4845 return res; | 4856 return res; |
4846 } | 4857 } |
4847 | 4858 |
| 4859 |
4848 /* Test MessageQueues */ | 4860 /* Test MessageQueues */ |
4849 /* Tests the message queues that hold debugger commands and | 4861 /* Tests the message queues that hold debugger commands and |
4850 * response messages to the debugger. Fills queues and makes | 4862 * response messages to the debugger. Fills queues and makes |
4851 * them grow. | 4863 * them grow. |
4852 */ | 4864 */ |
4853 Barriers message_queue_barriers; | 4865 Barriers message_queue_barriers; |
4854 | 4866 |
4855 // This is the debugger thread, that executes no v8 calls except | 4867 // This is the debugger thread, that executes no v8 calls except |
4856 // placing JSON debugger commands in the queue. | 4868 // placing JSON debugger commands in the queue. |
4857 class MessageQueueDebuggerThread : public v8::internal::Thread { | 4869 class MessageQueueDebuggerThread : public v8::internal::Thread { |
(...skipping 11 matching lines...) Expand all Loading... |
4869 // Lets test script wait until break occurs to send commands. | 4881 // Lets test script wait until break occurs to send commands. |
4870 // Signals when a break is reported. | 4882 // Signals when a break is reported. |
4871 message_queue_barriers.semaphore_2->Signal(); | 4883 message_queue_barriers.semaphore_2->Signal(); |
4872 } | 4884 } |
4873 | 4885 |
4874 // 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 |
4875 // messages while blocked. | 4887 // messages while blocked. |
4876 message_queue_barriers.semaphore_1->Wait(); | 4888 message_queue_barriers.semaphore_1->Wait(); |
4877 } | 4889 } |
4878 | 4890 |
| 4891 |
4879 void MessageQueueDebuggerThread::Run() { | 4892 void MessageQueueDebuggerThread::Run() { |
4880 const int kBufferSize = 1000; | 4893 const int kBufferSize = 1000; |
4881 uint16_t buffer_1[kBufferSize]; | 4894 uint16_t buffer_1[kBufferSize]; |
4882 uint16_t buffer_2[kBufferSize]; | 4895 uint16_t buffer_2[kBufferSize]; |
4883 const char* command_1 = | 4896 const char* command_1 = |
4884 "{\"seq\":117," | 4897 "{\"seq\":117," |
4885 "\"type\":\"request\"," | 4898 "\"type\":\"request\"," |
4886 "\"command\":\"evaluate\"," | 4899 "\"command\":\"evaluate\"," |
4887 "\"arguments\":{\"expression\":\"1+2\"}}"; | 4900 "\"arguments\":{\"expression\":\"1+2\"}}"; |
4888 const char* command_2 = | 4901 const char* command_2 = |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5168 global_template->Set(v8::String::New("ThreadedAtBarrier1"), | 5181 global_template->Set(v8::String::New("ThreadedAtBarrier1"), |
5169 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5182 v8::FunctionTemplate::New(ThreadedAtBarrier1)); |
5170 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(), | 5183 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(), |
5171 NULL, | 5184 NULL, |
5172 global_template); | 5185 global_template); |
5173 v8::Context::Scope context_scope(context); | 5186 v8::Context::Scope context_scope(context); |
5174 | 5187 |
5175 CompileRun(source); | 5188 CompileRun(source); |
5176 } | 5189 } |
5177 | 5190 |
| 5191 |
5178 void DebuggerThread::Run() { | 5192 void DebuggerThread::Run() { |
5179 const int kBufSize = 1000; | 5193 const int kBufSize = 1000; |
5180 uint16_t buffer[kBufSize]; | 5194 uint16_t buffer[kBufSize]; |
5181 | 5195 |
5182 const char* command_1 = "{\"seq\":102," | 5196 const char* command_1 = "{\"seq\":102," |
5183 "\"type\":\"request\"," | 5197 "\"type\":\"request\"," |
5184 "\"command\":\"evaluate\"," | 5198 "\"command\":\"evaluate\"," |
5185 "\"arguments\":{\"expression\":\"bar(false)\"}}"; | 5199 "\"arguments\":{\"expression\":\"bar(false)\"}}"; |
5186 const char* command_2 = "{\"seq\":103," | 5200 const char* command_2 = "{\"seq\":103," |
5187 "\"type\":\"request\"," | 5201 "\"type\":\"request\"," |
(...skipping 14 matching lines...) Expand all Loading... |
5202 // Create a V8 environment | 5216 // Create a V8 environment |
5203 threaded_debugging_barriers.Initialize(); | 5217 threaded_debugging_barriers.Initialize(); |
5204 | 5218 |
5205 v8_thread.Start(); | 5219 v8_thread.Start(); |
5206 debugger_thread.Start(); | 5220 debugger_thread.Start(); |
5207 | 5221 |
5208 v8_thread.Join(); | 5222 v8_thread.Join(); |
5209 debugger_thread.Join(); | 5223 debugger_thread.Join(); |
5210 } | 5224 } |
5211 | 5225 |
| 5226 |
5212 /* Test RecursiveBreakpoints */ | 5227 /* Test RecursiveBreakpoints */ |
5213 /* 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 |
5214 * 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 |
5215 * of the flag enabling recursive breakpoints, and verify that the second | 5230 * of the flag enabling recursive breakpoints, and verify that the second |
5216 * breakpoint is hit when enabled, and missed when disabled. | 5231 * breakpoint is hit when enabled, and missed when disabled. |
5217 */ | 5232 */ |
5218 | 5233 |
5219 class BreakpointsV8Thread : public v8::internal::Thread { | 5234 class BreakpointsV8Thread : public v8::internal::Thread { |
5220 public: | 5235 public: |
5221 BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { } | 5236 BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5393 // 8: Evaluate dog() with breaks disabled. | 5408 // 8: Evaluate dog() with breaks disabled. |
5394 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer)); | 5409 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer)); |
5395 // Evaluate dog() finishes. | 5410 // Evaluate dog() finishes. |
5396 breakpoints_barriers->semaphore_1->Wait(); | 5411 breakpoints_barriers->semaphore_1->Wait(); |
5397 // Must have result 116. | 5412 // Must have result 116. |
5398 CHECK_EQ(116, evaluate_int_result); | 5413 CHECK_EQ(116, evaluate_int_result); |
5399 // 9: Continue evaluation of source2, reach end. | 5414 // 9: Continue evaluation of source2, reach end. |
5400 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer)); | 5415 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer)); |
5401 } | 5416 } |
5402 | 5417 |
| 5418 |
5403 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { | 5419 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { |
5404 i::FLAG_debugger_auto_break = true; | 5420 i::FLAG_debugger_auto_break = true; |
5405 | 5421 |
5406 BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); | 5422 BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); |
5407 BreakpointsV8Thread breakpoints_v8_thread; | 5423 BreakpointsV8Thread breakpoints_v8_thread; |
5408 | 5424 |
5409 // Create a V8 environment | 5425 // Create a V8 environment |
5410 Barriers stack_allocated_breakpoints_barriers; | 5426 Barriers stack_allocated_breakpoints_barriers; |
5411 stack_allocated_breakpoints_barriers.Initialize(); | 5427 stack_allocated_breakpoints_barriers.Initialize(); |
5412 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 5428 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
5413 | 5429 |
5414 breakpoints_v8_thread.Start(); | 5430 breakpoints_v8_thread.Start(); |
5415 breakpoints_debugger_thread.Start(); | 5431 breakpoints_debugger_thread.Start(); |
5416 | 5432 |
5417 breakpoints_v8_thread.Join(); | 5433 breakpoints_v8_thread.Join(); |
5418 breakpoints_debugger_thread.Join(); | 5434 breakpoints_debugger_thread.Join(); |
5419 } | 5435 } |
5420 | 5436 |
| 5437 |
5421 TEST(RecursiveBreakpoints) { | 5438 TEST(RecursiveBreakpoints) { |
5422 TestRecursiveBreakpointsGeneric(false); | 5439 TestRecursiveBreakpointsGeneric(false); |
5423 } | 5440 } |
5424 | 5441 |
| 5442 |
5425 TEST(RecursiveBreakpointsGlobal) { | 5443 TEST(RecursiveBreakpointsGlobal) { |
5426 TestRecursiveBreakpointsGeneric(true); | 5444 TestRecursiveBreakpointsGeneric(true); |
5427 } | 5445 } |
5428 | 5446 |
5429 | 5447 |
5430 static void DummyDebugEventListener(v8::DebugEvent event, | 5448 static void DummyDebugEventListener(v8::DebugEvent event, |
5431 v8::Handle<v8::Object> exec_state, | 5449 v8::Handle<v8::Object> exec_state, |
5432 v8::Handle<v8::Object> event_data, | 5450 v8::Handle<v8::Object> event_data, |
5433 v8::Handle<v8::Value> data) { | 5451 v8::Handle<v8::Value> data) { |
5434 } | 5452 } |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6866 CheckDebuggerUnloaded(); | 6884 CheckDebuggerUnloaded(); |
6867 } | 6885 } |
6868 | 6886 |
6869 | 6887 |
6870 static int counting_message_handler_counter; | 6888 static int counting_message_handler_counter; |
6871 | 6889 |
6872 static void CountingMessageHandler(const v8::Debug::Message& message) { | 6890 static void CountingMessageHandler(const v8::Debug::Message& message) { |
6873 counting_message_handler_counter++; | 6891 counting_message_handler_counter++; |
6874 } | 6892 } |
6875 | 6893 |
| 6894 |
6876 // Test that debug messages get processed when ProcessDebugMessages is called. | 6895 // Test that debug messages get processed when ProcessDebugMessages is called. |
6877 TEST(ProcessDebugMessages) { | 6896 TEST(ProcessDebugMessages) { |
6878 DebugLocalContext env; | 6897 DebugLocalContext env; |
6879 v8::HandleScope scope(env->GetIsolate()); | 6898 v8::HandleScope scope(env->GetIsolate()); |
6880 | 6899 |
6881 counting_message_handler_counter = 0; | 6900 counting_message_handler_counter = 0; |
6882 | 6901 |
6883 v8::Debug::SetMessageHandler2(CountingMessageHandler); | 6902 v8::Debug::SetMessageHandler2(CountingMessageHandler); |
6884 | 6903 |
6885 const int kBufferSize = 1000; | 6904 const int kBufferSize = 1000; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7105 CHECK_EQ(*context1, *context2); | 7124 CHECK_EQ(*context1, *context2); |
7106 } | 7125 } |
7107 | 7126 |
7108 | 7127 |
7109 static v8::Handle<v8::Value> expected_callback_data; | 7128 static v8::Handle<v8::Value> expected_callback_data; |
7110 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { | 7129 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { |
7111 CHECK(details.GetEventContext() == expected_context); | 7130 CHECK(details.GetEventContext() == expected_context); |
7112 CHECK_EQ(expected_callback_data, details.GetCallbackData()); | 7131 CHECK_EQ(expected_callback_data, details.GetCallbackData()); |
7113 } | 7132 } |
7114 | 7133 |
| 7134 |
7115 // Check that event details contain context where debug event occured. | 7135 // Check that event details contain context where debug event occured. |
7116 TEST(DebugEventContext) { | 7136 TEST(DebugEventContext) { |
7117 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 7137 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
7118 v8::HandleScope scope(isolate); | 7138 v8::HandleScope scope(isolate); |
7119 expected_callback_data = v8::Int32::New(2010); | 7139 expected_callback_data = v8::Int32::New(2010); |
7120 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, | 7140 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, |
7121 expected_callback_data); | 7141 expected_callback_data); |
7122 expected_context = v8::Context::New(isolate); | 7142 expected_context = v8::Context::New(isolate); |
7123 v8::Context::Scope context_scope(expected_context); | 7143 v8::Context::Scope context_scope(expected_context); |
7124 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); | 7144 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7574 TEST(LiveEditDisabled) { | 7594 TEST(LiveEditDisabled) { |
7575 v8::internal::FLAG_allow_natives_syntax = true; | 7595 v8::internal::FLAG_allow_natives_syntax = true; |
7576 LocalContext env; | 7596 LocalContext env; |
7577 v8::HandleScope scope(env->GetIsolate()); | 7597 v8::HandleScope scope(env->GetIsolate()); |
7578 v8::Debug::SetLiveEditEnabled(false); | 7598 v8::Debug::SetLiveEditEnabled(false); |
7579 CompileRun("%LiveEditCompareStrings('', '')"); | 7599 CompileRun("%LiveEditCompareStrings('', '')"); |
7580 } | 7600 } |
7581 | 7601 |
7582 | 7602 |
7583 #endif // ENABLE_DEBUGGER_SUPPORT | 7603 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |