[Lldb-commits] [lldb] r299781 - Correct environ parsing on FreeBSD

Ed Maste via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 7 09:40:26 PDT 2017


Author: emaste
Date: Fri Apr  7 11:40:25 2017
New Revision: 299781

URL: http://llvm.org/viewvc/llvm-project?rev=299781&view=rev
Log:
Correct environ parsing on FreeBSD

Sync Host:GetEnvironment with Linux and Kamil Rytarowski's forthcoming
NetBSD change in review D31784.

Modified:
    lldb/trunk/source/Host/freebsd/Host.cpp

Modified: lldb/trunk/source/Host/freebsd/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=299781&r1=299780&r2=299781&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/Host.cpp (original)
+++ lldb/trunk/source/Host/freebsd/Host.cpp Fri Apr  7 11:40:25 2017
@@ -52,18 +52,6 @@ extern char **environ;
 using namespace lldb;
 using namespace lldb_private;
 
-size_t Host::GetEnvironment(StringList &env) {
-  char *v;
-  char **var = environ;
-  for (; var != NULL && *var != NULL; ++var) {
-    v = strchr(*var, (int)'-');
-    if (v == NULL)
-      continue;
-    env.AppendString(v);
-  }
-  return env.GetSize();
-}
-
 static bool
 GetFreeBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
                       ProcessInstanceInfo &process_info) {
@@ -243,6 +231,15 @@ bool Host::GetProcessInfo(lldb::pid_t pi
   return false;
 }
 
+size_t Host::GetEnvironment(StringList &env) {
+  char **host_env = environ;
+  char *env_entry;
+  size_t i;
+  for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+    env.AppendString(env_entry);
+  return i;
+}
+
 Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
   return Error("unimplemented");
 }




More information about the lldb-commits mailing list