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

STAP-MERGE(1)						      General Commands Manual						     STAP-MERGE(1)

NAME
stap-merge - systemtap per-cpu binary merger SYNOPSIS
stap-merge [ OPTIONS ] [ INPUT FILENAMES ] DESCRIPTION
The stap-merge executable applies when the -b option has been used while running a stap script. The -b option will generate files per-cpu, based on the timestamp field. Then stap-merge will merge and sort through the per-cpu files based on the timestamp field. OPTIONS
The systemtap merge executable supports the following options. -v Verbose mode, displays three extra fields per set of collected data. [cpunumber,sequencenumberofdata,thelengthofthedataset] -o OUTPUT_FILENAME Specify the name of the file you would like the output to be redirected into. If this option is not specified than the output will be pushed to standard out. EXAMPLES
$ stap -v -b -e 'probe syscall.open { printf("%s(%d) open ", execname(), pid()) }' This should result in several stpd_cpu files (each labled with a number representing which cpu the file was produced from). $ stap-merge -v stpd_cpu0 stpd_cpu1 Running the stap-merge program in the same directory as the stap script earlier in the example, will produce an ordered sequence of packets with the three part label for each set of data. This result will be pushed through the standard output. An output file could have been specified using the "-o" option. FILES
Important files and their corresponding paths can be located in the stappaths(7) manual page. SEE ALSO
stapprobes(3stap), stapfuncs(3stap), stappaths(7), staprun(8), stapvars(3stap), stapex(3stap), stap-server(8), gdb(1) BUGS
Use the Bugzilla link of the project web page or our mailing list. http://sourceware.org/systemtap/,<systemtap@sourceware.org>. STAP-MERGE(1)
Man Page