|
|
aea179 |
commit 438b5a402b6a93dd426f8c18de6fe3708c265328
|
|
|
aea179 |
Author: Stan Cox <scox@redhat.com>
|
|
|
aea179 |
Date: Tue Mar 28 14:39:14 2017 -0400
|
|
|
aea179 |
|
|
|
aea179 |
Adapt stapdyn to the dyninst 9.3.1 library search model.
|
|
|
aea179 |
|
|
|
aea179 |
stapdyn/dynutil.cxx (check_dyninst_rt): Use DYNINST_REWRITER_PATHS
|
|
|
aea179 |
and appendenv
|
|
|
aea179 |
|
|
|
aea179 |
util.c, util.h: New: appendenv.
|
|
|
aea179 |
|
|
|
aea179 |
diff --git a/stapdyn/dynutil.cxx b/stapdyn/dynutil.cxx
|
|
|
aea179 |
index cd2ae11..47a1e91 100644
|
|
|
aea179 |
--- a/stapdyn/dynutil.cxx
|
|
|
aea179 |
+++ b/stapdyn/dynutil.cxx
|
|
|
aea179 |
@@ -61,17 +61,28 @@ guess_dyninst_rt(void)
|
|
|
aea179 |
return libdyninstAPI_RT;
|
|
|
aea179 |
}
|
|
|
aea179 |
|
|
|
aea179 |
+
|
|
|
aea179 |
// Check that environment DYNINSTAPI_RT_LIB exists and is a valid file.
|
|
|
aea179 |
// If not, try to guess a good value and set it.
|
|
|
aea179 |
bool
|
|
|
aea179 |
check_dyninst_rt(void)
|
|
|
aea179 |
{
|
|
|
aea179 |
static const char rt_env_name[] = "DYNINSTAPI_RT_LIB";
|
|
|
aea179 |
- const char* rt_env = getenv(rt_env_name);
|
|
|
aea179 |
+ static const char dyn_rw_env_name[] = "DYNINST_REWRITER_PATHS";
|
|
|
aea179 |
+
|
|
|
aea179 |
+ char* rt_env = getenv(rt_env_name);
|
|
|
aea179 |
if (rt_env)
|
|
|
aea179 |
{
|
|
|
aea179 |
if (file_exists(rt_env))
|
|
|
aea179 |
- return true;
|
|
|
aea179 |
+ {
|
|
|
aea179 |
+ if (appendenv(dyn_rw_env_name, rt_env) != 0)
|
|
|
aea179 |
+ {
|
|
|
aea179 |
+ int olderrno = errno;
|
|
|
aea179 |
+ staperror() << "Can't set " << dyn_rw_env_name << ": " << strerror(olderrno);
|
|
|
aea179 |
+ return false;
|
|
|
aea179 |
+ }
|
|
|
aea179 |
+ return true;
|
|
|
aea179 |
+ }
|
|
|
aea179 |
staperror() << "Invalid " << rt_env_name << ": \"" << rt_env << "\"" << endl;
|
|
|
aea179 |
}
|
|
|
aea179 |
|
|
|
aea179 |
@@ -82,7 +93,7 @@ check_dyninst_rt(void)
|
|
|
aea179 |
return false;
|
|
|
aea179 |
}
|
|
|
aea179 |
|
|
|
aea179 |
- if (setenv(rt_env_name, rt.c_str(), 1) != 0)
|
|
|
aea179 |
+ if (appendenv(dyn_rw_env_name, rt) != 0)
|
|
|
aea179 |
{
|
|
|
aea179 |
int olderrno = errno;
|
|
|
aea179 |
staperror() << "Can't set " << rt_env_name << ": " << strerror(olderrno);
|
|
|
aea179 |
diff --git a/util.cxx b/util.cxx
|
|
|
aea179 |
index a1c8363..9157fb9 100644
|
|
|
aea179 |
--- a/util.cxx
|
|
|
aea179 |
+++ b/util.cxx
|
|
|
aea179 |
@@ -228,6 +228,23 @@ remove_file_or_dir (const char *name)
|
|
|
aea179 |
return 0;
|
|
|
aea179 |
}
|
|
|
aea179 |
|
|
|
aea179 |
+
|
|
|
aea179 |
+int
|
|
|
aea179 |
+appendenv (const char *env_name, const string source)
|
|
|
aea179 |
+{
|
|
|
aea179 |
+ string dirname = source.substr(0, source.rfind("/"));
|
|
|
aea179 |
+ char *env = getenv(env_name);
|
|
|
aea179 |
+ string new_env;
|
|
|
aea179 |
+
|
|
|
aea179 |
+ if (env)
|
|
|
aea179 |
+ new_env = string (env) + ":" + dirname;
|
|
|
aea179 |
+ else
|
|
|
aea179 |
+ new_env = dirname;
|
|
|
aea179 |
+
|
|
|
aea179 |
+ return setenv(env_name, new_env.c_str(), 1);
|
|
|
aea179 |
+}
|
|
|
aea179 |
+
|
|
|
aea179 |
+
|
|
|
aea179 |
/* Obtain the gid of the given group. */
|
|
|
aea179 |
gid_t get_gid (const char *group_name)
|
|
|
aea179 |
{
|
|
|
aea179 |
diff --git a/util.h b/util.h
|
|
|
aea179 |
index d7e0cfb..482f719 100644
|
|
|
aea179 |
--- a/util.h
|
|
|
aea179 |
+++ b/util.h
|
|
|
aea179 |
@@ -77,6 +77,7 @@ bool copy_file(const std::string& src, const std::string& dest,
|
|
|
aea179 |
int create_dir(const char *dir, int mode = 0777);
|
|
|
aea179 |
int remove_file_or_dir(const char *dir);
|
|
|
aea179 |
extern "C" gid_t get_gid (const char *group_name);
|
|
|
aea179 |
+int appendenv (const char *env_name, const std::string source);
|
|
|
aea179 |
bool in_group_id (gid_t target_gid);
|
|
|
aea179 |
std::string getmemusage ();
|
|
|
aea179 |
void tokenize(const std::string& str, std::vector<std::string>& tokens,
|