| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 4703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4714 * response messages to the debugger. Fills queues and makes | 4714 * response messages to the debugger. Fills queues and makes |
| 4715 * them grow. | 4715 * them grow. |
| 4716 */ | 4716 */ |
| 4717 Barriers message_queue_barriers; | 4717 Barriers message_queue_barriers; |
| 4718 | 4718 |
| 4719 // This is the debugger thread, that executes no v8 calls except | 4719 // This is the debugger thread, that executes no v8 calls except |
| 4720 // placing JSON debugger commands in the queue. | 4720 // placing JSON debugger commands in the queue. |
| 4721 class MessageQueueDebuggerThread : public v8::internal::Thread { | 4721 class MessageQueueDebuggerThread : public v8::internal::Thread { |
| 4722 public: | 4722 public: |
| 4723 explicit MessageQueueDebuggerThread(v8::internal::Isolate* isolate) | 4723 explicit MessageQueueDebuggerThread(v8::internal::Isolate* isolate) |
| 4724 : Thread(isolate) { } | 4724 : Thread(isolate, "MessageQueueDebuggerThread") { } |
| 4725 void Run(); | 4725 void Run(); |
| 4726 }; | 4726 }; |
| 4727 | 4727 |
| 4728 static void MessageHandler(const uint16_t* message, int length, | 4728 static void MessageHandler(const uint16_t* message, int length, |
| 4729 v8::Debug::ClientData* client_data) { | 4729 v8::Debug::ClientData* client_data) { |
| 4730 static char print_buffer[1000]; | 4730 static char print_buffer[1000]; |
| 4731 Utf16ToAscii(message, length, print_buffer); | 4731 Utf16ToAscii(message, length, print_buffer); |
| 4732 if (IsBreakEventMessage(print_buffer)) { | 4732 if (IsBreakEventMessage(print_buffer)) { |
| 4733 // Lets test script wait until break occurs to send commands. | 4733 // Lets test script wait until break occurs to send commands. |
| 4734 // Signals when a break is reported. | 4734 // Signals when a break is reported. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 /* This test interrupts a running infinite loop that is | 4965 /* This test interrupts a running infinite loop that is |
| 4966 * occupying the v8 thread by a break command from the | 4966 * occupying the v8 thread by a break command from the |
| 4967 * debugger thread. It then changes the value of a | 4967 * debugger thread. It then changes the value of a |
| 4968 * global object, to make the loop terminate. | 4968 * global object, to make the loop terminate. |
| 4969 */ | 4969 */ |
| 4970 | 4970 |
| 4971 Barriers threaded_debugging_barriers; | 4971 Barriers threaded_debugging_barriers; |
| 4972 | 4972 |
| 4973 class V8Thread : public v8::internal::Thread { | 4973 class V8Thread : public v8::internal::Thread { |
| 4974 public: | 4974 public: |
| 4975 explicit V8Thread(v8::internal::Isolate* isolate) : Thread(isolate) { } | 4975 explicit V8Thread(v8::internal::Isolate* isolate) |
| 4976 : Thread(isolate, "V8Thread") { } |
| 4976 void Run(); | 4977 void Run(); |
| 4977 }; | 4978 }; |
| 4978 | 4979 |
| 4979 class DebuggerThread : public v8::internal::Thread { | 4980 class DebuggerThread : public v8::internal::Thread { |
| 4980 public: | 4981 public: |
| 4981 explicit DebuggerThread(v8::internal::Isolate* isolate) : Thread(isolate) { } | 4982 explicit DebuggerThread(v8::internal::Isolate* isolate) |
| 4983 : Thread(isolate, "DebuggerThread") { } |
| 4982 void Run(); | 4984 void Run(); |
| 4983 }; | 4985 }; |
| 4984 | 4986 |
| 4985 | 4987 |
| 4986 static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) { | 4988 static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) { |
| 4987 threaded_debugging_barriers.barrier_1.Wait(); | 4989 threaded_debugging_barriers.barrier_1.Wait(); |
| 4988 return v8::Undefined(); | 4990 return v8::Undefined(); |
| 4989 } | 4991 } |
| 4990 | 4992 |
| 4991 | 4993 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5071 /* Test RecursiveBreakpoints */ | 5073 /* Test RecursiveBreakpoints */ |
| 5072 /* In this test, the debugger evaluates a function with a breakpoint, after | 5074 /* In this test, the debugger evaluates a function with a breakpoint, after |
| 5073 * hitting a breakpoint in another function. We do this with both values | 5075 * hitting a breakpoint in another function. We do this with both values |
| 5074 * of the flag enabling recursive breakpoints, and verify that the second | 5076 * of the flag enabling recursive breakpoints, and verify that the second |
| 5075 * breakpoint is hit when enabled, and missed when disabled. | 5077 * breakpoint is hit when enabled, and missed when disabled. |
| 5076 */ | 5078 */ |
| 5077 | 5079 |
| 5078 class BreakpointsV8Thread : public v8::internal::Thread { | 5080 class BreakpointsV8Thread : public v8::internal::Thread { |
| 5079 public: | 5081 public: |
| 5080 explicit BreakpointsV8Thread(v8::internal::Isolate* isolate) | 5082 explicit BreakpointsV8Thread(v8::internal::Isolate* isolate) |
| 5081 : Thread(isolate) { } | 5083 : Thread(isolate, "BreakpointsV8Thread") { } |
| 5082 void Run(); | 5084 void Run(); |
| 5083 }; | 5085 }; |
| 5084 | 5086 |
| 5085 class BreakpointsDebuggerThread : public v8::internal::Thread { | 5087 class BreakpointsDebuggerThread : public v8::internal::Thread { |
| 5086 public: | 5088 public: |
| 5087 explicit BreakpointsDebuggerThread(v8::internal::Isolate* isolate, | 5089 explicit BreakpointsDebuggerThread(v8::internal::Isolate* isolate, |
| 5088 bool global_evaluate) | 5090 bool global_evaluate) |
| 5089 : Thread(isolate), global_evaluate_(global_evaluate) {} | 5091 : Thread(isolate, "BreakpointsDebuggerThread"), |
| 5092 global_evaluate_(global_evaluate) {} |
| 5090 void Run(); | 5093 void Run(); |
| 5091 | 5094 |
| 5092 private: | 5095 private: |
| 5093 bool global_evaluate_; | 5096 bool global_evaluate_; |
| 5094 }; | 5097 }; |
| 5095 | 5098 |
| 5096 | 5099 |
| 5097 Barriers* breakpoints_barriers; | 5100 Barriers* breakpoints_barriers; |
| 5098 int break_event_breakpoint_id; | 5101 int break_event_breakpoint_id; |
| 5099 int evaluate_int_result; | 5102 int evaluate_int_result; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5640 | 5643 |
| 5641 | 5644 |
| 5642 /* Test DebuggerHostDispatch */ | 5645 /* Test DebuggerHostDispatch */ |
| 5643 /* In this test, the debugger waits for a command on a breakpoint | 5646 /* In this test, the debugger waits for a command on a breakpoint |
| 5644 * and is dispatching host commands while in the infinite loop. | 5647 * and is dispatching host commands while in the infinite loop. |
| 5645 */ | 5648 */ |
| 5646 | 5649 |
| 5647 class HostDispatchV8Thread : public v8::internal::Thread { | 5650 class HostDispatchV8Thread : public v8::internal::Thread { |
| 5648 public: | 5651 public: |
| 5649 explicit HostDispatchV8Thread(v8::internal::Isolate* isolate) | 5652 explicit HostDispatchV8Thread(v8::internal::Isolate* isolate) |
| 5650 : Thread(isolate) { } | 5653 : Thread(isolate, "HostDispatchV8Thread") { } |
| 5651 void Run(); | 5654 void Run(); |
| 5652 }; | 5655 }; |
| 5653 | 5656 |
| 5654 class HostDispatchDebuggerThread : public v8::internal::Thread { | 5657 class HostDispatchDebuggerThread : public v8::internal::Thread { |
| 5655 public: | 5658 public: |
| 5656 explicit HostDispatchDebuggerThread(v8::internal::Isolate* isolate) | 5659 explicit HostDispatchDebuggerThread(v8::internal::Isolate* isolate) |
| 5657 : Thread(isolate) { } | 5660 : Thread(isolate, "HostDispatchDebuggerThread") { } |
| 5658 void Run(); | 5661 void Run(); |
| 5659 }; | 5662 }; |
| 5660 | 5663 |
| 5661 Barriers* host_dispatch_barriers; | 5664 Barriers* host_dispatch_barriers; |
| 5662 | 5665 |
| 5663 static void HostDispatchMessageHandler(const v8::Debug::Message& message) { | 5666 static void HostDispatchMessageHandler(const v8::Debug::Message& message) { |
| 5664 static char print_buffer[1000]; | 5667 static char print_buffer[1000]; |
| 5665 v8::String::Value json(message.GetJSON()); | 5668 v8::String::Value json(message.GetJSON()); |
| 5666 Utf16ToAscii(*json, json.length(), print_buffer); | 5669 Utf16ToAscii(*json, json.length(), print_buffer); |
| 5667 } | 5670 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5746 | 5749 |
| 5747 /* Test DebugMessageDispatch */ | 5750 /* Test DebugMessageDispatch */ |
| 5748 /* In this test, the V8 thread waits for a message from the debug thread. | 5751 /* In this test, the V8 thread waits for a message from the debug thread. |
| 5749 * The DebugMessageDispatchHandler is executed from the debugger thread | 5752 * The DebugMessageDispatchHandler is executed from the debugger thread |
| 5750 * which signals the V8 thread to wake up. | 5753 * which signals the V8 thread to wake up. |
| 5751 */ | 5754 */ |
| 5752 | 5755 |
| 5753 class DebugMessageDispatchV8Thread : public v8::internal::Thread { | 5756 class DebugMessageDispatchV8Thread : public v8::internal::Thread { |
| 5754 public: | 5757 public: |
| 5755 explicit DebugMessageDispatchV8Thread(v8::internal::Isolate* isolate) | 5758 explicit DebugMessageDispatchV8Thread(v8::internal::Isolate* isolate) |
| 5756 : Thread(isolate) { } | 5759 : Thread(isolate, "DebugMessageDispatchV8Thread") { } |
| 5757 void Run(); | 5760 void Run(); |
| 5758 }; | 5761 }; |
| 5759 | 5762 |
| 5760 class DebugMessageDispatchDebuggerThread : public v8::internal::Thread { | 5763 class DebugMessageDispatchDebuggerThread : public v8::internal::Thread { |
| 5761 public: | 5764 public: |
| 5762 explicit DebugMessageDispatchDebuggerThread(v8::internal::Isolate* isolate) | 5765 explicit DebugMessageDispatchDebuggerThread(v8::internal::Isolate* isolate) |
| 5763 : Thread(isolate) { } | 5766 : Thread(isolate, "DebugMessageDispatchDebuggerThread") { } |
| 5764 void Run(); | 5767 void Run(); |
| 5765 }; | 5768 }; |
| 5766 | 5769 |
| 5767 Barriers* debug_message_dispatch_barriers; | 5770 Barriers* debug_message_dispatch_barriers; |
| 5768 | 5771 |
| 5769 | 5772 |
| 5770 static void DebugMessageHandler() { | 5773 static void DebugMessageHandler() { |
| 5771 debug_message_dispatch_barriers->semaphore_1->Signal(); | 5774 debug_message_dispatch_barriers->semaphore_1->Signal(); |
| 5772 } | 5775 } |
| 5773 | 5776 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5856 debugger->StartAgent("test", kPort3); | 5859 debugger->StartAgent("test", kPort3); |
| 5857 debugger->StopAgent(); | 5860 debugger->StopAgent(); |
| 5858 | 5861 |
| 5859 delete server; | 5862 delete server; |
| 5860 } | 5863 } |
| 5861 | 5864 |
| 5862 | 5865 |
| 5863 class DebuggerAgentProtocolServerThread : public i::Thread { | 5866 class DebuggerAgentProtocolServerThread : public i::Thread { |
| 5864 public: | 5867 public: |
| 5865 explicit DebuggerAgentProtocolServerThread(i::Isolate* isolate, int port) | 5868 explicit DebuggerAgentProtocolServerThread(i::Isolate* isolate, int port) |
| 5866 : Thread(isolate), port_(port), server_(NULL), client_(NULL), | 5869 : Thread(isolate, "DebuggerAgentProtocolServerThread"), |
| 5870 port_(port), |
| 5871 server_(NULL), |
| 5872 client_(NULL), |
| 5867 listening_(OS::CreateSemaphore(0)) { | 5873 listening_(OS::CreateSemaphore(0)) { |
| 5868 } | 5874 } |
| 5869 ~DebuggerAgentProtocolServerThread() { | 5875 ~DebuggerAgentProtocolServerThread() { |
| 5870 // Close both sockets. | 5876 // Close both sockets. |
| 5871 delete client_; | 5877 delete client_; |
| 5872 delete server_; | 5878 delete server_; |
| 5873 delete listening_; | 5879 delete listening_; |
| 5874 } | 5880 } |
| 5875 | 5881 |
| 5876 void Run(); | 5882 void Run(); |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7247 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); | 7253 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); |
| 7248 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); | 7254 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); |
| 7249 | 7255 |
| 7250 // Get rid of the debug event listener. | 7256 // Get rid of the debug event listener. |
| 7251 v8::Debug::SetDebugEventListener(NULL); | 7257 v8::Debug::SetDebugEventListener(NULL); |
| 7252 CheckDebuggerUnloaded(); | 7258 CheckDebuggerUnloaded(); |
| 7253 } | 7259 } |
| 7254 | 7260 |
| 7255 | 7261 |
| 7256 #endif // ENABLE_DEBUGGER_SUPPORT | 7262 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |