]> sourceware.org Git - systemtap.git/commitdiff
PR9993: tracepoint toleration for undeclared types in trace/*.h headers
authorFrank Ch. Eigler <fche@elastic.org>
Tue, 24 Mar 2009 16:53:17 +0000 (12:53 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Tue, 24 Mar 2009 16:56:41 +0000 (12:56 -0400)
* tapsets.cxx (tracepoint_extra_headers): New function to return
  needed header file names.
  (emit_module_decls): Emit them.
* buildrun.cxx (make_tracequery): Emit them.
* testsuite/systemtap.base/tracepoints.exp: Rewrite to exercise
  building each tracepoint.

buildrun.cxx
buildrun.h
tapsets.cxx
testsuite/systemtap.base/tracepoints.exp

index 6a266bd29a45fa57ce5055abe58dc7a4a40bd85a..e19043cf6312fd442e3726772a89c6bf42ca87b6 100644 (file)
@@ -345,7 +345,7 @@ run_pass (systemtap_session& s)
 
 // Build a tiny kernel module to query tracepoints
 int
-make_tracequery(systemtap_session& s, string& name)
+make_tracequery(systemtap_session& s, string& name, const vector<string>& extra_headers)
 {
   // create a subdirectory for the module
   string dir(s.tmpdir + "/tracequery");
@@ -382,6 +382,11 @@ make_tracequery(systemtap_session& s, string& name)
   osrc << "#define DEFINE_TRACE(name, proto, args) \\" << endl;
   osrc << "  DECLARE_TRACE(name, TPPROTO(proto), TPARGS(args))" << endl;
 
+  // PR9993: Add extra headers to work around undeclared types in individual
+  // include/trace/foo.h files
+  for (unsigned z=0; z<extra_headers.size(); z++)
+    osrc << "#include <" << extra_headers[z] << ">\n";
+
   // dynamically pull in all tracepoint headers from include/trace/
   glob_t trace_glob;
   string globs[2] = { "/include/trace/*.h", "/source/include/trace/*.h" };
index 881274496243663acfa6fa0cbcb82804026d7ff3..e87b7b85ac65798435808f9099d75d645c365e2e 100644 (file)
@@ -14,7 +14,7 @@
 int compile_pass (systemtap_session& s);
 int run_pass (systemtap_session& s);
 
-int make_tracequery(systemtap_session& s, std::string& name);
+int make_tracequery(systemtap_session& s, std::string& name, const std::vector<std::string>& extra_headers);
 
 #endif // BUILDRUN_H
 
index bc16d6fa6d6ec5e4f4df65a0a26ff082d6998c42..3a181cb3dc9ed60569c43fef61b7d6cb2c4d82fe 100644 (file)
@@ -9582,6 +9582,7 @@ tracepoint_derived_probe::tracepoint_derived_probe (systemtap_session& s,
   // tracepoints from FOO_event_types.h should really be included from FOO.h
   // XXX can dwarf tell us the include hierarchy?  it would be better to
   // ... walk up to see which one was directly included by tracequery.c
+  // XXX: see also PR9993.
   header_pos = header.find("_event_types");
   if (header_pos != string::npos)
     header.erase(header_pos, 12);
@@ -9757,6 +9758,16 @@ tracepoint_derived_probe::emit_probe_context_vars (translator_output* o)
 }
 
 
+static vector<string> tracepoint_extra_headers ()
+{
+  vector<string> they_live;
+  // PR 9993
+  // XXX: may need this to be configurable
+  they_live.push_back ("linux/skbuff.h");
+  return they_live;
+}
+
+
 void
 tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s)
 {
@@ -9766,6 +9777,12 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s)
   s.op->newline() << "/* ---- tracepoint probes ---- */";
   s.op->newline();
 
+  // PR9993: Add extra headers to work around undeclared types in individual
+  // include/trace/foo.h files
+  const vector<string>& extra_headers = tracepoint_extra_headers ();
+  for (unsigned z=0; z<extra_headers.size(); z++)
+    s.op->newline() << "#include <" << extra_headers[z] << ">\n";
+
   for (unsigned i = 0; i < probes.size(); ++i)
     {
       tracepoint_derived_probe *p = probes[i];
@@ -9963,6 +9980,7 @@ private:
   bool init_dw(systemtap_session& s);
 
 public:
+
   tracepoint_builder(): dw(0) {}
   ~tracepoint_builder() { delete dw; }
 
@@ -10009,7 +10027,7 @@ tracepoint_builder::init_dw(systemtap_session& s)
 
   // no cached module, time to make it
   string tracequery_ko;
-  int rc = make_tracequery(s, tracequery_ko);
+  int rc = make_tracequery(s, tracequery_ko, tracepoint_extra_headers());
   if (rc != 0)
     return false;
 
index bea461c4e9560930d6989e2d2d1adaf685e8a38f..cd033908e453f9f4b6ad0f5c35b9b06be16e7447 100644 (file)
@@ -1,3 +1,26 @@
+
+set tracepoints {}
+spawn stap -l {kernel.trace("*")}
+expect {
+    -re {^kernel.trace[^\r\n]*\r\n} {
+        append tracepoints $expect_out(0,string)
+        exp_continue
+    }
+    timeout {}
+    eof {}
+}
+catch {close}; catch { wait }
+
+foreach tp $tracepoints {
+    set test "tracepoint $tp -p4"
+    if {[catch {exec stap -w -p4 -e "probe $tp {}"} res]} {
+        fail "$test $res"
+    } else {
+        pass "$test"
+    }
+}
+
 set test "tracepoints"
+if {![installtest_p]} { untested $test; return }
 set ::result_string {tracepoints OK}
 stap_run2 $srcdir/$subdir/$test.stp
This page took 0.044663 seconds and 5 git commands to generate.