blob: 2f850bfda2b1f8279a3d66d085341381b2c3885e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
global _indent_counters, _indent_timestamps
function _generic_indent (idx, desc, 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
return sprintf("%6d %s:%-*s", (ts - _indent_timestamps[idx]), desc, (x>0 ? x-1 : 0), "")
}
/**
* 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(), 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)
}
|