Index: lldb/source/Host/windows/ProcessLauncherWindows.cpp =================================================================== --- lldb/source/Host/windows/ProcessLauncherWindows.cpp +++ lldb/source/Host/windows/ProcessLauncherWindows.cpp @@ -104,17 +104,21 @@ llvm::ConvertUTF8toWide(commandLine, wcommandLine); llvm::ConvertUTF8toWide(launch_info.GetWorkingDirectory().GetCString(), wworkingDirectory); + // If the command line is empty, it's best to pass a null pointer to tell + // CreateProcessW to use the executable name as the command line. If the + // command line is not empty, its contents may be modified by CreateProcessW. + WCHAR *pwcommandLine = wcommandLine.empty() ? nullptr : &wcommandLine[0]; - wcommandLine.resize(PATH_MAX); // Needs to be over-allocated because - // CreateProcessW can modify it BOOL result = ::CreateProcessW( - wexecutable.c_str(), &wcommandLine[0], NULL, NULL, TRUE, flags, env_block, + wexecutable.c_str(), pwcommandLine, NULL, NULL, TRUE, flags, env_block, wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(), &startupinfo, &pi); if (!result) { // Call GetLastError before we make any other system calls. error.SetError(::GetLastError(), eErrorTypeWin32); + // Note that error 50 ("The request is not supported") will occur if you + // try debug a 64-bit inferior from a 32-bit LLDB. } if (result) {