summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--buildrun.cxx33
-rw-r--r--buildrun.h6
-rw-r--r--tapsets.cxx23
-rwxr-xr-xtestsuite/semok/cast.stp4
-rw-r--r--testsuite/systemtap.base/cast.stp4
5 files changed, 45 insertions, 25 deletions
diff --git a/buildrun.cxx b/buildrun.cxx
index 71753e9f..311937e2 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -445,7 +445,7 @@ make_tracequery(systemtap_session& s, string& name, const vector<string>& extra_
// Build a tiny kernel module to query type information
-int
+static int
make_typequery_kmod(systemtap_session& s, const string& header, string& name)
{
static unsigned tick = 0;
@@ -485,7 +485,7 @@ make_typequery_kmod(systemtap_session& s, const string& header, string& name)
// Build a tiny user module to query type information
-int
+static int
make_typequery_umod(systemtap_session& s, const string& header, string& name)
{
static unsigned tick = 0;
@@ -500,4 +500,33 @@ make_typequery_umod(systemtap_session& s, const string& header, string& name)
return stap_system (cmd.c_str());
}
+
+int
+make_typequery(systemtap_session& s, string& module)
+{
+ int rc;
+ string new_module;
+
+ if (module[module.size() - 1] != '>')
+ return -1;
+
+ if (module[0] == '<')
+ {
+ string header = module.substr(1, module.size() - 2);
+ rc = make_typequery_umod(s, header, new_module);
+ }
+ else if (module.compare(0, 7, "kernel<") == 0)
+ {
+ string header = module.substr(7, module.size() - 8);
+ rc = make_typequery_kmod(s, header, new_module);
+ }
+ else
+ return -1;
+
+ if (!rc)
+ module = new_module;
+
+ return rc;
+}
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
diff --git a/buildrun.h b/buildrun.h
index fb33b4c8..7fa4ccfc 100644
--- a/buildrun.h
+++ b/buildrun.h
@@ -14,9 +14,9 @@
int compile_pass (systemtap_session& s);
int run_pass (systemtap_session& s);
-int make_tracequery(systemtap_session& s, std::string& name, const std::vector<std::string>& extra_headers);
-int make_typequery_kmod(systemtap_session& s, const std::string& header, std::string& name);
-int make_typequery_umod(systemtap_session& s, const std::string& header, std::string& name);
+int make_tracequery(systemtap_session& s, std::string& name,
+ const std::vector<std::string>& extra_headers);
+int make_typequery(systemtap_session& s, std::string& module);
#endif // BUILDRUN_H
diff --git a/tapsets.cxx b/tapsets.cxx
index f99fbef4..e43bc30b 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5140,11 +5140,10 @@ struct dwarf_cast_expanding_visitor: public var_expanding_visitor
void dwarf_cast_expanding_visitor::filter_special_modules(string& module)
{
- // look for "kmod<path/to/header>" or "umod<path/to/header>"
+ // look for "<path/to/header>" or "kernel<path/to/header>"
// for those cases, build a module including that header
- if (module.rfind('>') == module.size() - 1 &&
- (module.compare(0, 5, "kmod<") == 0 ||
- module.compare(0, 5, "umod<") == 0))
+ if (module[module.size() - 1] == '>' &&
+ (module[0] == '<' || module.compare(0, 7, "kernel<") == 0))
{
string cached_module;
if (s.use_cache)
@@ -5166,25 +5165,17 @@ void dwarf_cast_expanding_visitor::filter_special_modules(string& module)
}
// no cached module, time to make it
- int rc;
- string new_module, header = module.substr(5, module.size() - 6);
- if (module[0] == 'k')
- rc = make_typequery_kmod(s, header, new_module);
- else
- rc = make_typequery_umod(s, header, new_module);
- if (rc == 0)
+ if (make_typequery(s, module) == 0)
{
- module = new_module;
-
if (s.use_cache)
{
// try to save typequery in the cache
if (s.verbose > 2)
- clog << "Copying " << new_module
+ clog << "Copying " << module
<< " to " << cached_module << endl;
- if (copy_file(new_module.c_str(),
+ if (copy_file(module.c_str(),
cached_module.c_str()) != 0)
- cerr << "Copy failed (\"" << new_module << "\" to \""
+ cerr << "Copy failed (\"" << module << "\" to \""
<< cached_module << "\"): " << strerror(errno) << endl;
}
}
diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp
index d30823cd..769335f2 100755
--- a/testsuite/semok/cast.stp
+++ b/testsuite/semok/cast.stp
@@ -12,6 +12,6 @@ probe begin {
// but who knows what debuginfo is installed...
// check modules generated from headers
- println(@cast(0, "task_struct", "kmod<linux/sched.h>")->tgid)
- println(@cast(0, "timeval", "umod<sys/time.h>")->tv_sec)
+ println(@cast(0, "task_struct", "kernel<linux/sched.h>")->tgid)
+ println(@cast(0, "timeval", "<sys/time.h>")->tv_sec)
}
diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp
index 33a14a28..6298a06d 100644
--- a/testsuite/systemtap.base/cast.stp
+++ b/testsuite/systemtap.base/cast.stp
@@ -11,7 +11,7 @@ probe begin
printf("PID %d != %d\n", pid, cast_pid)
// Compare PIDs using a generated kernel module
- cast_pid = @cast(curr, "task_struct", "kmod<linux/sched.h>")->tgid
+ cast_pid = @cast(curr, "task_struct", "kernel<linux/sched.h>")->tgid
if (pid == cast_pid)
println("PID2 OK")
else
@@ -27,7 +27,7 @@ probe begin
// Compare tv_sec using a generated user module
sec = 42
- cast_sec = @cast(get_timeval(sec), "timeval", "umod<sys/time.h>")->tv_sec
+ cast_sec = @cast(get_timeval(sec), "timeval", "<sys/time.h>")->tv_sec
if (sec == cast_sec)
println("tv_sec OK")
else