// 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;
// 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;
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 : */
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
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)
}
// 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;
}
}
// 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)
}
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
// 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