From f982c59b2c2b1c25684213c816a69f18a98fea8a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Jul 2009 18:01:40 -0700 Subject: PR10424: Consider each tracepoint header separately With the current monolithic tracepoint query module, a failure in any of the discovered tracepoint headers means that you can't use any of the others either. This patch creates a separate query module for each header so they can pass or fail independently. * buildrun.cxx (make_tracequery): take a single header name instead of globbing for everything we can find. * hash.cxx (find_tracequery_hash): name the header file we're hashing. * tapsets.cxx (tracepoint_query::handle_query_func): make sure we don't duplicate tracepoints found through different headers. (tracepoint_builder::get_tracequery_module): get a header's module (tracepoint_builder::init_dw): glob for all tracepoint headers, and feed all their modules into dwflpp. --- buildrun.cxx | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 5967066e..e4b4b7bf 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -27,7 +27,6 @@ extern "C" { #include #include #include -#include } @@ -382,10 +381,15 @@ run_pass (systemtap_session& s) // Build a tiny kernel module to query tracepoints int -make_tracequery(systemtap_session& s, string& name, const vector& extra_headers) +make_tracequery(systemtap_session& s, string& name, + const std::string& header, + const vector& extra_headers) { + static unsigned tick = 0; + string basename("tracequery_kmod_" + lex_cast(++tick)); + // create a subdirectory for the module - string dir(s.tmpdir + "/tracequery"); + string dir(s.tmpdir + "/" + basename); if (create_dir(dir.c_str()) != 0) { if (! s.suppress_warnings) @@ -393,18 +397,18 @@ make_tracequery(systemtap_session& s, string& name, const vector& extra_ return 1; } - name = dir + "/tracequery.ko"; + name = dir + "/" + basename + ".ko"; // create a simple Makefile string makefile(dir + "/Makefile"); ofstream omf(makefile.c_str()); // force debuginfo generation, and relax implicit functions omf << "EXTRA_CFLAGS := -g -Wno-implicit-function-declaration" << endl; - omf << "obj-m := tracequery.o" << endl; + omf << "obj-m := " + basename + ".o" << endl; omf.close(); // create our source file - string source(dir + "/tracequery.c"); + string source(dir + "/" + basename + ".c"); ofstream osrc(source.c_str()); osrc << "#ifdef CONFIG_TRACEPOINTS" << endl; osrc << "#include " << endl; @@ -424,37 +428,8 @@ make_tracequery(systemtap_session& s, string& name, const vector& extra_ for (unsigned z=0; z\n"; - // dynamically pull in all tracepoint headers from include/trace/ - glob_t trace_glob; - string globs[] = { - "/include/trace/*.h", - "/include/trace/events/*.h", - "/source/include/trace/*.h", - "/source/include/trace/events/*.h", - }; - for (unsigned z = 0; z < sizeof(globs) / sizeof(globs[0]); z++) - { - string glob_str(s.kernel_build_tree + globs[z]); - glob(glob_str.c_str(), 0, NULL, &trace_glob); - for (unsigned i = 0; i < trace_glob.gl_pathc; ++i) - { - string header(trace_glob.gl_pathv[i]); - size_t root_pos = header.rfind("/include/"); - assert(root_pos != string::npos); - header.erase(0, root_pos + 9); - - // filter out a few known "internal-only" headers - if (header.find("/ftrace.h") != string::npos) - continue; - if (header.find("/trace_events.h") != string::npos) - continue; - if (header.find("_event_types.h") != string::npos) - continue; - - osrc << "#include <" << header << ">" << endl; - } - globfree(&trace_glob); - } + // add the requested tracepoint header + osrc << "#include <" << header << ">" << endl; // finish up the module source osrc << "#endif /* CONFIG_TRACEPOINTS */" << endl; -- cgit