From: Fahad Arshad Date: Wed, 26 Feb 2014 14:41:05 +0000 (-0500) Subject: PR16472: Add a thread_indent_depth() tapset function X-Git-Tag: release-2.5~245 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=cecdb2dddae55b510814dc8a6d7510e5fa5e0d9f;p=systemtap.git PR16472: Add a thread_indent_depth() tapset function --- diff --git a/tapset/indent.stp b/tapset/indent.stp index bc608461b..33bb98d1f 100644 --- a/tapset/indent.stp +++ b/tapset/indent.stp @@ -36,6 +36,30 @@ function thread_indent:string (delta:long) return _generic_indent (tid(), sprintf("%s(%d)", execname(), tid()), delta) } +function _generic_indent_depth:long (idx, delta) +{ + # pre-increment for positive delta and post-decrement for negative delta + x = _indent_counters[idx] + (delta > 0 ? delta : 0) + _indent_counters[idx] += delta + + return (x>0 ? x-1 : 0) +} + +/** + * sfunction thread_indent_depth - returns an integer corresponding to the nested-depth in the current task information + * + * @delta: the amount of increment added/removed for each call + * + * Description: This function returns an integer equal to the nested function-call depth starting + * from the outermost initial level. This function is useful for saving space (consumed by whitespace) + * in traces with long nested function calls. Use this function in a similar fashion to thread_indent(), i.e., + * in call-probe, use thread_indent_depth(1) and in return-probe, use thread_indent_depth(-1) + */ +function thread_indent_depth:long (delta:long) +{ + return _generic_indent_depth (tid(), delta) +} + /** * sfunction indent - returns an amount of space to indent *