Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stapex(3stap) [suse man page]

STAPEX(3stap)                                                                                                                        STAPEX(3stap)

NAME
stapex - systemtap examples LANGUAGE BASICS
These examples give a feel for basic systemtap syntax and control structures. global odds, evens probe begin { # "no" and "ne" are local integers for (i=0; i<10; i++) { if (i % 2) odds [no++] = i else evens [ne++] = i } delete odds[2] delete evens[3] exit () } probe end { foreach (x+ in odds) { printf ("odds[%d] = %d0, x, odds[x]) } foreach (x in evens-) { printf ("evens[%d] = %d0, x, evens[x]) } } This prints: odds[1] = 1 odds[3] = 5 odds[4] = 7 odds[5] = 9 evens[5] = 8 evens[4] = 6 evens[2] = 2 evens[1] = 0 Note that all variables types are inferred, and that all locals and globals are automatically initialized. This script prints the primes between 0 and 49. function isprime (x) { if (x < 2) return 0 for (i=2; i<x; i++) { if (x % i == 0) return 0 if (i * i > x) break } return 1 } probe begin { for (i=0; i<50; i++) if (isprime (i)) printf("%d0, i) exit() } This script demonstrates recursive functions. function fibonacci(i) { if (i < 1) error ("bad number") if (i == 1) return 1 if (i == 2) return 2 return fibonacci (i-1) + fibonacci (i-2) } probe begin { printf ("11th fibonacci number: %d0, fibonacci(11)) exit () } Any larger number may exceed the MAXACTION or MAXNESTING limits, and result in an error. PROBING
To trace entry and exit from a function, use a pair of probes: probe kernel.function("sys_mkdir") { println ("enter") } probe kernel.function("sys_mkdir").return { println ("exit") } To list the probeable functions in the kernel, use the listings mode. % stap -l 'kernel.function("*")' To list the probeable functions and local variables in the kernel, use another listings mode. % stap -L 'kernel.function("*")' MORE EXAMPLES
The directory to find more examples can be found in the stappaths(7) manual page. SEE ALSO
stap(1) stapprobes(3stap) stapfuncs(3stap) stappaths(7) STAPEX(3stap)

Check Out this Related Man Page

TAPSET::PERF(3stap)													       TAPSET::PERF(3stap)

NAME
tapset::perf - systemtap perf probe points DESCRIPTION
This family of probe points is used to probe "perf events" on suitably configured kernels (2.6.33+). It contains a number of aliases for the ABI-specified event type/config tuples. The default sampling interval of the translator(1000000) is not overridden, so some of these probe points may fire very infrequently. Use the lower level perf.type(AA).config(BB).sample(CC) probe point if this is a problem. perf.hw.* A variety of hardware events, as generalized by the kernel. These generally require running on bare hardware with selected proces- sors. probe perf.hw.cpu_cycles probe perf.hw.instructions probe perf.hw.cache_references probe perf.hw.cache_misses probe perf.hw.branch_instructions probe perf.hw.branch_misses probe perf.hw.bus_cycles perf.sw.* Special "software" events provided by the kernel. These sometimes work in virtualized environments and with more processor archi- tectures. probe perf.sw.cpu_clock probe perf.sw.task_clock probe perf.sw.page_faults probe perf.sw.context_switches probe perf.sw.cpu_migrations probe perf.sw.page_faults_min probe perf.sw.page_faults_maj probe perf.sw.alignment_faults probe perf.sw.emulation_faults perf.hw_cache.TYPE.ACCESS.RESULT Hardware cache events, where available. A subset of the following cartesian product may be available: probe perf.hw_cache.l1d.*.* probe perf.hw_cache.l1i.*.* probe perf.hw_cache.ll.*.* probe perf.hw_cache.dtlb.*.* probe perf.hw_cache.itlb.*.* probe perf.hw_cache.bpu.*.* probe perf.hw_cache.*.read.* probe perf.hw_cache.*.write.* probe perf.hw_cache.*.prefetch.* probe perf.hw_cache.*.*.access probe perf.hw_cache.*.*.miss SEE ALSO
stap(1), stapprobes(3stap) IBM
TAPSET::PERF(3stap)
Man Page