From: Frank Ch. Eigler Date: Tue, 24 Mar 2009 16:53:17 +0000 (-0400) Subject: PR9993: tracepoint toleration for undeclared types in trace/*.h headers X-Git-Tag: release-0.9.5~31 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=3c1b3d06ef3134b30e804d189d346c5f83c6f3a6;p=systemtap.git 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. --- diff --git a/buildrun.cxx b/buildrun.cxx index 6a266bd29..e19043cf6 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& 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\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 881274496..e87b7b85a 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& extra_headers); #endif // BUILDRUN_H diff --git a/tapsets.cxx b/tapsets.cxx index bc16d6fa6..3a181cb3d 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 tracepoint_extra_headers () +{ + vector 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& extra_headers = tracepoint_extra_headers (); + for (unsigned z=0; znewline() << "#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 bea461c4e..cd033908e 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