[Lldb-commits] [PATCH] D41352: debugserver: Propagate environment in launch-mode (pr35671)

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 18 07:25:35 PST 2017


labath created this revision.
labath added reviewers: jasonmolenda, clayborg.
Herald added a subscriber: JDevlieghere.

Make sure we propagate environment when starting debugserver with a pre-loaded
inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior
scenario, so we can just pick up the debugserver environment instead of trying
to construct an envp from the (empty) context.

This makes debugserver pass an test added for an equivalent lldb-server fix.


https://reviews.llvm.org/D41352

Files:
  tools/debugserver/source/debugserver.cpp
  unittests/tools/lldb-server/tests/LLGSTest.cpp


Index: unittests/tools/lldb-server/tests/LLGSTest.cpp
===================================================================
--- unittests/tools/lldb-server/tests/LLGSTest.cpp
+++ unittests/tools/lldb-server/tests/LLGSTest.cpp
@@ -16,11 +16,6 @@
 using namespace llvm;
 
 TEST_F(TestBase, LaunchModePreservesEnvironment) {
-  if (TestClient::IsDebugServer()) {
-    GTEST_LOG_(WARNING) << "Test fails with debugserver: llvm.org/pr35671";
-    return;
-  }
-
   putenv(const_cast<char *>("LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE"));
 
   auto ClientOr = TestClient::launch(getLogFileName(),
Index: tools/debugserver/source/debugserver.cpp
===================================================================
--- tools/debugserver/source/debugserver.cpp
+++ tools/debugserver/source/debugserver.cpp
@@ -190,15 +190,6 @@
   for (i = 0; i < inferior_argc; i++)
     inferior_argv[i] = ctx.ArgumentAtIndex(i);
 
-  // Pass the environment array the same way:
-
-  size_t inferior_envc = ctx.EnvironmentCount();
-  // Initialize inferior_argv with inferior_argc + 1 NULLs
-  std::vector<const char *> inferior_envp(inferior_envc + 1, NULL);
-
-  for (i = 0; i < inferior_envc; i++)
-    inferior_envp[i] = ctx.EnvironmentAtIndex(i);
-
   // Our launch type hasn't been set to anything concrete, so we need to
   // figure our how we are going to launch automatically.
 
@@ -241,7 +232,7 @@
                                        : ctx.GetWorkingDirectory());
   const char *process_event = ctx.GetProcessEvent();
   nub_process_t pid = DNBProcessLaunch(
-      resolved_path, &inferior_argv[0], &inferior_envp[0], cwd, stdin_path,
+      resolved_path, &inferior_argv[0], const_cast<const char**>(*_NSGetEnviron()), cwd, stdin_path,
       stdout_path, stderr_path, no_stdio, launch_flavor, g_disable_aslr,
       process_event, launch_err_str, sizeof(launch_err_str));
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41352.127357.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171218/81830098/attachment.bin>


More information about the lldb-commits mailing list