Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/stmt_counting_loops.stp

raw
1 # stap stmt_counting_loops.stp 6
2 # substituting 5 for some really large number
3 # can trigger a MAXACTION error
4
5 global num
6 probe begin {
7 printf("systemtap starting probe\n");
8 for (i=1; i<10 && i<=$1; i++){
9 func1(i);
10 }
11
12 for (i=1; i<10 && i<=$1; i++){
13 func2(i);
14 }
15 printf("systemtap ending probe\n");
16 if (num == 0)
17 printf("pass\n");
18 else
19 printf("fail\n");
20 exit();
21 }
22
23 function func1 (a) {
24 for (j=0; j<=$1; j+=a)
25 num++;
26 }
27
28 function func2 (b) {
29 for (k=$1; k>=0; k=k-b)
30 num --;
31 }
32
33