| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/vmservice_dartium.h" | 5 #include "bin/vmservice_dartium.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
| 10 #include "bin/platform.h" | 10 #include "bin/platform.h" |
| 11 #include "bin/thread.h" | 11 #include "bin/thread.h" |
| 12 #include "bin/utils.h" | 12 #include "bin/utils.h" |
| 13 #include "bin/vmservice_impl.h" | 13 #include "bin/vmservice_impl.h" |
| 14 #include "zlib/zlib.h" | 14 #include "zlib/zlib.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 namespace bin { | 17 namespace bin { |
| 18 | 18 |
| 19 #define CHECK_RESULT(result) \ | 19 #define CHECK_RESULT(result) \ |
| 20 if (Dart_IsError(result)) { \ | 20 if (Dart_IsError(result)) { \ |
| 21 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ | 21 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ |
| 22 Dart_ExitScope(); \ | 22 Dart_ExitScope(); \ |
| 23 Dart_ShutdownIsolate(); \ | 23 Dart_ShutdownIsolate(); \ |
| 24 return 0; \ | 24 return 0; \ |
| 25 } | 25 } |
| 26 | 26 |
| 27 static const char* DART_IPV6_ONLY_FLAG = "DART_IPV6_ONLY"; |
| 28 static const char* DEFAULT_VM_SERVICE_SERVER_IP_V6 = "::1"; |
| 29 static const char* DEFAULT_VM_SERVICE_SERVER_IP_V4 = "127.0.0.1"; |
| 30 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; |
| 27 | 31 |
| 28 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 32 static bool IsIpv6Only() { |
| 29 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; | 33 char* v = getenv(DART_IPV6_ONLY_FLAG); |
| 34 if (!v) return 0; |
| 35 return v[0] == '1'; |
| 36 } |
| 30 | 37 |
| 31 void VmServiceServer::Bootstrap() { | 38 void VmServiceServer::Bootstrap() { |
| 32 if (!Platform::Initialize()) { | 39 if (!Platform::Initialize()) { |
| 33 fprintf(stderr, "Platform::Initialize() failed\n"); | 40 fprintf(stderr, "Platform::Initialize() failed\n"); |
| 34 } | 41 } |
| 35 DartUtils::SetOriginalWorkingDirectory(); | 42 DartUtils::SetOriginalWorkingDirectory(); |
| 36 Thread::InitOnce(); | 43 Thread::InitOnce(); |
| 37 TimerUtils::InitOnce(); | 44 TimerUtils::InitOnce(); |
| 38 EventHandler::Start(); | 45 EventHandler::Start(); |
| 39 } | 46 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); | 59 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); |
| 53 return 0; | 60 return 0; |
| 54 } | 61 } |
| 55 | 62 |
| 56 Dart_EnterScope(); | 63 Dart_EnterScope(); |
| 57 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 64 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 58 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 65 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 59 | 66 |
| 60 ASSERT(Dart_IsServiceIsolate(isolate)); | 67 ASSERT(Dart_IsServiceIsolate(isolate)); |
| 61 if (!VmService::Setup( | 68 if (!VmService::Setup( |
| 62 DEFAULT_VM_SERVICE_SERVER_IP, DEFAULT_VM_SERVICE_SERVER_PORT, | 69 IsIpv6Only() ? DEFAULT_VM_SERVICE_SERVER_IP_V6 : |
| 70 DEFAULT_VM_SERVICE_SERVER_IP_V4, |
| 71 DEFAULT_VM_SERVICE_SERVER_PORT, |
| 63 false /* running_precompiled */, false /* disable origin checks */, | 72 false /* running_precompiled */, false /* disable origin checks */, |
| 64 false /* trace_loading */)) { | 73 false /* trace_loading */)) { |
| 65 fprintf(stderr, "Vmservice::Setup failed: %s\n", | 74 fprintf(stderr, "Vmservice::Setup failed: %s\n", |
| 66 VmService::GetErrorMessage()); | 75 VmService::GetErrorMessage()); |
| 67 isolate = NULL; | 76 isolate = NULL; |
| 68 } | 77 } |
| 69 Dart_ExitScope(); | 78 Dart_ExitScope(); |
| 70 Dart_ExitIsolate(); | 79 Dart_ExitIsolate(); |
| 71 return isolate; | 80 return isolate; |
| 72 } | 81 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 150 |
| 142 | 151 |
| 143 /* DISALLOW_ALLOCATION */ | 152 /* DISALLOW_ALLOCATION */ |
| 144 void VmServiceServer::operator delete(void* pointer) { | 153 void VmServiceServer::operator delete(void* pointer) { |
| 145 fprintf(stderr, "unreachable code\n"); | 154 fprintf(stderr, "unreachable code\n"); |
| 146 abort(); | 155 abort(); |
| 147 } | 156 } |
| 148 | 157 |
| 149 } // namespace bin | 158 } // namespace bin |
| 150 } // namespace dart | 159 } // namespace dart |
| OLD | NEW |