| 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/event.h> | 9 #include <sys/event.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 /* For now, don't poll the debugger connection. | 78 /* For now, don't poll the debugger connection. |
| 79 struct kevent ev_add; | 79 struct kevent ev_add; |
| 80 EV_SET(&ev_add, fd, EVFILT_READ, EV_ADD, 0, 0, NULL); | 80 EV_SET(&ev_add, fd, EVFILT_READ, EV_ADD, 0, 0, NULL); |
| 81 int status = | 81 int status = |
| 82 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &ev_add, 1, NULL, 0, NULL)); | 82 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &ev_add, 1, NULL, 0, NULL)); |
| 83 if (status == -1) { | 83 if (status == -1) { |
| 84 FATAL1("Failed adding debugger socket to kqueue: %s\n", strerror(errno)); | 84 FATAL1("Failed adding debugger socket to kqueue: %s\n", strerror(errno)); |
| 85 } | 85 } |
| 86 */ | 86 */ |
| 87 } else if (ident == DebuggerConnectionHandler::debugger_fd_) { | 87 } else if (ident == wakeup_fds[0]) { |
| 88 printf("unexpected: receiving debugger connection event.\n"); | |
| 89 UNIMPLEMENTED(); | |
| 90 } else { | |
| 91 Message msg; | 88 Message msg; |
| 92 if (ReceiveMessage(&msg)) { | 89 if (ReceiveMessage(&msg)) { |
| 93 printf("Received sync message id %d.\n", msg.msg_id); | 90 printf("Received sync message id %d.\n", msg.msg_id); |
| 94 } | 91 } |
| 92 } else { |
| 93 printf("unexpected: receiving debugger connection event.\n"); |
| 94 UNIMPLEMENTED(); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 void DebuggerConnectionImpl::Handler(uword args) { | 99 void DebuggerConnectionImpl::Handler(uword args) { |
| 100 static const intptr_t kMaxEvents = 4; | 100 static const intptr_t kMaxEvents = 4; |
| 101 struct kevent events[kMaxEvents]; | 101 struct kevent events[kMaxEvents]; |
| 102 | 102 |
| 103 while (1) { | 103 while (1) { |
| 104 // Wait indefinitely for an event. | 104 // Wait indefinitely for an event. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 void DebuggerConnectionImpl::StartHandler(int port_number) { | 150 void DebuggerConnectionImpl::StartHandler(int port_number) { |
| 151 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); | 151 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); |
| 152 SetupPollQueue(); | 152 SetupPollQueue(); |
| 153 int result = | 153 int result = |
| 154 dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0); | 154 dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0); |
| 155 if (result != 0) { | 155 if (result != 0) { |
| 156 FATAL1("Failed to start debugger connection handler thread: %d\n", result); | 156 FATAL1("Failed to start debugger connection handler thread: %d\n", result); |
| 157 } | 157 } |
| 158 } | 158 } |
| OLD | NEW |