diff options
author | William Cohen <wcohen@redhat.com> | 2009-04-23 11:13:59 -0400 |
---|---|---|
committer | William Cohen <wcohen@redhat.com> | 2009-04-23 11:13:59 -0400 |
commit | 927dab9f7b4298b4ef28ae87cdb7dafe43e5d76a (patch) | |
tree | 1cd2cc946800969a9816883a8b2f2edc27caccdb /buildrun.cxx | |
parent | 1e0a708d560ed69405e94a45d11067abae7f79a5 (diff) | |
parent | 4fecf7f1c9fd8ae54ff13677c710b75a10d8cc91 (diff) | |
download | systemtap-steved-927dab9f7b4298b4ef28ae87cdb7dafe43e5d76a.tar.gz systemtap-steved-927dab9f7b4298b4ef28ae87cdb7dafe43e5d76a.tar.xz systemtap-steved-927dab9f7b4298b4ef28ae87cdb7dafe43e5d76a.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'buildrun.cxx')
-rw-r--r-- | buildrun.cxx | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/buildrun.cxx b/buildrun.cxx index 71753e9f..14c6a395 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -370,7 +370,8 @@ make_tracequery(systemtap_session& s, string& name, const vector<string>& extra_ // create a simple Makefile string makefile(dir + "/Makefile"); ofstream omf(makefile.c_str()); - omf << "EXTRA_CFLAGS := -g" << endl; // force debuginfo generation + // force debuginfo generation, and relax implicit functions + omf << "EXTRA_CFLAGS := -g -Wno-implicit-function-declaration" << endl; omf << "obj-m := tracequery.o" << endl; omf.close(); @@ -390,10 +391,6 @@ make_tracequery(systemtap_session& s, string& name, const vector<string>& extra_ osrc << "#define DEFINE_TRACE(name, proto, args) \\" << endl; osrc << " DECLARE_TRACE(name, TPPROTO(proto), TPARGS(args))" << endl; - // some headers may have been pulled in already indirectly, so we need this - // to ensure that they still use our definition - osrc << "#define TRACE_HEADER_MULTI_READ 1" << 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++) @@ -445,7 +442,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; @@ -466,7 +463,16 @@ make_typequery_kmod(systemtap_session& s, const string& header, string& name) string makefile(dir + "/Makefile"); ofstream omf(makefile.c_str()); omf << "EXTRA_CFLAGS := -g -fno-eliminate-unused-debug-types" << endl; + + // NB: We use -include instead of #include because that gives us more power. + // Using #include searches relative to the source's path, which in this case + // is /tmp/..., so that's not helpful. Using -include will search relative + // to the cwd, which will be the kernel build root. This means if you have a + // full kernel build tree, it's possible to get at types that aren't in the + // normal include path, e.g.: + // @cast(foo, "bsd_acct_struct", "kernel<kernel/acct.c>")->... omf << "CFLAGS_" << basename << ".o := -include " << header << endl; + omf << "obj-m := " + basename + ".o" << endl; omf.close(); @@ -485,7 +491,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; @@ -493,6 +499,11 @@ make_typequery_umod(systemtap_session& s, const string& header, string& name) name = s.tmpdir + "/typequery_umod_" + lex_cast<string>(++tick) + ".so"; // make the module + // + // NB: As with kmod, using -include makes relative paths more useful. The + // cwd in this case will be the cwd of stap itself though, which may be + // trickier to deal with. It might be better to "cd `dirname $script`" + // first... string cmd = "gcc -shared -g -fno-eliminate-unused-debug-types -o " + name + " -xc /dev/null -include " + header; if (s.verbose < 4) @@ -500,4 +511,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 : */ |