This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH] Create a function that indents without the tid()
- From: Breno Leitao <leitao at linux dot vnet dot ibm dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: systemtap at sources dot redhat dot com
- Date: Wed, 30 Sep 2009 22:25:27 -0300
- Subject: Re: [PATCH] Create a function that indents without the tid()
- References: <4AC39EFA.50407@linux.vnet.ibm.com> <y0m4oqkjlcf.fsf@fche.csb> <4AC3B809.9040503@linux.vnet.ibm.com> <y0mzl8ci3if.fsf@fche.csb> <4AC3C5A5.8070403@linux.vnet.ibm.com> <20090930210015.GA20893@redhat.com>
Frank,
Frank Ch. Eigler wrote:
> How about generalizing _generic_indent to also take the
> execname()/tid() as incoming parameters:
Yes. It works perfectly as you told.
Here is the patch, with some basic documentation:
---
diff --git a/tapset/indent.stp b/tapset/indent.stp
index dface78..1dbbebd 100644
--- a/tapset/indent.stp
+++ b/tapset/indent.stp
@@ -1,6 +1,6 @@
global _indent_counters, _indent_timestamps
-function _generic_indent (idx, delta)
+function _generic_indent (idx, desc, delta)
{
ts = __indent_timestamp ()
if (! _indent_counters[idx]) _indent_timestamps[idx] = ts
@@ -9,14 +9,26 @@ function _generic_indent (idx, delta)
x = _indent_counters[idx] + (delta > 0 ? delta : 0)
_indent_counters[idx] += delta
- r = sprintf("%6d %s(%d):", (ts - _indent_timestamps[idx]),
- execname(), tid())
+ r = sprintf("%6d %s:", (ts - _indent_timestamps[idx]), desc)
+
for (i=1; i<x; i++) r .= " "
return r
}
+/**
+ * sfunction thread_indent - returns an amount of space with the current task information
+ * @delta: the amount of space added/removed for each call
+ */
function thread_indent (delta)
{
- return _generic_indent (tid(), delta)
+ return _generic_indent (tid(), sprintf("%s(%d)", execname(), tid()), delta)
+}
+
+/**
+ * sfunction indent - returns an amount of space to indent
+ * @delta: the amount of space added/removed for each call
+ */
+function indent(delta){
+ return _generic_indent(-1, "", delta)
}