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_debugger_api.h" | 10 #include "include/dart_debugger_api.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 | 287 |
288 // Parse out the command line arguments. Returns -1 if the arguments | 288 // Parse out the command line arguments. Returns -1 if the arguments |
289 // are incorrect, 0 otherwise. | 289 // are incorrect, 0 otherwise. |
290 static int ParseArguments(int argc, | 290 static int ParseArguments(int argc, |
291 char** argv, | 291 char** argv, |
292 CommandLineOptions* vm_options, | 292 CommandLineOptions* vm_options, |
293 char** executable_name, | 293 char** executable_name, |
294 char** script_name, | 294 char** script_name, |
295 CommandLineOptions* dart_options, | 295 CommandLineOptions* dart_options, |
296 bool* print_flags_seen) { | 296 bool* print_flags_seen, |
| 297 bool* verbose_debug_seen) { |
297 const char* kPrefix = "--"; | 298 const char* kPrefix = "--"; |
298 const intptr_t kPrefixLen = strlen(kPrefix); | 299 const intptr_t kPrefixLen = strlen(kPrefix); |
299 | 300 |
300 // Get the executable name. | 301 // Get the executable name. |
301 *executable_name = argv[0]; | 302 *executable_name = argv[0]; |
302 | 303 |
303 // Start the rest after the executable name. | 304 // Start the rest after the executable name. |
304 int i = 1; | 305 int i = 1; |
305 | 306 |
306 // Parse out the vm options. | 307 // Parse out the vm options. |
307 while (i < argc) { | 308 while (i < argc) { |
308 if (ProcessMainOptions(argv[i])) { | 309 if (ProcessMainOptions(argv[i])) { |
309 i++; | 310 i++; |
310 } else { | 311 } else { |
311 // Check if this flag is a potentially valid VM flag. | 312 // Check if this flag is a potentially valid VM flag. |
312 if (!IsValidFlag(argv[i], kPrefix, kPrefixLen)) { | 313 if (!IsValidFlag(argv[i], kPrefix, kPrefixLen)) { |
313 break; | 314 break; |
314 } | 315 } |
315 const char* kPrintFlags1 = "--print-flags"; | 316 const char* kPrintFlags1 = "--print-flags"; |
316 const char* kPrintFlags2 = "--print_flags"; | 317 const char* kPrintFlags2 = "--print_flags"; |
317 if ((strncmp(argv[i], kPrintFlags1, strlen(kPrintFlags1)) == 0) || | 318 if ((strncmp(argv[i], kPrintFlags1, strlen(kPrintFlags1)) == 0) || |
318 (strncmp(argv[i], kPrintFlags2, strlen(kPrintFlags2)) == 0)) { | 319 (strncmp(argv[i], kPrintFlags2, strlen(kPrintFlags2)) == 0)) { |
319 *print_flags_seen = true; | 320 *print_flags_seen = true; |
320 } | 321 } |
| 322 const char* kVerboseDebug = "--verbose_debug"; |
| 323 if (strncmp(argv[i], kVerboseDebug, strlen(kVerboseDebug)) == 0) { |
| 324 *verbose_debug_seen = true; |
| 325 } |
321 vm_options->AddArgument(argv[i]); | 326 vm_options->AddArgument(argv[i]); |
322 i++; | 327 i++; |
323 } | 328 } |
324 } | 329 } |
325 | 330 |
326 | 331 |
327 // Get the script name. | 332 // Get the script name. |
328 if (i < argc) { | 333 if (i < argc) { |
329 *script_name = argv[i]; | 334 *script_name = argv[i]; |
330 i++; | 335 i++; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 return Dart_True(); | 675 return Dart_True(); |
671 } | 676 } |
672 | 677 |
673 | 678 |
674 int main(int argc, char** argv) { | 679 int main(int argc, char** argv) { |
675 char* executable_name; | 680 char* executable_name; |
676 char* script_name; | 681 char* script_name; |
677 CommandLineOptions vm_options(argc); | 682 CommandLineOptions vm_options(argc); |
678 CommandLineOptions dart_options(argc); | 683 CommandLineOptions dart_options(argc); |
679 bool print_flags_seen = false; | 684 bool print_flags_seen = false; |
| 685 bool verbose_debug_seen = false; |
680 | 686 |
681 // Perform platform specific initialization. | 687 // Perform platform specific initialization. |
682 if (!Platform::Initialize()) { | 688 if (!Platform::Initialize()) { |
683 Log::PrintErr("Initialization failed\n"); | 689 Log::PrintErr("Initialization failed\n"); |
684 } | 690 } |
685 | 691 |
686 // On Windows, the argv strings are code page encoded and not | 692 // On Windows, the argv strings are code page encoded and not |
687 // utf8. We need to convert them to utf8. | 693 // utf8. We need to convert them to utf8. |
688 bool argv_converted = Utf8ConvertArgv(argc, argv); | 694 bool argv_converted = Utf8ConvertArgv(argc, argv); |
689 | 695 |
690 // Parse command line arguments. | 696 // Parse command line arguments. |
691 if (ParseArguments(argc, | 697 if (ParseArguments(argc, |
692 argv, | 698 argv, |
693 &vm_options, | 699 &vm_options, |
694 &executable_name, | 700 &executable_name, |
695 &script_name, | 701 &script_name, |
696 &dart_options, | 702 &dart_options, |
697 &print_flags_seen) < 0) { | 703 &print_flags_seen, |
| 704 &verbose_debug_seen) < 0) { |
698 if (has_help_option) { | 705 if (has_help_option) { |
699 PrintUsage(); | 706 PrintUsage(); |
700 return 0; | 707 return 0; |
701 } else if (has_version_option) { | 708 } else if (has_version_option) { |
702 PrintVersion(); | 709 PrintVersion(); |
703 return 0; | 710 return 0; |
704 } else if (print_flags_seen) { | 711 } else if (print_flags_seen) { |
705 // Will set the VM flags, print them out and then we exit as no | 712 // Will set the VM flags, print them out and then we exit as no |
706 // script was specified on the command line. | 713 // script was specified on the command line. |
707 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 714 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
(...skipping 13 matching lines...) Expand all Loading... |
721 fflush(stderr); | 728 fflush(stderr); |
722 return kErrorExitCode; | 729 return kErrorExitCode; |
723 } | 730 } |
724 | 731 |
725 DartUtils::SetOriginalWorkingDirectory(); | 732 DartUtils::SetOriginalWorkingDirectory(); |
726 | 733 |
727 // Start the debugger wire protocol handler if necessary. | 734 // Start the debugger wire protocol handler if necessary. |
728 if (start_debugger) { | 735 if (start_debugger) { |
729 ASSERT(debug_port != 0); | 736 ASSERT(debug_port != 0); |
730 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); | 737 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); |
| 738 if (verbose_debug_seen) { |
| 739 Log::Print("Debugger initialized\n"); |
| 740 } |
731 } | 741 } |
732 | 742 |
733 // Call CreateIsolateAndSetup which creates an isolate and loads up | 743 // Call CreateIsolateAndSetup which creates an isolate and loads up |
734 // the specified application script. | 744 // the specified application script. |
735 char* error = NULL; | 745 char* error = NULL; |
736 char* isolate_name = BuildIsolateName(script_name, "main"); | 746 char* isolate_name = BuildIsolateName(script_name, "main"); |
737 if (!CreateIsolateAndSetupHelper(script_name, | 747 if (!CreateIsolateAndSetupHelper(script_name, |
738 "main", | 748 "main", |
739 new IsolateData(), | 749 new IsolateData(), |
740 &error)) { | 750 &error)) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 Dart_ShutdownIsolate(); | 841 Dart_ShutdownIsolate(); |
832 // Terminate process exit-code handler. | 842 // Terminate process exit-code handler. |
833 Process::TerminateExitCodeHandler(); | 843 Process::TerminateExitCodeHandler(); |
834 // Free copied argument strings if converted. | 844 // Free copied argument strings if converted. |
835 if (argv_converted) { | 845 if (argv_converted) { |
836 for (int i = 0; i < argc; i++) free(argv[i]); | 846 for (int i = 0; i < argc; i++) free(argv[i]); |
837 } | 847 } |
838 | 848 |
839 return Process::GlobalExitCode(); | 849 return Process::GlobalExitCode(); |
840 } | 850 } |
OLD | NEW |