| 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/thread.h" | 15 #include "platform/thread.h" |
| 15 // Declare the OS-specific types ahead of defining the generic class. | 16 // Declare the OS-specific types ahead of defining the generic class. |
| 16 #if defined(TARGET_OS_LINUX) | 17 #if defined(TARGET_OS_LINUX) |
| 17 #include "bin/dbg_connection_linux.h" | 18 #include "bin/dbg_connection_linux.h" |
| 18 #elif defined(TARGET_OS_MACOS) | 19 #elif defined(TARGET_OS_MACOS) |
| 19 #include "bin/dbg_connection_macos.h" | 20 #include "bin/dbg_connection_macos.h" |
| 20 #elif defined(TARGET_OS_WINDOWS) | 21 #elif defined(TARGET_OS_WINDOWS) |
| 21 #include "bin/dbg_connection_win.h" | 22 #include "bin/dbg_connection_win.h" |
| 22 #else | 23 #else |
| 23 #error Unknown target os. | 24 #error Unknown target os. |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 | 27 |
| 27 class MessageBuffer; | 28 class MessageBuffer; |
| 28 | 29 |
| 29 class DebuggerConnectionHandler { | 30 class DebuggerConnectionHandler { |
| 30 public: | 31 public: |
| 31 ~DebuggerConnectionHandler(); | 32 ~DebuggerConnectionHandler(); |
| 32 static void StartHandler(const char* address, int port_number); | 33 static void StartHandler(const char* address, int port_number); |
| 33 | 34 |
| 34 static bool IsConnected() { | 35 static bool IsConnected() { |
| 35 return debugger_fd_ >= 0; | 36 return debugger_fd_ >= 0; |
| 36 } | 37 } |
| 37 | 38 |
| 38 private: | 39 private: |
| 40 static void SendMsg(dart::TextBuffer* msg); |
| 41 static void QueueMsg(dart::TextBuffer* msg); |
| 42 static void SendQueuedMsgs(); |
| 43 |
| 39 static void SendBreakpointEvent(Dart_Breakpoint bpt, Dart_StackTrace trace); | 44 static void SendBreakpointEvent(Dart_Breakpoint bpt, Dart_StackTrace trace); |
| 45 static void BptResolvedHandler(intptr_t bp_id, |
| 46 Dart_Handle url, |
| 47 intptr_t line_number); |
| 40 static void BreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace); | 48 static void BreakpointHandler(Dart_Breakpoint bpt, Dart_StackTrace trace); |
| 41 | 49 |
| 42 static void AcceptDbgConnection(int debug_fd); | 50 static void AcceptDbgConnection(int debug_fd); |
| 43 static void CloseDbgConnection(); | 51 static void CloseDbgConnection(); |
| 44 | 52 |
| 45 static void HandleMessages(); | 53 static void HandleMessages(); |
| 46 static void HandleResumeCmd(const char* msg); | 54 static void HandleResumeCmd(const char* msg); |
| 47 static void HandleStepIntoCmd(const char* msg); | 55 static void HandleStepIntoCmd(const char* msg); |
| 48 static void HandleStepOverCmd(const char* msg); | 56 static void HandleStepOverCmd(const char* msg); |
| 49 static void HandleStepOutCmd(const char* msg); | 57 static void HandleStepOutCmd(const char* msg); |
| 50 static void HandleGetLibraryURLsCmd(const char* json_msg); | 58 static void HandleGetLibraryURLsCmd(const char* json_msg); |
| 51 static void HandleGetScriptURLsCmd(const char* json_msg); | 59 static void HandleGetScriptURLsCmd(const char* json_msg); |
| 60 static void HandleGetStackTraceCmd(const char* json_msg); |
| 61 static void HandleSetBpCmd(const char* json_msg); |
| 62 static void HandleUnknownMsg(const char* json_msg); |
| 52 | 63 |
| 53 static void SendError(int msg_id, const char* err_msg); | 64 static void SendError(int msg_id, const char* err_msg); |
| 54 | 65 |
| 66 // Text buffer that accumulates messages to be sent to front end. |
| 67 static dart::TextBuffer queued_messages_; |
| 68 |
| 55 static bool handler_started_; | 69 static bool handler_started_; |
| 56 | 70 |
| 57 static bool request_resume_; | 71 static bool request_resume_; |
| 58 | 72 |
| 59 // The socket that is listening for incoming debugger connections. | 73 // The socket that is listening for incoming debugger connections. |
| 60 // This descriptor is created and closed by a VM thread. | 74 // This descriptor is created and closed by a VM thread. |
| 61 static int listener_fd_; | 75 static int listener_fd_; |
| 62 | 76 |
| 63 // The socket that connects with the debugger client. | 77 // The socket that connects with the debugger client. |
| 64 // The descriptor is created by the debugger connection thread and | 78 // The descriptor is created by the debugger connection thread and |
| 65 // closed by a VM thread. | 79 // closed by a VM thread. |
| 66 static int debugger_fd_; | 80 static int debugger_fd_; |
| 67 | 81 |
| 68 // The VM thread waits on this condition variable when it reaches a | 82 // The VM thread waits on this condition variable when it reaches a |
| 69 // breakpoint and the debugger client has not connected yet. | 83 // breakpoint and the debugger client has not connected yet. |
| 70 static dart::Monitor is_connected_; | 84 static dart::Monitor is_connected_; |
| 71 | 85 |
| 72 static MessageBuffer* msgbuf_; | 86 static MessageBuffer* msgbuf_; |
| 73 | 87 |
| 74 friend class DebuggerConnectionImpl; | 88 friend class DebuggerConnectionImpl; |
| 75 | 89 |
| 76 DISALLOW_ALLOCATION(); | 90 DISALLOW_ALLOCATION(); |
| 77 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); | 91 DISALLOW_IMPLICIT_CONSTRUCTORS(DebuggerConnectionHandler); |
| 78 }; | 92 }; |
| 79 | 93 |
| 80 #endif // BIN_DBG_CONNECTION_H_ | 94 #endif // BIN_DBG_CONNECTION_H_ |
| OLD | NEW |