| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 const intptr_t length = strlen(name); | 36 const intptr_t length = strlen(name); |
| 37 if (strncmp(option, name, length) == 0) { | 37 if (strncmp(option, name, length) == 0) { |
| 38 return (option + length); | 38 return (option + length); |
| 39 } | 39 } |
| 40 return NULL; | 40 return NULL; |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 static bool ProcessPprofOption(const char* option) { | 44 static bool ProcessPprofOption(const char* option) { |
| 45 const char* kProfOption = "--generate_pprof_symbols="; | 45 const char* kProfOption = "--generate_pprof_symbols="; |
| 46 generate_pprof_symbols_filename = ProcessOption(option, kProfOption); | 46 const char* filename = ProcessOption(option, kProfOption); |
| 47 return generate_pprof_symbols_filename != NULL; | 47 if (filename != NULL) { |
| 48 generate_pprof_symbols_filename = filename; |
| 49 } |
| 50 return filename != NULL; |
| 48 } | 51 } |
| 49 | 52 |
| 50 | 53 |
| 51 // Parse out the command line arguments. Returns -1 if the arguments | 54 // Parse out the command line arguments. Returns -1 if the arguments |
| 52 // are incorrect, 0 otherwise. | 55 // are incorrect, 0 otherwise. |
| 53 static int ParseArguments(int argc, | 56 static int ParseArguments(int argc, |
| 54 char** argv, | 57 char** argv, |
| 55 CommandLineOptions* vm_options, | 58 CommandLineOptions* vm_options, |
| 56 char** script_name, | 59 char** script_name, |
| 57 CommandLineOptions* dart_options) { | 60 CommandLineOptions* dart_options) { |
| 58 const char* kPrefix = "--"; | 61 const char* kPrefix = "--"; |
| 59 const intptr_t kPrefixLen = strlen(kPrefix); | 62 const intptr_t kPrefixLen = strlen(kPrefix); |
| 60 | 63 |
| 61 // Skip the binary name. | 64 // Skip the binary name. |
| 62 int i = 1; | 65 int i = 1; |
| 63 | 66 |
| 64 // Parse out the vm options. | 67 // Parse out the vm options. |
| 65 while ((i < argc) && IsValidFlag(argv[i], kPrefix, kPrefixLen)) { | 68 while ((i < argc) && IsValidFlag(argv[i], kPrefix, kPrefixLen)) { |
| 66 if (ProcessPprofOption(argv[i])) { | 69 if (ProcessPprofOption(argv[i])) { |
| 67 i += 1; | 70 i += 1; |
| 68 Dart_InitPprofSupport(); | |
| 69 continue; | 71 continue; |
| 70 } | 72 } |
| 71 vm_options->AddArgument(argv[i]); | 73 vm_options->AddArgument(argv[i]); |
| 72 i += 1; | 74 i += 1; |
| 73 } | 75 } |
| 76 if (generate_pprof_symbols_filename != NULL) { |
| 77 Dart_InitPprofSupport(); |
| 78 } |
| 74 | 79 |
| 75 // Get the script name. | 80 // Get the script name. |
| 76 if (i < argc) { | 81 if (i < argc) { |
| 77 *script_name = argv[i]; | 82 *script_name = argv[i]; |
| 78 i += 1; | 83 i += 1; |
| 79 } else { | 84 } else { |
| 80 return -1; | 85 return -1; |
| 81 } | 86 } |
| 82 | 87 |
| 83 // Parse out options to be passed to dart main. | 88 // Parse out options to be passed to dart main. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return 255; // Indicates we encountered an error. | 318 return 255; // Indicates we encountered an error. |
| 314 } | 319 } |
| 315 free(canonical_script_name); | 320 free(canonical_script_name); |
| 316 Dart_ExitScope(); | 321 Dart_ExitScope(); |
| 317 // Dump symbol information for the profiler. | 322 // Dump symbol information for the profiler. |
| 318 DumpPprofSymbolInfo(); | 323 DumpPprofSymbolInfo(); |
| 319 // Shutdown the isolate. | 324 // Shutdown the isolate. |
| 320 Dart_ShutdownIsolate(); | 325 Dart_ShutdownIsolate(); |
| 321 return 0; | 326 return 0; |
| 322 } | 327 } |
| OLD | NEW |