| 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/log.h" |
| 8 #include "bin/socket.h" | 9 #include "bin/socket.h" |
| 9 #include "bin/thread.h" | 10 #include "bin/thread.h" |
| 10 #include "bin/utils.h" | 11 #include "bin/utils.h" |
| 11 | 12 |
| 12 #include "platform/globals.h" | 13 #include "platform/globals.h" |
| 13 #include "platform/json.h" | 14 #include "platform/json.h" |
| 14 #include "platform/thread.h" | 15 #include "platform/thread.h" |
| 15 #include "platform/utils.h" | 16 #include "platform/utils.h" |
| 16 | 17 |
| 17 #include "include/dart_api.h" | 18 #include "include/dart_api.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return; | 192 return; |
| 192 } | 193 } |
| 193 | 194 |
| 194 // Parse out the command portion from the message. | 195 // Parse out the command portion from the message. |
| 195 dart::JSONReader r(msgbuf_->buf()); | 196 dart::JSONReader r(msgbuf_->buf()); |
| 196 bool found = r.Seek("command"); | 197 bool found = r.Seek("command"); |
| 197 if (r.Error()) { | 198 if (r.Error()) { |
| 198 FATAL("Illegal JSON message received"); | 199 FATAL("Illegal JSON message received"); |
| 199 } | 200 } |
| 200 if (!found) { | 201 if (!found) { |
| 201 printf("'command' not found in JSON message: '%s'\n", msgbuf_->buf()); | 202 Log::Print("'command' not found in JSON message: '%s'\n", |
| 203 msgbuf_->buf()); |
| 202 msgbuf_->PopMessage(); | 204 msgbuf_->PopMessage(); |
| 203 } | 205 } |
| 204 | 206 |
| 205 // Check if this is a generic command (not isolate specific). | 207 // Check if this is a generic command (not isolate specific). |
| 206 int i = 0; | 208 int i = 0; |
| 207 bool is_handled = false; | 209 bool is_handled = false; |
| 208 while (generic_debugger_commands[i].cmd_string != NULL) { | 210 while (generic_debugger_commands[i].cmd_string != NULL) { |
| 209 if (r.IsStringLiteral(generic_debugger_commands[i].cmd_string)) { | 211 if (r.IsStringLiteral(generic_debugger_commands[i].cmd_string)) { |
| 210 DbgMessage* msg = new DbgMessage(i, | 212 DbgMessage* msg = new DbgMessage(i, |
| 211 msgbuf_->buf(), | 213 msgbuf_->buf(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 235 msgbuf_->buf(), | 237 msgbuf_->buf(), |
| 236 r.EndOfObject(), | 238 r.EndOfObject(), |
| 237 debug_fd_)) { | 239 debug_fd_)) { |
| 238 SendError(debug_fd_, MessageId(), "Invalid isolate specified"); | 240 SendError(debug_fd_, MessageId(), "Invalid isolate specified"); |
| 239 } | 241 } |
| 240 msgbuf_->PopMessage(); | 242 msgbuf_->PopMessage(); |
| 241 continue; | 243 continue; |
| 242 } | 244 } |
| 243 | 245 |
| 244 // This is an unrecognized command, report error and move on to next. | 246 // This is an unrecognized command, report error and move on to next. |
| 245 printf("unrecognized command received: '%s'\n", msgbuf_->buf()); | 247 Log::Print("unrecognized command received: '%s'\n", msgbuf_->buf()); |
| 246 HandleUnknownMsg(); | 248 HandleUnknownMsg(); |
| 247 msgbuf_->PopMessage(); | 249 msgbuf_->PopMessage(); |
| 248 } | 250 } |
| 249 } | 251 } |
| 250 } | 252 } |
| 251 | 253 |
| 252 | 254 |
| 253 void DebuggerConnectionHandler::SendError(int debug_fd, | 255 void DebuggerConnectionHandler::SendError(int debug_fd, |
| 254 int msg_id, | 256 int msg_id, |
| 255 const char* err_msg) { | 257 const char* err_msg) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 ASSERT(singleton_handler != NULL); | 424 ASSERT(singleton_handler != NULL); |
| 423 return singleton_handler; | 425 return singleton_handler; |
| 424 } | 426 } |
| 425 | 427 |
| 426 | 428 |
| 427 bool DebuggerConnectionHandler::IsConnected() { | 429 bool DebuggerConnectionHandler::IsConnected() { |
| 428 // TODO(asiva): Support multiple debugger connections. | 430 // TODO(asiva): Support multiple debugger connections. |
| 429 // Return true if a connection has been established. | 431 // Return true if a connection has been established. |
| 430 return singleton_handler != NULL; | 432 return singleton_handler != NULL; |
| 431 } | 433 } |
| OLD | NEW |