From e15fcaa2e50882407bfc44086b9aa28f22dcbef5 Mon Sep 17 00:00:00 2001
From: Todd Fiala <todd.fiala@gmail.com>
Date: Wed, 24 Sep 2014 23:10:30 +0000
Subject: [PATCH] Moved PlatformDarwin::GetEnvironment() to PlatformPOSIX to
 fix Linux/llgs issue.

See http://reviews.llvm.org/D5486 for more details.

I was tracking a problem where llgs on linux would not pick up any environment variables. On OSX there is a virtual function PlatformDarwin::GetEnvironment() which correctly sets up the list of environment variables. On linux llgs it defaults to a base class default implementation which clears the list.

I moved the OSX implementation down to PlatformPOSIX. This fixes my problem on linux still works properly on OSX.

Change by Shawn Best.
Slight tweak to convert 'virtual' to 'override' in PlatformDarwin.h virtual method override by Todd.

Tested:
Ubuntu 14.04 x86_64, cmake/ninja build + tests.
MacOSX 10.9.5 x86_64, Xcode 6.1 Beta build + tests.

llvm-svn: 218424
---
 .../Plugins/Platform/MacOSX/PlatformDarwin.cpp       | 11 -----------
 lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h |  3 ---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 12 ++++++++++++
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h   |  3 +++
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index fc7f6c5a1316..7fdd77cffcda 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1212,17 +1212,6 @@ PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
     return bp_sp;
 }
 
-size_t
-PlatformDarwin::GetEnvironment (StringList &env)
-{
-    if (IsRemote())
-    {
-        if (m_remote_platform_sp)
-            return m_remote_platform_sp->GetEnvironment(env);
-        return 0;
-    }
-    return Host::GetEnvironment(env);
-}
 
 int32_t
 PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index 535e38bf76ad..a4105c58ccca 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -78,9 +78,6 @@ public:
     virtual bool
     ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp);
     
-    virtual size_t
-    GetEnvironment (lldb_private::StringList &environment);
-
     bool
     ARMGetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
     
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 0b06a6efd11b..16ef03035212 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -634,6 +634,18 @@ PlatformPOSIX::GetRemoteOSBuildString (std::string &s)
     return false;
 }
 
+size_t
+PlatformPOSIX::GetEnvironment (StringList &env)
+{
+    if (IsRemote())
+    {
+        if (m_remote_platform_sp)
+            return m_remote_platform_sp->GetEnvironment(env);
+        return 0;
+    }
+    return Host::GetEnvironment(env);
+}
+
 bool
 PlatformPOSIX::GetRemoteOSKernelDescription (std::string &s)
 {
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 374e36495d88..700c0fe20734 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -101,6 +101,9 @@ public:
     lldb_private::ArchSpec
     GetRemoteSystemArchitecture () override;
 
+    size_t
+    GetEnvironment (lldb_private::StringList &environment) override;
+
     bool
     IsConnected () const override;