From 4f988cd3365c63ac792317337670155d3351d577 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 16 Apr 2009 14:34:21 -0400 Subject: Simplify dtrace. * dtrace: Simplify the macro generator. --- dtrace | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/dtrace b/dtrace index ca95b678..304c1bf6 100755 --- a/dtrace +++ b/dtrace @@ -59,29 +59,18 @@ class provider: i += 1 if (len(new_args) > 0): self.arglist[this_probe] = ('%s arg%d' % (new_args, c)) - if (len(new_args) == 0): - self.h.write ('#define %s() STAP_PROBE(provider,%s)\n' % (this_probe_canon, this_probe)) - elif (c == 0): - self.h.write ('#define %s(arg1) STAP_PROBE%d(provider,%s,arg1)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 1): - self.h.write ('#define %s(arg1,arg2) STAP_PROBE%d(provider,%s,arg1,arg2)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 2): - self.h.write ('#define %s(arg1,arg2,arg3) STAP_PROBE%d(provider,%s,arg1,arg2,arg3)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 3): - self.h.write ('#define %s(arg1,arg2,arg3,arg4) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 4): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 5): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 6): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6,arg7) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 7): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 8): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\n' % (this_probe_canon, c+1, this_probe)) - elif (c == 9): - self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\n' % (this_probe_canon, c+1, this_probe)) + define_str = "#define %s(" % (this_probe_canon) + stap_str = "STAP_PROBE%s(provider,%s" % (c+1,this_probe) + i = 0 + while (i <= c): + if (i != 0): + define_str += "," + define_str = define_str + "arg%s" % (i+1); + stap_str = stap_str + ",arg%s" % (i+1); + i += 1 self.h.write ('#define %s_ENABLED() 1\n' % this_probe_canon) + self.h.write (define_str + ")\\\n") + self.h.write (stap_str + ")\n\n") def get(self, arg): print arg @@ -89,9 +78,6 @@ class provider: return self.arglist[arg] else: return "" -######################################################################## -# main -######################################################################## def usage (): print "Usage " + sys.argv[0] + " [-h | -G] -s File.d -o File {Files}" @@ -107,6 +93,11 @@ def open_file (arg): sys.exit(1) return file + +######################################################################## +# main +######################################################################## + if (len (sys.argv) < 2): usage() -- cgit From 466076411bb00af1b2d13423b47ee2835e9b1c97 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Thu, 16 Apr 2009 15:04:29 -0400 Subject: Handle dtrace no argument macro case specially. * dtrace: No argument case is DTRACE_PROBE/STAP_PROBE. --- dtrace | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dtrace b/dtrace index 304c1bf6..114e70a6 100755 --- a/dtrace +++ b/dtrace @@ -59,17 +59,22 @@ class provider: i += 1 if (len(new_args) > 0): self.arglist[this_probe] = ('%s arg%d' % (new_args, c)) + if (len(new_args) == 0): + c = 0 + stap_str = "STAP_PROBE(provider,%s" % (this_probe) + else: + c += 1 + stap_str = "STAP_PROBE%d(provider,%s" % (c,this_probe) define_str = "#define %s(" % (this_probe_canon) - stap_str = "STAP_PROBE%s(provider,%s" % (c+1,this_probe) - i = 0 + i = 1 while (i <= c): if (i != 0): define_str += "," - define_str = define_str + "arg%s" % (i+1); - stap_str = stap_str + ",arg%s" % (i+1); + define_str = define_str + "arg%s" % (i); + stap_str = stap_str + ",arg%s" % (i); i += 1 self.h.write ('#define %s_ENABLED() 1\n' % this_probe_canon) - self.h.write (define_str + ")\\\n") + self.h.write (define_str + ") \\\n") self.h.write (stap_str + ")\n\n") def get(self, arg): -- cgit From 9afe68eda6c01ca07a4f6010104f524a337d2050 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 16 Apr 2009 15:07:42 -0700 Subject: Privatize MAX_STACK_DEPTH The kernel-tip tree also has a MAX_STACK_DEPTH defined in perf_counter.h, so we need to separate our definition. I've changed the definition in our unwinder to STP_MAX_STACK_DEPTH. --- runtime/unwind.c | 2 +- runtime/unwind/unwind.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/unwind.c b/runtime/unwind.c index f7b19def..41af72a7 100644 --- a/runtime/unwind.c +++ b/runtime/unwind.c @@ -345,7 +345,7 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc, s state->label = NULL; return 1; } - if (state->stackDepth >= MAX_STACK_DEPTH) + if (state->stackDepth >= STP_MAX_STACK_DEPTH) return 0; state->stack[state->stackDepth++] = ptr.p8; break; diff --git a/runtime/unwind/unwind.h b/runtime/unwind/unwind.h index 78a4bfef..3b6d0de0 100644 --- a/runtime/unwind/unwind.h +++ b/runtime/unwind/unwind.h @@ -23,7 +23,7 @@ #error "Unsupported dwarf unwind architecture" #endif -#define MAX_STACK_DEPTH 8 +#define STP_MAX_STACK_DEPTH 8 #ifndef BUILD_BUG_ON_ZERO #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) @@ -135,7 +135,7 @@ struct unwind_state { unsigned stackDepth:8; unsigned version:8; const u8 *label; - const u8 *stack[MAX_STACK_DEPTH]; + const u8 *stack[STP_MAX_STACK_DEPTH]; }; static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 }; -- cgit From 0f2c85234527a02ca73909169a6750446a5a94f5 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 16 Apr 2009 15:20:02 -0700 Subject: Keep up with tracepoint changes in kernel-tip - Define TRACE_HEADER_MULTI_READ to allow re-pulling headers that were already included indirectly elsewhere. - Some tracepoint headers were moved down to include/trace/events/, so add that to our glob paths. - Add ftrace.h as a header that we should never include. --- buildrun.cxx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/buildrun.cxx b/buildrun.cxx index 82ac9d4e..aac0c356 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -391,6 +391,10 @@ 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& extra_ // dynamically pull in all tracepoint headers from include/trace/ glob_t trace_glob; - string globs[2] = { "/include/trace/*.h", "/source/include/trace/*.h" }; - for (unsigned z=0; z<2; z++) + 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(basename(trace_glob.gl_pathv[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 == "trace_events.h") + 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 " << endl; + osrc << "#include <" << header << ">" << endl; } globfree(&trace_glob); } -- cgit From 2a22df62a80d032e9450570c32009bfea4be7305 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Fri, 17 Apr 2009 10:15:41 -0400 Subject: Output probe calling sequence comment * dtrace: Output probe calling sequence comment --- dtrace | 16 +++------------- testsuite/systemtap.base/static_uprobes.exp | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/dtrace b/dtrace index 114e70a6..a2b495b2 100755 --- a/dtrace +++ b/dtrace @@ -17,12 +17,11 @@ from subprocess import call from tempfile import mkstemp class provider: - arglist = dict() def open(self, provider, header): have_provider = False self.f = open(provider) self.h = open(header,mode='w') - self.h.write("// Generated by the Systemtap dtrace wrapper\n") + self.h.write("/* Generated by the Systemtap dtrace wrapper */\n") self.h.write("\n#include \n\n") in_comment = False while (True): @@ -49,7 +48,6 @@ class provider: new_args = "" i = 0 c = 0 - self.arglist[this_probe] = "" while (i < len(args)): if (args[i:i+1] == ","): new_args = ('%s%s' % (new_args, args[i])) @@ -57,8 +55,6 @@ class provider: else: new_args = new_args + args[i] i += 1 - if (len(new_args) > 0): - self.arglist[this_probe] = ('%s arg%d' % (new_args, c)) if (len(new_args) == 0): c = 0 stap_str = "STAP_PROBE(provider,%s" % (this_probe) @@ -68,22 +64,16 @@ class provider: define_str = "#define %s(" % (this_probe_canon) i = 1 while (i <= c): - if (i != 0): + if (i != 1): define_str += "," define_str = define_str + "arg%s" % (i); stap_str = stap_str + ",arg%s" % (i); i += 1 + self.h.write ('/* %s (%s) */\n' % (this_probe_canon,new_args)) self.h.write ('#define %s_ENABLED() 1\n' % this_probe_canon) self.h.write (define_str + ") \\\n") self.h.write (stap_str + ")\n\n") - def get(self, arg): - print arg - if (arg in self.arglist): - return self.arglist[arg] - else: - return "" - def usage (): print "Usage " + sys.argv[0] + " [-h | -G] -s File.d -o File {Files}" sys.exit(1) diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index 07ff83e9..1e53d5d3 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -93,7 +93,6 @@ if {[installtest_p]} { if {[catch {exec $dtrace -h -s $sup_dpath} res]} { verbose -log "unable to run $dtrace: $res" } -catch {exec rm -f $sup_dpath} if {[file exists $sup_hpath]} then { pass "$test dtrace" } else { -- cgit