Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stapex(3stap) [hpux 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::memory(3stap)													     tapset::memory(3stap)

NAME
tapset::memory - systemtap memory tapset DESCRIPTION
This family of probe points is used to probe memory-related events. vm_fault_contains Test return value for page fault reason See function::vm_fault_contains(3stap) for details. vm.pagefault Records that a page fault occurred See probe::vm.pagefault(3stap) for details. vm.pagefault.return Indicates what type of fault occurred See probe::vm.pagefault.return(3stap) for details. addr_to_node Returns which node a given address belongs to within a NUMA system See function::addr_to_node(3stap) for details. vm.write_shared Attempts at writing to a shared page See probe::vm.write_shared(3stap) for details. vm.write_shared_copy Page copy for shared page write See probe::vm.write_shared_copy(3stap) for details. vm.mmap Fires when an mmap is requested See probe::vm.mmap(3stap) for details. vm.munmap Fires when an munmap is requested See probe::vm.munmap(3stap) for details. vm.brk Fires when a brk is requested (i.e. the heap will be resized) See probe::vm.brk(3stap) for details. vm.oom_kill Fires when a thread is selected for termination by the OOM killer See probe::vm.oom_kill(3stap) for details. vm.kmalloc Fires when kmalloc is requested See probe::vm.kmalloc(3stap) for details. vm.kmem_cache_alloc Fires when kmem_cache_alloc is requested See probe::vm.kmem_cache_alloc(3stap) for details. vm.kmalloc_node Fires when kmalloc_node is requested See probe::vm.kmalloc_node(3stap) for details. vm.kmem_cache_alloc_node Fires when kmem_cache_alloc_node is requested See probe::vm.kmem_cache_alloc_node(3stap) for details. vm.kfree Fires when kfree is requested See probe::vm.kfree(3stap) for details. vm.kmem_cache_free Fires when kmem_cache_free is requested See probe::vm.kmem_cache_free(3stap) for details. SEE ALSO
function::vm_fault_contains(3stap), function::addr_to_node(3stap), probe::vm.pagefault(3stap), probe::vm.pagefault.return(3stap), probe::vm.write_shared(3stap), probe::vm.write_shared_copy(3stap), probe::vm.mmap(3stap), probe::vm.munmap(3stap), probe::vm.brk(3stap), probe::vm.oom_kill(3stap), probe::vm.kmalloc(3stap), probe::vm.kmem_cache_alloc(3stap), probe::vm.kmalloc_node(3stap), probe::vm.kmem_cache_alloc_node(3stap), probe::vm.kfree(3stap), probe::vm.kmem_cache_free(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::memory(3stap)
Man Page