From 4090de8ca2717fd028548f06783582b7c6c74931 Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 3 Mar 2006 17:44:23 +0000 Subject: 2006-03-03 Frank Ch. Eigler * tapset/indent.stp, indent-default.stp: New little tapset. * stapfuncs.5.in: Document it. * testsuite/buildok/indent.stp: Build it. --- ChangeLog | 6 ++++++ stapfuncs.5.in | 17 +++++++++++++++++ tapset/indent-default.stp | 1 + tapset/indent.stp | 22 ++++++++++++++++++++++ testsuite/buildok/indent.stp | 6 ++++++ 5 files changed, 52 insertions(+) create mode 100644 tapset/indent-default.stp create mode 100644 tapset/indent.stp create mode 100755 testsuite/buildok/indent.stp diff --git a/ChangeLog b/ChangeLog index 00287684..27bccb2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-03 Frank Ch. Eigler + + * tapset/indent.stp, indent-default.stp: New little tapset. + * stapfuncs.5.in: Document it. + * testsuite/buildok/indent.stp: Build it. + 2006-02-27 Josh Stone * safety/*: Add a static safety checker. diff --git a/stapfuncs.5.in b/stapfuncs.5.in index e1337993..43356564 100644 --- a/stapfuncs.5.in +++ b/stapfuncs.5.in @@ -226,6 +226,23 @@ Return the average time a request took from being enqueued to completed. qsq_throughput:long (qname:string, scale:long) Return the average rate of requests per scale units of time. +.SS INDENT +.PP +The indent tapset provides functions to generate indented lines for +nested kinds of trace messages. Each line contains a relative +timestamp, and the process name / pid. +.TP +thread_indent:string (delta:long) +Return a string with an appropriate indentation for this thread. +Call it with a small positive or matching negative delta. +If this is the outermost, initial level of indentation, reset the +relative timestamp base to zero. +.TP +thread_timestamp:long () +Return an absolute timestamp value for use by the indentation function. +The default function uses +.IR gettimeofday_us + .SH FILES .nh .IR /usr/share/systemtap/tapset diff --git a/tapset/indent-default.stp b/tapset/indent-default.stp new file mode 100644 index 00000000..fb9ff572 --- /dev/null +++ b/tapset/indent-default.stp @@ -0,0 +1 @@ +function __indent_timestamp() { return gettimeofday_us() } diff --git a/tapset/indent.stp b/tapset/indent.stp new file mode 100644 index 00000000..dface781 --- /dev/null +++ b/tapset/indent.stp @@ -0,0 +1,22 @@ +global _indent_counters, _indent_timestamps + +function _generic_indent (idx, delta) +{ + ts = __indent_timestamp () + if (! _indent_counters[idx]) _indent_timestamps[idx] = ts + + # pre-increment for positive delta and post-decrement for negative delta + x = _indent_counters[idx] + (delta > 0 ? delta : 0) + _indent_counters[idx] += delta + + r = sprintf("%6d %s(%d):", (ts - _indent_timestamps[idx]), + execname(), tid()) + for (i=1; i