doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/stmt_counting_recursion.stp
raw| 1 | # stap stmt_counting_recursion.stp 5 |
| 2 | |
| 3 | global num |
| 4 | probe begin { |
| 5 | printf("systemtap starting probe\n"); |
| 6 | func1(1); |
| 7 | printf("systemtap ending probe\n"); |
| 8 | if (num == $1*2 -1) |
| 9 | printf("pass\n"); |
| 10 | else |
| 11 | printf("fail\n"); |
| 12 | exit(); |
| 13 | } |
| 14 | |
| 15 | function func1 (a) { |
| 16 | num++; |
| 17 | if (a < $1) |
| 18 | func2(a); |
| 19 | } |
| 20 | |
| 21 | function func2 (b) { |
| 22 | num++; |
| 23 | func1(b+1); |
| 24 | } |
| 25 |