* tapset/indent.stp, indent-default.stp: New little tapset.
* stapfuncs.5.in: Document it.
* testsuite/buildok/indent.stp: Build it.
+2006-03-03 Frank Ch. Eigler <fche@elastic.org>
+
+ * 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 <joshua.i.stone@intel.com>
* safety/*: Add a static safety checker.
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
--- /dev/null
+function __indent_timestamp() { return gettimeofday_us() }
--- /dev/null
+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<x; i++) r .= " "
+
+ return r
+}
+
+function thread_indent (delta)
+{
+ return _generic_indent (tid(), delta)
+}
--- /dev/null
+probe begin {
+ print (thread_indent (1)) print ("yo\n")
+ print (thread_indent (-1)) print ("ta\n")
+ exit ()
+}
+