summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--main.cxx30
-rw-r--r--stap.1.in9
3 files changed, 41 insertions, 2 deletions
diff --git a/README b/README
index 7c1ab412..ac6f0a97 100644
--- a/README
+++ b/README
@@ -106,3 +106,7 @@ Building a kernel.org kernel:
- Or else, if you wish to install the kernel build/debuginfo data into
a place where systemtap will find it without the "-r" option:
% ln -s /path/to/kernel/build/tree /lib/modules/RELEASE/build
+
+- Instead of using the "-r" option, you can also use the environment
+ variable SYSTEMTAP_RELEASE to direct systemtap to the kernel data.
+
diff --git a/main.cxx b/main.cxx
index 794a5891..37c5b135 100644
--- a/main.cxx
+++ b/main.cxx
@@ -425,6 +425,36 @@ main (int argc, char * const argv [])
if (s_tc != NULL)
s.tapset_compile_coverage = true;
+ const char* s_kr = getenv ("SYSTEMTAP_RELEASE");
+ if (s_kr != NULL) {
+ if (s_kr[0] == '/') // fully specified path
+ {
+ s.kernel_build_tree = s_kr;
+ string version_file_name = s.kernel_build_tree + "/include/config/kernel.release";
+ // The file include/config/kernel.release within the
+ // build tree is used to pull out the version information
+ ifstream version_file (version_file_name.c_str());
+ if (version_file.fail ())
+ {
+ cerr << "Missing " << version_file_name << endl;
+ exit(1);
+ }
+ else
+ {
+ char c;
+ s.kernel_release = "";
+ while (version_file.get(c) && c != '\n')
+ s.kernel_release.push_back(c);
+ }
+ }
+ else
+ {
+ s.kernel_release = string (s_kr);
+ s.kernel_build_tree = "/lib/modules/" + s.kernel_release + "/build";
+ }
+ }
+
+
while (true)
{
int long_opt;
diff --git a/stap.1.in b/stap.1.in
index c664962c..a5a8ab84 100644
--- a/stap.1.in
+++ b/stap.1.in
@@ -157,11 +157,16 @@ be used to override limit parameters described below.
Look for the systemtap runtime sources in the given directory.
.TP
.BI \-r " /DIR"
-Build for kernel in given build tree.
+Build for kernel in given build tree. Can also be set with the
+.I SYSTEMTAP_RELEASE
+environment variable.
.TP
.BI \-r " RELEASE"
Build for kernel in build tree
-.BR /lib/modules/RELEASE/build .
+.BR /lib/modules/RELEASE/build .
+Can also be set with the
+.I SYSTEMTAP_RELEASE
+environment variable.
.TP
.BI \-m " MODULE"
Use the given name for the generated kernel object module, instead