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 5124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5135 " while ( flag == true ) {\n" | 5135 " while ( flag == true ) {\n" |
5136 " if ( x == 1 ) {\n" | 5136 " if ( x == 1 ) {\n" |
5137 " ThreadedAtBarrier1();\n" | 5137 " ThreadedAtBarrier1();\n" |
5138 " }\n" | 5138 " }\n" |
5139 " x = x + 1;\n" | 5139 " x = x + 1;\n" |
5140 " }\n" | 5140 " }\n" |
5141 "}\n" | 5141 "}\n" |
5142 "\n" | 5142 "\n" |
5143 "foo();\n"; | 5143 "foo();\n"; |
5144 | 5144 |
5145 v8::V8::Initialize(); | 5145 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
5146 DebugLocalContext env; | 5146 DebugLocalContext env; |
5147 v8::HandleScope scope(env->GetIsolate()); | 5147 v8::HandleScope scope(env->GetIsolate()); |
5148 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); | 5148 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); |
5149 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5149 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5150 global_template->Set(v8::String::New("ThreadedAtBarrier1"), | 5150 global_template->Set(v8::String::New("ThreadedAtBarrier1"), |
5151 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5151 v8::FunctionTemplate::New(ThreadedAtBarrier1)); |
5152 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5152 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
5153 NULL, | 5153 NULL, |
5154 global_template); | 5154 global_template); |
5155 v8::Context::Scope context_scope(context); | 5155 v8::Context::Scope context_scope(context); |
(...skipping 16 matching lines...) Expand all Loading... |
5172 | 5172 |
5173 v8::Isolate* isolate = CcTest::isolate(); | 5173 v8::Isolate* isolate = CcTest::isolate(); |
5174 threaded_debugging_barriers.barrier_1.Wait(); | 5174 threaded_debugging_barriers.barrier_1.Wait(); |
5175 v8::Debug::DebugBreak(isolate); | 5175 v8::Debug::DebugBreak(isolate); |
5176 threaded_debugging_barriers.barrier_2.Wait(); | 5176 threaded_debugging_barriers.barrier_2.Wait(); |
5177 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); | 5177 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); |
5178 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); | 5178 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); |
5179 } | 5179 } |
5180 | 5180 |
5181 | 5181 |
5182 UNINITIALIZED_TEST(ThreadedDebugging) { | 5182 TEST(ThreadedDebugging) { |
5183 DebuggerThread debugger_thread; | 5183 DebuggerThread debugger_thread; |
5184 V8Thread v8_thread; | 5184 V8Thread v8_thread; |
5185 | 5185 |
5186 // Create a V8 environment | 5186 // Create a V8 environment |
5187 v8_thread.Start(); | 5187 v8_thread.Start(); |
5188 debugger_thread.Start(); | 5188 debugger_thread.Start(); |
5189 | 5189 |
5190 v8_thread.Join(); | 5190 v8_thread.Join(); |
5191 debugger_thread.Join(); | 5191 debugger_thread.Join(); |
5192 } | 5192 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5251 " var x = 1;\n" | 5251 " var x = 1;\n" |
5252 " x = y_global;" | 5252 " x = y_global;" |
5253 " var z = 3;" | 5253 " var z = 3;" |
5254 " x += 100;\n" | 5254 " x += 100;\n" |
5255 " return x;\n" | 5255 " return x;\n" |
5256 "}\n" | 5256 "}\n" |
5257 "\n"; | 5257 "\n"; |
5258 const char* source_2 = "cat(17);\n" | 5258 const char* source_2 = "cat(17);\n" |
5259 "cat(19);\n"; | 5259 "cat(19);\n"; |
5260 | 5260 |
5261 v8::V8::Initialize(); | 5261 v8::Isolate* isolate = CcTest::isolate(); |
| 5262 v8::Isolate::Scope isolate_scope(isolate); |
5262 DebugLocalContext env; | 5263 DebugLocalContext env; |
5263 v8::HandleScope scope(env->GetIsolate()); | 5264 v8::HandleScope scope(isolate); |
5264 v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler); | 5265 v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler); |
5265 | 5266 |
5266 CompileRun(source_1); | 5267 CompileRun(source_1); |
5267 breakpoints_barriers->barrier_1.Wait(); | 5268 breakpoints_barriers->barrier_1.Wait(); |
5268 breakpoints_barriers->barrier_2.Wait(); | 5269 breakpoints_barriers->barrier_2.Wait(); |
5269 CompileRun(source_2); | 5270 CompileRun(source_2); |
5270 } | 5271 } |
5271 | 5272 |
5272 | 5273 |
5273 void BreakpointsDebuggerThread::Run() { | 5274 void BreakpointsDebuggerThread::Run() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5326 "\"type\":\"request\"," | 5327 "\"type\":\"request\"," |
5327 "\"command\":\"evaluate\"," | 5328 "\"command\":\"evaluate\"," |
5328 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":true}}"; | 5329 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":true}}"; |
5329 } | 5330 } |
5330 const char* command_8 = "{\"seq\":108," | 5331 const char* command_8 = "{\"seq\":108," |
5331 "\"type\":\"request\"," | 5332 "\"type\":\"request\"," |
5332 "\"command\":\"continue\"}"; | 5333 "\"command\":\"continue\"}"; |
5333 | 5334 |
5334 | 5335 |
5335 v8::Isolate* isolate = CcTest::isolate(); | 5336 v8::Isolate* isolate = CcTest::isolate(); |
| 5337 v8::Isolate::Scope isolate_scope(isolate); |
5336 // v8 thread initializes, runs source_1 | 5338 // v8 thread initializes, runs source_1 |
5337 breakpoints_barriers->barrier_1.Wait(); | 5339 breakpoints_barriers->barrier_1.Wait(); |
5338 // 1:Set breakpoint in cat() (will get id 1). | 5340 // 1:Set breakpoint in cat() (will get id 1). |
5339 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); | 5341 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); |
5340 // 2:Set breakpoint in dog() (will get id 2). | 5342 // 2:Set breakpoint in dog() (will get id 2). |
5341 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); | 5343 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); |
5342 breakpoints_barriers->barrier_2.Wait(); | 5344 breakpoints_barriers->barrier_2.Wait(); |
5343 // V8 thread starts compiling source_2. | 5345 // V8 thread starts compiling source_2. |
5344 // Automatic break happens, to run queued commands | 5346 // Automatic break happens, to run queued commands |
5345 // breakpoints_barriers->semaphore_1.Wait(); | 5347 // breakpoints_barriers->semaphore_1.Wait(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5396 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 5398 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
5397 | 5399 |
5398 breakpoints_v8_thread.Start(); | 5400 breakpoints_v8_thread.Start(); |
5399 breakpoints_debugger_thread.Start(); | 5401 breakpoints_debugger_thread.Start(); |
5400 | 5402 |
5401 breakpoints_v8_thread.Join(); | 5403 breakpoints_v8_thread.Join(); |
5402 breakpoints_debugger_thread.Join(); | 5404 breakpoints_debugger_thread.Join(); |
5403 } | 5405 } |
5404 | 5406 |
5405 | 5407 |
5406 UNINITIALIZED_TEST(RecursiveBreakpoints) { | 5408 TEST(RecursiveBreakpoints) { |
5407 TestRecursiveBreakpointsGeneric(false); | 5409 TestRecursiveBreakpointsGeneric(false); |
5408 } | 5410 } |
5409 | 5411 |
5410 | 5412 |
5411 UNINITIALIZED_TEST(RecursiveBreakpointsGlobal) { | 5413 TEST(RecursiveBreakpointsGlobal) { |
5412 TestRecursiveBreakpointsGeneric(true); | 5414 TestRecursiveBreakpointsGeneric(true); |
5413 } | 5415 } |
5414 | 5416 |
5415 | 5417 |
5416 static void DummyDebugEventListener( | 5418 static void DummyDebugEventListener( |
5417 const v8::Debug::EventDetails& event_details) { | 5419 const v8::Debug::EventDetails& event_details) { |
5418 } | 5420 } |
5419 | 5421 |
5420 | 5422 |
5421 TEST(SetDebugEventListenerOnUninitializedVM) { | 5423 TEST(SetDebugEventListenerOnUninitializedVM) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5782 "function cat( new_value ) {\n" | 5784 "function cat( new_value ) {\n" |
5783 " var x = new_value;\n" | 5785 " var x = new_value;\n" |
5784 " y_global = 4;\n" | 5786 " y_global = 4;\n" |
5785 " x = 3 * x + 1;\n" | 5787 " x = 3 * x + 1;\n" |
5786 " y_global = 5;\n" | 5788 " y_global = 5;\n" |
5787 " return x;\n" | 5789 " return x;\n" |
5788 "}\n" | 5790 "}\n" |
5789 "\n"; | 5791 "\n"; |
5790 const char* source_2 = "cat(17);\n"; | 5792 const char* source_2 = "cat(17);\n"; |
5791 | 5793 |
5792 v8::V8::Initialize(); | 5794 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
5793 DebugLocalContext env; | 5795 DebugLocalContext env; |
5794 v8::HandleScope scope(env->GetIsolate()); | 5796 v8::HandleScope scope(env->GetIsolate()); |
5795 | 5797 |
5796 // Set up message and host dispatch handlers. | 5798 // Set up message and host dispatch handlers. |
5797 v8::Debug::SetMessageHandler2(HostDispatchMessageHandler); | 5799 v8::Debug::SetMessageHandler2(HostDispatchMessageHandler); |
5798 v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */); | 5800 v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */); |
5799 | 5801 |
5800 CompileRun(source_1); | 5802 CompileRun(source_1); |
5801 host_dispatch_barriers->barrier_1.Wait(); | 5803 host_dispatch_barriers->barrier_1.Wait(); |
5802 host_dispatch_barriers->barrier_2.Wait(); | 5804 host_dispatch_barriers->barrier_2.Wait(); |
(...skipping 22 matching lines...) Expand all Loading... |
5825 host_dispatch_barriers->barrier_2.Wait(); | 5827 host_dispatch_barriers->barrier_2.Wait(); |
5826 // v8 thread starts compiling source_2. | 5828 // v8 thread starts compiling source_2. |
5827 // Break happens, to run queued commands and host dispatches. | 5829 // Break happens, to run queued commands and host dispatches. |
5828 // Wait for host dispatch to be processed. | 5830 // Wait for host dispatch to be processed. |
5829 host_dispatch_barriers->semaphore_1.Wait(); | 5831 host_dispatch_barriers->semaphore_1.Wait(); |
5830 // 2: Continue evaluation | 5832 // 2: Continue evaluation |
5831 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); | 5833 v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); |
5832 } | 5834 } |
5833 | 5835 |
5834 | 5836 |
5835 UNINITIALIZED_TEST(DebuggerHostDispatch) { | 5837 TEST(DebuggerHostDispatch) { |
5836 HostDispatchDebuggerThread host_dispatch_debugger_thread; | 5838 HostDispatchDebuggerThread host_dispatch_debugger_thread; |
5837 HostDispatchV8Thread host_dispatch_v8_thread; | 5839 HostDispatchV8Thread host_dispatch_v8_thread; |
5838 i::FLAG_debugger_auto_break = true; | 5840 i::FLAG_debugger_auto_break = true; |
5839 | 5841 |
5840 // Create a V8 environment | 5842 // Create a V8 environment |
5841 Barriers stack_allocated_host_dispatch_barriers; | 5843 Barriers stack_allocated_host_dispatch_barriers; |
5842 host_dispatch_barriers = &stack_allocated_host_dispatch_barriers; | 5844 host_dispatch_barriers = &stack_allocated_host_dispatch_barriers; |
5843 | 5845 |
5844 host_dispatch_v8_thread.Start(); | 5846 host_dispatch_v8_thread.Start(); |
5845 host_dispatch_debugger_thread.Start(); | 5847 host_dispatch_debugger_thread.Start(); |
(...skipping 24 matching lines...) Expand all Loading... |
5870 | 5872 |
5871 Barriers* debug_message_dispatch_barriers; | 5873 Barriers* debug_message_dispatch_barriers; |
5872 | 5874 |
5873 | 5875 |
5874 static void DebugMessageHandler() { | 5876 static void DebugMessageHandler() { |
5875 debug_message_dispatch_barriers->semaphore_1.Signal(); | 5877 debug_message_dispatch_barriers->semaphore_1.Signal(); |
5876 } | 5878 } |
5877 | 5879 |
5878 | 5880 |
5879 void DebugMessageDispatchV8Thread::Run() { | 5881 void DebugMessageDispatchV8Thread::Run() { |
5880 v8::V8::Initialize(); | 5882 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
5881 DebugLocalContext env; | 5883 DebugLocalContext env; |
5882 v8::HandleScope scope(env->GetIsolate()); | 5884 v8::HandleScope scope(env->GetIsolate()); |
5883 | 5885 |
5884 // Set up debug message dispatch handler. | 5886 // Set up debug message dispatch handler. |
5885 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler); | 5887 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler); |
5886 | 5888 |
5887 CompileRun("var y = 1 + 2;\n"); | 5889 CompileRun("var y = 1 + 2;\n"); |
5888 debug_message_dispatch_barriers->barrier_1.Wait(); | 5890 debug_message_dispatch_barriers->barrier_1.Wait(); |
5889 debug_message_dispatch_barriers->semaphore_1.Wait(); | 5891 debug_message_dispatch_barriers->semaphore_1.Wait(); |
5890 debug_message_dispatch_barriers->barrier_2.Wait(); | 5892 debug_message_dispatch_barriers->barrier_2.Wait(); |
5891 } | 5893 } |
5892 | 5894 |
5893 | 5895 |
5894 void DebugMessageDispatchDebuggerThread::Run() { | 5896 void DebugMessageDispatchDebuggerThread::Run() { |
5895 debug_message_dispatch_barriers->barrier_1.Wait(); | 5897 debug_message_dispatch_barriers->barrier_1.Wait(); |
5896 SendContinueCommand(); | 5898 SendContinueCommand(); |
5897 debug_message_dispatch_barriers->barrier_2.Wait(); | 5899 debug_message_dispatch_barriers->barrier_2.Wait(); |
5898 } | 5900 } |
5899 | 5901 |
5900 | 5902 |
5901 UNINITIALIZED_TEST(DebuggerDebugMessageDispatch) { | 5903 TEST(DebuggerDebugMessageDispatch) { |
5902 DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread; | 5904 DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread; |
5903 DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread; | 5905 DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread; |
5904 | 5906 |
5905 i::FLAG_debugger_auto_break = true; | 5907 i::FLAG_debugger_auto_break = true; |
5906 | 5908 |
5907 // Create a V8 environment | 5909 // Create a V8 environment |
5908 Barriers stack_allocated_debug_message_dispatch_barriers; | 5910 Barriers stack_allocated_debug_message_dispatch_barriers; |
5909 debug_message_dispatch_barriers = | 5911 debug_message_dispatch_barriers = |
5910 &stack_allocated_debug_message_dispatch_barriers; | 5912 &stack_allocated_debug_message_dispatch_barriers; |
5911 | 5913 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6356 last_function_hit[0] = '\0'; | 6358 last_function_hit[0] = '\0'; |
6357 } else { | 6359 } else { |
6358 CHECK(result->IsString()); | 6360 CHECK(result->IsString()); |
6359 v8::Handle<v8::String> function_name(result->ToString()); | 6361 v8::Handle<v8::String> function_name(result->ToString()); |
6360 function_name->WriteUtf8(last_function_hit); | 6362 function_name->WriteUtf8(last_function_hit); |
6361 } | 6363 } |
6362 } | 6364 } |
6363 | 6365 |
6364 // Keep forcing breaks. | 6366 // Keep forcing breaks. |
6365 if (break_point_hit_count < 20) { | 6367 if (break_point_hit_count < 20) { |
6366 v8::Debug::DebugBreak(); | 6368 v8::Debug::DebugBreak(CcTest::isolate()); |
6367 } | 6369 } |
6368 } | 6370 } |
6369 } | 6371 } |
6370 | 6372 |
6371 | 6373 |
6372 UNINITIALIZED_TEST(RegExpDebugBreak) { | 6374 TEST(RegExpDebugBreak) { |
6373 // This test only applies to native regexps. | 6375 // This test only applies to native regexps. |
6374 DebugLocalContext env; | 6376 DebugLocalContext env; |
6375 v8::HandleScope scope(env->GetIsolate()); | 6377 v8::HandleScope scope(env->GetIsolate()); |
6376 | 6378 |
6377 // Create a function for checking the function when hitting a break point. | 6379 // Create a function for checking the function when hitting a break point. |
6378 frame_function_name = CompileFunction(&env, | 6380 frame_function_name = CompileFunction(&env, |
6379 frame_function_name_source, | 6381 frame_function_name_source, |
6380 "frame_function_name"); | 6382 "frame_function_name"); |
6381 | 6383 |
6382 // Test RegExp which matches white spaces and comments at the begining of a | 6384 // Test RegExp which matches white spaces and comments at the begining of a |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6798 isolate->stack_guard()->DebugBreak(); | 6800 isolate->stack_guard()->DebugBreak(); |
6799 } else { | 6801 } else { |
6800 isolate->stack_guard()->Continue(i::DEBUGBREAK); | 6802 isolate->stack_guard()->Continue(i::DEBUGBREAK); |
6801 } | 6803 } |
6802 } | 6804 } |
6803 } | 6805 } |
6804 | 6806 |
6805 | 6807 |
6806 // Test that if DebugBreak is forced it is ignored when code from | 6808 // Test that if DebugBreak is forced it is ignored when code from |
6807 // debug-delay.js is executed. | 6809 // debug-delay.js is executed. |
6808 UNINITIALIZED_TEST(NoDebugBreakInAfterCompileMessageHandler) { | 6810 TEST(NoDebugBreakInAfterCompileMessageHandler) { |
6809 DebugLocalContext env; | 6811 DebugLocalContext env; |
6810 v8::HandleScope scope(env->GetIsolate()); | 6812 v8::HandleScope scope(env->GetIsolate()); |
6811 | 6813 |
6812 // Register a debug event listener which sets the break flag and counts. | 6814 // Register a debug event listener which sets the break flag and counts. |
6813 v8::Debug::SetMessageHandler2(BreakMessageHandler); | 6815 v8::Debug::SetMessageHandler2(BreakMessageHandler); |
6814 | 6816 |
6815 // Set the debug break flag. | 6817 // Set the debug break flag. |
6816 v8::Debug::DebugBreak(); | 6818 v8::Debug::DebugBreak(env->GetIsolate()); |
6817 | 6819 |
6818 // Create a function for testing stepping. | 6820 // Create a function for testing stepping. |
6819 const char* src = "function f() { eval('var x = 10;'); } "; | 6821 const char* src = "function f() { eval('var x = 10;'); } "; |
6820 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); | 6822 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); |
6821 | 6823 |
6822 // There should be only one break event. | 6824 // There should be only one break event. |
6823 CHECK_EQ(1, break_point_hit_count); | 6825 CHECK_EQ(1, break_point_hit_count); |
6824 | 6826 |
6825 // Set the debug break flag again. | 6827 // Set the debug break flag again. |
6826 v8::Debug::DebugBreak(env->GetIsolate()); | 6828 v8::Debug::DebugBreak(env->GetIsolate()); |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7549 TEST(LiveEditDisabled) { | 7551 TEST(LiveEditDisabled) { |
7550 v8::internal::FLAG_allow_natives_syntax = true; | 7552 v8::internal::FLAG_allow_natives_syntax = true; |
7551 LocalContext env; | 7553 LocalContext env; |
7552 v8::HandleScope scope(env->GetIsolate()); | 7554 v8::HandleScope scope(env->GetIsolate()); |
7553 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); | 7555 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); |
7554 CompileRun("%LiveEditCompareStrings('', '')"); | 7556 CompileRun("%LiveEditCompareStrings('', '')"); |
7555 } | 7557 } |
7556 | 7558 |
7557 | 7559 |
7558 #endif // ENABLE_DEBUGGER_SUPPORT | 7560 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |