Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: runtime/bin/dbg_connection.cc

Issue 15507004: Let debug target pick the debugger port (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | runtime/bin/dbg_connection_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/log.h"
9 #include "bin/socket.h" 9 #include "bin/socket.h"
10 #include "bin/thread.h" 10 #include "bin/thread.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 if (msgbuf_ != NULL) { 272 if (msgbuf_ != NULL) {
273 delete msgbuf_; 273 delete msgbuf_;
274 msgbuf_ = NULL; 274 msgbuf_ = NULL;
275 } 275 }
276 // TODO(hausner): Need to tell the VM debugger object to remove all 276 // TODO(hausner): Need to tell the VM debugger object to remove all
277 // breakpoints. 277 // breakpoints.
278 } 278 }
279 279
280 280
281 void DebuggerConnectionHandler::StartHandler(const char* address, 281 int DebuggerConnectionHandler::StartHandler(const char* address,
282 int port_number) { 282 int port_number) {
283 ASSERT(handler_lock_ != NULL); 283 ASSERT(handler_lock_ != NULL);
284 MonitorLocker ml(handler_lock_); 284 MonitorLocker ml(handler_lock_);
285 if (listener_fd_ != -1) { 285 if (listener_fd_ != -1) {
286 return; // The debugger connection handler was already started. 286 // The debugger connection handler was already started.
287 return Socket::GetPort(listener_fd_);
287 } 288 }
288 289
289 // First setup breakpoint, exception and delayed breakpoint handlers. 290 // First setup breakpoint, exception and delayed breakpoint handlers.
290 DbgMsgQueueList::Initialize(); 291 DbgMsgQueueList::Initialize();
291 292
292 // Initialize the socket implementation. 293 // Initialize the socket implementation.
293 if (!Socket::Initialize()) { 294 if (!Socket::Initialize()) {
294 FATAL("Failed initializing socket implementation."); 295 FATAL("Failed initializing socket implementation.");
295 } 296 }
296 297
297 // Now setup a listener socket and start a thread which will 298 // Now setup a listener socket and start a thread which will
298 // listen, accept connections from debuggers, read and handle/dispatch 299 // listen, accept connections from debuggers, read and handle/dispatch
299 // debugger commands received on these connections. 300 // debugger commands received on these connections.
300 ASSERT(listener_fd_ == -1); 301 ASSERT(listener_fd_ == -1);
301
302 OSError *os_error; 302 OSError *os_error;
303 SocketAddresses* addresses = Socket::LookupAddress(address, -1, &os_error); 303 SocketAddresses* addresses = Socket::LookupAddress(address, -1, &os_error);
304 listener_fd_ = ServerSocket::CreateBindListen( 304 listener_fd_ = ServerSocket::CreateBindListen(
305 addresses->GetAt(0)->addr(), port_number, 1); 305 addresses->GetAt(0)->addr(), port_number, 1);
306 port_number = Socket::GetPort(listener_fd_);
306 DebuggerConnectionImpl::StartHandler(port_number); 307 DebuggerConnectionImpl::StartHandler(port_number);
308 return port_number;
307 } 309 }
308 310
309 311
310 void DebuggerConnectionHandler::WaitForConnection() { 312 void DebuggerConnectionHandler::WaitForConnection() {
311 ASSERT(handler_lock_ != NULL); 313 ASSERT(handler_lock_ != NULL);
312 MonitorLocker ml(handler_lock_); 314 MonitorLocker ml(handler_lock_);
313 while (!IsConnected()) { 315 while (!IsConnected()) {
314 dart::Monitor::WaitResult res = ml.Wait(); 316 dart::Monitor::WaitResult res = ml.Wait();
315 ASSERT(res == dart::Monitor::kNotified); 317 ASSERT(res == dart::Monitor::kNotified);
316 } 318 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 452
451 453
452 bool DebuggerConnectionHandler::IsConnected() { 454 bool DebuggerConnectionHandler::IsConnected() {
453 // TODO(asiva): Support multiple debugger connections. 455 // TODO(asiva): Support multiple debugger connections.
454 // Return true if a connection has been established. 456 // Return true if a connection has been established.
455 return singleton_handler != NULL; 457 return singleton_handler != NULL;
456 } 458 }
457 459
458 } // namespace bin 460 } // namespace bin
459 } // namespace dart 461 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | runtime/bin/dbg_connection_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698