summaryrefslogtreecommitdiffstats
path: root/stapfuncs.5.in
blob: f8891310f5ef5d85db80a4921aca62d01d8ce7a9 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
.\" -*- nroff -*-
.TH STAPFUNCS 5 @DATE@ "Red Hat"
.SH NAME
stapfuncs \- systemtap functions

.SH DESCRIPTION
The following sections enumerate the public functions provided by
standard tapsets installed under /usr/share/systemtap/tapset.  Each
function is described with a signature, and its behavior/restrictions.
The signature line includes the name of the function, the type of
its return value (if any), and the names and types of all parameters.
The syntax is the same as printed with the 
.IR stap " option " \-p2 .
Examples:

.TP
example1:long (v:string, k:long)
In function "example1", do something with the given string and integer.
Return some integer.

.TP
example2:unknown ()
In function "example2", do something.  There is no explicit return value
and take no parameters.

.SS LOGGING

.TP
log:unknown (msg:string)
Log the given string to the common trace buffer.  Append an implicit
end-of-line.

.TP
print:unknown (...)
Print the given integer, string, or statistics value to
the common trace buffer.

.TP
printf:unknown (fmt:string, ...)
Like the C printf, except valid types are limited to string ("%s")
and integer ("%d"). 

.TP
warn:unknown (msg:string)
Log the given string to the warning stream.  Append an implicit end-of-line.
.I staprun
prepends the string "WARNING:". 

.TP
error:unknown (msg:string)
An error has occurred.  Log the given string to the error stream.
Append an implicit end-of-line.
.I staprun
prepends the string "ERROR:".
Block any further execution of statements in this probe.  If the number
of errors so far exceeds the MAXERRORS parameter, also trigger an 
.IR exit() .

.TP
exit:unknown ()
Enqueue a request to shut down the systemtap session.  This does
.B not
unwind the current probe handler, nor block new probe handlers.
.I staprun
will shortly respond to the request and initiate an orderly shutdown.

.SS CONVERSIONS
.TP
kernel_string:string (addr:long)
Copy a string from kernel space at given address.  The validation of this
address is only partial at present.
.TP
user_string:string (addr:long)
Copy a string from user space at given address.  The validation of this
address is only partial at present.

.SS STRING
.TP
strlen:long (str:string)
Return the number of characters in str.
.TP
substr:string (str:string,start:long, stop:long)
Return the substring of str starting from character start and ending at character stop.
.TP
isinstr:long (s1:string, s2:string)
Return 1 if string s1 contains string s2, returns 0 otherwise.

.SS TIMESTAMP
.TP
get_cycles:long ()
Return the processor cycle counter value, or 0 if unavailable.
.TP
gettimeofday_ns:long ()
Return the number of nanoseconds since the UNIX epoch.
.TP
gettimeofday_us:long ()
Return the number of microseconds since the UNIX epoch.
.TP
gettimeofday_ms:long ()
Return the number of milliseconds since the UNIX epoch.
.TP
gettimeofday_s:long ()
Return the number of seconds since the UNIX epoch.

.SS CONTEXTINFO
.TP
cpu:long ()
Return the current cpu number.
.TP
execname:string ()
Return the name of the current process.
.TP
pexecname:string()
Return the name of the parent process.
.TP
tid:long ()
Return the id of the current thread.
.TP
pid:long ()
Return the id of the current process.
.TP
ppid:long ()
Return the id of the parent process.
.TP
uid:long ()
Return the uid of the current process.
.TP
euid:long ()
Return the effective uid of the current process.
.TP
gid:long ()
Return the gid of the current process.
.TP
egid:long ()
Return the effective gid of the current process.
.TP
print_regs:unknown ()
Print a register dump.
.TP
backtrace:string ()
Return a string of hex addresses that are a backtrace of the stack.
It may be truncated due to maximum string length.
.TP
print_stack:unknown (bt:string)
Perform a symbolic lookup of the addresses in the given string,
which is assumed to be the result of a prior call to
.IR backtrace() .
Print one line per address, including the address, the name of the
function containing the address, and an estimate of its position
within that function.  Return nothing.
.TP
print_backtrace:unknown ()
Equivalent to
.IR print_stack(backtrace()) ,
except that deeper stack nesting may be supported.  Return nothing.
.TP
pp:string ()
Return the probe point associated with the currently running probe handler,
including alias and wildcard expansion effects.
.TP
probefunc:string ()
Return the probe point's function name, if known.
.TP
probemod:string ()
Return the probe point's module name, if known.
.TP
target:long ()
Return the pid of the target process.
.TP
is_return:long ()
Return 1 if the probe point is a return probe.  Deprecated.

.SS ERRNO
.TP
errno_str:string (e:long)
Return the symbolic string associated with the given error code, like
"ENOENT" for the number 2, or "E#3333" for an out-of-range value like 3333.

.SS QUEUE_STATS
.PP
The queue_stats tapset provides functions that, given notifications of
elementary queuing events (wait, run, done), tracks averages such as
queue length, service and wait times, utilization.  The following
three functions should be called from appropriate probes, in sequence.
.TP
qs_wait:unknown (qname:string)
Record that a new request was enqueued for the given queue name.
.TP
qs_run:unknown (qname:string)
Record that a previously enqueued request was removed from the given
wait queue and is now being serviced.
.TP
qs_done:unknown (qname:string)
Record that a request originally from the given queue has completed
being serviced.
.\" XXX: qs_time
.PP
Functions with the prefix 
.BR qsq_
are for querying the statistics averaged since the first queue operation
(or when
.BR qsq_start
was called). Since statistics are often fractional, a scale parameter
is multiplies the result to a more useful scale.  For some fractions,
a scale of 100 will usefully return percentage numbers.
.TP
qsq_start:unknown (qname:string)
Reset the statistics counters for the given queue, and start tracking
anew from this moment.
.TP
qsq_print:unknown (qname:string)
Print a line containing a selection of the given queue's statistics.
.TP
qsq_utilization:long (qname:string, scale:long)
Return the fraction of elapsed time when the resource was utilized.
.TP
qsq_blocked:long (qname:string, scale:long)
Return the fraction of elapsed time when the wait queue was used.
.TP
qsq_wait_queue_length:long (qname:string, scale:long)
Return the average length of the wait queue.
.TP
qsq_service_time:long (qname:string, scale:long)
Return the average time required to service a request.
.TP
qsq_wait_time:long (qname:string, scale:long)
Return the average time a request took from being enqueued to completed.
.TP
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

.SS SYSTEM
.TP
system (cmd:string)
Runs a command on the system. The command will run in the background
when the current probe completes.

.SS NUMA
.TP
addr_to_node:long (addr:long)
Return which node the given address belongs to in a NUMA system.

.SS CTIME
.TP
ctime:string (seconds:long)
Return a simple textual rendering (e.g., "Wed\ Jun\ 30\ 21:49:008\ 1993")
of the given number of seconds since the epoch, as perhaps returned by
.IR gettimeofday_s() .

.SS PERFMON
.TP
read_counter:long (handle:long)
Returns the value for the processor's performance counter for the associated
handle. The body of the a perfmon probe should set record
the handle being used for that event.

.SH FILES
.nh
.IR /usr/share/systemtap/tapset
.hy

.SH SEE ALSO
.IR stap (1)