summaryrefslogtreecommitdiffstats
path: root/man/stapex.3stap.html
diff options
Diffstat (limited to 'man/stapex.3stap.html')
-rw-r--r--man/stapex.3stap.html246
1 files changed, 246 insertions, 0 deletions
diff --git a/man/stapex.3stap.html b/man/stapex.3stap.html
new file mode 100644
index 00000000..492b878b
--- /dev/null
+++ b/man/stapex.3stap.html
@@ -0,0 +1,246 @@
1
2<HTML><HEAD><TITLE>Manpage of STAPEX</TITLE>
3</HEAD><BODY>
4<H1>STAPEX</H1>
5Section: Misc. Reference Manual Pages (3stap)<BR><A HREF="#index">Index</A>
6<A HREF="index.html">Return to Main Contents</A><HR>
7
8<A NAME="lbAB">&nbsp;</A>
9<H2>NAME</H2>
10
11stapex - systemtap examples
12<P>
13
14
15
16<P>
17<A NAME="lbAC">&nbsp;</A>
18<H2>LANGUAGE BASICS</H2>
19
20These examples give a feel for basic systemtap syntax and
21control structures.
22<P>
23
24<P>
25
26<BR>
27
28<DL COMPACT><DT><DD>
29<PRE>
30global odds, evens
31
32probe begin {
33 # &quot;no&quot; and &quot;ne&quot; are local integers
34 for (i=0; i&lt;10; i++) {
35 if (i % 2) odds [no++] = i
36 else evens [ne++] = i
37 }
38 delete odds[2]
39 delete evens[3]
40 exit ()
41}
42
43probe end {
44 foreach (x+ in odds) {
45 printf (&quot;odds[%d] = %d, x, odds[x])
46 }
47 foreach (x in evens-) {
48 printf (&quot;evens[%d] = %d, x, evens[x])
49 }
50}
51
52</PRE>
53
54</DL>
55
56
57<P>
58
59This prints:
60
61<P>
62
63<BR>
64
65<DL COMPACT><DT><DD>
66<PRE>
67odds[1] = 1
68odds[3] = 5
69odds[4] = 7
70odds[5] = 9
71evens[5] = 8
72evens[4] = 6
73evens[2] = 2
74evens[1] = 0
75
76</PRE>
77
78</DL>
79
80
81<P>
82
83Note that all variables types are inferred, and that all locals
84and globals are automatically initialized.
85<P>
86<P>
87
88This script prints the primes between 0 and 49.
89
90<P>
91
92<BR>
93
94<DL COMPACT><DT><DD>
95<PRE>
96function isprime (x) {
97 if (x &lt; 2) return 0
98 for (i=2; i&lt;x; i++) {
99 if (x % i == 0) return 0
100 if (i * i &gt; x) break
101 }
102 return 1
103}
104probe begin {
105 for (i=0; i&lt;50; i++)
106 if (isprime (i)) printf(&quot;%d, i)
107 exit()
108}
109
110</PRE>
111
112</DL>
113
114
115<P>
116
117<P>
118<P>
119
120This script demonstrates recursive functions.
121
122<P>
123
124<BR>
125
126<DL COMPACT><DT><DD>
127<PRE>
128function fibonacci(i) {
129 if (i &lt; 1) error (&quot;bad number&quot;)
130 if (i == 1) return 1
131 if (i == 2) return 2
132 return fibonacci (i-1) + fibonacci (i-2)
133}
134probe begin {
135 printf (&quot;11th fibonacci number: %d, fibonacci (11))
136 exit ()
137}
138
139</PRE>
140
141</DL>
142
143
144<P>
145
146Any larger number may exceed the MAXACTION or MAXNESTING
147limits, and result in an error.
148<P>
149<P>
150<A NAME="lbAD">&nbsp;</A>
151<H2>PROBING</H2>
152
153<P>
154To trace entry and exit from a function, use a pair of probes:
155
156<P>
157
158<BR>
159
160<DL COMPACT><DT><DD>
161<PRE>
162probe kernel.function(&quot;sys_mkdir&quot;) { println (&quot;enter&quot;) }
163probe kernel.function(&quot;sys_mkdir&quot;).return { println (&quot;exit&quot;) }
164
165</PRE>
166
167</DL>
168
169
170<P>
171
172<P>
173To list the probeable functions in the kernel, use the listings mode.
174
175<P>
176
177<BR>
178
179<DL COMPACT><DT><DD>
180<PRE>
181% stap -l 'kernel.function(&quot;*&quot;)'
182
183</PRE>
184
185</DL>
186
187
188<P>
189
190<P>
191To list the probeable functions and local variables in the kernel, use another listings mode.
192
193<P>
194
195<BR>
196
197<DL COMPACT><DT><DD>
198<PRE>
199% stap -L 'kernel.function(&quot;*&quot;)'
200
201</PRE>
202
203</DL>
204
205
206<P>
207
208<P>
209<A NAME="lbAE">&nbsp;</A>
210<H2>MORE EXAMPLES</H2>
211
212<P>
213The directory to find more examples can be found in the stappaths (7) manual page,
214and online at
215
216<B><A HREF="http://sourceware.org/systemtap/examples/">http://sourceware.org/systemtap/examples/</A></B>
217
218
219<P>
220<A NAME="lbAF">&nbsp;</A>
221<H2>SEE ALSO</H2>
222
223
224<PRE>
225<I><A HREF="stap.1.html">stap</A></I>(1)
226<I><A HREF="stapprobes.3stap.html">stapprobes</A></I>(3stap)
227<I><A HREF="stappaths.7.html">stappaths</A></I>(7)
228
229
230</PRE>
231<HR>
232<A NAME="index">&nbsp;</A><H2>Index</H2>
233<DL>
234<DT><A HREF="#lbAB">NAME</A><DD>
235<DT><A HREF="#lbAC">LANGUAGE BASICS</A><DD>
236<DT><A HREF="#lbAD">PROBING</A><DD>
237<DT><A HREF="#lbAE">MORE EXAMPLES</A><DD>
238<DT><A HREF="#lbAF">SEE ALSO</A><DD>
239</DL>
240<HR>
241This document was created by
242<A HREFhttp://www.kapiti.co.nz/michael/vhman2html.html">man2html</A>,
243using the manual pages.<BR>
244Time: 17:59:59 GMT, May 16, 2014
245</BODY>
246</HTML>