Debian Codegraph @

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

raw
1 function foo:long (x:long) %{ /* bpf */ /* pure */
2 /* compute (100-x)*(x+2) */
3 0xb7, $$, -, -, 100; /* mov $$, 100 */
4 0x1f, $$, $x, -, -; /* sub $$, $x */
5 0xbf, $tmp, $x, -, -; /* mov $tmp, $x */
6 0x07, $tmp, -, -, 2; /* add $tmp, 2 */
7 0x2f, $$, $tmp, -, -; /* mul $$, $tmp */
8 %}
9
10 probe begin {
11 printf("U foo(1)=%d, should be 99*3=297\n", foo(1))
12 printf("U foo(15)=%d, should be 85*17=1445\n", foo(15))
13 }
14
15 probe kernel.function("vfs_read") {
16 printf("K foo(1)=%d, should be 99*3=297\n", foo(1))
17 printf("K foo(15)=%d, should be 85*17=1445\n", foo(15))
18 exit()
19 }