[Lldb-commits] [lldb] r238042 - Implement PlatformWindows::GetEnvironment.
Zachary Turner
zturner at google.com
Fri May 22 12:34:17 PDT 2015
Author: zturner
Date: Fri May 22 14:34:17 2015
New Revision: 238042
URL: http://llvm.org/viewvc/llvm-project?rev=238042&view=rev
Log:
Implement PlatformWindows::GetEnvironment.
This fixes a couple of tests that rely on being able to get the
host's environment or spawn an inferior with specific arguments.
Modified:
lldb/trunk/include/lldb/Core/StringList.h
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/source/Core/StringList.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Host/windows/Host.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
Modified: lldb/trunk/include/lldb/Core/StringList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StringList.h?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StringList.h (original)
+++ lldb/trunk/include/lldb/Core/StringList.h Fri May 22 14:34:17 2015
@@ -14,6 +14,7 @@
#include "lldb/Core/STLUtils.h"
#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringRef.h"
namespace lldb_private {
@@ -43,6 +44,9 @@ public:
AppendString (const char *str, size_t str_len);
void
+ AppendString(llvm::StringRef str);
+
+ void
AppendList (const char ** strv, int strc);
void
Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Fri May 22 14:34:17 2015
@@ -287,7 +287,7 @@ public:
static bool
OpenFileInExternalEditor (const FileSpec &file_spec,
uint32_t line_no);
-
+
static size_t
GetEnvironment (StringList &env);
};
Modified: lldb/trunk/source/Core/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StringList.cpp?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/source/Core/StringList.cpp (original)
+++ lldb/trunk/source/Core/StringList.cpp Fri May 22 14:34:17 2015
@@ -69,6 +69,12 @@ StringList::AppendString (const char *st
}
void
+StringList::AppendString(llvm::StringRef str)
+{
+ m_strings.push_back(str.str());
+}
+
+void
StringList::AppendList (const char **strv, int strc)
{
for (int i = 0; i < strc; ++i)
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Fri May 22 14:34:17 2015
@@ -423,17 +423,6 @@ Host::GetSignalAsCString (int signo)
#endif
-#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__) // see macosx/Host.mm
-
-size_t
-Host::GetEnvironment (StringList &env)
-{
- // TODO: Is there a way to the host environment for this process on other systems?
- return 0;
-}
-
-#endif // #if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__)
-
#ifndef _WIN32
lldb::thread_key_t
Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Fri May 22 14:34:17 2015
@@ -306,3 +306,21 @@ Host::ShellExpandArguments (ProcessLaunc
return error;
}
+
+size_t
+Host::GetEnvironment(StringList &env)
+{
+ // The environment block on Windows is a contiguous buffer of NULL terminated strings,
+ // where the end of the environment block is indicated by two consecutive NULLs.
+ LPCH environment_block = ::GetEnvironmentStrings();
+ env.Clear();
+ while (*environment_block != '\0')
+ {
+ llvm::StringRef current_var(environment_block);
+ if (current_var[0] != '=')
+ env.AppendString(current_var);
+
+ environment_block += current_var.size()+1;
+ }
+ return env.GetSize();
+}
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Fri May 22 14:34:17 2015
@@ -730,3 +730,16 @@ PlatformWindows::CanDebugProcess()
{
return true;
}
+
+size_t
+PlatformWindows::GetEnvironment(StringList &env)
+{
+ if (IsRemote())
+ {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment(env);
+ return 0;
+ }
+
+ return Host::GetEnvironment(env);
+}
\ No newline at end of file
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h?rev=238042&r1=238041&r2=238042&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h Fri May 22 14:34:17 2015
@@ -149,6 +149,8 @@ public:
bool CanDebugProcess() override;
+ size_t GetEnvironment(StringList &env) override;
+
// FIXME not sure what the _sigtramp equivalent would be on this platform
void
CalculateTrapHandlerSymbolNames () override
More information about the lldb-commits
mailing list