2 .TH STAPFUNCS 3stap @DATE@ "Red Hat"
4 stapfuncs \- systemtap functions
7 The following sections enumerate the public functions provided by
8 standard tapsets installed under @prefix@/share/systemtap/tapset. Each
9 function is described with a signature, and its behavior/restrictions.
10 The signature line includes the name of the function, the type of
11 its return value (if any), and the names and types of all parameters.
12 The syntax is the same as printed with the
13 .IR stap " option " \-p2 .
17 example1:long (v:string, k:long)
18 In function "example1", do something with the given string and integer.
23 In function "example2", do something. There is no explicit return value
24 and take no parameters.
29 These functions access kernel or user-space data. They try to validate the
30 supplied addresses, and can thus result in errors if the pointers are invalid,
31 or if a user-space access would cause a fault.
33 kernel_string:string (addr:long)
34 Copy a 0-terminated string from kernel space at given address.
36 kernel_string_n:string (addr:long, n:long)
37 Similar with kernel_string, except that not more than n bytes are copied.
38 Thus, if there are null bytes among the first n bytes, it is same as
39 kernel_string(addr). If not, n bytes will be copied and a null byte will
42 kernel_long:long (addr:long)
43 Copy a long from kernel space at given address.
45 kernel_int:long (addr:long)
46 Copy an int from kernel space at given address.
48 kernel_short:long (addr:long)
49 Copy a short from kernel space at given address.
51 kernel_char:long (addr:long)
52 Copy a char from kernel space at given address.
54 user_string:string (addr:long)
55 Copy a string from user space at given address. If the access would
56 fault, return "<unknown>" and signal no errors.
58 user_string2:string (addr:long, err_msg:string)
59 Copy a string from user space at given address. If the access would
60 fault, return instead the err_msg value.
62 user_string_warn:string (addr:long)
63 Copy a string from user space at given address. If the access would
64 fault, signal a warning and return "<unknown>".
66 user_string_quoted:string (addr:long)
67 Copy a string from user space at given address. Any ASCII characters
68 that are not printable are replaced by the corresponding escape
69 sequence in the returned string.
71 user_string_n:string (addr:long, n:long)
72 Copy a string of n bytes from user space at given address. If the access
73 would fault, return "<unknown>".
75 user_string_n2:string (addr:long, n:long, err_msg:string)
76 Copy a string of n bytes from user space at given address. If the access
77 would fault, return the err_msg value.
79 user_string_n_warn:string (addr:long, n:long)
80 Copy a string of n bytes from user space at given address. If the access
81 would fault, signal a warning and return "<unknown>".
83 user_string_n_quoted:string (addr:long, n:long)
84 Copy a string of n bytes from user space at given address. Any ASCII
85 characters that are not printable are replaced by the corresponding escape
86 sequence in the returned string. If the access would fault, return "<unknown>".
88 user_short:long (addr:long)
89 Copy a short from user space at given address. If the access would fault,
92 user_short_warn:long (addr:long)
93 Copy a short from user space at given address. If the access would fault,
94 signal a warning and return 0.
96 user_int:long (addr:long)
97 Copy an int from user space at given address. If the access would fault,
100 user_int_warn:long (addr:long)
101 Copy an int from user space at given address. If the access would fault,
102 signal a warning and return 0.
104 user_long:long (addr:long)
105 Copy a long from user space at given address. If the access would fault,
108 user_long_warn:long (addr:long)
109 Copy a long from user space at given address. If the access would fault,
110 signal a warning and return 0.
112 user_char:long (addr:long)
113 Copy a char from user space at given address. If the access would fault,
116 user_char_warn:long (addr:long)
117 Copy a char from user space at given address. If the access would fault,
118 signal a warning and return 0.
121 strlen:long (str:string)
122 Return the number of characters in str.
124 substr:string (str:string,start:long, stop:long)
125 Return the substring of str starting from character start and ending at character stop.
127 stringat:string (str:string,pos:long)
128 Return the character in given position of string.
130 isinstr:long (s1:string, s2:string)
131 Return 1 if string s1 contains string s2, returns 0 otherwise.
133 strtol:long (str:string, base:long)
134 Convert the string representation of a number to a long using the numbering system
135 specified by base. For example, strtol("1000", 16) returns 4096. Returns 0 if the
136 string cannot be converted.
138 tokenize:string (str:string, delim:string)
139 Return the next non-empty token in the given str string, where the tokens are
140 delimited by characters in the delim string. If the str string is not blank,
141 it returns the first token. If the str string is blank, it returns the next
142 token in the string passed in the previous call to tokenize. If no delimiter
143 is found, the entire remaining str string is returned. Returns blank when
144 no more tokens are left.
149 Return the processor cycle counter value, or 0 if unavailable.
151 gettimeofday_ns:long ()
152 Return the number of nanoseconds since the UNIX epoch.
154 gettimeofday_us:long ()
155 Return the number of microseconds since the UNIX epoch.
157 gettimeofday_ms:long ()
158 Return the number of milliseconds since the UNIX epoch.
160 gettimeofday_s:long ()
161 Return the number of seconds since the UNIX epoch.
166 Return the current cpu number.
169 Return the name of the current process.
172 Return the name of the parent process.
175 Return the id of the current thread.
178 Return the id of the current process.
181 Return the id of the parent process.
184 Return the pgrp of the current process.
187 Return the sid of the current process.
190 Return the uid of the current process.
193 Return the effective uid of the current process.
196 Return the gid of the current process.
199 Return the effective gid of the current process.
201 print_regs:unknown ()
202 Print a register dump.
205 Return a string of hex addresses that are a backtrace of the stack.
206 It may be truncated due to maximum string length.
208 print_stack:unknown (bt:string)
209 Perform a symbolic lookup of the addresses in the given string,
210 which is assumed to be the result of a prior call to
212 Print one line per address, including the address, the name of the
213 function containing the address, and an estimate of its position
214 within that function. Return nothing.
216 print_backtrace:unknown ()
218 .IR print_stack(backtrace()) ,
219 except that deeper stack nesting may be supported. Return nothing.
222 Return the probe point associated with the currently running probe handler,
223 including alias and wildcard expansion effects.
226 Return the probe point's function name, if known.
229 Return the probe point's module name, if known.
232 Return the pid of the target process.
235 Return 1 if the probe point occurred in user-mode.
238 Return 1 if the probe point is a return probe. Deprecated.
242 target_set_pid:long (tid:long)
243 Return whether the given process-id is within the "target set", that is whether
244 it is a descendent of the top-level target() process.
246 target_set_report:unknown ()
247 Print a report about the target set, and their ancestry.
251 errno_str:string (e:long)
252 Return the symbolic string associated with the given error code, like
253 "ENOENT" for the number 2, or "E#3333" for an out-of-range value like 3333.
257 These functions return data about a task. They all require
258 a task handle as input, such as the value return by task_current() or the variables
259 prev_task and next_task in the scheduler.ctxswitch probe alias.
263 Return the task_struct of the current process.
266 task_parent:long(task:long)
267 Return the parent task_struct of the given task.
269 task_state:long(task:long)
270 Return the state of the given task, which can be one of the following:
274 TASK_UNINTERRUPTIBLE 2
281 task_execname:string(task:long)
282 Return the name of the given task.
285 task_pid:long(task:long)
286 Return the process id of the given task.
289 task_tid:long(task:long)
290 Return the thread id of the given task.
293 task_gid:long(task:long)
294 Return the group id of the given task.
297 task_egid:long(task:long)
298 Return the effective group id of the given task.
301 task_uid:long(task:long)
302 Return the user id of the given task.
305 task_euid:long(task:long)
306 Return the effective user id of the given task.
309 task_prio:long(task:long)
310 Return the priority of the given task.
313 task_nice:long(task:long)
314 Return the nice value of the given task.
317 task_cpu:long(task:long)
318 Return the scheduled cpu for the given task.
321 task_open_file_handles:long(task:long)
322 Return the number of open file handles for the given task.
325 task_max_file_handles:long(task:long)
326 Return the maximum number of file handles for the given task.
329 pid2task:long(pid:long)
330 Return the task of the given process id.
333 pid2execname:string(pid:long)
334 Return the name of the given process id.
338 registers_valid:long ()
339 Return 1 if register() and u_register() can be used
340 in the current context, or 0 otherwise.
341 For example, registers_valid() returns 0 when called from a begin or end probe.
343 register:long (name:string)
344 Return the value of the named CPU register,
345 as it was saved when the current probe point was hit.
346 If the register is 32 bits, it is sign-extended to 64 bits.
348 For the i386 architecture, the following names are recognized.
349 (name1/name2 indicates that name1 and name2 are alternative names
350 for the same register.)
351 eax/ax, ebp/bp, ebx/bx, ecx/cx, edi/di, edx/dx, eflags/flags,
352 eip/ip, esi/si, esp/sp, orig_eax/orig_ax,
353 xcs/cs, xds/ds, xes/es, xfs/fs, xss/ss.
355 For the x86_64 architecture, the following names are recognized:
357 r8, r9, r10, r11, r12, r13, r14, r15,
358 rax/ax, rbp/bp, rbx/bx, rcx/cx, rdi/di, rdx/dx,
359 rip/ip, rsi/si, rsp/sp;
361 eax, ebp, ebx, ecx, edx, edi, edx, eip, esi, esp, flags/eflags, orig_eax;
362 segment registers: xcs/cs, xss/ss.
364 For powerpc, the following names are recognized:
365 r0, r1, ... r31, nip, msr, orig_gpr3, ctr, link, xer, ccr, softe, trap,
368 For s390x, the following names are recognized:
369 r0, r1, ... r15, args, psw.mask, psw.addr, orig_gpr2, ilc, trap.
372 u_register:long (name:string)
373 Same as register(name), except that
374 if the register is 32 bits, it is zero-extended to 64 bits.
376 .SS NUMBERED FUNCTION ARGUMENTS
377 The functions in this section provide the values of a probed function's
379 They can be called when you have hit
380 a probe point at the entry to a function.
381 Arguments are referred to by number, starting at 1.
382 Ordinarily, you can access arguments by name as well,
383 but you may find these functions useful if the code you are probing
384 was built without debugging information.
386 On 32-bit architectures
387 \(em and when probing 32-bit applications on 64-bit architectures \(em
388 a 64-bit argument occupies two "arg slots."
389 For example, if you are probing the following function
391 void f(int a, long long b, char *c)
393 you would refer to a, b, and c as int_arg(1), longlong_arg(2), and
394 pointer_arg(3), respectively, on a 64-bit architecture;
395 but on a 32-bit architecture, you would refer to c as pointer_arg(4)
396 (since b occupies slots 2 and 3).
398 If the function you are probing doesn't follow the default rules
399 for argument passing, you need to call one of the following functions
400 (which see) in your handler before calling any *_arg function:
401 asmlinkage(), fastcall(), or regparm().
402 (This isn't necessary when referring to arguments only by name.)
404 int_arg:long (n:long)
405 Return the value of argument n as a signed int
406 (i.e., a 32-bit integer sign-extended to 64 bits).
408 uint_arg:long (n:long)
409 Return the value of argument n as an unsigned int
410 (i.e., a 32-bit integer zero-extended to 64 bits).
412 long_arg:long (n:long)
413 Return the value of argument n as a signed long.
414 On architectures where a long is 32 bits, the value is sign-extended to 64 bits.
416 ulong_arg:long (n:long)
417 Return the value of argument n as an unsigned long.
418 On architectures where a long is 32 bits, the value is zero-extended to 64 bits.
420 longlong_arg:long (n:long)
421 Return the value of argument n as a 64-bit value.
423 ulonglong_arg:long (n:long)
424 Same as longlong_arg(n).
426 pointer_arg:long (n:long)
427 Same as ulong_arg(n).
428 Use with any type of pointer.
430 s32_arg:long (n:long)
433 u32_arg:long (n:long)
436 s64_arg:long (n:long)
437 Same as longlong_arg(n).
439 u64_arg:long (n:long)
440 Same as [u]longlong_arg(n).
442 asmlinkage:unknown ()
443 The probed kernel function is declared asmlinkage in the source.
446 The probed kernel function is declared fastcall in the source.
448 regparm:unknown (n:long)
449 The probed function was built with the gcc \-mregparm=n option.
450 (The i386 kernel is built with \-mregparm=3, so systemtap considers
451 regparm(3) the default for kernel functions on that architecture.)
453 For some architectures, the *_arg functions may reject unusually high
458 The queue_stats tapset provides functions that, given notifications of
459 elementary queuing events (wait, run, done), tracks averages such as
460 queue length, service and wait times, utilization. The following
461 three functions should be called from appropriate probes, in sequence.
463 qs_wait:unknown (qname:string)
464 Record that a new request was enqueued for the given queue name.
466 qs_run:unknown (qname:string)
467 Record that a previously enqueued request was removed from the given
468 wait queue and is now being serviced.
470 qs_done:unknown (qname:string)
471 Record that a request originally from the given queue has completed
475 Functions with the prefix
477 are for querying the statistics averaged since the first queue operation
480 was called). Since statistics are often fractional, a scale parameter
481 is multiplies the result to a more useful scale. For some fractions,
482 a scale of 100 will usefully return percentage numbers.
484 qsq_start:unknown (qname:string)
485 Reset the statistics counters for the given queue, and start tracking
486 anew from this moment.
488 qsq_print:unknown (qname:string)
489 Print a line containing a selection of the given queue's statistics.
491 qsq_utilization:long (qname:string, scale:long)
492 Return the fraction of elapsed time when the resource was utilized.
494 qsq_blocked:long (qname:string, scale:long)
495 Return the fraction of elapsed time when the wait queue was used.
497 qsq_wait_queue_length:long (qname:string, scale:long)
498 Return the average length of the wait queue.
500 qsq_service_time:long (qname:string, scale:long)
501 Return the average time required to service a request.
503 qsq_wait_time:long (qname:string, scale:long)
504 Return the average time a request took from being enqueued to completed.
506 qsq_throughput:long (qname:string, scale:long)
507 Return the average rate of requests per scale units of time.
511 The indent tapset provides functions to generate indented lines for
512 nested kinds of trace messages. Each line contains a relative
513 timestamp, and the process name / pid.
515 thread_indent:string (delta:long)
516 Return a string with an appropriate indentation for this thread.
517 Call it with a small positive or matching negative delta.
518 If this is the outermost, initial level of indentation, reset the
519 relative timestamp base to zero.
521 thread_timestamp:long ()
522 Return an absolute timestamp value for use by the indentation function.
523 The default function uses
529 Runs a command on the system. The command will run in the background
530 when the current probe completes.
534 addr_to_node:long (addr:long)
535 Return which node the given address belongs to in a NUMA system.
539 ctime:string (seconds:long)
540 Return a simple textual rendering (e.g., "Wed\ Jun\ 30\ 21:49:008\ 1993")
541 of the given number of seconds since the epoch, as perhaps returned by
542 .IR gettimeofday_s() .
546 read_counter:long (handle:long)
547 Returns the value for the processor's performance counter for the associated
548 handle. The body of the a perfmon probe should set record
549 the handle being used for that event.
552 These functions convert arguments in the socket tapset back and
553 forth between their numeric and string representations.
555 .IR stapprobes.socket (3stap)
559 sock_prot_num2str:string (proto:long)
560 Returns the string representation of the given protocol value.
562 sock_prot_str2num:long (proto:string)
563 Returns the numeric value associated with the given protocol string.
565 sock_fam_num2str:string (family:long)
566 Returns the string representation of the given protocol family value.
568 sock_fam_str2num:long (family:string)
569 Returns the numeric value associated with the given protocol family string.
571 sock_state_num2str:string (state:long)
572 Returns the string representation of the given socket state value.
574 sock_state_str2num:long (state:string)
575 Returns the numeric value associated with the given socket state string.
577 sock_type_num2str:string (type:long)
578 Returns the string representation of the given socket type value.
580 sock_type_str2num:long (type:string)
581 Returns the numeric value associated with the given socket type string.
583 sock_flags_num2str:string (flags:long)
584 Returns the string representation of the given socket flags value.
586 msg_flags_num2str:string (flags:long)
587 Returns the string representation of the given message flags bit map.
590 These functions convert between network (big-endian) and host byte order, like their
591 namesake C functions.
594 Convert from network to host byte order, 64-bit.
597 Convert from network to host byte order, 32-bit.
600 Convert from network to host byte order, 16-bit.
603 Convert from host to network byte order, 64-bit.
606 Convert from host to network byte order, 32-bit.
609 Convert from host to network byte order, 16-bit.
613 get_sa_flags:long (act:long)
614 Returns the numeric value of sa_flags.
616 get_sa_handler:long (act:long)
617 Returns the numeric value of sa_handler.
619 sigset_mask_str:string (mask:long)
620 Returns the string representation of the sigset sa_mask.
622 is_sig_blocked:long (task:long, sig:long)
623 Returns 1 if the signal is currently blocked, or 0 if it is not.
625 sa_flags_str:string (sa_flags:long)
626 Returns the string representation of sa_flags.
628 sa_handler_str(handler)
629 Returns the string representation of sa_handler. If it is not SIG_DFL, SIG_IGN
630 or SIG_ERR, it will return the address of the handler.
633 Returns the string representation of the given signal number.
638 Extracts the major device number from a kernel device number (kdev_t).
641 Extracts the minor device number from a kernel device number (kdev_t).
643 MKDEV:long(major:long, minor:long)
644 Creates a value that can be compared to a kernel device number (kdev_t).
646 usrdev2kerndev:long(dev:long)
647 Converts a user-space device number into the format used in the kernel.
651 .IR @prefix@/share/systemtap/tapset