summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-03-24 12:53:17 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-03-24 12:56:41 -0400
commit3c1b3d06ef3134b30e804d189d346c5f83c6f3a6 (patch)
tree4eb573618dab33cf73fe5abb8c343f5421a21f6f
parent64c6aab0a7992ed950d01fec0d9592630af39ca4 (diff)
downloadsystemtap-steved-3c1b3d06ef3134b30e804d189d346c5f83c6f3a6.tar.gz
systemtap-steved-3c1b3d06ef3134b30e804d189d346c5f83c6f3a6.tar.xz
systemtap-steved-3c1b3d06ef3134b30e804d189d346c5f83c6f3a6.zip
PR9993: tracepoint toleration for undeclared types in trace/*.h headers
* 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.
-rw-r--r--buildrun.cxx7
-rw-r--r--buildrun.h2
-rw-r--r--tapsets.cxx20
-rw-r--r--testsuite/systemtap.base/tracepoints.exp23
4 files changed, 49 insertions, 3 deletions
diff --git a/buildrun.cxx b/buildrun.cxx
index 6a266bd2..e19043cf 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -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" };
diff --git a/buildrun.h b/buildrun.h
index 88127449..e87b7b85 100644
--- a/buildrun.h
+++ b/buildrun.h
@@ -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
diff --git a/tapsets.cxx b/tapsets.cxx
index bc16d6fa..3a181cb3 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -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;
diff --git a/testsuite/systemtap.base/tracepoints.exp b/testsuite/systemtap.base/tracepoints.exp
index bea461c4..cd033908 100644
--- a/testsuite/systemtap.base/tracepoints.exp
+++ b/testsuite/systemtap.base/tracepoints.exp
@@ -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