| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 using ::v8::internal::EmbeddedVector; | 39 using ::v8::internal::EmbeddedVector; |
| 40 using ::v8::internal::Object; | 40 using ::v8::internal::Object; |
| 41 using ::v8::internal::OS; | 41 using ::v8::internal::OS; |
| 42 using ::v8::internal::Handle; | 42 using ::v8::internal::Handle; |
| 43 using ::v8::internal::Heap; | 43 using ::v8::internal::Heap; |
| 44 using ::v8::internal::JSGlobalProxy; | 44 using ::v8::internal::JSGlobalProxy; |
| 45 using ::v8::internal::Code; | 45 using ::v8::internal::Code; |
| 46 using ::v8::internal::Debug; | 46 using ::v8::internal::Debug; |
| 47 using ::v8::internal::Debugger; | 47 using ::v8::internal::Debugger; |
| 48 using ::v8::internal::Message; |
| 49 using ::v8::internal::MessageQueue; |
| 48 using ::v8::internal::StepAction; | 50 using ::v8::internal::StepAction; |
| 49 using ::v8::internal::StepIn; // From StepAction enum | 51 using ::v8::internal::StepIn; // From StepAction enum |
| 50 using ::v8::internal::StepNext; // From StepAction enum | 52 using ::v8::internal::StepNext; // From StepAction enum |
| 51 using ::v8::internal::StepOut; // From StepAction enum | 53 using ::v8::internal::StepOut; // From StepAction enum |
| 54 using ::v8::internal::Vector; |
| 52 | 55 |
| 53 | 56 |
| 54 // Size of temp buffer for formatting small strings. | 57 // Size of temp buffer for formatting small strings. |
| 55 #define SMALL_STRING_BUFFER_SIZE 80 | 58 #define SMALL_STRING_BUFFER_SIZE 80 |
| 56 | 59 |
| 57 // --- A d d i t i o n a l C h e c k H e l p e r s | 60 // --- A d d i t i o n a l C h e c k H e l p e r s |
| 58 | 61 |
| 59 | 62 |
| 60 // Helper function used by the CHECK_EQ function when given Address | 63 // Helper function used by the CHECK_EQ function when given Address |
| 61 // arguments. Should not be called directly. | 64 // arguments. Should not be called directly. |
| (...skipping 3306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3368 */ | 3371 */ |
| 3369 Barriers message_queue_barriers; | 3372 Barriers message_queue_barriers; |
| 3370 | 3373 |
| 3371 // This is the debugger thread, that executes no v8 calls except | 3374 // This is the debugger thread, that executes no v8 calls except |
| 3372 // placing JSON debugger commands in the queue. | 3375 // placing JSON debugger commands in the queue. |
| 3373 class MessageQueueDebuggerThread : public v8::internal::Thread { | 3376 class MessageQueueDebuggerThread : public v8::internal::Thread { |
| 3374 public: | 3377 public: |
| 3375 void Run(); | 3378 void Run(); |
| 3376 }; | 3379 }; |
| 3377 | 3380 |
| 3378 static void MessageHandler(const uint16_t* message, int length, void *data) { | 3381 static void MessageHandler(const uint16_t* message, int length, |
| 3382 v8::Debug::ClientData* client_data) { |
| 3379 static char print_buffer[1000]; | 3383 static char print_buffer[1000]; |
| 3380 Utf16ToAscii(message, length, print_buffer); | 3384 Utf16ToAscii(message, length, print_buffer); |
| 3381 if (IsBreakEventMessage(print_buffer)) { | 3385 if (IsBreakEventMessage(print_buffer)) { |
| 3382 // Lets test script wait until break occurs to send commands. | 3386 // Lets test script wait until break occurs to send commands. |
| 3383 // Signals when a break is reported. | 3387 // Signals when a break is reported. |
| 3384 message_queue_barriers.semaphore_2->Signal(); | 3388 message_queue_barriers.semaphore_2->Signal(); |
| 3385 } | 3389 } |
| 3386 // Allow message handler to block on a semaphore, to test queueing of | 3390 // Allow message handler to block on a semaphore, to test queueing of |
| 3387 // messages while blocked. | 3391 // messages while blocked. |
| 3388 message_queue_barriers.semaphore_1->Wait(); | 3392 message_queue_barriers.semaphore_1->Wait(); |
| 3389 printf("%s\n", print_buffer); | 3393 printf("%s\n", print_buffer); |
| 3390 fflush(stdout); | 3394 fflush(stdout); |
| 3391 } | 3395 } |
| 3392 | 3396 |
| 3393 | |
| 3394 void MessageQueueDebuggerThread::Run() { | 3397 void MessageQueueDebuggerThread::Run() { |
| 3395 const int kBufferSize = 1000; | 3398 const int kBufferSize = 1000; |
| 3396 uint16_t buffer_1[kBufferSize]; | 3399 uint16_t buffer_1[kBufferSize]; |
| 3397 uint16_t buffer_2[kBufferSize]; | 3400 uint16_t buffer_2[kBufferSize]; |
| 3398 const char* command_1 = | 3401 const char* command_1 = |
| 3399 "{\"seq\":117," | 3402 "{\"seq\":117," |
| 3400 "\"type\":\"request\"," | 3403 "\"type\":\"request\"," |
| 3401 "\"command\":\"evaluate\"," | 3404 "\"command\":\"evaluate\"," |
| 3402 "\"arguments\":{\"expression\":\"1+2\"}}"; | 3405 "\"arguments\":{\"expression\":\"1+2\"}}"; |
| 3403 const char* command_2 = | 3406 const char* command_2 = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3474 CompileRun(source_1); | 3477 CompileRun(source_1); |
| 3475 message_queue_barriers.barrier_1.Wait(); | 3478 message_queue_barriers.barrier_1.Wait(); |
| 3476 message_queue_barriers.barrier_2.Wait(); | 3479 message_queue_barriers.barrier_2.Wait(); |
| 3477 CompileRun(source_2); | 3480 CompileRun(source_2); |
| 3478 message_queue_barriers.barrier_3.Wait(); | 3481 message_queue_barriers.barrier_3.Wait(); |
| 3479 CompileRun(source_3); | 3482 CompileRun(source_3); |
| 3480 message_queue_debugger_thread.Join(); | 3483 message_queue_debugger_thread.Join(); |
| 3481 fflush(stdout); | 3484 fflush(stdout); |
| 3482 } | 3485 } |
| 3483 | 3486 |
| 3487 |
| 3488 class TestClientData : public v8::Debug::ClientData { |
| 3489 public: |
| 3490 TestClientData() { |
| 3491 constructor_call_counter++; |
| 3492 } |
| 3493 virtual ~TestClientData() { |
| 3494 destructor_call_counter++; |
| 3495 } |
| 3496 |
| 3497 static void ResetCounters() { |
| 3498 constructor_call_counter = 0; |
| 3499 destructor_call_counter = 0; |
| 3500 } |
| 3501 |
| 3502 static int constructor_call_counter; |
| 3503 static int destructor_call_counter; |
| 3504 }; |
| 3505 |
| 3506 int TestClientData::constructor_call_counter = 0; |
| 3507 int TestClientData::destructor_call_counter = 0; |
| 3508 |
| 3509 |
| 3510 // Tests that MessageQueue doesn't destroy client data when expands and |
| 3511 // does destroy when it dies. |
| 3512 TEST(MessageQueueExpandAndDestroy) { |
| 3513 TestClientData::ResetCounters(); |
| 3514 { // Create a scope for the queue. |
| 3515 MessageQueue queue(1); |
| 3516 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), |
| 3517 new TestClientData())); |
| 3518 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), |
| 3519 new TestClientData())); |
| 3520 queue.Put(Message::NewHostDispatch(new TestClientData())); |
| 3521 ASSERT_EQ(0, TestClientData::destructor_call_counter); |
| 3522 queue.Get().Dispose(); |
| 3523 ASSERT_EQ(1, TestClientData::destructor_call_counter); |
| 3524 queue.Put(Message::NewHostDispatch(new TestClientData())); |
| 3525 queue.Put(Message::NewHostDispatch(new TestClientData())); |
| 3526 queue.Put(Message::NewHostDispatch(new TestClientData())); |
| 3527 queue.Put(Message::NewOutput(v8::Handle<v8::String>(), |
| 3528 new TestClientData())); |
| 3529 queue.Put(Message::NewEmptyMessage()); |
| 3530 ASSERT_EQ(1, TestClientData::destructor_call_counter); |
| 3531 queue.Get().Dispose(); |
| 3532 ASSERT_EQ(2, TestClientData::destructor_call_counter); |
| 3533 } |
| 3534 // All the client data should be destroyed when the queue is destroyed. |
| 3535 ASSERT_EQ(TestClientData::destructor_call_counter, |
| 3536 TestClientData::destructor_call_counter); |
| 3537 } |
| 3538 |
| 3539 |
| 3540 static int handled_client_data_instances_count = 0; |
| 3541 static void MessageHandlerCountingClientData( |
| 3542 const uint16_t* message, |
| 3543 int length, |
| 3544 v8::Debug::ClientData* client_data) { |
| 3545 if (client_data) { |
| 3546 handled_client_data_instances_count++; |
| 3547 } |
| 3548 } |
| 3549 |
| 3550 |
| 3551 // Tests that all client data passed to the debugger are sent to the handler. |
| 3552 TEST(SendClientDataToHandler) { |
| 3553 // Create a V8 environment |
| 3554 v8::HandleScope scope; |
| 3555 DebugLocalContext env; |
| 3556 TestClientData::ResetCounters(); |
| 3557 handled_client_data_instances_count = 0; |
| 3558 v8::Debug::SetMessageHandler(MessageHandlerCountingClientData, |
| 3559 false /* message_handler_thread */); |
| 3560 const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5; debugger;"; |
| 3561 const int kBufferSize = 1000; |
| 3562 uint16_t buffer[kBufferSize]; |
| 3563 const char* command_1 = |
| 3564 "{\"seq\":117," |
| 3565 "\"type\":\"request\"," |
| 3566 "\"command\":\"evaluate\"," |
| 3567 "\"arguments\":{\"expression\":\"1+2\"}}"; |
| 3568 const char* command_2 = |
| 3569 "{\"seq\":118," |
| 3570 "\"type\":\"request\"," |
| 3571 "\"command\":\"evaluate\"," |
| 3572 "\"arguments\":{\"expression\":\"1+a\"}}"; |
| 3573 const char* command_continue = |
| 3574 "{\"seq\":106," |
| 3575 "\"type\":\"request\"," |
| 3576 "\"command\":\"continue\"}"; |
| 3577 |
| 3578 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer), |
| 3579 new TestClientData()); |
| 3580 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer), NULL); |
| 3581 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer), |
| 3582 new TestClientData()); |
| 3583 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer), |
| 3584 new TestClientData()); |
| 3585 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); |
| 3586 CompileRun(source_1); |
| 3587 ASSERT_EQ(3, TestClientData::constructor_call_counter); |
| 3588 ASSERT_EQ(TestClientData::constructor_call_counter, |
| 3589 handled_client_data_instances_count); |
| 3590 ASSERT_EQ(TestClientData::constructor_call_counter, |
| 3591 TestClientData::destructor_call_counter); |
| 3592 } |
| 3593 |
| 3594 |
| 3484 /* Test ThreadedDebugging */ | 3595 /* Test ThreadedDebugging */ |
| 3485 /* This test interrupts a running infinite loop that is | 3596 /* This test interrupts a running infinite loop that is |
| 3486 * occupying the v8 thread by a break command from the | 3597 * occupying the v8 thread by a break command from the |
| 3487 * debugger thread. It then changes the value of a | 3598 * debugger thread. It then changes the value of a |
| 3488 * global object, to make the loop terminate. | 3599 * global object, to make the loop terminate. |
| 3489 */ | 3600 */ |
| 3490 | 3601 |
| 3491 Barriers threaded_debugging_barriers; | 3602 Barriers threaded_debugging_barriers; |
| 3492 | 3603 |
| 3493 class V8Thread : public v8::internal::Thread { | 3604 class V8Thread : public v8::internal::Thread { |
| 3494 public: | 3605 public: |
| 3495 void Run(); | 3606 void Run(); |
| 3496 }; | 3607 }; |
| 3497 | 3608 |
| 3498 class DebuggerThread : public v8::internal::Thread { | 3609 class DebuggerThread : public v8::internal::Thread { |
| 3499 public: | 3610 public: |
| 3500 void Run(); | 3611 void Run(); |
| 3501 }; | 3612 }; |
| 3502 | 3613 |
| 3503 | 3614 |
| 3504 static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) { | 3615 static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) { |
| 3505 threaded_debugging_barriers.barrier_1.Wait(); | 3616 threaded_debugging_barriers.barrier_1.Wait(); |
| 3506 return v8::Undefined(); | 3617 return v8::Undefined(); |
| 3507 } | 3618 } |
| 3508 | 3619 |
| 3509 | 3620 |
| 3510 static void ThreadedMessageHandler(const uint16_t* message, int length, | 3621 static void ThreadedMessageHandler(const uint16_t* message, int length, |
| 3511 void *data) { | 3622 v8::Debug::ClientData* client_data) { |
| 3512 static char print_buffer[1000]; | 3623 static char print_buffer[1000]; |
| 3513 Utf16ToAscii(message, length, print_buffer); | 3624 Utf16ToAscii(message, length, print_buffer); |
| 3514 if (IsBreakEventMessage(print_buffer)) { | 3625 if (IsBreakEventMessage(print_buffer)) { |
| 3515 threaded_debugging_barriers.barrier_2.Wait(); | 3626 threaded_debugging_barriers.barrier_2.Wait(); |
| 3516 } | 3627 } |
| 3517 printf("%s\n", print_buffer); | 3628 printf("%s\n", print_buffer); |
| 3518 fflush(stdout); | 3629 fflush(stdout); |
| 3519 } | 3630 } |
| 3520 | 3631 |
| 3521 | 3632 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 class BreakpointsDebuggerThread : public v8::internal::Thread { | 3710 class BreakpointsDebuggerThread : public v8::internal::Thread { |
| 3600 public: | 3711 public: |
| 3601 void Run(); | 3712 void Run(); |
| 3602 }; | 3713 }; |
| 3603 | 3714 |
| 3604 | 3715 |
| 3605 Barriers* breakpoints_barriers; | 3716 Barriers* breakpoints_barriers; |
| 3606 | 3717 |
| 3607 static void BreakpointsMessageHandler(const uint16_t* message, | 3718 static void BreakpointsMessageHandler(const uint16_t* message, |
| 3608 int length, | 3719 int length, |
| 3609 void *data) { | 3720 v8::Debug::ClientData* client_data) { |
| 3610 static char print_buffer[1000]; | 3721 static char print_buffer[1000]; |
| 3611 Utf16ToAscii(message, length, print_buffer); | 3722 Utf16ToAscii(message, length, print_buffer); |
| 3612 printf("%s\n", print_buffer); | 3723 printf("%s\n", print_buffer); |
| 3613 fflush(stdout); | 3724 fflush(stdout); |
| 3614 | 3725 |
| 3615 // Is break_template a prefix of the message? | 3726 // Is break_template a prefix of the message? |
| 3616 if (IsBreakEventMessage(print_buffer)) { | 3727 if (IsBreakEventMessage(print_buffer)) { |
| 3617 breakpoints_barriers->semaphore_1->Signal(); | 3728 breakpoints_barriers->semaphore_1->Signal(); |
| 3618 } | 3729 } |
| 3619 } | 3730 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3745 v8::Handle<v8::Value> data) { | 3856 v8::Handle<v8::Value> data) { |
| 3746 } | 3857 } |
| 3747 | 3858 |
| 3748 | 3859 |
| 3749 TEST(SetDebugEventListenerOnUninitializedVM) { | 3860 TEST(SetDebugEventListenerOnUninitializedVM) { |
| 3750 v8::Debug::SetDebugEventListener(DummyDebugEventListener); | 3861 v8::Debug::SetDebugEventListener(DummyDebugEventListener); |
| 3751 } | 3862 } |
| 3752 | 3863 |
| 3753 | 3864 |
| 3754 static void DummyMessageHandler(const uint16_t* message, | 3865 static void DummyMessageHandler(const uint16_t* message, |
| 3755 int length, void *data) { | 3866 int length, |
| 3867 v8::Debug::ClientData* client_data) { |
| 3756 } | 3868 } |
| 3757 | 3869 |
| 3758 | 3870 |
| 3759 TEST(SetMessageHandlerOnUninitializedVM) { | 3871 TEST(SetMessageHandlerOnUninitializedVM) { |
| 3760 v8::Debug::SetMessageHandler(DummyMessageHandler); | 3872 v8::Debug::SetMessageHandler(DummyMessageHandler); |
| 3761 } | 3873 } |
| 3762 | 3874 |
| 3763 | 3875 |
| 3764 TEST(DebugBreakOnUninitializedVM) { | 3876 TEST(DebugBreakOnUninitializedVM) { |
| 3765 v8::Debug::DebugBreak(); | 3877 v8::Debug::DebugBreak(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3971 | 4083 |
| 3972 // Remove the debug event listener without clearing breakpoints again. | 4084 // Remove the debug event listener without clearing breakpoints again. |
| 3973 v8::Debug::SetDebugEventListener(NULL); | 4085 v8::Debug::SetDebugEventListener(NULL); |
| 3974 CheckDebuggerUnloaded(true); | 4086 CheckDebuggerUnloaded(true); |
| 3975 } | 4087 } |
| 3976 | 4088 |
| 3977 | 4089 |
| 3978 // Debugger message handler which counts the number of times it is called. | 4090 // Debugger message handler which counts the number of times it is called. |
| 3979 static int message_handler_hit_count = 0; | 4091 static int message_handler_hit_count = 0; |
| 3980 static void MessageHandlerHitCount(const uint16_t* message, | 4092 static void MessageHandlerHitCount(const uint16_t* message, |
| 3981 int length, void* data) { | 4093 int length, |
| 4094 v8::Debug::ClientData* client_data) { |
| 3982 message_handler_hit_count++; | 4095 message_handler_hit_count++; |
| 3983 | 4096 |
| 3984 const int kBufferSize = 1000; | 4097 const int kBufferSize = 1000; |
| 3985 uint16_t buffer[kBufferSize]; | 4098 uint16_t buffer[kBufferSize]; |
| 3986 const char* command_continue = | 4099 const char* command_continue = |
| 3987 "{\"seq\":0," | 4100 "{\"seq\":0," |
| 3988 "\"type\":\"request\"," | 4101 "\"type\":\"request\"," |
| 3989 "\"command\":\"continue\"}"; | 4102 "\"command\":\"continue\"}"; |
| 3990 | 4103 |
| 3991 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); | 4104 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4019 CompileRun("throw 1"); | 4132 CompileRun("throw 1"); |
| 4020 | 4133 |
| 4021 // The message handler should not be called more. | 4134 // The message handler should not be called more. |
| 4022 CHECK_EQ(0, message_handler_hit_count); | 4135 CHECK_EQ(0, message_handler_hit_count); |
| 4023 | 4136 |
| 4024 CheckDebuggerUnloaded(true); | 4137 CheckDebuggerUnloaded(true); |
| 4025 } | 4138 } |
| 4026 | 4139 |
| 4027 | 4140 |
| 4028 // Debugger message handler which clears the message handler while active. | 4141 // Debugger message handler which clears the message handler while active. |
| 4029 static void MessageHandlerClearingMessageHandler(const uint16_t* message, | 4142 static void MessageHandlerClearingMessageHandler( |
| 4030 int length, | 4143 const uint16_t* message, |
| 4031 void* data) { | 4144 int length, |
| 4145 v8::Debug::ClientData* client_data) { |
| 4032 message_handler_hit_count++; | 4146 message_handler_hit_count++; |
| 4033 | 4147 |
| 4034 // Clear debug message handler. | 4148 // Clear debug message handler. |
| 4035 v8::Debug::SetMessageHandler(NULL); | 4149 v8::Debug::SetMessageHandler(NULL); |
| 4036 } | 4150 } |
| 4037 | 4151 |
| 4038 | 4152 |
| 4039 // Test clearing the debug message handler while processing a debug event. | 4153 // Test clearing the debug message handler while processing a debug event. |
| 4040 TEST(DebuggerClearMessageHandlerWhileActive) { | 4154 TEST(DebuggerClearMessageHandlerWhileActive) { |
| 4041 v8::HandleScope scope; | 4155 v8::HandleScope scope; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4052 CompileRun("throw 1"); | 4166 CompileRun("throw 1"); |
| 4053 | 4167 |
| 4054 // The message handler should be called. | 4168 // The message handler should be called. |
| 4055 CHECK_EQ(1, message_handler_hit_count); | 4169 CHECK_EQ(1, message_handler_hit_count); |
| 4056 | 4170 |
| 4057 CheckDebuggerUnloaded(true); | 4171 CheckDebuggerUnloaded(true); |
| 4058 } | 4172 } |
| 4059 | 4173 |
| 4060 | 4174 |
| 4061 int host_dispatch_hit_count = 0; | 4175 int host_dispatch_hit_count = 0; |
| 4062 static void HostDispatchHandlerHitCount(void* dispatch, void *data) { | 4176 static void HostDispatchHandlerHitCount(v8::Debug::ClientData* dispatch) { |
| 4063 host_dispatch_hit_count++; | 4177 host_dispatch_hit_count++; |
| 4064 } | 4178 } |
| 4065 | 4179 |
| 4066 | 4180 |
| 4067 // Test that clearing the debug event listener actually clears all break points | 4181 // Test that clearing the debug event listener actually clears all break points |
| 4068 // and related information. | 4182 // and related information. |
| 4069 TEST(DebuggerHostDispatch) { | 4183 TEST(DebuggerHostDispatch) { |
| 4070 i::FLAG_debugger_auto_break = true; | 4184 i::FLAG_debugger_auto_break = true; |
| 4071 | 4185 |
| 4072 v8::HandleScope scope; | 4186 v8::HandleScope scope; |
| 4073 DebugLocalContext env; | 4187 DebugLocalContext env; |
| 4074 | 4188 |
| 4075 const int kBufferSize = 1000; | 4189 const int kBufferSize = 1000; |
| 4076 uint16_t buffer[kBufferSize]; | 4190 uint16_t buffer[kBufferSize]; |
| 4077 const char* command_continue = | 4191 const char* command_continue = |
| 4078 "{\"seq\":0," | 4192 "{\"seq\":0," |
| 4079 "\"type\":\"request\"," | 4193 "\"type\":\"request\"," |
| 4080 "\"command\":\"continue\"}"; | 4194 "\"command\":\"continue\"}"; |
| 4081 | 4195 |
| 4082 // Create an empty function to call for processing debug commands | 4196 // Create an empty function to call for processing debug commands |
| 4083 v8::Local<v8::Function> empty = | 4197 v8::Local<v8::Function> empty = |
| 4084 CompileFunction(&env, "function empty(){}", "empty"); | 4198 CompileFunction(&env, "function empty(){}", "empty"); |
| 4085 | 4199 |
| 4086 // Setup message and host dispatch handlers. | 4200 // Setup message and host dispatch handlers. |
| 4087 v8::Debug::SetMessageHandler(DummyMessageHandler); | 4201 v8::Debug::SetMessageHandler(DummyMessageHandler); |
| 4088 v8::Debug::SetHostDispatchHandler(HostDispatchHandlerHitCount, | 4202 v8::Debug::SetHostDispatchHandler(HostDispatchHandlerHitCount); |
| 4089 NULL); | |
| 4090 | 4203 |
| 4091 // Send a host dispatch by itself. | 4204 // Send a host dispatch by itself. |
| 4092 v8::Debug::SendHostDispatch(NULL); | 4205 v8::Debug::SendHostDispatch(NULL); |
| 4093 empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. | 4206 empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. |
| 4094 CHECK_EQ(1, host_dispatch_hit_count); | 4207 CHECK_EQ(1, host_dispatch_hit_count); |
| 4095 | 4208 |
| 4096 // Fill a host dispatch and a continue command on the command queue. | 4209 // Fill a host dispatch and a continue command on the command queue. |
| 4097 v8::Debug::SendHostDispatch(NULL); | 4210 v8::Debug::SendHostDispatch(NULL); |
| 4098 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); | 4211 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_continue, buffer)); |
| 4099 empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. | 4212 empty->Call(env->Global(), 0, NULL); // Run JavaScript to activate debugger. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4351 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); | 4464 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); |
| 4352 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); | 4465 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); |
| 4353 script2->Run(); | 4466 script2->Run(); |
| 4354 script2->SetData(data_obj); | 4467 script2->SetData(data_obj); |
| 4355 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 4468 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
| 4356 f->Call(env->Global(), 0, NULL); | 4469 f->Call(env->Global(), 0, NULL); |
| 4357 CHECK_EQ(2, break_point_hit_count); | 4470 CHECK_EQ(2, break_point_hit_count); |
| 4358 CHECK_EQ("new name", last_script_name_hit); | 4471 CHECK_EQ("new name", last_script_name_hit); |
| 4359 CHECK_EQ("abc 123", last_script_data_hit); | 4472 CHECK_EQ("abc 123", last_script_data_hit); |
| 4360 } | 4473 } |
| OLD | NEW |