summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--stapfuncs.5.in17
-rw-r--r--tapset/indent-default.stp1
-rw-r--r--tapset/indent.stp22
-rwxr-xr-xtestsuite/buildok/indent.stp6
5 files changed, 52 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 00287684..27bccb2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
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<x; i++) r .= " "
+
+ return r
+}
+
+function thread_indent (delta)
+{
+ return _generic_indent (tid(), delta)
+}
diff --git a/testsuite/buildok/indent.stp b/testsuite/buildok/indent.stp
new file mode 100755
index 00000000..03480a51
--- /dev/null
+++ b/testsuite/buildok/indent.stp
@@ -0,0 +1,6 @@
+probe begin {
+ print (thread_indent (1)) print ("yo\n")
+ print (thread_indent (-1)) print ("ta\n")
+ exit ()
+}
+