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/lockers.h" | 8 #include "bin/lockers.h" |
9 #include "bin/log.h" | 9 #include "bin/log.h" |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 { "getIsolateIds", HandleIsolatesListCmd }, | 191 { "getIsolateIds", HandleIsolatesListCmd }, |
192 { NULL, NULL } | 192 { NULL, NULL } |
193 }; | 193 }; |
194 | 194 |
195 for (;;) { | 195 for (;;) { |
196 // Read a message. | 196 // Read a message. |
197 while (!msgbuf_->IsValidMessage() && msgbuf_->Alive()) { | 197 while (!msgbuf_->IsValidMessage() && msgbuf_->Alive()) { |
198 msgbuf_->ReadData(); | 198 msgbuf_->ReadData(); |
199 } | 199 } |
200 if (!msgbuf_->Alive()) { | 200 if (!msgbuf_->Alive()) { |
| 201 if (trace_debug_protocol) { |
| 202 Log::Print("Debugger is exiting HandleMessages loop.\n"); |
| 203 } |
201 return; | 204 return; |
202 } | 205 } |
203 | 206 |
204 if (trace_debug_protocol) { | 207 if (trace_debug_protocol) { |
205 dart::JSONReader r(msgbuf_->buf()); | 208 dart::JSONReader r(msgbuf_->buf()); |
206 const char* msg_end = r.EndOfObject(); | 209 const char* msg_end = r.EndOfObject(); |
207 if (msg_end != NULL) { | 210 if (msg_end != NULL) { |
208 intptr_t msg_len = msg_end - msgbuf_->buf(); | 211 intptr_t msg_len = msg_end - msgbuf_->buf(); |
209 int print_len = ((msg_len > kMaxPrintMessageLen) | 212 int print_len = ((msg_len > kMaxPrintMessageLen) |
210 ? kMaxPrintMessageLen : msg_len); | 213 ? kMaxPrintMessageLen : msg_len); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 fflush(stderr); | 340 fflush(stderr); |
338 exit(255); | 341 exit(255); |
339 } | 342 } |
340 | 343 |
341 port_number = Socket::GetPort(listener_fd_); | 344 port_number = Socket::GetPort(listener_fd_); |
342 DebuggerConnectionImpl::StartHandler(port_number); | 345 DebuggerConnectionImpl::StartHandler(port_number); |
343 return port_number; | 346 return port_number; |
344 } | 347 } |
345 | 348 |
346 | 349 |
| 350 void DebuggerConnectionHandler::StopHandler() { |
| 351 if (IsConnected()) { |
| 352 DebuggerConnectionImpl::StopHandler(singleton_handler->debug_fd()); |
| 353 } |
| 354 } |
| 355 |
| 356 |
347 void DebuggerConnectionHandler::WaitForConnection() { | 357 void DebuggerConnectionHandler::WaitForConnection() { |
348 ASSERT(handler_lock_ != NULL); | 358 ASSERT(handler_lock_ != NULL); |
349 MonitorLocker ml(handler_lock_); | 359 MonitorLocker ml(handler_lock_); |
350 if (!IsListening()) { | 360 if (!IsListening()) { |
351 // If we are only running the vm service, don't wait for | 361 // If we are only running the vm service, don't wait for |
352 // connections. | 362 // connections. |
353 return; | 363 return; |
354 } | 364 } |
355 while (!IsConnected()) { | 365 while (!IsConnected()) { |
356 Monitor::WaitResult res = ml.Wait(); | 366 Monitor::WaitResult res = ml.Wait(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 517 |
508 | 518 |
509 bool DebuggerConnectionHandler::IsConnected() { | 519 bool DebuggerConnectionHandler::IsConnected() { |
510 // TODO(asiva): Support multiple debugger connections. | 520 // TODO(asiva): Support multiple debugger connections. |
511 // Return true if a connection has been established. | 521 // Return true if a connection has been established. |
512 return singleton_handler != NULL; | 522 return singleton_handler != NULL; |
513 } | 523 } |
514 | 524 |
515 } // namespace bin | 525 } // namespace bin |
516 } // namespace dart | 526 } // namespace dart |
OLD | NEW |