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_MESSAGE_H_ | 5 #ifndef BIN_DBG_MESSAGE_H_ |
6 #define BIN_DBG_MESSAGE_H_ | 6 #define BIN_DBG_MESSAGE_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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 int buf_length_; | 56 int buf_length_; |
57 | 57 |
58 DISALLOW_COPY_AND_ASSIGN(MessageParser); | 58 DISALLOW_COPY_AND_ASSIGN(MessageParser); |
59 }; | 59 }; |
60 | 60 |
61 | 61 |
62 // Class which represents a debug command message and handles it. | 62 // Class which represents a debug command message and handles it. |
63 class DbgMessage { | 63 class DbgMessage { |
64 public: | 64 public: |
65 DbgMessage(int32_t cmd_idx, const char* start, | 65 DbgMessage(int32_t cmd_idx, const char* start, |
66 const char* end, int debug_fd) | 66 const char* end, intptr_t debug_fd) |
67 : next_(NULL), cmd_idx_(cmd_idx), | 67 : next_(NULL), cmd_idx_(cmd_idx), |
68 buffer_(NULL), buffer_len_(end - start), | 68 buffer_(NULL), buffer_len_(end - start), |
69 debug_fd_(debug_fd) { | 69 debug_fd_(debug_fd) { |
70 buffer_ = reinterpret_cast<char*>(malloc(buffer_len_)); | 70 buffer_ = reinterpret_cast<char*>(malloc(buffer_len_)); |
71 ASSERT(buffer_ != NULL); | 71 ASSERT(buffer_ != NULL); |
72 memmove(buffer_, start, buffer_len_); | 72 memmove(buffer_, start, buffer_len_); |
73 } | 73 } |
74 ~DbgMessage() { | 74 ~DbgMessage() { |
75 next_ = NULL; | 75 next_ = NULL; |
76 free(buffer_); | 76 free(buffer_); |
77 } | 77 } |
78 | 78 |
79 // Accessors. | 79 // Accessors. |
80 DbgMessage* next() const { return next_; } | 80 DbgMessage* next() const { return next_; } |
81 void set_next(DbgMessage* next) { next_ = next; } | 81 void set_next(DbgMessage* next) { next_ = next; } |
82 char* buffer() const { return buffer_; } | 82 char* buffer() const { return buffer_; } |
83 int32_t buffer_len() const { return buffer_len_; } | 83 int32_t buffer_len() const { return buffer_len_; } |
84 int debug_fd() const { return debug_fd_; } | 84 intptr_t debug_fd() const { return debug_fd_; } |
85 | 85 |
86 // Handle debugger command message. | 86 // Handle debugger command message. |
87 // Returns true if the execution needs to resume after this message is | 87 // Returns true if the execution needs to resume after this message is |
88 // handled, false otherwise. | 88 // handled, false otherwise. |
89 bool HandleMessage(); | 89 bool HandleMessage(); |
90 | 90 |
91 // Send reply after successful handling of command. | 91 // Send reply after successful handling of command. |
92 void SendReply(dart::TextBuffer* msg); | 92 void SendReply(dart::TextBuffer* msg); |
93 | 93 |
94 // Reply error returned by the command handler. | 94 // Reply error returned by the command handler. |
(...skipping 19 matching lines...) Expand all Loading... |
114 static bool HandleGetStackTraceCmd(DbgMessage* msg); | 114 static bool HandleGetStackTraceCmd(DbgMessage* msg); |
115 static bool HandlePauseOnExcCmd(DbgMessage* msg); | 115 static bool HandlePauseOnExcCmd(DbgMessage* msg); |
116 static bool HandleSetBpCmd(DbgMessage* msg); | 116 static bool HandleSetBpCmd(DbgMessage* msg); |
117 static bool HandleRemBpCmd(DbgMessage* msg); | 117 static bool HandleRemBpCmd(DbgMessage* msg); |
118 | 118 |
119 private: | 119 private: |
120 DbgMessage* next_; // Next message in the queue. | 120 DbgMessage* next_; // Next message in the queue. |
121 int32_t cmd_idx_; // Isolate specific debugger command index. | 121 int32_t cmd_idx_; // Isolate specific debugger command index. |
122 char* buffer_; // Debugger command message. | 122 char* buffer_; // Debugger command message. |
123 int32_t buffer_len_; // Length of the debugger command message. | 123 int32_t buffer_len_; // Length of the debugger command message. |
124 int debug_fd_; // Debugger connection on which replies are to be sent. | 124 intptr_t debug_fd_; // Debugger connection on which replies are to be sent. |
125 | 125 |
126 DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMessage); | 126 DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMessage); |
127 }; | 127 }; |
128 | 128 |
129 | 129 |
130 // Class which represents a queue of debug command messages sent to an isolate. | 130 // Class which represents a queue of debug command messages sent to an isolate. |
131 class DbgMsgQueue { | 131 class DbgMsgQueue { |
132 public: | 132 public: |
133 DbgMsgQueue(Dart_IsolateId isolate_id, DbgMsgQueue* next) | 133 DbgMsgQueue(Dart_IsolateId isolate_id, DbgMsgQueue* next) |
134 : is_running_(true), | 134 : is_running_(true), |
(...skipping 18 matching lines...) Expand all Loading... |
153 | 153 |
154 // Accessors. | 154 // Accessors. |
155 Dart_IsolateId isolate_id() const { return isolate_id_; } | 155 Dart_IsolateId isolate_id() const { return isolate_id_; } |
156 DbgMsgQueue* next() const { return next_; } | 156 DbgMsgQueue* next() const { return next_; } |
157 void set_next(DbgMsgQueue* next) { next_ = next; } | 157 void set_next(DbgMsgQueue* next) { next_ = next; } |
158 | 158 |
159 // Add specified debug command message to the queue. | 159 // Add specified debug command message to the queue. |
160 void AddMessage(int32_t cmd_idx, | 160 void AddMessage(int32_t cmd_idx, |
161 const char* start, | 161 const char* start, |
162 const char* end, | 162 const char* end, |
163 int debug_fd); | 163 intptr_t debug_fd); |
164 | 164 |
165 // Notify an isolate of a pending vmservice message. | 165 // Notify an isolate of a pending vmservice message. |
166 void Notify(); | 166 void Notify(); |
167 | 167 |
168 // Run a message loop which handles messages as they arrive until | 168 // Run a message loop which handles messages as they arrive until |
169 // normal program execution resumes. | 169 // normal program execution resumes. |
170 void MessageLoop(); | 170 void MessageLoop(); |
171 | 171 |
172 // Handle any pending debug command messages in the queue. Return | 172 // Handle any pending debug command messages in the queue. Return |
173 // value indicates whether a resume has been requested. | 173 // value indicates whether a resume has been requested. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // Parses the input message and returns the command index if the message | 225 // Parses the input message and returns the command index if the message |
226 // contains a valid isolate specific command. | 226 // contains a valid isolate specific command. |
227 // It returns kInvalidCommand otherwise. | 227 // It returns kInvalidCommand otherwise. |
228 static int32_t LookupIsolateCommand(const char* buf, int32_t buflen); | 228 static int32_t LookupIsolateCommand(const char* buf, int32_t buflen); |
229 | 229 |
230 // Queue debugger message targetted for the isolate. | 230 // Queue debugger message targetted for the isolate. |
231 static bool AddIsolateMessage(Dart_IsolateId isolate_id, | 231 static bool AddIsolateMessage(Dart_IsolateId isolate_id, |
232 int32_t cmd_idx, | 232 int32_t cmd_idx, |
233 const char* start, | 233 const char* start, |
234 const char* end, | 234 const char* end, |
235 int debug_fd); | 235 intptr_t debug_fd); |
236 | 236 |
237 // Notify an isolate of a pending vmservice message. | 237 // Notify an isolate of a pending vmservice message. |
238 static void NotifyIsolate(Dart_Isolate isolate); | 238 static void NotifyIsolate(Dart_Isolate isolate); |
239 | 239 |
240 // Interrupt isolate. | 240 // Interrupt isolate. |
241 static bool InterruptIsolate(Dart_IsolateId isolate_id); | 241 static bool InterruptIsolate(Dart_IsolateId isolate_id); |
242 | 242 |
243 // Add Debugger Message Queue corresponding to the Isolate. | 243 // Add Debugger Message Queue corresponding to the Isolate. |
244 static DbgMsgQueue* AddIsolateMsgQueue(Dart_IsolateId isolate_id); | 244 static DbgMsgQueue* AddIsolateMsgQueue(Dart_IsolateId isolate_id); |
245 | 245 |
(...skipping 27 matching lines...) Expand all Loading... |
273 static dart::Mutex* msg_queue_list_lock_; | 273 static dart::Mutex* msg_queue_list_lock_; |
274 | 274 |
275 DISALLOW_ALLOCATION(); | 275 DISALLOW_ALLOCATION(); |
276 DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMsgQueueList); | 276 DISALLOW_IMPLICIT_CONSTRUCTORS(DbgMsgQueueList); |
277 }; | 277 }; |
278 | 278 |
279 } // namespace bin | 279 } // namespace bin |
280 } // namespace dart | 280 } // namespace dart |
281 | 281 |
282 #endif // BIN_DBG_MESSAGE_H_ | 282 #endif // BIN_DBG_MESSAGE_H_ |
OLD | NEW |