doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/stable_function_loop.stp
raw| 1 | // stable_function_loop.stp |
| 2 | |
| 3 | %{int hits = 0; %} |
| 4 | |
| 5 | function test:long() %{ |
| 6 | /* pure */ /* stable */ |
| 7 | hits++; |
| 8 | STAP_RETURN(100); |
| 9 | %} |
| 10 | |
| 11 | probe begin { |
| 12 | sum = 0 |
| 13 | |
| 14 | if (sum == 0) { |
| 15 | for (i = 0; i < 10; i++) { |
| 16 | if (i > 0) { |
| 17 | for (j = 0; j < 10; j++) { |
| 18 | sum += test() |
| 19 | sum += test() |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | println(sum, " ", %{hits%}) |
| 26 | |
| 27 | exit() |
| 28 | } |