Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.bpf/asm_tests/leniency.stp

raw
1 function foo:long (x:long) %{ /* bpf */ /* pure */
2 /* if x < 10 then 17 else 16 */
3 0xa5, $x, -, _bar, 10; /* jlt $x, 10, _bar */
4 0xb7, $this is an "!!ide\nt!!" believe it or not, -, -, 16; /* mov $t, 0 */
5 0xbf, $$, $thisisan"!!ide\nt!!"believeitornot, -, -; /* mov $$, $t */
6 0x05, -, -, _done, -; /* ja _done; */
7 label, _bar;
8 0xb7, $$, -, -, 17; /* mov $$, 1 */
9 label, _done;
10 %}
11
12 function bar:long (x:long) {
13 if (x < 10) return 17 else return 16
14 }
15
16 probe begin {
17 printf("U foo(1)=%d should be %d\n", foo(1), bar(1))
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(15)=%d should be %d\n", foo(15), bar(15))
24 exit()
25 }