| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void RunRemoteDebugger(int port); | 46 void RunRemoteDebugger(int port); |
| 47 | 47 |
| 48 // Forward declerations. | 48 // Forward declerations. |
| 49 class RemoteDebuggerEvent; | 49 class RemoteDebuggerEvent; |
| 50 class ReceiverThread; | 50 class ReceiverThread; |
| 51 | 51 |
| 52 | 52 |
| 53 // Remote debugging class. | 53 // Remote debugging class. |
| 54 class RemoteDebugger { | 54 class RemoteDebugger { |
| 55 public: | 55 public: |
| 56 RemoteDebugger(i::Isolate* isolate, int port) | 56 explicit RemoteDebugger(int port) |
| 57 : port_(port), | 57 : port_(port), |
| 58 event_access_(i::OS::CreateMutex()), | 58 event_access_(i::OS::CreateMutex()), |
| 59 event_available_(i::OS::CreateSemaphore(0)), | 59 event_available_(i::OS::CreateSemaphore(0)), |
| 60 head_(NULL), tail_(NULL), isolate_(isolate) {} | 60 head_(NULL), tail_(NULL) {} |
| 61 void Run(); | 61 void Run(); |
| 62 | 62 |
| 63 // Handle events from the subordinate threads. | 63 // Handle events from the subordinate threads. |
| 64 void MessageReceived(i::SmartPointer<char> message); | 64 void MessageReceived(i::SmartPointer<char> message); |
| 65 void KeyboardCommand(i::SmartPointer<char> command); | 65 void KeyboardCommand(i::SmartPointer<char> command); |
| 66 void ConnectionClosed(); | 66 void ConnectionClosed(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 // Add new debugger event to the list. | 69 // Add new debugger event to the list. |
| 70 void AddEvent(RemoteDebuggerEvent* event); | 70 void AddEvent(RemoteDebuggerEvent* event); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 82 int port_; // Port used to connect to debugger V8. | 82 int port_; // Port used to connect to debugger V8. |
| 83 i::Socket* conn_; // Connection to debugger agent in debugged V8. | 83 i::Socket* conn_; // Connection to debugger agent in debugged V8. |
| 84 | 84 |
| 85 // Linked list of events from debugged V8 and from keyboard input. Access to | 85 // Linked list of events from debugged V8 and from keyboard input. Access to |
| 86 // the list is guarded by a mutex and a semaphore signals new items in the | 86 // the list is guarded by a mutex and a semaphore signals new items in the |
| 87 // list. | 87 // list. |
| 88 i::Mutex* event_access_; | 88 i::Mutex* event_access_; |
| 89 i::Semaphore* event_available_; | 89 i::Semaphore* event_available_; |
| 90 RemoteDebuggerEvent* head_; | 90 RemoteDebuggerEvent* head_; |
| 91 RemoteDebuggerEvent* tail_; | 91 RemoteDebuggerEvent* tail_; |
| 92 i::Isolate* isolate_; | |
| 93 | 92 |
| 94 friend class ReceiverThread; | 93 friend class ReceiverThread; |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 | 96 |
| 98 // Thread reading from debugged V8 instance. | 97 // Thread reading from debugged V8 instance. |
| 99 class ReceiverThread: public i::Thread { | 98 class ReceiverThread: public i::Thread { |
| 100 public: | 99 public: |
| 101 ReceiverThread(i::Isolate* isolate, RemoteDebugger* remote_debugger) | 100 explicit ReceiverThread(RemoteDebugger* remote_debugger) |
| 102 : Thread(isolate, "d8:ReceiverThrd"), | 101 : Thread("d8:ReceiverThrd"), |
| 103 remote_debugger_(remote_debugger) {} | 102 remote_debugger_(remote_debugger) {} |
| 104 ~ReceiverThread() {} | 103 ~ReceiverThread() {} |
| 105 | 104 |
| 106 void Run(); | 105 void Run(); |
| 107 | 106 |
| 108 private: | 107 private: |
| 109 RemoteDebugger* remote_debugger_; | 108 RemoteDebugger* remote_debugger_; |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 | 111 |
| 113 // Thread reading keyboard input. | 112 // Thread reading keyboard input. |
| 114 class KeyboardThread: public i::Thread { | 113 class KeyboardThread: public i::Thread { |
| 115 public: | 114 public: |
| 116 explicit KeyboardThread(i::Isolate* isolate, RemoteDebugger* remote_debugger) | 115 explicit KeyboardThread(RemoteDebugger* remote_debugger) |
| 117 : Thread(isolate, "d8:KeyboardThrd"), | 116 : Thread("d8:KeyboardThrd"), |
| 118 remote_debugger_(remote_debugger) {} | 117 remote_debugger_(remote_debugger) {} |
| 119 ~KeyboardThread() {} | 118 ~KeyboardThread() {} |
| 120 | 119 |
| 121 void Run(); | 120 void Run(); |
| 122 | 121 |
| 123 private: | 122 private: |
| 124 RemoteDebugger* remote_debugger_; | 123 RemoteDebugger* remote_debugger_; |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 | 126 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 149 RemoteDebuggerEvent* next_; | 148 RemoteDebuggerEvent* next_; |
| 150 | 149 |
| 151 friend class RemoteDebugger; | 150 friend class RemoteDebugger; |
| 152 }; | 151 }; |
| 153 | 152 |
| 154 | 153 |
| 155 } // namespace v8 | 154 } // namespace v8 |
| 156 | 155 |
| 157 | 156 |
| 158 #endif // V8_D8_DEBUG_H_ | 157 #endif // V8_D8_DEBUG_H_ |
| OLD | NEW |