]>
Commit | Line | Data |
---|---|---|
ba4a90fd | 1 | .\" -*- nroff -*- |
ec1a2239 | 2 | .TH STAPFUNCS 3stap |
ba4a90fd FCE |
3 | .SH NAME |
4 | stapfuncs \- systemtap functions | |
5 | ||
6 | .SH DESCRIPTION | |
89965a32 | 7 | The following sections enumerate a few of public functions provided by |
ec1a2239 | 8 | standard tapsets installed, show in the stappaths (7) manual page. Most |
89965a32 FCE |
9 | are individually documented in the |
10 | .IR 3stap | |
11 | manual section, with the | |
12 | .IR function:: | |
13 | prefix. | |
14 | .PP | |
15 | Each function is described with a signature, and its behavior/restrictions. | |
ba4a90fd FCE |
16 | The signature line includes the name of the function, the type of |
17 | its return value (if any), and the names and types of all parameters. | |
18 | The syntax is the same as printed with the | |
13d2ecdb | 19 | .IR stap " option " \-p2 . |
ba4a90fd FCE |
20 | Examples: |
21 | ||
22 | .TP | |
23 | example1:long (v:string, k:long) | |
cc9ee605 FCE |
24 | In function "example1", do something with the given string and integer. |
25 | Return some integer. | |
ba4a90fd FCE |
26 | |
27 | .TP | |
28 | example2:unknown () | |
cc9ee605 FCE |
29 | In function "example2", do something. There is no explicit return value |
30 | and take no parameters. | |
ba4a90fd | 31 | |
ba4a90fd | 32 | |
1902aec1 FCE |
33 | .SS TARGET_SET |
34 | .TP | |
35 | target_set_pid:long (tid:long) | |
36 | Return whether the given process-id is within the "target set", that is whether | |
37 | it is a descendent of the top-level target() process. | |
38 | .TP | |
39 | target_set_report:unknown () | |
40 | Print a report about the target set, and their ancestry. | |
41 | ||
ab4ff75b | 42 | .SS ERRNO |
48ce39e1 KS |
43 | .TP |
44 | errno_str:string (e:long) | |
ab4ff75b FCE |
45 | Return the symbolic string associated with the given error code, like |
46 | "ENOENT" for the number 2, or "E#3333" for an out-of-range value like 3333. | |
48ce39e1 | 47 | |
89965a32 | 48 | .SS REGISTERS |
af26b140 | 49 | .TP |
ff0c3d4c JK |
50 | register:long (name:string) |
51 | Return the value of the named CPU register, | |
52 | as it was saved when the current probe point was hit. | |
53 | If the register is 32 bits, it is sign-extended to 64 bits. | |
54 | ||
55 | For the i386 architecture, the following names are recognized. | |
56 | (name1/name2 indicates that name1 and name2 are alternative names | |
57 | for the same register.) | |
58 | eax/ax, ebp/bp, ebx/bx, ecx/cx, edi/di, edx/dx, eflags/flags, | |
59 | eip/ip, esi/si, esp/sp, orig_eax/orig_ax, | |
60 | xcs/cs, xds/ds, xes/es, xfs/fs, xss/ss. | |
61 | ||
62 | For the x86_64 architecture, the following names are recognized: | |
63 | 64-bit registers: | |
64 | r8, r9, r10, r11, r12, r13, r14, r15, | |
65 | rax/ax, rbp/bp, rbx/bx, rcx/cx, rdi/di, rdx/dx, | |
66 | rip/ip, rsi/si, rsp/sp; | |
67 | 32-bit registers: | |
68 | eax, ebp, ebx, ecx, edx, edi, edx, eip, esi, esp, flags/eflags, orig_eax; | |
69 | segment registers: xcs/cs, xss/ss. | |
dbb280c7 AM |
70 | |
71 | For powerpc, the following names are recognized: | |
50a0afbe | 72 | r0, r1, ... r31, nip, msr, orig_gpr3, ctr, link, xer, ccr, softe, trap, |
af26b140 | 73 | dar, dsisr, result. |
dbb280c7 | 74 | |
50a0afbe JK |
75 | For s390x, the following names are recognized: |
76 | r0, r1, ... r15, args, psw.mask, psw.addr, orig_gpr2, ilc, trap. | |
77 | ||
ff0c3d4c JK |
78 | .TP |
79 | u_register:long (name:string) | |
80 | Same as register(name), except that | |
81 | if the register is 32 bits, it is zero-extended to 64 bits. | |
82 | ||
83 | .SS NUMBERED FUNCTION ARGUMENTS | |
84 | The functions in this section provide the values of a probed function's | |
85 | arguments. | |
86 | They can be called when you have hit | |
87 | a probe point at the entry to a function. | |
88 | Arguments are referred to by number, starting at 1. | |
89 | Ordinarily, you can access arguments by name as well, | |
90 | but you may find these functions useful if the code you are probing | |
91 | was built without debugging information. | |
92 | ||
93 | On 32-bit architectures | |
94 | \(em and when probing 32-bit applications on 64-bit architectures \(em | |
95 | a 64-bit argument occupies two "arg slots." | |
96 | For example, if you are probing the following function | |
97 | ||
98 | void f(int a, long long b, char *c) | |
99 | ||
100 | you would refer to a, b, and c as int_arg(1), longlong_arg(2), and | |
101 | pointer_arg(3), respectively, on a 64-bit architecture; | |
102 | but on a 32-bit architecture, you would refer to c as pointer_arg(4) | |
103 | (since b occupies slots 2 and 3). | |
104 | ||
105 | If the function you are probing doesn't follow the default rules | |
106 | for argument passing, you need to call one of the following functions | |
107 | (which see) in your handler before calling any *_arg function: | |
108 | asmlinkage(), fastcall(), or regparm(). | |
109 | (This isn't necessary when referring to arguments only by name.) | |
110 | .TP | |
111 | int_arg:long (n:long) | |
112 | Return the value of argument n as a signed int | |
113 | (i.e., a 32-bit integer sign-extended to 64 bits). | |
114 | .TP | |
115 | uint_arg:long (n:long) | |
116 | Return the value of argument n as an unsigned int | |
117 | (i.e., a 32-bit integer zero-extended to 64 bits). | |
118 | .TP | |
119 | long_arg:long (n:long) | |
120 | Return the value of argument n as a signed long. | |
121 | On architectures where a long is 32 bits, the value is sign-extended to 64 bits. | |
122 | .TP | |
123 | ulong_arg:long (n:long) | |
124 | Return the value of argument n as an unsigned long. | |
125 | On architectures where a long is 32 bits, the value is zero-extended to 64 bits. | |
126 | .TP | |
127 | longlong_arg:long (n:long) | |
128 | Return the value of argument n as a 64-bit value. | |
129 | .TP | |
130 | ulonglong_arg:long (n:long) | |
131 | Same as longlong_arg(n). | |
132 | .TP | |
133 | pointer_arg:long (n:long) | |
134 | Same as ulong_arg(n). | |
135 | Use with any type of pointer. | |
136 | .TP | |
137 | s32_arg:long (n:long) | |
138 | Same as int_arg(n). | |
139 | .TP | |
140 | u32_arg:long (n:long) | |
141 | Same as uint_arg(n). | |
142 | .TP | |
143 | s64_arg:long (n:long) | |
144 | Same as longlong_arg(n). | |
145 | .TP | |
146 | u64_arg:long (n:long) | |
147 | Same as [u]longlong_arg(n). | |
148 | .TP | |
149 | asmlinkage:unknown () | |
150 | The probed kernel function is declared asmlinkage in the source. | |
151 | .TP | |
152 | fastcall:unknown () | |
153 | The probed kernel function is declared fastcall in the source. | |
154 | .TP | |
155 | regparm:unknown (n:long) | |
156 | The probed function was built with the gcc \-mregparm=n option. | |
157 | (The i386 kernel is built with \-mregparm=3, so systemtap considers | |
158 | regparm(3) the default for kernel functions on that architecture.) | |
159 | ||
50a0afbe | 160 | For some architectures, the *_arg functions may reject unusually high |
dbb280c7 AM |
161 | values of n. |
162 | ||
2a99f48f FCE |
163 | .SS QUEUE_STATS |
164 | .PP | |
165 | The queue_stats tapset provides functions that, given notifications of | |
166 | elementary queuing events (wait, run, done), tracks averages such as | |
5db55886 | 167 | queue length, service and wait times, utilization. The following |
2a99f48f FCE |
168 | three functions should be called from appropriate probes, in sequence. |
169 | .TP | |
170 | qs_wait:unknown (qname:string) | |
171 | Record that a new request was enqueued for the given queue name. | |
172 | .TP | |
173 | qs_run:unknown (qname:string) | |
174 | Record that a previously enqueued request was removed from the given | |
175 | wait queue and is now being serviced. | |
176 | .TP | |
177 | qs_done:unknown (qname:string) | |
178 | Record that a request originally from the given queue has completed | |
179 | being serviced. | |
180 | .\" XXX: qs_time | |
181 | .PP | |
182 | Functions with the prefix | |
183 | .BR qsq_ | |
184 | are for querying the statistics averaged since the first queue operation | |
185 | (or when | |
186 | .BR qsq_start | |
187 | was called). Since statistics are often fractional, a scale parameter | |
188 | is multiplies the result to a more useful scale. For some fractions, | |
189 | a scale of 100 will usefully return percentage numbers. | |
190 | .TP | |
191 | qsq_start:unknown (qname:string) | |
192 | Reset the statistics counters for the given queue, and start tracking | |
193 | anew from this moment. | |
194 | .TP | |
195 | qsq_print:unknown (qname:string) | |
196 | Print a line containing a selection of the given queue's statistics. | |
197 | .TP | |
198 | qsq_utilization:long (qname:string, scale:long) | |
199 | Return the fraction of elapsed time when the resource was utilized. | |
200 | .TP | |
201 | qsq_blocked:long (qname:string, scale:long) | |
202 | Return the fraction of elapsed time when the wait queue was used. | |
203 | .TP | |
204 | qsq_wait_queue_length:long (qname:string, scale:long) | |
205 | Return the average length of the wait queue. | |
206 | .TP | |
207 | qsq_service_time:long (qname:string, scale:long) | |
208 | Return the average time required to service a request. | |
209 | .TP | |
210 | qsq_wait_time:long (qname:string, scale:long) | |
211 | Return the average time a request took from being enqueued to completed. | |
212 | .TP | |
213 | qsq_throughput:long (qname:string, scale:long) | |
214 | Return the average rate of requests per scale units of time. | |
21c0e74e | 215 | |
4090de8c FCE |
216 | .SS INDENT |
217 | .PP | |
218 | The indent tapset provides functions to generate indented lines for | |
219 | nested kinds of trace messages. Each line contains a relative | |
220 | timestamp, and the process name / pid. | |
221 | .TP | |
222 | thread_indent:string (delta:long) | |
223 | Return a string with an appropriate indentation for this thread. | |
224 | Call it with a small positive or matching negative delta. | |
225 | If this is the outermost, initial level of indentation, reset the | |
226 | relative timestamp base to zero. | |
227 | .TP | |
228 | thread_timestamp:long () | |
229 | Return an absolute timestamp value for use by the indentation function. | |
230 | The default function uses | |
231 | .IR gettimeofday_us | |
232 | ||
70404fc5 MH |
233 | .SS SYSTEM |
234 | .TP | |
235 | system (cmd:string) | |
236 | Runs a command on the system. The command will run in the background | |
237 | when the current probe completes. | |
238 | ||
3797855d | 239 | |
bfb72442 FCE |
240 | .SS INET |
241 | These functions convert between network (big-endian) and host byte order, like their | |
242 | namesake C functions. | |
243 | .TP | |
244 | ntohll:long (x:long) | |
245 | Convert from network to host byte order, 64-bit. | |
246 | .TP | |
247 | ntohl:long (x:long) | |
248 | Convert from network to host byte order, 32-bit. | |
249 | .TP | |
250 | ntohs:long (x:long) | |
251 | Convert from network to host byte order, 16-bit. | |
252 | .TP | |
253 | htonll:long (x:long) | |
254 | Convert from host to network byte order, 64-bit. | |
255 | .TP | |
256 | htonl:long (x:long) | |
257 | Convert from host to network byte order, 32-bit. | |
258 | .TP | |
259 | htons:long (x:long) | |
260 | Convert from host to network byte order, 16-bit. | |
261 | ||
ed22941d ET |
262 | .SS SIGNAL |
263 | .TP | |
264 | get_sa_flags:long (act:long) | |
265 | Returns the numeric value of sa_flags. | |
266 | .TP | |
267 | get_sa_handler:long (act:long) | |
268 | Returns the numeric value of sa_handler. | |
269 | .TP | |
270 | sigset_mask_str:string (mask:long) | |
271 | Returns the string representation of the sigset sa_mask. | |
272 | .TP | |
273 | is_sig_blocked:long (task:long, sig:long) | |
274 | Returns 1 if the signal is currently blocked, or 0 if it is not. | |
275 | .TP | |
276 | sa_flags_str:string (sa_flags:long) | |
277 | Returns the string representation of sa_flags. | |
278 | .TP | |
279 | sa_handler_str(handler) | |
280 | Returns the string representation of sa_handler. If it is not SIG_DFL, SIG_IGN | |
281 | or SIG_ERR, it will return the address of the handler. | |
282 | .TP | |
283 | signal_str(num) | |
284 | Returns the string representation of the given signal number. | |
bfb72442 | 285 | |
e3cbdeff WC |
286 | .SS DEVICE |
287 | .TP | |
288 | MAJOR:long(dev:long) | |
289 | Extracts the major device number from a kernel device number (kdev_t). | |
290 | .TP | |
291 | MINOR:long(dev:long) | |
292 | Extracts the minor device number from a kernel device number (kdev_t). | |
293 | .TP | |
294 | MKDEV:long(major:long, minor:long) | |
295 | Creates a value that can be compared to a kernel device number (kdev_t). | |
296 | .TP | |
297 | usrdev2kerndev:long(dev:long) | |
298 | Converts a user-space device number into the format used in the kernel. | |
299 | ||
ba4a90fd | 300 | .SH FILES |
ec1a2239 LB |
301 | .TP |
302 | More files and their corresponding paths can be found in the stappaths (7) manual page. | |
ba4a90fd FCE |
303 | |
304 | .SH SEE ALSO | |
89965a32 FCE |
305 | .IR stap (1), |
306 | .IR function::* (3stap), | |
ec1a2239 LB |
307 | .IR tapset::* (3stap), |
308 | .IR stappaths (7) |