]> sourceware.org Git - systemtap.git/commitdiff
Refine the @cast-with-header syntax
authorJosh Stone <jistone@redhat.com>
Tue, 21 Apr 2009 19:08:42 +0000 (12:08 -0700)
committerJosh Stone <jistone@redhat.com>
Tue, 21 Apr 2009 19:34:43 +0000 (12:34 -0700)
The special syntax to generate a module for type information is now:
- "kernel<path/to/header.h>" to use the kernel's build environment
- "<path/to/header.h>" to use no special build environment, and so use
  gcc's default parameters only (for user mode).

buildrun.cxx
buildrun.h
tapsets.cxx
testsuite/semok/cast.stp
testsuite/systemtap.base/cast.stp

index 71753e9fca8071348d8b608c2cd5f7a6988d0cf0..311937e2d3a0c9eded2850fdd91236245cc7c9f0 100644 (file)
@@ -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 : */
index fb33b4c8f651171873640622b5c0bf1f72490c5a..7fa4ccfc67c8c514d583774f7c201a55df34e0b0 100644 (file)
@@ -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
 
index f99fbef4169f9bb50bc84316f4518b8cb854b549..e43bc30b1f2b4f2d4c88350b2f7326fa2f54d7a5 100644 (file)
@@ -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;
             }
         }
index d30823cdef67f432ba553d06d442d878da33905f..769335f24fe086bb25e7f6ef2d4d52c8b61ca541 100755 (executable)
@@ -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)
 }
index 33a14a28c0c08cff29e7bf6159ea1dfb092099ee..6298a06d3f2a1c3c6a6eddeadcf6d337b778e2a5 100644 (file)
@@ -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
This page took 0.044285 seconds and 5 git commands to generate.