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