| 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 #include "bin/dbg_connection.h" | 5 #include "bin/dbg_connection.h" |
| 6 #include "bin/dbg_message.h" | 6 #include "bin/dbg_message.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/socket.h" | 8 #include "bin/socket.h" |
| 9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
| 10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 i++; | 220 i++; |
| 221 } | 221 } |
| 222 if (!is_handled) { | 222 if (!is_handled) { |
| 223 // Check if this is an isolate specific command. | 223 // Check if this is an isolate specific command. |
| 224 int32_t cmd_idx = DbgMsgQueueList::LookupIsolateCommand(r.ValueChars(), | 224 int32_t cmd_idx = DbgMsgQueueList::LookupIsolateCommand(r.ValueChars(), |
| 225 r.ValueLen()); | 225 r.ValueLen()); |
| 226 if (cmd_idx != DbgMsgQueueList::kInvalidCommand) { | 226 if (cmd_idx != DbgMsgQueueList::kInvalidCommand) { |
| 227 // Get debug message queue corresponding to isolate. | 227 // Get debug message queue corresponding to isolate. |
| 228 // TODO(asiva): Once we have support for including the isolate id | 228 // TODO(asiva): Once we have support for including the isolate id |
| 229 // in the debug wire protocol we need to read the isolate id and | 229 // in the debug wire protocol we need to read the isolate id and |
| 230 // pass it down to GetIsolateMsgQueue to get the appropriate debug | 230 // pass it down to AddIsolateMessage. |
| 231 // message queue. | 231 if (!DbgMsgQueueList::AddIsolateMessage(ILLEGAL_ISOLATE_ID, |
| 232 DbgMsgQueue* queue = | 232 cmd_idx, |
| 233 DbgMsgQueueList::GetIsolateMsgQueue(ILLEGAL_ISOLATE_ID); | 233 msgbuf_->buf(), |
| 234 ASSERT(queue != NULL); | 234 r.EndOfObject(), |
| 235 queue->AddMessage(cmd_idx, msgbuf_->buf(), r.EndOfObject(), debug_fd_); | 235 debug_fd_)) { |
| 236 SendError(debug_fd_, MessageId(), "Invalid isolate specified"); |
| 237 } |
| 236 msgbuf_->PopMessage(); | 238 msgbuf_->PopMessage(); |
| 237 continue; | 239 continue; |
| 238 } | 240 } |
| 239 | 241 |
| 240 // This is an unrecognized command, report error and move on to next. | 242 // This is an unrecognized command, report error and move on to next. |
| 241 printf("unrecognized command received: '%s'\n", msgbuf_->buf()); | 243 printf("unrecognized command received: '%s'\n", msgbuf_->buf()); |
| 242 HandleUnknownMsg(); | 244 HandleUnknownMsg(); |
| 243 msgbuf_->PopMessage(); | 245 msgbuf_->PopMessage(); |
| 244 } | 246 } |
| 245 } | 247 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 372 |
| 371 void DebuggerConnectionHandler::HandleInterruptCmd(DbgMessage* in_msg) { | 373 void DebuggerConnectionHandler::HandleInterruptCmd(DbgMessage* in_msg) { |
| 372 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 374 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 373 int msg_id = msg_parser.MessageId(); | 375 int msg_id = msg_parser.MessageId(); |
| 374 Dart_IsolateId isolate_id = | 376 Dart_IsolateId isolate_id = |
| 375 static_cast<Dart_IsolateId>(msg_parser.GetIntParam("isolateId")); | 377 static_cast<Dart_IsolateId>(msg_parser.GetIntParam("isolateId")); |
| 376 if (isolate_id == ILLEGAL_ISOLATE_ID || Dart_GetIsolate(isolate_id) == NULL) { | 378 if (isolate_id == ILLEGAL_ISOLATE_ID || Dart_GetIsolate(isolate_id) == NULL) { |
| 377 in_msg->SendErrorReply(msg_id, "Invalid isolate specified"); | 379 in_msg->SendErrorReply(msg_id, "Invalid isolate specified"); |
| 378 return; | 380 return; |
| 379 } | 381 } |
| 380 DbgMsgQueue* queue = DbgMsgQueueList::GetIsolateMsgQueue(isolate_id); | 382 if (!DbgMsgQueueList::InterruptIsolate(isolate_id)) { |
| 381 ASSERT(queue != NULL); | 383 in_msg->SendErrorReply(msg_id, "Invalid isolate specified"); |
| 382 queue->InterruptIsolate(); | 384 return; |
| 385 } |
| 383 dart::TextBuffer msg(64); | 386 dart::TextBuffer msg(64); |
| 384 msg.Printf("{ \"id\": %d }", msg_id); | 387 msg.Printf("{ \"id\": %d }", msg_id); |
| 385 in_msg->SendReply(&msg); | 388 in_msg->SendReply(&msg); |
| 386 } | 389 } |
| 387 | 390 |
| 388 | 391 |
| 389 void DebuggerConnectionHandler::HandleIsolatesListCmd(DbgMessage* in_msg) { | 392 void DebuggerConnectionHandler::HandleIsolatesListCmd(DbgMessage* in_msg) { |
| 390 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 393 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 391 int msg_id = msg_parser.MessageId(); | 394 int msg_id = msg_parser.MessageId(); |
| 392 ASSERT(msg_id >= 0); | 395 ASSERT(msg_id >= 0); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 417 ASSERT(singleton_handler != NULL); | 420 ASSERT(singleton_handler != NULL); |
| 418 return singleton_handler; | 421 return singleton_handler; |
| 419 } | 422 } |
| 420 | 423 |
| 421 | 424 |
| 422 bool DebuggerConnectionHandler::IsConnected() { | 425 bool DebuggerConnectionHandler::IsConnected() { |
| 423 // TODO(asiva): Support multiple debugger connections. | 426 // TODO(asiva): Support multiple debugger connections. |
| 424 // Return true if a connection has been established. | 427 // Return true if a connection has been established. |
| 425 return singleton_handler != NULL; | 428 return singleton_handler != NULL; |
| 426 } | 429 } |
| OLD | NEW |