Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

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

NAME
tapset::stap_staticmarkers - systemtap stap_staticmarkers tapset DESCRIPTION
stap.pass0 Starting stap pass0 (parsing command line arguments) See probe::stap.pass0(3stap) for details. stap.pass0.end Finished stap pass0 (parsing command line arguments) See probe::stap.pass0.end(3stap) for details. stap.pass1a Starting stap pass1 (parsing user script) See probe::stap.pass1a(3stap) for details. stap.pass1b Starting stap pass1 (parsing library scripts) See probe::stap.pass1b(3stap) for details. stap.pass1.end Finished stap pass1 (parsing scripts) See probe::stap.pass1.end(3stap) for details. stap.pass2 Starting stap pass2 (elaboration) See probe::stap.pass2(3stap) for details. stap.pass2.end Finished stap pass2 (elaboration) See probe::stap.pass2.end(3stap) for details. stap.pass3 Starting stap pass3 (translation to C) See probe::stap.pass3(3stap) for details. stap.pass3.end Finished stap pass3 (translation to C) See probe::stap.pass3.end(3stap) for details. stap.pass4 Starting stap pass4 (compile C code into kernel module) See probe::stap.pass4(3stap) for details. stap.pass4.end Finished stap pass4 (compile C code into kernel module) See probe::stap.pass4.end(3stap) for details. stap.pass5 Starting stap pass5 (running the instrumentation) See probe::stap.pass5(3stap) for details. stap.pass5.end Finished stap pass5 (running the instrumentation) See probe::stap.pass5.end(3stap) for details. stap.pass6 Starting stap pass6 (cleanup) See probe::stap.pass6(3stap) for details. stap.pass6.end Finished stap pass6 (cleanup) See probe::stap.pass6.end(3stap) for details. stap.cache_clean Removing file from stap cache See probe::stap.cache_clean(3stap) for details. stap.cache_add_mod Adding kernel instrumentation module to cache See probe::stap.cache_add_mod(3stap) for details. stap.cache_add_src Adding C code translation to cache See probe::stap.cache_add_src(3stap) for details. stap.cache_add_nss Add NSS (Network Security Services) information to cache See probe::stap.cache_add_nss(3stap) for details. stap.cache_get Found item in stap cache See probe::stap.cache_get(3stap) for details. stap.system Starting a command from stap See probe::stap.system(3stap) for details. stap.system.spawn stap spawned new process See probe::stap.system.spawn(3stap) for details. stap.system.return Finished a command from stap See probe::stap.system.return(3stap) for details. staprun.insert_module Inserting SystemTap instrumentation module See probe::staprun.insert_module(3stap) for details. staprun.remove_module Removing SystemTap instrumentation module See probe::staprun.remove_module(3stap) for details. staprun.send_control_message Sending a control message See probe::staprun.send_control_message(3stap) for details. stapio.receive_control_message Received a control message See probe::stapio.receive_control_message(3stap) for details. SEE ALSO
probe::stap.pass0(3stap), probe::stap.pass0.end(3stap), probe::stap.pass1a(3stap), probe::stap.pass1b(3stap), probe::stap.pass1.end(3stap), probe::stap.pass2(3stap), probe::stap.pass2.end(3stap), probe::stap.pass3(3stap), probe::stap.pass3.end(3stap), probe::stap.pass4(3stap), probe::stap.pass4.end(3stap), probe::stap.pass5(3stap), probe::stap.pass5.end(3stap), probe::stap.pass6(3stap), probe::stap.pass6.end(3stap), probe::stap.cache_clean(3stap), probe::stap.cache_add_mod(3stap), probe::stap.cache_add_src(3stap), probe::stap.cache_add_nss(3stap), probe::stap.cache_get(3stap), probe::stap.system(3stap), probe::stap.system.spawn(3stap), probe::stap.system.return(3stap), probe::staprun.insert_module(3stap), probe::staprun.remove_module(3stap), probe::staprun.send_control_message(3stap), probe::stapio.receive_control_message(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::stap_staticmarkers(3stap)
Man Page