]> sourceware.org Git - systemtap.git/commitdiff
2006-03-03 Frank Ch. Eigler <fche@elastic.org>
authorfche <fche>
Fri, 3 Mar 2006 17:44:23 +0000 (17:44 +0000)
committerfche <fche>
Fri, 3 Mar 2006 17:44:23 +0000 (17:44 +0000)
* tapset/indent.stp, indent-default.stp: New little tapset.
* stapfuncs.5.in: Document it.
* testsuite/buildok/indent.stp: Build it.

ChangeLog
stapfuncs.5.in
tapset/indent-default.stp [new file with mode: 0644]
tapset/indent.stp [new file with mode: 0644]
testsuite/buildok/indent.stp [new file with mode: 0755]

index 00287684babbcc23a59ddbd8aa5d419770535161..27bccb2cf53819c558e1d59c286fe850fcc9d5cc 100644 (file)
--- 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.
index e133799345a987c307e5d8306fd48630fdad8ea1..433565647649dfcc7c1ac3731bfb1592b954de8a 100644 (file)
@@ -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 (file)
index 0000000..fb9ff57
--- /dev/null
@@ -0,0 +1 @@
+function __indent_timestamp() { return gettimeofday_us() }
diff --git a/tapset/indent.stp b/tapset/indent.stp
new file mode 100644 (file)
index 0000000..dface78
--- /dev/null
@@ -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 (executable)
index 0000000..03480a5
--- /dev/null
@@ -0,0 +1,6 @@
+probe begin {
+  print (thread_indent (1)) print ("yo\n")
+  print (thread_indent (-1)) print ("ta\n")
+  exit ()
+}
+
This page took 0.041446 seconds and 5 git commands to generate.