| 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_MACOS_H_ | 5 #ifndef BIN_DBG_CONNECTION_MACOS_H_ |
| 6 #define BIN_DBG_CONNECTION_MACOS_H_ | 6 #define BIN_DBG_CONNECTION_MACOS_H_ |
| 7 | 7 |
| 8 #include <arpa/inet.h> | 8 #include <arpa/inet.h> |
| 9 #include <netdb.h> | 9 #include <netdb.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| 11 | 11 |
| 12 | 12 |
| 13 class DebuggerConnectionImpl { | 13 class DebuggerConnectionImpl { |
| 14 public: | 14 public: |
| 15 static void StartHandler(int port_number); | 15 static void StartHandler(int port_number); |
| 16 static intptr_t Send(intptr_t socket, const char* buf, int len); |
| 17 static intptr_t Receive(intptr_t socket, char* buf, int len); |
| 16 | 18 |
| 17 private: | 19 private: |
| 18 enum MessageType { | 20 enum MessageType { |
| 19 kAddDbgFd = 1, | 21 kAddDbgFd = 1, |
| 20 kRemoveDbgFd, | 22 kRemoveDbgFd, |
| 21 kQuit | 23 kQuit |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 struct Message { | 26 struct Message { |
| 25 MessageType msg_id; | 27 MessageType msg_id; |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 static void SendMessage(MessageType id); | 30 static void SendMessage(MessageType id); |
| 29 static bool ReceiveMessage(Message* msg); | 31 static bool ReceiveMessage(Message* msg); |
| 30 | 32 |
| 31 static void SetupPollQueue(); | 33 static void SetupPollQueue(); |
| 32 static void HandleEvent(struct kevent* event); | 34 static void HandleEvent(struct kevent* event); |
| 33 static void Handler(uword args); | 35 static void Handler(uword args); |
| 34 | 36 |
| 35 | 37 |
| 36 | 38 |
| 37 // File descriptors for pipes used to communicate with the debugger thread. | 39 // File descriptors for pipes used to communicate with the debugger thread. |
| 38 static int wakeup_fds_[2]; | 40 static int wakeup_fds_[2]; |
| 39 // File descriptor for the polling queue. | 41 // File descriptor for the polling queue. |
| 40 static int kqueue_fd_; | 42 static int kqueue_fd_; |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 | 45 |
| 44 #endif // BIN_DBG_CONNECTION_MACOS_H_ | 46 #endif // BIN_DBG_CONNECTION_MACOS_H_ |
| OLD | NEW |