From 60708c55af46b7e42392e0d679df85a824d71b45 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 20 Feb 2009 17:23:02 -0800 Subject: Remove STAPCONF_CFLAGS from the generated Makefile This was leftover from my initial draft of autoconf caching. It's not used at all anymore... --- buildrun.cxx | 3 --- 1 file changed, 3 deletions(-) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 3a6e20ae..fe060236 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -125,9 +125,6 @@ compile_pass (systemtap_session& s) // o << module_cflags << " += -Iusr/include" << endl; // since such headers are cleansed of _KERNEL_ pieces that we need - string stapconf_cflags = "STAPCONF_CFLAGS"; - o << stapconf_cflags << " :=" << endl; - o << "STAPCONF_HEADER := " << s.tmpdir << "/" << s.stapconf_name << endl; o << s.translated_source << ": $(STAPCONF_HEADER)" << endl; o << "$(STAPCONF_HEADER):" << endl; -- cgit From 8c5905d0b6c8206c5ed971a637077aa8ef5c1b02 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 4 Mar 2009 11:56:45 +0100 Subject: stap autoconf test for kernel stack trace support * buildrun.cxx (compile_pass): Add autoconf line for stack trace test, which defines STAPCONF_KERNEL_STACKTRACE. * runtime/autoconf-save-stack-trace.c: New file. * runtime/stack.c : Use STAPCONF_KERNEL_STACKTRACE instead of tests for kernel configuration and versions. * runtime/stack-i386.c : ditto * runtime/stack-x86_64.c : ditto --- buildrun.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index fe060236..973343cd 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -153,6 +153,8 @@ compile_pass (systemtap_session& s) * this autoconf. */ output_autoconf(s, o, "autoconf-probe-kernel.c", "STAPCONF_PROBE_KERNEL", NULL); #endif + output_autoconf(s, o, "autoconf-save-stack-trace.c", + "STAPCONF_KERNEL_STACKTRACE", NULL); o << module_cflags << " += -include $(STAPCONF_HEADER)" << endl; -- cgit From 0a6f5a3f0c2ecfb8b4a416dd07d5b976daf79551 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 4 Mar 2009 19:32:25 -0800 Subject: Build tracequery to scan for tracepoints * session.h (systemtap_session): add tracepoint_derived_probes * buildrun.cxx (make_tracequery): New - builds a kernel module that hijacks the tracepoint declarations, so we can query debuginfo. * buildrun.h: declare above * tapsets.cxx (tracepoint_builder): New builder for tracepoint probes. For now it just handles the initialization to build the tracequery kernel module. --- buildrun.cxx | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 973343cd..b81cba23 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -24,6 +24,7 @@ extern "C" { #include #include #include +#include } @@ -336,4 +337,73 @@ run_pass (systemtap_session& s) return rc; } + +// Build a tiny kernel module to query tracepoints +int +make_tracequery(systemtap_session& s, string& name) +{ + // create a subdirectory for the module + string dir(s.tmpdir + "/tracequery"); + if (create_dir(dir.c_str()) != 0) + { + if (! s.suppress_warnings) + cerr << "Warning: failed to create directory for querying tracepoints." << endl; + return 1; + } + + name = dir + "/tracequery.ko"; + + // create a simple Makefile + string makefile(dir + "/Makefile"); + ofstream omf(makefile.c_str()); + omf << "EXTRA_CFLAGS := -g" << endl; // force debuginfo generation + omf << "obj-m := tracequery.o" << endl; + omf.close(); + + // create our source file + string source(dir + "/tracequery.c"); + ofstream osrc(source.c_str()); + osrc << "#include " << endl; + osrc << "#ifdef CONFIG_TRACEPOINTS" << endl; + osrc << "#include " << endl; + + // override DECLARE_TRACE to synthesize probe functions for us + osrc << "#undef DECLARE_TRACE" << endl; + osrc << "#define DECLARE_TRACE(name, proto, args) \\" << endl; + osrc << " void stapprobe_##name(proto) {}" << endl; + + // dynamically pull in all tracepoint headers from include/trace/ + glob_t trace_glob; + string glob_str(s.kernel_build_tree + "/include/trace/*.h"); + glob(glob_str.c_str(), 0, NULL, &trace_glob); + for (unsigned i = 0; i < trace_glob.gl_pathc; ++i) + { + string header(basename(trace_glob.gl_pathv[i])); + + // filter out a few known "internal-only" headers + if (header == "trace_events.h") + continue; + if (header.find("_event_types.h") != string::npos) + continue; + + osrc << "#include " << endl; + } + globfree(&trace_glob); + + // finish up the module source + osrc << "#endif /* CONFIG_TRACEPOINTS */" << endl; + osrc << "int init_module(void) { return 0; }" << endl; + osrc << "void cleanup_module(void) {}" << endl; + osrc << "MODULE_DESCRIPTION(\"tracepoint query\");" << endl; + osrc << "MODULE_LICENSE(\"GPL\");" << endl; + osrc.close(); + + // make the module + string make_cmd = "make -C '" + s.kernel_build_tree + "'" + + " M='" + dir + "' modules"; + if (s.verbose < 4) + make_cmd += " >/dev/null 2>&1"; + return run_make_cmd(s, make_cmd); +} + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ -- cgit From d99d881952436f5b01364b8f31b1bc90c22a1444 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 6 Mar 2009 15:44:50 -0800 Subject: Support older tracepoints using DEFINE_TRACE At one point, the tracepoints API didn't have DECLARE_TRACE, and the trace headers all used DEFINE_TRACE. This is what got pulled into RHEL, so we need to support this older usage. The rest of the API stays the same though. * buildrun.cxx (make_tracequery): Redefine DEFINE_TRACE as well. --- buildrun.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index b81cba23..2685949d 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -372,6 +372,11 @@ make_tracequery(systemtap_session& s, string& name) osrc << "#define DECLARE_TRACE(name, proto, args) \\" << endl; osrc << " void stapprobe_##name(proto) {}" << endl; + // older tracepoints used DEFINE_TRACE, so redirect that too + osrc << "#undef DEFINE_TRACE" << endl; + osrc << "#define DEFINE_TRACE(name, proto, args) \\" << endl; + osrc << " DECLARE_TRACE(name, TPPROTO(proto), TPARGS(args))" << endl; + // dynamically pull in all tracepoint headers from include/trace/ glob_t trace_glob; string glob_str(s.kernel_build_tree + "/include/trace/*.h"); -- cgit From b1f85b93f4cdc5eaad45891399c30341d4d6ce93 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 8 Mar 2009 22:28:03 -0400 Subject: Adapt to linux-next commit changing __alloc_percpu API. After linux-next commit f2a8205c, it takes two parameters again, so we autoconf for it rather than use KERNEL_VERSION ifdefs. --- buildrun.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'buildrun.cxx') diff --git a/buildrun.cxx b/buildrun.cxx index 2685949d..b9d648ef 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -147,6 +147,7 @@ compile_pass (systemtap_session& s) output_autoconf(s, o, "autoconf-task-uid.c", "STAPCONF_TASK_UID", NULL); output_autoconf(s, o, "autoconf-vm-area.c", "STAPCONF_VM_AREA", NULL); output_autoconf(s, o, "autoconf-procfs-owner.c", "STAPCONF_PROCFS_OWNER", NULL); + output_autoconf(s, o, "autoconf-alloc-percpu-align.c", "STAPCONF_ALLOC_PERCPU_ALIGN", NULL); #if 0 /* NB: For now, the performance hit of probe_kernel_read/write (vs. our -- cgit