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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/dbg_connection.h" | 8 #include "bin/dbg_connection.h" |
9 | 9 |
10 #include "bin/eventhandler.h" | 10 #include "bin/eventhandler.h" |
11 | 11 |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 namespace bin { | 14 namespace bin { |
15 | 15 |
16 void DebuggerConnectionImpl::ThreadEntry(uword args) { | 16 void DebuggerConnectionImpl::ThreadEntry(uword args) { |
17 ListenSocket* listen_socket = | 17 ListenSocket* listen_socket = |
18 reinterpret_cast<ListenSocket*>(DebuggerConnectionHandler::listener_fd_); | 18 reinterpret_cast<ListenSocket*>(DebuggerConnectionHandler::listener_fd_); |
19 SOCKET client_socket = accept(listen_socket->socket(), NULL, NULL); | 19 SOCKET client_socket = accept(listen_socket->socket(), NULL, NULL); |
20 if (client_socket == INVALID_SOCKET) { | 20 if (client_socket == INVALID_SOCKET) { |
21 FATAL("Accepting new debugger connection failed.\n"); | 21 FATAL("Accepting new debugger connection failed.\n"); |
22 } | 22 } |
23 ClientSocket* socket = new ClientSocket(client_socket); | 23 ClientSocket* socket = new ClientSocket(client_socket); |
24 DebuggerConnectionHandler::AcceptDbgConnection(reinterpret_cast<int>(socket)); | 24 DebuggerConnectionHandler::AcceptDbgConnection( |
| 25 reinterpret_cast<intptr_t>(socket)); |
25 } | 26 } |
26 | 27 |
27 | 28 |
28 void DebuggerConnectionImpl::StartHandler(int port_number) { | 29 void DebuggerConnectionImpl::StartHandler(int port_number) { |
29 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); | 30 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); |
30 int result = dart::Thread::Start(&DebuggerConnectionImpl::ThreadEntry, 0); | 31 int result = dart::Thread::Start(&DebuggerConnectionImpl::ThreadEntry, 0); |
31 if (result != 0) { | 32 if (result != 0) { |
32 FATAL1("Failed to start debugger connection handler thread: %d\n", result); | 33 FATAL1("Failed to start debugger connection handler thread: %d\n", result); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 | 37 |
37 intptr_t DebuggerConnectionImpl::Send(intptr_t socket, | 38 intptr_t DebuggerConnectionImpl::Send(intptr_t socket, |
38 const char* buf, | 39 const char* buf, |
39 int len) { | 40 int len) { |
40 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(socket); | 41 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(socket); |
41 return send(client_socket->socket(), buf, len, 0); | 42 return send(client_socket->socket(), buf, len, 0); |
42 } | 43 } |
43 | 44 |
44 | 45 |
45 intptr_t DebuggerConnectionImpl::Receive(intptr_t socket, char* buf, int len) { | 46 intptr_t DebuggerConnectionImpl::Receive(intptr_t socket, char* buf, int len) { |
46 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(socket); | 47 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(socket); |
47 return recv(client_socket->socket(), buf, len, 0); | 48 return recv(client_socket->socket(), buf, len, 0); |
48 } | 49 } |
49 | 50 |
50 } // namespace bin | 51 } // namespace bin |
51 } // namespace dart | 52 } // namespace dart |
52 | 53 |
53 #endif // defined(TARGET_OS_WINDOWS) | 54 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |