doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/stable_function_branch.stp
raw| 1 | // stable_function_branch.stp - multiple branches |
| 2 | |
| 3 | %{int f1hits = 0; %} |
| 4 | %{int f2hits = 0; %} |
| 5 | %{int f3hits = 0; %} |
| 6 | |
| 7 | function fn1:long() %{ |
| 8 | /* pure */ /* stable */ |
| 9 | f1hits++; |
| 10 | STAP_RETURN(100); |
| 11 | %} |
| 12 | |
| 13 | function fn2:long() %{ |
| 14 | /* pure */ /* stable */ |
| 15 | f2hits++; |
| 16 | STAP_RETURN(101); |
| 17 | %} |
| 18 | |
| 19 | function fn3:long() %{ |
| 20 | /* pure */ /* stable */ |
| 21 | f3hits++; |
| 22 | STAP_RETURN(102); |
| 23 | %} |
| 24 | |
| 25 | probe begin { |
| 26 | x = 5 |
| 27 | y = 5 |
| 28 | |
| 29 | if (x=fn1()) { |
| 30 | y = fn2() |
| 31 | |
| 32 | if (x>y) { |
| 33 | x = fn3() |
| 34 | } else { |
| 35 | x = fn3() |
| 36 | } |
| 37 | |
| 38 | for (g = 100; g < 110; g++) { |
| 39 | z = fn1() |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | println(x, " ", y, " ", z, " ", fn2(), " ", %{f1hits%}, " ", %{f2hits%}, " ", %{f3hits%}) |
| 44 | |
| 45 | exit() |
| 46 | } |