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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 | 90 |
91 // Global flag that is used to indicate that we want to trace resolution of | 91 // Global flag that is used to indicate that we want to trace resolution of |
92 // URIs and the loading of libraries, parts and scripts. | 92 // URIs and the loading of libraries, parts and scripts. |
93 static bool has_trace_loading = false; | 93 static bool has_trace_loading = false; |
94 | 94 |
95 | 95 |
96 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 96 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; |
97 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; | 97 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; |
98 // VM Service options. | 98 // VM Service options. |
99 static bool start_vm_service = false; | |
100 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; | 99 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; |
101 // The 0 port is a magic value which results in the first available port | 100 // The 0 port is a magic value which results in the first available port |
102 // being allocated. | 101 // being allocated. |
103 static int vm_service_server_port = -1; | 102 static int vm_service_server_port = -1; |
104 | 103 |
105 | 104 |
106 // Exit code indicating an API error. | 105 // Exit code indicating an API error. |
107 static const int kApiErrorExitCode = 253; | 106 static const int kApiErrorExitCode = 253; |
108 // Exit code indicating a compilation error. | 107 // Exit code indicating a compilation error. |
109 static const int kCompilationErrorExitCode = 254; | 108 static const int kCompilationErrorExitCode = 254; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 if (!ExtractPortAndIP(option_value, | 384 if (!ExtractPortAndIP(option_value, |
386 &vm_service_server_port, | 385 &vm_service_server_port, |
387 &vm_service_server_ip, | 386 &vm_service_server_ip, |
388 DEFAULT_VM_SERVICE_SERVER_PORT, | 387 DEFAULT_VM_SERVICE_SERVER_PORT, |
389 DEFAULT_VM_SERVICE_SERVER_IP)) { | 388 DEFAULT_VM_SERVICE_SERVER_IP)) { |
390 Log::PrintErr("unrecognized --enable-vm-service option syntax. " | 389 Log::PrintErr("unrecognized --enable-vm-service option syntax. " |
391 "Use --enable-vm-service[:<port number>[/<IPv4 address>]]\n"); | 390 "Use --enable-vm-service[:<port number>[/<IPv4 address>]]\n"); |
392 return false; | 391 return false; |
393 } | 392 } |
394 | 393 |
395 start_vm_service = true; | |
396 return true; | 394 return true; |
397 } | 395 } |
398 | 396 |
399 | 397 |
400 static bool ProcessObserveOption(const char* option_value, | 398 static bool ProcessObserveOption(const char* option_value, |
401 CommandLineOptions* vm_options) { | 399 CommandLineOptions* vm_options) { |
402 ASSERT(option_value != NULL); | 400 ASSERT(option_value != NULL); |
403 | 401 |
404 if (!ExtractPortAndIP(option_value, | 402 if (!ExtractPortAndIP(option_value, |
405 &vm_service_server_port, | 403 &vm_service_server_port, |
406 &vm_service_server_ip, | 404 &vm_service_server_ip, |
407 DEFAULT_VM_SERVICE_SERVER_PORT, | 405 DEFAULT_VM_SERVICE_SERVER_PORT, |
408 DEFAULT_VM_SERVICE_SERVER_IP)) { | 406 DEFAULT_VM_SERVICE_SERVER_IP)) { |
409 Log::PrintErr("unrecognized --observe option syntax. " | 407 Log::PrintErr("unrecognized --observe option syntax. " |
410 "Use --observe[:<port number>[/<IPv4 address>]]\n"); | 408 "Use --observe[:<port number>[/<IPv4 address>]]\n"); |
411 return false; | 409 return false; |
412 } | 410 } |
413 | 411 |
414 start_vm_service = true; | |
415 | |
416 vm_options->AddArgument("--pause-isolates-on-exit"); | 412 vm_options->AddArgument("--pause-isolates-on-exit"); |
417 return true; | 413 return true; |
418 } | 414 } |
419 | 415 |
420 | 416 |
421 extern bool trace_debug_protocol; | 417 extern bool trace_debug_protocol; |
422 static bool ProcessTraceDebugProtocolOption(const char* arg, | 418 static bool ProcessTraceDebugProtocolOption(const char* arg, |
423 CommandLineOptions* vm_options) { | 419 CommandLineOptions* vm_options) { |
424 if (*arg != '\0') { | 420 if (*arg != '\0') { |
425 return false; | 421 return false; |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 ErrorExit(kErrorExitCode, | 1058 ErrorExit(kErrorExitCode, |
1063 "Error: Unable to read snapshot file %s\n", filename); | 1059 "Error: Unable to read snapshot file %s\n", filename); |
1064 } | 1060 } |
1065 DartUtils::CloseFile(file); | 1061 DartUtils::CloseFile(file); |
1066 } | 1062 } |
1067 | 1063 |
1068 | 1064 |
1069 static void* LoadLibrarySymbol(const char* libname, const char* symname) { | 1065 static void* LoadLibrarySymbol(const char* libname, const char* symname) { |
1070 void* library = Extensions::LoadExtensionLibrary(libname); | 1066 void* library = Extensions::LoadExtensionLibrary(libname); |
1071 if (library == NULL) { | 1067 if (library == NULL) { |
1072 ErrorExit(kErrorExitCode, | 1068 Log::PrintErr("Error: Failed to load library '%s'\n", libname); |
1073 "Error: Failed to load library '%s'\n", libname); | 1069 exit(kErrorExitCode); |
1074 } | 1070 } |
1075 void* symbol = Extensions::ResolveSymbol(library, symname); | 1071 void* symbol = Extensions::ResolveSymbol(library, symname); |
1076 if (symbol == NULL) { | 1072 if (symbol == NULL) { |
1077 ErrorExit(kErrorExitCode, | 1073 Log::PrintErr("Error: Failed to load symbol '%s'\n", symname); |
1078 "Error: Failed to load symbol '%s'\n", symname); | 1074 exit(kErrorExitCode); |
1079 } | 1075 } |
1080 return symbol; | 1076 return symbol; |
1081 } | 1077 } |
1082 | 1078 |
1083 | 1079 |
1084 void main(int argc, char** argv) { | 1080 void main(int argc, char** argv) { |
1085 char* script_name; | 1081 char* script_name; |
1086 const int EXTRA_VM_ARGUMENTS = 2; | 1082 const int EXTRA_VM_ARGUMENTS = 2; |
1087 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); | 1083 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); |
1088 CommandLineOptions dart_options(argc); | 1084 CommandLineOptions dart_options(argc); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 exit(Process::GlobalExitCode()); | 1366 exit(Process::GlobalExitCode()); |
1371 } | 1367 } |
1372 | 1368 |
1373 } // namespace bin | 1369 } // namespace bin |
1374 } // namespace dart | 1370 } // namespace dart |
1375 | 1371 |
1376 int main(int argc, char** argv) { | 1372 int main(int argc, char** argv) { |
1377 dart::bin::main(argc, argv); | 1373 dart::bin::main(argc, argv); |
1378 UNREACHABLE(); | 1374 UNREACHABLE(); |
1379 } | 1375 } |
OLD | NEW |