| 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 |
| 11 #include "include/dart_debugger_api.h" | 11 #include "include/dart_debugger_api.h" |
| 12 | 12 |
| 13 #include "platform/globals.h" | 13 #include "platform/globals.h" |
| 14 #include "platform/json.h" | 14 #include "platform/json.h" |
| 15 #include "platform/thread.h" | 15 #include "platform/thread.h" |
| 16 // Declare the OS-specific types ahead of defining the generic class. | 16 // Declare the OS-specific types ahead of defining the generic class. |
| 17 #if defined(TARGET_OS_ANDROID) | 17 #if defined(TARGET_OS_ANDROID) |
| 18 #include "bin/dbg_connection_android.h" | 18 #include "bin/dbg_connection_android.h" |
| 19 #elif defined(TARGET_OS_LINUX) | 19 #elif defined(TARGET_OS_LINUX) |
| 20 #include "bin/dbg_connection_linux.h" | 20 #include "bin/dbg_connection_linux.h" |
| 21 #elif defined(TARGET_OS_MACOS) | 21 #elif defined(TARGET_OS_MACOS) |
| 22 #include "bin/dbg_connection_macos.h" | 22 #include "bin/dbg_connection_macos.h" |
| 23 #elif defined(TARGET_OS_WINDOWS) | 23 #elif defined(TARGET_OS_WINDOWS) |
| 24 #include "bin/dbg_connection_win.h" | 24 #include "bin/dbg_connection_win.h" |
| 25 #else | 25 #else |
| 26 #error Unknown target os. | 26 #error Unknown target os. |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 | 29 |
| 30 // Forward declarations. |
| 31 class DbgMessage; |
| 30 class MessageBuffer; | 32 class MessageBuffer; |
| 31 | 33 |
| 34 |
| 32 class DebuggerConnectionHandler { | 35 class DebuggerConnectionHandler { |
| 33 public: | 36 public: |
| 34 explicit DebuggerConnectionHandler(int debug_fd); | 37 explicit DebuggerConnectionHandler(int debug_fd); |
| 35 ~DebuggerConnectionHandler(); | 38 ~DebuggerConnectionHandler(); |
| 36 | 39 |
| 37 // Accessors. | 40 // Accessors. |
| 38 int debug_fd() const { return debug_fd_; } | 41 int debug_fd() const { return debug_fd_; } |
| 39 | 42 |
| 40 // Return message id of current debug command message. | 43 // Return message id of current debug command message. |
| 41 int MessageId(); | 44 int MessageId(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 69 // Buffer holding the messages received over the wire from the debugger | 72 // Buffer holding the messages received over the wire from the debugger |
| 70 // front end.. | 73 // front end.. |
| 71 MessageBuffer* msgbuf_; | 74 MessageBuffer* msgbuf_; |
| 72 | 75 |
| 73 // Accepts connection requests from debugger client and sets up a | 76 // Accepts connection requests from debugger client and sets up a |
| 74 // connection handler object to read and handle messages from the client. | 77 // connection handler object to read and handle messages from the client. |
| 75 static void AcceptDbgConnection(int debug_fd); | 78 static void AcceptDbgConnection(int debug_fd); |
| 76 | 79 |
| 77 // Handlers for generic debug command messages which are not specific to | 80 // Handlers for generic debug command messages which are not specific to |
| 78 // an isolate. | 81 // an isolate. |
| 79 static void HandleInterruptCmd(DebuggerConnectionHandler* handler); | 82 static void HandleInterruptCmd(DbgMessage* msg); |
| 80 static void HandleIsolatesListCmd(DebuggerConnectionHandler* handler); | 83 static void HandleIsolatesListCmd(DbgMessage* msg); |
| 81 static void HandleQuitCmd(DebuggerConnectionHandler* handler); | |
| 82 | 84 |
| 83 // Helper methods to manage debugger client connections. | 85 // Helper methods to manage debugger client connections. |
| 84 static void AddNewDebuggerConnection(int debug_fd); | 86 static void AddNewDebuggerConnection(int debug_fd); |
| 85 static void RemoveDebuggerConnection(int debug_fd); | 87 static void RemoveDebuggerConnection(int debug_fd); |
| 86 static DebuggerConnectionHandler* GetDebuggerConnectionHandler(int debug_fd); | 88 static DebuggerConnectionHandler* GetDebuggerConnectionHandler(int debug_fd); |
| 87 static bool IsConnected(); | 89 static bool IsConnected(); |
| 88 | 90 |
| 89 // Helper method for sending messages back to a debugger client. | 91 // Helper method for sending messages back to a debugger client. |
| 90 static void SendMsgHelper(int debug_fd, dart::TextBuffer* msg); | 92 static void SendMsgHelper(int debug_fd, dart::TextBuffer* msg); |
| 91 | 93 |
| 92 // mutex/condition variable used by isolates when writing back to the | 94 // mutex/condition variable used by isolates when writing back to the |
| 93 // debugger. This is also used to ensure that the isolate waits for | 95 // debugger. This is also used to ensure that the isolate waits for |
| 94 // a debugger to be attached when that is requested on the command line. | 96 // a debugger to be attached when that is requested on the command line. |
| 95 static dart::Monitor handler_lock_; | 97 static dart::Monitor handler_lock_; |
| 96 | 98 |
| 97 // The socket that is listening for incoming debugger connections. | 99 // The socket that is listening for incoming debugger connections. |
| 98 // This descriptor is created and closed by a native thread. | 100 // This descriptor is created and closed by a native thread. |
| 99 static int listener_fd_; | 101 static int listener_fd_; |
| 100 | 102 |
| 101 friend class DebuggerConnectionImpl; | 103 friend class DebuggerConnectionImpl; |
| 102 | 104 |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); | 105 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 #endif // BIN_DBG_CONNECTION_H_ | 108 #endif // BIN_DBG_CONNECTION_H_ |
| OLD | NEW |