summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/RNBContext.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-12-22 11:09:21 +0000
committerPavel Labath <labath@google.com>2017-12-22 11:09:21 +0000
commitdeb45f2043a5e0d1d6644df31f98efd3cfda03ae (patch)
tree24e36c3593f511ec3510cc9518a07ba097d3e741 /lldb/tools/debugserver/source/RNBContext.cpp
parent68773859c83eae33a6b02be8e647ed9ce2afcd7a (diff)
downloadbcm5719-llvm-deb45f2043a5e0d1d6644df31f98efd3cfda03ae.tar.gz
bcm5719-llvm-deb45f2043a5e0d1d6644df31f98efd3cfda03ae.zip
debugserver: Propagate environment in launch-mode (pr35671)
Summary: Make sure we propagate environment when starting debugserver with a pre-loaded inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior scenario, so we can just pick up the debugserver environment instead of trying to construct an envp from the (empty) context. This makes debugserver pass an test added for an equivalent lldb-server fix. Reviewers: jasonmolenda, clayborg Subscribers: JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D41352 llvm-svn: 321355
Diffstat (limited to 'lldb/tools/debugserver/source/RNBContext.cpp')
-rw-r--r--lldb/tools/debugserver/source/RNBContext.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/RNBContext.cpp b/lldb/tools/debugserver/source/RNBContext.cpp
index c1319af0232..c86511c6e22 100644
--- a/lldb/tools/debugserver/source/RNBContext.cpp
+++ b/lldb/tools/debugserver/source/RNBContext.cpp
@@ -42,6 +42,25 @@ const char *RNBContext::EnvironmentAtIndex(size_t index) {
return NULL;
}
+static std::string GetEnvironmentKey(const std::string &env) {
+ std::string key = env.substr(0, env.find('='));
+ if (!key.empty() && key.back() == '=')
+ key.pop_back();
+ return key;
+}
+
+void RNBContext::PushEnvironmentIfNeeded(const char *arg) {
+ if (!arg)
+ return;
+ std::string arg_key = GetEnvironmentKey(arg);
+
+ for (const std::string &entry: m_env_vec) {
+ if (arg_key == GetEnvironmentKey(entry))
+ return;
+ }
+ m_env_vec.push_back(arg);
+}
+
const char *RNBContext::ArgumentAtIndex(size_t index) {
if (index < m_arg_vec.size())
return m_arg_vec[index].c_str();
OpenPOWER on IntegriCloud