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

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

Issue 11312242: Revised CL for customisable logging (replacing printfs). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
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 <errno.h> 5 #include <errno.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <sys/epoll.h> 8 #include <sys/epoll.h>
9 9
10 #include "bin/dbg_connection.h" 10 #include "bin/dbg_connection.h"
11 #include "bin/fdutils.h" 11 #include "bin/fdutils.h"
12 #include "bin/log.h"
12 #include "bin/socket.h" 13 #include "bin/socket.h"
13 14
14 int DebuggerConnectionImpl::epoll_fd_ = -1; 15 int DebuggerConnectionImpl::epoll_fd_ = -1;
15 int DebuggerConnectionImpl::wakeup_fds_[2] = {-1, -1}; 16 int DebuggerConnectionImpl::wakeup_fds_[2] = {-1, -1};
16 17
17 18
18 void DebuggerConnectionImpl::HandleEvent(struct epoll_event* event) { 19 void DebuggerConnectionImpl::HandleEvent(struct epoll_event* event) {
19 if (event->data.fd == DebuggerConnectionHandler::listener_fd_) { 20 if (event->data.fd == DebuggerConnectionHandler::listener_fd_) {
20 if (DebuggerConnectionHandler::IsConnected()) { 21 if (DebuggerConnectionHandler::IsConnected()) {
21 FATAL("Cannot connect to more than one debugger.\n"); 22 FATAL("Cannot connect to more than one debugger.\n");
22 } 23 }
23 int fd = ServerSocket::Accept(event->data.fd); 24 int fd = ServerSocket::Accept(event->data.fd);
24 if (fd < 0) { 25 if (fd < 0) {
25 FATAL("Accepting new debugger connection failed.\n"); 26 FATAL("Accepting new debugger connection failed.\n");
26 } 27 }
27 FDUtils::SetBlocking(fd); 28 FDUtils::SetBlocking(fd);
28 DebuggerConnectionHandler::AcceptDbgConnection(fd); 29 DebuggerConnectionHandler::AcceptDbgConnection(fd);
29 // TODO(hausner): add the debugger wire socket fd to the event poll queue 30 // TODO(hausner): add the debugger wire socket fd to the event poll queue
30 // once we poll the debugger connection. 31 // once we poll the debugger connection.
31 } else if (event->data.fd == wakeup_fds_[0]) { 32 } else if (event->data.fd == wakeup_fds_[0]) {
32 // Sync message. Not yet implemented. 33 // Sync message. Not yet implemented.
33 UNIMPLEMENTED(); 34 UNIMPLEMENTED();
34 } else { 35 } else {
35 printf("unexpected: receiving debugger connection event.\n"); 36 Log::Print("unexpected: receiving debugger connection event.\n");
36 UNIMPLEMENTED(); 37 UNIMPLEMENTED();
37 } 38 }
38 } 39 }
39 40
40 41
41 void DebuggerConnectionImpl::Handler(uword args) { 42 void DebuggerConnectionImpl::Handler(uword args) {
42 static const intptr_t kMaxEvents = 4; 43 static const intptr_t kMaxEvents = 4;
43 struct epoll_event events[kMaxEvents]; 44 struct epoll_event events[kMaxEvents];
44 while (1) { 45 while (1) {
45 const int no_timeout = -1; 46 const int no_timeout = -1;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 97
97 void DebuggerConnectionImpl::StartHandler(int port_number) { 98 void DebuggerConnectionImpl::StartHandler(int port_number) {
98 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); 99 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1);
99 SetupPollQueue(); 100 SetupPollQueue();
100 int result = dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0); 101 int result = dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0);
101 if (result != 0) { 102 if (result != 0) {
102 FATAL1("Failed to start debugger connection handler thread: %d\n", result); 103 FATAL1("Failed to start debugger connection handler thread: %d\n", result);
103 } 104 }
104 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698