Author: kamil
Date: Fri Apr  7 11:45:36 2017
New Revision: 299783

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

Summary:
This replaces old code in Host::GetEnvironment for NetBSD
with the version from Linux. This makes parsing environment
variables correctly. It also fixes programs that depend on the
variables like curses(3) applications.

Long term this function should be moved to Process Plugin,
as currently env variables are not available with remote
debugging.

Other BSDs might want to catch up after this change.

Tested with NetBSD top(1).

Sponsored by <The NetBSD Foundation>

Reviewers: emaste, labath, joerg, kettenis

Reviewed By: emaste

Subscribers: #lldb

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D31784

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

Modified: lldb/trunk/source/Host/netbsd/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=299783&r1=299782&r2=299783&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/Host.cpp (original)
+++ lldb/trunk/source/Host/netbsd/Host.cpp Fri Apr  7 11:45:36 2017
@@ -52,15 +52,12 @@ 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();
+  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;
 }
 
 static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch 
*match_info_ptr,


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to