summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajan Arora <rarora@redhat.com>2008-12-01 02:06:51 -0500
committerRajan Arora <rarora@redhat.com>2008-12-01 02:10:48 -0500
commit7471ea1f77971b814bc366a3e09d99aaddcfb0f7 (patch)
treec155f76087281c1f5603f40c0a44a4c3911e1c87
parent4ea5a9d947ac41fc9da143ce501642673d27c7bf (diff)
downloadsystemtap-steved-7471ea1f77971b814bc366a3e09d99aaddcfb0f7.tar.gz
systemtap-steved-7471ea1f77971b814bc366a3e09d99aaddcfb0f7.tar.xz
systemtap-steved-7471ea1f77971b814bc366a3e09d99aaddcfb0f7.zip
BZ 5892: Add stap -B to sic systemtap at an alternate kernel build tree
-rw-r--r--ChangeLog15
-rw-r--r--NEWS3
-rw-r--r--buildrun.cxx22
-rw-r--r--main.cxx48
-rw-r--r--session.h1
-rw-r--r--tapsets.cxx16
-rw-r--r--translate.cxx8
7 files changed, 91 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 80cb6b3c..bde86e62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-12-01 Rajan Arora <rarora@redhat.com>
+
+ PR 5892: Add -B and parameterize all occurences of /lib/modules/...
+ * buildrun.cxx (compile_pass, kernel_built_uprobes): Audit
+ mentions of /lib/modules/... with path to kernel_build_tree
+ provided by -B.
+ * tapsets.cxx (setup_kernel, setup_user, mark_builder::build):
+ Likewise.
+ * translate.cxx (emit_symbol_data): Likewise.
+ * session.h (struct systemtap_session): New member kernel_build_tree.
+ * main.cxx (main): Add case for 'B' and attempt to fetch Version for
+ the kernel build tree using include/config/kernel.release in build
+ path, remove -r REV implies -p4 logic altogether.
+
+
2008-11-29 Frank Ch. Eigler <fche@elastic.org>
Warnings cleanup.
diff --git a/NEWS b/NEWS
index eecee974..374bcec3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
* What's new
+- A new stap -B option is now available which enables user to sic systemtap
+ at a kernel build tree in any oddball directory.
+
- A serious problem associated with user-space probing in shared libraries
was corrected, making it now possible to experiment with probe shared
libraries. Assuming dwarf debugging information is installed, use this
diff --git a/buildrun.cxx b/buildrun.cxx
index f9588906..86da95d3 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -150,8 +150,12 @@ compile_pass (systemtap_session& s)
o.close ();
// Generate module directory pathname and make sure it exists.
- string module_dir = string("/lib/modules/")
- + s.kernel_release + "/build";
+ string module_dir;
+ if (! s.kernel_build_tree.size ())
+ module_dir = string("/lib/modules/")
+ + s.kernel_release + "/build";
+ else
+ module_dir = s.kernel_build_tree;
struct stat st;
rc = stat(module_dir.c_str(), &st);
if (rc != 0)
@@ -176,14 +180,20 @@ static const string uprobes_home = string(PKGDATADIR "/runtime/uprobes");
/*
* If uprobes was built as part of the kernel build (either built-in
- * or as a module), the uprobes exports should show up in
- * /lib/modules/`uname -r`/build/Module.symvers. Return true if so.
+ * or as a module), the uprobes exports should show up in either
+ * /lib/modules/`uname -r`/build/Module.symvers or in the oddball
+ * directory where the user's kernel is built. Return true if so.
*/
static bool
kernel_built_uprobes (systemtap_session& s)
{
- string grep_cmd = string ("/bin/grep -q unregister_uprobe /lib/modules/")
- + s.kernel_release + string ("/build/Module.symvers");
+ string grep_cmd;
+ if (! s.kernel_build_tree.size ())
+ grep_cmd = string ("/bin/grep -q unregister_uprobe /lib/modules/")
+ + s.kernel_release + string ("/build/Module.symvers");
+ else
+ grep_cmd = string ("/bin/grep -q unregister_uprobe ") +
+ s.kernel_build_tree + string ("/Module.symvers");
int rc = system (grep_cmd.c_str());
return (rc == 0);
}
diff --git a/main.cxx b/main.cxx
index 9d322fe4..7907080d 100644
--- a/main.cxx
+++ b/main.cxx
@@ -328,7 +328,6 @@ main (int argc, char * const argv [])
string cmdline_script; // -e PROGRAM
string script_file; // FILE
bool have_script = false;
- bool release_changed = false;
bool save_module = false;
// Initialize defaults
@@ -435,7 +434,7 @@ main (int argc, char * const argv [])
{ "vp", 1, &long_opt, LONG_OPT_VERBOSE_PASS },
{ NULL, 0, NULL, 0 }
};
- int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:F",
+ int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:B:m:kgPc:x:D:bs:uqwl:d:L:F",
long_options, NULL);
if (grc < 0)
break;
@@ -551,9 +550,36 @@ main (int argc, char * const argv [])
case 'r':
s.kernel_release = string (optarg);
- release_changed = true;
break;
+ case 'B':
+ s.kernel_build_tree = string (optarg);
+ {
+ 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
+ // : Failing which -B is ignored
+
+ ifstream version_file (version_file_name.c_str());
+ if (version_file.fail ())
+ {
+ cerr << "error: No file: " << version_file_name
+ << " found" << endl;
+ cerr << "Please check path to -B again" << endl;
+ s.kernel_build_tree = "";
+ }
+ else
+ {
+ char c;
+ string kernel_build_version;
+ while (version_file.get(c) && c != '\n')
+ kernel_build_version.push_back(c);
+ s.kernel_release = kernel_build_version;
+ }
+ }
+ break;
+
case 'k':
s.keep_tmpdir = true;
s.use_cache = false; /* User wants to keep a usable build tree. */
@@ -712,12 +738,16 @@ main (int argc, char * const argv [])
s.kernel_symtab_path = string("/boot/System.map-") + s.kernel_release;
}
- if (s.last_pass > 4 && release_changed)
- {
- if (s.verbose)
- cerr << "Warning: changing last pass to 4 since cross-compiling" << endl;
- s.last_pass = 4;
- }
+ // Since the introduction of -B, the logic of -r REV implies -p4 is dropped.
+ // If the version of kernel build tree specified by -B is not the same as
+ // `uname -r`, stap will give a failure message in pass5 anyways.
+ //
+ // if (s.last_pass > 4 && release_changed)
+ // {
+ // if (s.verbose)
+ // cerr << "Warning: changing last pass to 4 since cross-compiling" << endl;
+ // s.last_pass = 4;
+ // }
for (int i = optind; i < argc; i++)
{
diff --git a/session.h b/session.h
index 0a1e6fc4..e6b409cf 100644
--- a/session.h
+++ b/session.h
@@ -81,6 +81,7 @@ struct systemtap_session
std::vector<std::string> args;
std::string kernel_release;
std::string kernel_base_release;
+ std::string kernel_build_tree;
std::string architecture;
std::string runtime_path;
std::string data_path;
diff --git a/tapsets.cxx b/tapsets.cxx
index 4e4d471d..88c6ea41 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -898,9 +898,11 @@ struct dwflpp
static char *debuginfo_env_arr = getenv("SYSTEMTAP_DEBUGINFO_PATH");
static char *debuginfo_path = (debuginfo_env_arr ?
- debuginfo_env_arr : debuginfo_path_arr);
+ debuginfo_env_arr : sess.kernel_build_tree.size () ?
+ (char *) sess.kernel_build_tree.c_str() : debuginfo_path_arr);
static const char *debug_path = (debuginfo_env_arr ?
- debuginfo_env_arr : sess.kernel_release.c_str());
+ debuginfo_env_arr : sess.kernel_build_tree.size () ?
+ sess.kernel_build_tree.c_str() : sess.kernel_release.c_str());
static const Dwfl_Callbacks kernel_callbacks =
{
@@ -951,7 +953,8 @@ struct dwflpp
// XXX: this is where the session -R parameter could come in
static char debuginfo_path_arr[] = "-:.debug:/usr/lib/debug:build";
static char *debuginfo_env_arr = getenv("SYSTEMTAP_DEBUGINFO_PATH");
- static char *debuginfo_path = (debuginfo_env_arr ?: debuginfo_path_arr);
+ static char *debuginfo_path = (debuginfo_env_arr ?: sess.kernel_build_tree.size () ?
+ (char *) sess.kernel_build_tree.c_str() : debuginfo_path_arr);
static const Dwfl_Callbacks user_callbacks =
{
@@ -8712,8 +8715,13 @@ mark_builder::build(systemtap_session & sess,
if (! cache_initialized)
{
cache_initialized = true;
- string module_markers_path = "/lib/modules/" + sess.kernel_release
+ string module_markers_path;
+ if (! sess.kernel_build_tree.size ())
+ module_markers_path = "/lib/modules/" + sess.kernel_release
+ "/build/Module.markers";
+ else
+ module_markers_path = sess.kernel_build_tree + "/Module.markers";
+
ifstream module_markers;
module_markers.open(module_markers_path.c_str(), ifstream::in);
diff --git a/translate.cxx b/translate.cxx
index b90bb5ab..dc9f12bc 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4710,9 +4710,11 @@ emit_symbol_data (systemtap_session& s)
static char *debuginfo_env_arr = getenv("SYSTEMTAP_DEBUGINFO_PATH");
static char *debuginfo_path = (debuginfo_env_arr ?
- debuginfo_env_arr : debuginfo_path_arr);
- static const char *debug_path = (debuginfo_env_arr ?
- debuginfo_env_arr : s.kernel_release.c_str());
+ debuginfo_env_arr : s.kernel_build_tree.size () ?
+ (char *) s.kernel_build_tree.c_str() : debuginfo_path_arr);
+ static const char *debug_path = (debuginfo_env_arr ?
+ debuginfo_env_arr : s.kernel_build_tree.size () ?
+ s.kernel_build_tree.c_str() : s.kernel_release.c_str());
// ---- step 1: process any kernel modules listed
static const Dwfl_Callbacks kernel_callbacks =