[Lldb-commits] [PATCH] D61864: Merge target and launch info environments

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 13 12:15:54 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB360612: Merge target and launch info environments (authored by JDevlieghere, committed by ).
Herald added a subscriber: teemperor.

Changed prior to commit:
  https://reviews.llvm.org/D61864?vs=199294&id=199305#toc

Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61864/new/

https://reviews.llvm.org/D61864

Files:
  lit/Process/Inputs/env.cpp
  lit/Process/TestEnvironment.test
  source/Commands/CommandObjectProcess.cpp


Index: lit/Process/TestEnvironment.test
===================================================================
--- lit/Process/TestEnvironment.test
+++ lit/Process/TestEnvironment.test
@@ -0,0 +1,7 @@
+The double quotes around "BAR" ensure we don't match the command.
+
+RUN: %clangxx -std=c++11 %p/Inputs/env.cpp -o %t
+RUN: %lldb %t -o 'process launch --environment FOO="BAR"' | FileCheck %s
+RUN: %lldb %t -o 'env FOO="BAR"' -o 'process launch' | FileCheck %s
+
+CHECK: FOO=BAR
Index: lit/Process/Inputs/env.cpp
===================================================================
--- lit/Process/Inputs/env.cpp
+++ lit/Process/Inputs/env.cpp
@@ -0,0 +1,7 @@
+#include <cstdlib>
+#include <iostream>
+
+int main() {
+  if (const char *env_p = std::getenv("FOO"))
+    std::cout << "FOO=" << env_p << '\n';
+}
Index: source/Commands/CommandObjectProcess.cpp
===================================================================
--- source/Commands/CommandObjectProcess.cpp
+++ source/Commands/CommandObjectProcess.cpp
@@ -193,7 +193,10 @@
     if (target->GetDisableSTDIO())
       m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
 
-    m_options.launch_info.GetEnvironment() = target->GetEnvironment();
+    // Merge the launch info environment with the target environment.
+    Environment target_env = target->GetEnvironment();
+    m_options.launch_info.GetEnvironment().insert(target_env.begin(),
+                                                  target_env.end());
 
     if (!target_settings_argv0.empty()) {
       m_options.launch_info.GetArguments().AppendArgument(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61864.199305.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190513/db233ada/attachment.bin>


More information about the lldb-commits mailing list