| 1 |
function foo:long (x:long) %{ /* bpf */ /* pure */ |
| 2 |
/* if x <= 10 then 50 else 100 */ |
| 3 |
0xd5, $x, -, _bar, 10; /* jsle $x, 10, _bar */ |
| 4 |
0xb7, $$, -, -, 100; /* mov $$, 100 */ |
| 5 |
0x05, -, -, _done, -; /* ja _done; */ |
| 6 |
label, _bar; |
| 7 |
0xb7, $$, -, -, 50; /* mov $$, 50 */ |
| 8 |
label, _done; |
| 9 |
%} |
| 10 |
|
| 11 |
function bar:long (x:long) { |
| 12 |
if (x <= 10) return 50 else return 100 |
| 13 |
} |
| 14 |
|
| 15 |
probe begin { |
| 16 |
printf("U foo(1)=%d should be %d\n", foo(1), bar(1)) |
| 17 |
printf("U foo(8)=%d should be %d\n", foo(8), bar(8)) |
| 18 |
printf("U foo(15)=%d should be %d\n", foo(15), bar(15)) |
| 19 |
} |
| 20 |
|
| 21 |
probe kernel.function("vfs_read") { |
| 22 |
printf("K foo(1)=%d should be %d\n", foo(1), bar(1)) |
| 23 |
printf("K foo(8)=%d should be %d\n", foo(8), bar(8)) |
| 24 |
printf("K foo(15)=%d should be %d\n", foo(15), bar(15)) |
| 25 |
exit() |
| 26 |
} |