| 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 5246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5257 v8::ObjectTemplate::New(env->GetIsolate()); | 5257 v8::ObjectTemplate::New(env->GetIsolate()); |
| 5258 global_template->Set( | 5258 global_template->Set( |
| 5259 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), | 5259 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), |
| 5260 v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1)); | 5260 v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1)); |
| 5261 v8::Handle<v8::Context> context = | 5261 v8::Handle<v8::Context> context = |
| 5262 v8::Context::New(isolate_, NULL, global_template); | 5262 v8::Context::New(isolate_, NULL, global_template); |
| 5263 v8::Context::Scope context_scope(context); | 5263 v8::Context::Scope context_scope(context); |
| 5264 | 5264 |
| 5265 CompileRun(source); | 5265 CompileRun(source); |
| 5266 } | 5266 } |
| 5267 threaded_debugging_barriers.barrier_4.Wait(); |
| 5267 isolate_->Dispose(); | 5268 isolate_->Dispose(); |
| 5268 } | 5269 } |
| 5269 | 5270 |
| 5270 | 5271 |
| 5271 void DebuggerThread::Run() { | 5272 void DebuggerThread::Run() { |
| 5272 const int kBufSize = 1000; | 5273 const int kBufSize = 1000; |
| 5273 uint16_t buffer[kBufSize]; | 5274 uint16_t buffer[kBufSize]; |
| 5274 | 5275 |
| 5275 const char* command_1 = "{\"seq\":102," | 5276 const char* command_1 = "{\"seq\":102," |
| 5276 "\"type\":\"request\"," | 5277 "\"type\":\"request\"," |
| 5277 "\"command\":\"evaluate\"," | 5278 "\"command\":\"evaluate\"," |
| 5278 "\"arguments\":{\"expression\":\"bar(false)\"}}"; | 5279 "\"arguments\":{\"expression\":\"bar(false)\"}}"; |
| 5279 const char* command_2 = "{\"seq\":103," | 5280 const char* command_2 = "{\"seq\":103," |
| 5280 "\"type\":\"request\"," | 5281 "\"type\":\"request\"," |
| 5281 "\"command\":\"continue\"}"; | 5282 "\"command\":\"continue\"}"; |
| 5282 | 5283 |
| 5283 threaded_debugging_barriers.barrier_1.Wait(); | 5284 threaded_debugging_barriers.barrier_1.Wait(); |
| 5284 v8::Debug::DebugBreak(isolate_); | 5285 v8::Debug::DebugBreak(isolate_); |
| 5285 threaded_debugging_barriers.barrier_2.Wait(); | 5286 threaded_debugging_barriers.barrier_2.Wait(); |
| 5286 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer)); | 5287 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer)); |
| 5287 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer)); | 5288 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer)); |
| 5289 threaded_debugging_barriers.barrier_4.Wait(); |
| 5288 } | 5290 } |
| 5289 | 5291 |
| 5290 | 5292 |
| 5291 TEST(ThreadedDebugging) { | 5293 TEST(ThreadedDebugging) { |
| 5292 V8Thread v8_thread; | 5294 V8Thread v8_thread; |
| 5293 | 5295 |
| 5294 // Create a V8 environment | 5296 // Create a V8 environment |
| 5295 v8_thread.Start(); | 5297 v8_thread.Start(); |
| 5296 threaded_debugging_barriers.barrier_3.Wait(); | 5298 threaded_debugging_barriers.barrier_3.Wait(); |
| 5297 DebuggerThread debugger_thread(v8_thread.isolate()); | 5299 DebuggerThread debugger_thread(v8_thread.isolate()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5381 v8::Isolate::Scope isolate_scope(isolate_); | 5383 v8::Isolate::Scope isolate_scope(isolate_); |
| 5382 DebugLocalContext env(isolate_); | 5384 DebugLocalContext env(isolate_); |
| 5383 v8::HandleScope scope(isolate_); | 5385 v8::HandleScope scope(isolate_); |
| 5384 v8::Debug::SetMessageHandler(&BreakpointsMessageHandler); | 5386 v8::Debug::SetMessageHandler(&BreakpointsMessageHandler); |
| 5385 | 5387 |
| 5386 CompileRun(source_1); | 5388 CompileRun(source_1); |
| 5387 breakpoints_barriers->barrier_1.Wait(); | 5389 breakpoints_barriers->barrier_1.Wait(); |
| 5388 breakpoints_barriers->barrier_2.Wait(); | 5390 breakpoints_barriers->barrier_2.Wait(); |
| 5389 CompileRun(source_2); | 5391 CompileRun(source_2); |
| 5390 } | 5392 } |
| 5393 breakpoints_barriers->barrier_4.Wait(); |
| 5391 isolate_->Dispose(); | 5394 isolate_->Dispose(); |
| 5392 } | 5395 } |
| 5393 | 5396 |
| 5394 | 5397 |
| 5395 void BreakpointsDebuggerThread::Run() { | 5398 void BreakpointsDebuggerThread::Run() { |
| 5396 const int kBufSize = 1000; | 5399 const int kBufSize = 1000; |
| 5397 uint16_t buffer[kBufSize]; | 5400 uint16_t buffer[kBufSize]; |
| 5398 | 5401 |
| 5399 const char* command_1 = "{\"seq\":101," | 5402 const char* command_1 = "{\"seq\":101," |
| 5400 "\"type\":\"request\"," | 5403 "\"type\":\"request\"," |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5496 // Must have hit breakpoint #1. | 5499 // Must have hit breakpoint #1. |
| 5497 CHECK_EQ(1, break_event_breakpoint_id); | 5500 CHECK_EQ(1, break_event_breakpoint_id); |
| 5498 // 8: Evaluate dog() with breaks disabled. | 5501 // 8: Evaluate dog() with breaks disabled. |
| 5499 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_7, buffer)); | 5502 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_7, buffer)); |
| 5500 // Evaluate dog() finishes. | 5503 // Evaluate dog() finishes. |
| 5501 breakpoints_barriers->semaphore_1.Wait(); | 5504 breakpoints_barriers->semaphore_1.Wait(); |
| 5502 // Must have result 116. | 5505 // Must have result 116. |
| 5503 CHECK_EQ(116, evaluate_int_result); | 5506 CHECK_EQ(116, evaluate_int_result); |
| 5504 // 9: Continue evaluation of source2, reach end. | 5507 // 9: Continue evaluation of source2, reach end. |
| 5505 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer)); | 5508 v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer)); |
| 5509 breakpoints_barriers->barrier_4.Wait(); |
| 5506 } | 5510 } |
| 5507 | 5511 |
| 5508 | 5512 |
| 5509 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { | 5513 void TestRecursiveBreakpointsGeneric(bool global_evaluate) { |
| 5510 BreakpointsV8Thread breakpoints_v8_thread; | 5514 BreakpointsV8Thread breakpoints_v8_thread; |
| 5511 | 5515 |
| 5512 // Create a V8 environment | 5516 // Create a V8 environment |
| 5513 Barriers stack_allocated_breakpoints_barriers; | 5517 Barriers stack_allocated_breakpoints_barriers; |
| 5514 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 5518 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
| 5515 | 5519 |
| (...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7583 env->Global()->Set(v8_str("fun"), fun->GetFunction()); | 7587 env->Global()->Set(v8_str("fun"), fun->GetFunction()); |
| 7584 | 7588 |
| 7585 CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); | 7589 CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); |
| 7586 CompileRun( | 7590 CompileRun( |
| 7587 "var r;" | 7591 "var r;" |
| 7588 "p.chain(function() { r = 'resolved'; }," | 7592 "p.chain(function() { r = 'resolved'; }," |
| 7589 " function(e) { r = 'rejected' + e; });"); | 7593 " function(e) { r = 'rejected' + e; });"); |
| 7590 CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection"))); | 7594 CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection"))); |
| 7591 CHECK_EQ(1, exception_event_counter); | 7595 CHECK_EQ(1, exception_event_counter); |
| 7592 } | 7596 } |
| OLD | NEW |