| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BIN_DBG_CONNECTION_H_ | 5 #ifndef BIN_DBG_CONNECTION_H_ |
| 6 #define BIN_DBG_CONNECTION_H_ | 6 #define BIN_DBG_CONNECTION_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 int debug_fd() const { return debug_fd_; } | 44 int debug_fd() const { return debug_fd_; } |
| 45 | 45 |
| 46 // Return message id of current debug command message. | 46 // Return message id of current debug command message. |
| 47 int MessageId(); | 47 int MessageId(); |
| 48 | 48 |
| 49 // Starts the native thread which listens for connections from | 49 // Starts the native thread which listens for connections from |
| 50 // debugger clients, reads and dispatches debug command messages | 50 // debugger clients, reads and dispatches debug command messages |
| 51 // from the client. | 51 // from the client. |
| 52 static int StartHandler(const char* address, int port_number); | 52 static int StartHandler(const char* address, int port_number); |
| 53 | 53 |
| 54 // Initializes the parts of the debugger which are needed by the vm |
| 55 // service. This function should only be called when StartHandler |
| 56 // is not called. |
| 57 static void InitForVmService(); |
| 58 |
| 54 // Called by Isolates when they need to wait for a connection | 59 // Called by Isolates when they need to wait for a connection |
| 55 // from debugger clients. | 60 // from debugger clients. |
| 56 static void WaitForConnection(); | 61 static void WaitForConnection(); |
| 57 | 62 |
| 58 // Sends a reply or an error message to a specific debugger client. | 63 // Sends a reply or an error message to a specific debugger client. |
| 59 static void SendMsg(int debug_fd, dart::TextBuffer* msg); | 64 static void SendMsg(int debug_fd, dart::TextBuffer* msg); |
| 60 static void SendError(int debug_fd, int msg_id, const char* err_msg); | 65 static void SendError(int debug_fd, int msg_id, const char* err_msg); |
| 61 | 66 |
| 62 // Sends an event message to all debugger clients that are connected. | 67 // Sends an event message to all debugger clients that are connected. |
| 63 static void BroadcastMsg(dart::TextBuffer* msg); | 68 static void BroadcastMsg(dart::TextBuffer* msg); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 92 static bool IsConnected(); | 97 static bool IsConnected(); |
| 93 | 98 |
| 94 // Helper method for sending messages back to a debugger client. | 99 // Helper method for sending messages back to a debugger client. |
| 95 static void SendMsgHelper(int debug_fd, dart::TextBuffer* msg); | 100 static void SendMsgHelper(int debug_fd, dart::TextBuffer* msg); |
| 96 | 101 |
| 97 // mutex/condition variable used by isolates when writing back to the | 102 // mutex/condition variable used by isolates when writing back to the |
| 98 // debugger. This is also used to ensure that the isolate waits for | 103 // debugger. This is also used to ensure that the isolate waits for |
| 99 // a debugger to be attached when that is requested on the command line. | 104 // a debugger to be attached when that is requested on the command line. |
| 100 static dart::Monitor* handler_lock_; | 105 static dart::Monitor* handler_lock_; |
| 101 | 106 |
| 107 static bool IsListening() { |
| 108 return listener_fd_ != -1; |
| 109 } |
| 110 |
| 102 // The socket that is listening for incoming debugger connections. | 111 // The socket that is listening for incoming debugger connections. |
| 103 // This descriptor is created and closed by a native thread. | 112 // This descriptor is created and closed by a native thread. |
| 104 static int listener_fd_; | 113 static int listener_fd_; |
| 105 | 114 |
| 106 friend class DebuggerConnectionImpl; | 115 friend class DebuggerConnectionImpl; |
| 107 | 116 |
| 108 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); | 117 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); |
| 109 }; | 118 }; |
| 110 | 119 |
| 111 } // namespace bin | 120 } // namespace bin |
| 112 } // namespace dart | 121 } // namespace dart |
| 113 | 122 |
| 114 #endif // BIN_DBG_CONNECTION_H_ | 123 #endif // BIN_DBG_CONNECTION_H_ |
| OLD | NEW |