| 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/dartutils.h" | 6 #include "bin/dartutils.h" |
| 7 #include "bin/fdutils.h" | |
| 8 #include "bin/socket.h" | 7 #include "bin/socket.h" |
| 9 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 10 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 11 | 10 |
| 12 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 13 #include "platform/json.h" | 12 #include "platform/json.h" |
| 14 #include "platform/thread.h" | 13 #include "platform/thread.h" |
| 15 #include "platform/utils.h" | 14 #include "platform/utils.h" |
| 16 | 15 |
| 17 #include "include/dart_api.h" | 16 #include "include/dart_api.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 static bool IsValidJSON(const char* msg) { | 141 static bool IsValidJSON(const char* msg) { |
| 143 dart::JSONReader r(msg); | 142 dart::JSONReader r(msg); |
| 144 return r.EndOfObject() != NULL; | 143 return r.EndOfObject() != NULL; |
| 145 } | 144 } |
| 146 | 145 |
| 147 | 146 |
| 148 void DebuggerConnectionHandler::HandleResumeCmd() { | 147 void DebuggerConnectionHandler::HandleResumeCmd() { |
| 149 int msg_id = msgbuf_->MessageId(); | 148 int msg_id = msgbuf_->MessageId(); |
| 150 dart::TextBuffer msg(64); | 149 dart::TextBuffer msg(64); |
| 151 msg.Printf("{ \"id\": %d }", msg_id); | 150 msg.Printf("{ \"id\": %d }", msg_id); |
| 152 FDUtils::WriteToBlocking(debugger_fd_, msg.buf(), msg.length()); | 151 Socket::Write(debugger_fd_, msg.buf(), msg.length()); |
| 153 // TODO(hausner): Error checking. Probably just shut down the debugger | 152 // TODO(hausner): Error checking. Probably just shut down the debugger |
| 154 // session if we there is an error while writing. | 153 // session if we there is an error while writing. |
| 155 } | 154 } |
| 156 | 155 |
| 157 | 156 |
| 158 void DebuggerConnectionHandler::HandleMessages() { | 157 void DebuggerConnectionHandler::HandleMessages() { |
| 159 for (;;) { | 158 for (;;) { |
| 160 while (!msgbuf_->IsValidMessage() && msgbuf_->Alive()) { | 159 while (!msgbuf_->IsValidMessage() && msgbuf_->Alive()) { |
| 161 msgbuf_->ReadData(); | 160 msgbuf_->ReadData(); |
| 162 } | 161 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 262 |
| 264 handler_started_ = true; | 263 handler_started_ = true; |
| 265 DebuggerConnectionImpl::StartHandler(port_number); | 264 DebuggerConnectionImpl::StartHandler(port_number); |
| 266 Dart_SetBreakpointHandler(BreakpointHandler); | 265 Dart_SetBreakpointHandler(BreakpointHandler); |
| 267 } | 266 } |
| 268 | 267 |
| 269 | 268 |
| 270 DebuggerConnectionHandler::~DebuggerConnectionHandler() { | 269 DebuggerConnectionHandler::~DebuggerConnectionHandler() { |
| 271 CloseDbgConnection(); | 270 CloseDbgConnection(); |
| 272 } | 271 } |
| OLD | NEW |