Author: Pavel Labath Date: 2020-03-30T17:32:42+02:00 New Revision: 37889786b040bd2bc48e5a01c6b92de777564a8f
URL: https://github.com/llvm/llvm-project/commit/37889786b040bd2bc48e5a01c6b92de777564a8f DIFF: https://github.com/llvm/llvm-project/commit/37889786b040bd2bc48e5a01c6b92de777564a8f.diff LOG: Revert "[lldb] Fix TestSettings.test_pass_host_env_vars on windows" This reverts commit because of test failures in TestHelloWorld. It seems that this test (specifically running "ls" as a platform shell command) depended on the implicit passing of the host environment. The fix should be fairly simple (inherit the environment explicitly), but it may take me a while to figure where exactly to do that. Revert while I am figuring that out. Added: Modified: lldb/source/Host/windows/ProcessLauncherWindows.cpp lldb/test/API/commands/settings/TestSettings.py Removed: ################################################################################ diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp index 00470f558e94..31101944d75c 100644 --- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp +++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp @@ -23,9 +23,10 @@ using namespace lldb_private; namespace { void CreateEnvironmentBuffer(const Environment &env, std::vector<char> &buffer) { - // The buffer is a list of null-terminated UTF-16 strings, followed by an - // extra L'\0' (two bytes of 0). An empty environment must have one - // empty string, followed by an extra L'\0'. + if (env.size() == 0) + return; + + // Environment buffer is a null terminated list of null terminated strings for (const auto &KV : env) { std::wstring warg; if (llvm::ConvertUTF8toWide(Environment::compose(KV), warg)) { @@ -37,9 +38,6 @@ void CreateEnvironmentBuffer(const Environment &env, // One null wchar_t (to end the block) is two null bytes buffer.push_back(0); buffer.push_back(0); - // Insert extra two bytes, just in case the environment was empty. - buffer.push_back(0); - buffer.push_back(0); } bool GetFlattenedWindowsCommandString(Args args, std::string &command) { @@ -96,7 +94,8 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, LPVOID env_block = nullptr; ::CreateEnvironmentBuffer(launch_info.GetEnvironment(), environment); - env_block = environment.data(); + if (!environment.empty()) + env_block = environment.data(); executable = launch_info.GetExecutableFile().GetPath(); GetFlattenedWindowsCommandString(launch_info.GetArguments(), commandLine); diff --git a/lldb/test/API/commands/settings/TestSettings.py b/lldb/test/API/commands/settings/TestSettings.py index 29360856a735..c0cdc085f129 100644 --- a/lldb/test/API/commands/settings/TestSettings.py +++ b/lldb/test/API/commands/settings/TestSettings.py @@ -286,6 +286,7 @@ def do_test_run_args_and_env_vars(self, use_launchsimple): "Environment variable 'MY_ENV_VAR' successfully passed."]) @skipIfRemote # it doesn't make sense to send host env to remote target + @skipIf(oslist=["windows"]) def test_pass_host_env_vars(self): """Test that the host env vars are passed to the launched process.""" self.build() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits