From d90053e72a515371936e10bf83ecb822aec91b17 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 21 Apr 2009 12:08:42 -0700 Subject: Refine the @cast-with-header syntax The special syntax to generate a module for type information is now: - "kernel" to use the kernel's build environment - "" to use no special build environment, and so use gcc's default parameters only (for user mode). --- buildrun.cxx | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 71753e9f..311937e2 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -445,7 +445,7 @@ make_tracequery(systemtap_session& s, string& name, const vector& 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; @@ -485,7 +485,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; @@ -500,4 +500,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 : */ -- cgit From 3ae4cdf91d758136cbf71c814c725c643d251f41 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 21 Apr 2009 12:12:43 -0700 Subject: NB @cast's relative header searching --- buildrun.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 311937e2..6c51d0cd 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -466,7 +466,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")->... omf << "CFLAGS_" << basename << ".o := -include " << header << endl; + omf << "obj-m := " + basename + ".o" << endl; omf.close(); @@ -493,6 +502,11 @@ make_typequery_umod(systemtap_session& s, const string& header, string& name) name = s.tmpdir + "/typequery_umod_" + lex_cast(++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) -- cgit From 43e8f8d02ab60eb24b6d8cba1105ef92a080e5f1 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 21 Apr 2009 19:55:47 -0700 Subject: [tracepoints] Don't use TRACE_HEADER_MULTI_READ At one point that macro was needed to get all of the tracepoints on the tip tree, but now it's causing us to get duplicate stapprobe_X definitions. AFAICS, we're now getting all tracepoints even without MULTI_READ, so I'm pulling that workaround out. --- buildrun.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 6c51d0cd..41b593fa 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -390,10 +390,6 @@ make_tracequery(systemtap_session& s, string& name, const vector& 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 Date: Tue, 21 Apr 2009 19:57:59 -0700 Subject: [tracepoints] Resolve implicit trace_X use Some of the tracepoints are actually being called in inlines in the common headers (e.g. trace_kmalloc), which is causing errors about implicit function declarations. We don't care about ever running the code in the tracequery module, so I'm just suppressing that error. --- buildrun.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 41b593fa..14c6a395 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -370,7 +370,8 @@ make_tracequery(systemtap_session& s, string& name, const vector& 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(); -- cgit