| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 25 matching lines...) Expand all Loading... |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 // Forward decelrations. | 38 // Forward decelrations. |
| 39 class DebuggerAgentSession; | 39 class DebuggerAgentSession; |
| 40 | 40 |
| 41 | 41 |
| 42 // Debugger agent which starts a socket listener on the debugger port and | 42 // Debugger agent which starts a socket listener on the debugger port and |
| 43 // handles connection from a remote debugger. | 43 // handles connection from a remote debugger. |
| 44 class DebuggerAgent: public Thread { | 44 class DebuggerAgent: public Thread { |
| 45 public: | 45 public: |
| 46 explicit DebuggerAgent(Isolate* isolate, const char* name, int port) | 46 DebuggerAgent(Isolate* isolate, const char* name, int port) |
| 47 : Thread(isolate), name_(StrDup(name)), port_(port), | 47 : Thread(isolate, name), |
| 48 name_(StrDup(name)), port_(port), |
| 48 server_(OS::CreateSocket()), terminate_(false), | 49 server_(OS::CreateSocket()), terminate_(false), |
| 49 session_access_(OS::CreateMutex()), session_(NULL), | 50 session_access_(OS::CreateMutex()), session_(NULL), |
| 50 terminate_now_(OS::CreateSemaphore(0)), | 51 terminate_now_(OS::CreateSemaphore(0)), |
| 51 listening_(OS::CreateSemaphore(0)) { | 52 listening_(OS::CreateSemaphore(0)) { |
| 52 ASSERT(Isolate::Current()->debugger_agent_instance() == NULL); | 53 ASSERT(Isolate::Current()->debugger_agent_instance() == NULL); |
| 53 Isolate::Current()->set_debugger_agent_instance(this); | 54 Isolate::Current()->set_debugger_agent_instance(this); |
| 54 } | 55 } |
| 55 ~DebuggerAgent() { | 56 ~DebuggerAgent() { |
| 56 Isolate::Current()->set_debugger_agent_instance(NULL); | 57 Isolate::Current()->set_debugger_agent_instance(NULL); |
| 57 delete server_; | 58 delete server_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(DebuggerAgent); | 83 DISALLOW_COPY_AND_ASSIGN(DebuggerAgent); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 | 86 |
| 86 // Debugger agent session. The session receives requests from the remote | 87 // Debugger agent session. The session receives requests from the remote |
| 87 // debugger and sends debugger events/responses to the remote debugger. | 88 // debugger and sends debugger events/responses to the remote debugger. |
| 88 class DebuggerAgentSession: public Thread { | 89 class DebuggerAgentSession: public Thread { |
| 89 public: | 90 public: |
| 90 DebuggerAgentSession(Isolate* isolate, DebuggerAgent* agent, Socket* client) | 91 DebuggerAgentSession(Isolate* isolate, DebuggerAgent* agent, Socket* client) |
| 91 : Thread(isolate), agent_(agent), client_(client) {} | 92 : Thread(isolate, "v8:DbgAgntSessn"), |
| 93 agent_(agent), client_(client) {} |
| 92 | 94 |
| 93 void DebuggerMessage(Vector<uint16_t> message); | 95 void DebuggerMessage(Vector<uint16_t> message); |
| 94 void Shutdown(); | 96 void Shutdown(); |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 void Run(); | 99 void Run(); |
| 98 | 100 |
| 99 void DebuggerMessage(Vector<char> message); | 101 void DebuggerMessage(Vector<char> message); |
| 100 | 102 |
| 101 DebuggerAgent* agent_; | 103 DebuggerAgent* agent_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 118 static bool SendMessage(const Socket* conn, | 120 static bool SendMessage(const Socket* conn, |
| 119 const v8::Handle<v8::String> message); | 121 const v8::Handle<v8::String> message); |
| 120 static int ReceiveAll(const Socket* conn, char* data, int len); | 122 static int ReceiveAll(const Socket* conn, char* data, int len); |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 } } // namespace v8::internal | 125 } } // namespace v8::internal |
| 124 | 126 |
| 125 #endif // ENABLE_DEBUGGER_SUPPORT | 127 #endif // ENABLE_DEBUGGER_SUPPORT |
| 126 | 128 |
| 127 #endif // V8_DEBUG_AGENT_H_ | 129 #endif // V8_DEBUG_AGENT_H_ |
| OLD | NEW |