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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 | 102 |
103 // Global flag that is used to indicate that we want to trace resolution of | 103 // Global flag that is used to indicate that we want to trace resolution of |
104 // URIs and the loading of libraries, parts and scripts. | 104 // URIs and the loading of libraries, parts and scripts. |
105 static bool trace_loading = false; | 105 static bool trace_loading = false; |
106 | 106 |
107 | 107 |
108 static Dart_Isolate main_isolate = NULL; | 108 static Dart_Isolate main_isolate = NULL; |
109 | 109 |
110 | 110 |
111 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 111 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost"; |
112 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; | 112 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; |
113 // VM Service options. | 113 // VM Service options. |
114 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; | 114 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; |
115 // The 0 port is a magic value which results in the first available port | 115 // The 0 port is a magic value which results in the first available port |
116 // being allocated. | 116 // being allocated. |
117 static int vm_service_server_port = -1; | 117 static int vm_service_server_port = -1; |
118 // True when we are running in development mode and cross origin security | 118 // True when we are running in development mode and cross origin security |
119 // checks are disabled. | 119 // checks are disabled. |
120 static bool vm_service_dev_mode = false; | 120 static bool vm_service_dev_mode = false; |
121 | 121 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 commandline_packages_file = arg; | 216 commandline_packages_file = arg; |
217 return true; | 217 return true; |
218 } | 218 } |
219 | 219 |
220 | 220 |
221 static void* GetHashmapKeyFromString(char* key) { | 221 static void* GetHashmapKeyFromString(char* key) { |
222 return reinterpret_cast<void*>(key); | 222 return reinterpret_cast<void*>(key); |
223 } | 223 } |
224 | 224 |
225 | 225 |
226 static bool ExtractPortAndIP(const char* option_value, | 226 static bool ExtractPortAndAddress(const char* option_value, |
227 int* out_port, | 227 int* out_port, |
228 const char** out_ip, | 228 const char** out_ip, |
229 int default_port, | 229 int default_port, |
230 const char* default_ip) { | 230 const char* default_ip) { |
231 // [option_value] has to be one of the following formats: | 231 // [option_value] has to be one of the following formats: |
232 // - "" | 232 // - "" |
233 // - ":8181" | 233 // - ":8181" |
234 // - "=8181" | 234 // - "=8181" |
235 // - ":8181/192.168.0.1" | 235 // - ":8181/192.168.0.1" |
236 // - "=8181/192.168.0.1" | 236 // - "=8181/192.168.0.1" |
| 237 // - "=8181/::1" |
237 | 238 |
238 if (*option_value == '\0') { | 239 if (*option_value == '\0') { |
239 *out_ip = default_ip; | 240 *out_ip = default_ip; |
240 *out_port = default_port; | 241 *out_port = default_port; |
241 return true; | 242 return true; |
242 } | 243 } |
243 | 244 |
244 if ((*option_value != '=') && (*option_value != ':')) { | 245 if ((*option_value != '=') && (*option_value != ':')) { |
245 return false; | 246 return false; |
246 } | 247 } |
247 | 248 |
248 int port = atoi(option_value + 1); | 249 int port = atoi(option_value + 1); |
249 const char* slash = strstr(option_value, "/"); | 250 const char* slash = strstr(option_value, "/"); |
250 if (slash == NULL) { | 251 if (slash == NULL) { |
251 *out_ip = default_ip; | 252 *out_ip = default_ip; |
252 *out_port = port; | 253 *out_port = port; |
253 return true; | 254 return true; |
254 } | 255 } |
255 | 256 |
256 int _, n; | 257 *out_ip = slash + 1; |
257 if (sscanf(option_value + 1, "%d/%d.%d.%d.%d%n", // NOLINT(runtime/printf) | 258 *out_port = port; |
258 &_, &_, &_, &_, &_, &n)) { | 259 return true; |
259 if (option_value[1 + n] == '\0') { | |
260 *out_ip = slash + 1; | |
261 *out_port = port; | |
262 return true; | |
263 } | |
264 } | |
265 return false; | |
266 } | 260 } |
267 | 261 |
268 | 262 |
269 static bool ProcessEnvironmentOption(const char* arg, | 263 static bool ProcessEnvironmentOption(const char* arg, |
270 CommandLineOptions* vm_options) { | 264 CommandLineOptions* vm_options) { |
271 ASSERT(arg != NULL); | 265 ASSERT(arg != NULL); |
272 if (*arg == '\0') { | 266 if (*arg == '\0') { |
273 // Ignore empty -D option. | 267 // Ignore empty -D option. |
274 Log::PrintErr("No arguments given to -D option, ignoring it\n"); | 268 Log::PrintErr("No arguments given to -D option, ignoring it\n"); |
275 return true; | 269 return true; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 "script, app-aot, app-jit\n", | 363 "script, app-aot, app-jit\n", |
370 kind); | 364 kind); |
371 return false; | 365 return false; |
372 } | 366 } |
373 | 367 |
374 | 368 |
375 static bool ProcessEnableVmServiceOption(const char* option_value, | 369 static bool ProcessEnableVmServiceOption(const char* option_value, |
376 CommandLineOptions* vm_options) { | 370 CommandLineOptions* vm_options) { |
377 ASSERT(option_value != NULL); | 371 ASSERT(option_value != NULL); |
378 | 372 |
379 if (!ExtractPortAndIP(option_value, &vm_service_server_port, | 373 if (!ExtractPortAndAddress( |
380 &vm_service_server_ip, DEFAULT_VM_SERVICE_SERVER_PORT, | 374 option_value, &vm_service_server_port, &vm_service_server_ip, |
381 DEFAULT_VM_SERVICE_SERVER_IP)) { | 375 DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) { |
382 Log::PrintErr( | 376 Log::PrintErr( |
383 "unrecognized --enable-vm-service option syntax. " | 377 "unrecognized --enable-vm-service option syntax. " |
384 "Use --enable-vm-service[=<port number>[/<IPv4 address>]]\n"); | 378 "Use --enable-vm-service[=<port number>[/<bind address>]]\n"); |
385 return false; | 379 return false; |
386 } | 380 } |
387 | 381 |
388 return true; | 382 return true; |
389 } | 383 } |
390 | 384 |
391 | 385 |
392 static bool ProcessDisableServiceOriginCheckOption( | 386 static bool ProcessDisableServiceOriginCheckOption( |
393 const char* option_value, | 387 const char* option_value, |
394 CommandLineOptions* vm_options) { | 388 CommandLineOptions* vm_options) { |
395 ASSERT(option_value != NULL); | 389 ASSERT(option_value != NULL); |
396 Log::PrintErr( | 390 Log::PrintErr( |
397 "WARNING: You are running with the service protocol in an " | 391 "WARNING: You are running with the service protocol in an " |
398 "insecure mode.\n"); | 392 "insecure mode.\n"); |
399 vm_service_dev_mode = true; | 393 vm_service_dev_mode = true; |
400 return true; | 394 return true; |
401 } | 395 } |
402 | 396 |
403 | 397 |
404 static bool ProcessObserveOption(const char* option_value, | 398 static bool ProcessObserveOption(const char* option_value, |
405 CommandLineOptions* vm_options) { | 399 CommandLineOptions* vm_options) { |
406 ASSERT(option_value != NULL); | 400 ASSERT(option_value != NULL); |
407 | 401 |
408 if (!ExtractPortAndIP(option_value, &vm_service_server_port, | 402 if (!ExtractPortAndAddress( |
409 &vm_service_server_ip, DEFAULT_VM_SERVICE_SERVER_PORT, | 403 option_value, &vm_service_server_port, &vm_service_server_ip, |
410 DEFAULT_VM_SERVICE_SERVER_IP)) { | 404 DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) { |
411 Log::PrintErr( | 405 Log::PrintErr( |
412 "unrecognized --observe option syntax. " | 406 "unrecognized --observe option syntax. " |
413 "Use --observe[=<port number>[/<IPv4 address>]]\n"); | 407 "Use --observe[=<port number>[/<bind address>]]\n"); |
414 return false; | 408 return false; |
415 } | 409 } |
416 | 410 |
417 // These options should also be documented in the help message. | 411 // These options should also be documented in the help message. |
418 vm_options->AddArgument("--pause-isolates-on-exit"); | 412 vm_options->AddArgument("--pause-isolates-on-exit"); |
419 vm_options->AddArgument("--pause-isolates-on-unhandled-exceptions"); | 413 vm_options->AddArgument("--pause-isolates-on-unhandled-exceptions"); |
420 vm_options->AddArgument("--warn-on-pause-with-no-debugger"); | 414 vm_options->AddArgument("--warn-on-pause-with-no-debugger"); |
421 return true; | 415 return true; |
422 } | 416 } |
423 | 417 |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 " script(default), app-aot or app-jit\n" | 1017 " script(default), app-aot or app-jit\n" |
1024 " <file_name> specifies the file into which the snapshot is written\n" | 1018 " <file_name> specifies the file into which the snapshot is written\n" |
1025 "--version\n" | 1019 "--version\n" |
1026 " Print the VM version.\n" | 1020 " Print the VM version.\n" |
1027 "\n" | 1021 "\n" |
1028 "--trace-loading\n" | 1022 "--trace-loading\n" |
1029 " enables tracing of library and script loading\n" | 1023 " enables tracing of library and script loading\n" |
1030 "\n" | 1024 "\n" |
1031 "--enable-vm-service[=<port>[/<bind-address>]]\n" | 1025 "--enable-vm-service[=<port>[/<bind-address>]]\n" |
1032 " enables the VM service and listens on specified port for connections\n" | 1026 " enables the VM service and listens on specified port for connections\n" |
1033 " (default port number is 8181, default bind address is 127.0.0.1).\n" | 1027 " (default port number is 8181, default bind address is localhost).\n" |
1034 #if !defined(TARGET_OS_MACOS) | 1028 #if !defined(TARGET_OS_MACOS) |
1035 "\n" | 1029 "\n" |
1036 "--root-certs-file=<path>\n" | 1030 "--root-certs-file=<path>\n" |
1037 " The path to a file containing the trusted root certificates to use for\n" | 1031 " The path to a file containing the trusted root certificates to use for\n" |
1038 " secure socket connections.\n" | 1032 " secure socket connections.\n" |
1039 "--root-certs-cache=<path>\n" | 1033 "--root-certs-cache=<path>\n" |
1040 " The path to a cache directory containing the trusted root certificates to\n" | 1034 " The path to a cache directory containing the trusted root certificates to\n" |
1041 " use for secure socket connections.\n" | 1035 " use for secure socket connections.\n" |
1042 #endif // !defined(TARGET_OS_MACOS) | 1036 #endif // !defined(TARGET_OS_MACOS) |
1043 "\n" | 1037 "\n" |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 Platform::Exit(Process::GlobalExitCode()); | 1942 Platform::Exit(Process::GlobalExitCode()); |
1949 } | 1943 } |
1950 | 1944 |
1951 } // namespace bin | 1945 } // namespace bin |
1952 } // namespace dart | 1946 } // namespace dart |
1953 | 1947 |
1954 int main(int argc, char** argv) { | 1948 int main(int argc, char** argv) { |
1955 dart::bin::main(argc, argv); | 1949 dart::bin::main(argc, argv); |
1956 UNREACHABLE(); | 1950 UNREACHABLE(); |
1957 } | 1951 } |
OLD | NEW |