@@ -492,8 +492,8 @@ class DartDev {
492492 // Invoke the Dart VM directly bypassing dartdev.
493493 static void InvokeDartVM (int argc, char ** argv, bool argv_converted) {
494494 auto dartvm_path = DartDev::ResolvedDartVmPath ();
495- char * exec_name = dartvm_path.get ();
496- if (exec_name == nullptr || !CheckForInvalidPath (exec_name )) {
495+ if ( dartvm_path.get () == nullptr ||
496+ !CheckForInvalidPath (dartvm_path. get () )) {
497497 // Free environment if any.
498498 Syslog::PrintErr (" Unable to locate the Dart VM executable" );
499499 Options::Cleanup ();
@@ -504,12 +504,23 @@ class DartDev {
504504 err_msg[0 ] = ' \0 ' ;
505505 intptr_t num_args = argc + 2 ;
506506 char ** exec_argv = new char *[num_args];
507- exec_argv[idx] = Utils::StrDup (exec_name);
507+ #if defined(DART_HOST_OS_WINDOWS)
508+ char * exec_name = StringUtilsWin::ArgumentEscape (dartvm_path.get ());
509+ #else
510+ char * exec_name = Utils::StrDup (dartvm_path.get ());
511+ #endif
512+ exec_argv[idx] = exec_name;
508513 const size_t kPathBufSize = PATH_MAX + 1 ;
509514 char dart_path[kPathBufSize ];
510515 Platform::ResolveExecutablePathInto (dart_path, kPathBufSize );
511516 idx += 1 ;
517+ #if defined(DART_HOST_OS_WINDOWS)
518+ char * dart_name = Utils::SCreate (" --executable_name=%s" , dart_path);
519+ exec_argv[idx] = StringUtilsWin::ArgumentEscape (dart_name);
520+ free (dart_name);
521+ #else
512522 exec_argv[idx] = Utils::SCreate (" --executable_name=%s" , dart_path);
523+ #endif
513524 for (intptr_t i = 1 ; i < argc; ++i) {
514525#if defined(DART_HOST_OS_WINDOWS)
515526 exec_argv[i + idx] = StringUtilsWin::ArgumentEscape (argv[i]);
@@ -584,8 +595,8 @@ class DartDev {
584595 static void RunExecResultCallback (Dart_CObject* message) {
585596 result_ = DartDev_Result_RunExec;
586597 auto dartvm_path = DartDev::ResolvedDartVmPath ();
587- char * exec_name = dartvm_path.get ();
588- if (exec_name == nullptr || !CheckForInvalidPath (exec_name )) {
598+ if ( dartvm_path.get () == nullptr ||
599+ !CheckForInvalidPath (dartvm_path. get () )) {
589600 Syslog::PrintErr (" Unable to locate the Dart VM executable" );
590601 Platform::Exit (kErrorExitCode );
591602 }
@@ -629,7 +640,11 @@ class DartDev {
629640
630641 intptr_t idx = 0 ;
631642 // Copy in name of the executable to run (should be the dart vm).
632- script_name_ = Utils::StrDup (exec_name);
643+ #if defined(DART_HOST_OS_WINDOWS)
644+ script_name_ = StringUtilsWin::ArgumentEscape (dartvm_path.get ());
645+ #else
646+ script_name_ = Utils::StrDup (dartvm_path.get ());
647+ #endif
633648 argv_[idx++] = script_name_;
634649 // Copy in VM options if any.
635650 // Copy in any vm options that need to be passed to the execed process.
@@ -641,7 +656,13 @@ class DartDev {
641656 const size_t kPathBufSize = PATH_MAX + 1 ;
642657 char dart_path[kPathBufSize ];
643658 Platform::ResolveExecutablePathInto (dart_path, kPathBufSize );
659+ #if defined(DART_HOST_OS_WINDOWS)
660+ char * dart_name = Utils::SCreate (" --executable_name=%s" , dart_path);
661+ argv_[idx++] = StringUtilsWin::ArgumentEscape (dart_name);
662+ free (dart_name);
663+ #else
644664 argv_[idx++] = Utils::SCreate (" --executable_name=%s" , dart_path);
665+ #endif
645666 }
646667 if (mark_main_isolate_as_system_isolate) {
647668 argv_[idx++] = Utils::StrDup (" --mark_main_isolate_as_system_isolate" );
0 commit comments