Debian Codegraph @

tapset/bpf/exit.stp

raw
1 /**
2 * function _set_exit_status
3 *
4 * Description: Set exit flag.
5 */
6 function _set_exit_status:long ()
7 %{ /* bpf */ /* unprivileged */
8 0x118, 1, 0, 0, 0; /* BPF_LD_MAP_FD(r1, map0) */
9 0x7a, 10, 0, -8, 1; /* *(u64 *)(r10 - 8) = 1 (map value) */
10 0xbf, 3, 10, 0, 0; /* r3 = r10 */
11 0x07, 3, 0, 0, -8; /* r3 += -8 */
12 0x62, 10, 0, -12, 0; /* *(u32 *)(r10 - 12) = 0 (map key) */
13 0xbf, 2, 10, 0, 0; /* r2 = r10 */
14 0x07, 2, 0, 0, -12; /* r2 += -12 */
15 0xb7, 4, 0, 0, 0; /* r4 = 0 (flags) */
16 0x85, 0, 0, 0, 2; /* call bpf_map_update_elem */
17 0xbf, $$, 0, 0, 0 /* return r0 */
18 %}
19
20 /**
21 * function _send_exit_msg
22 *
23 * Description: Send an exit request through perf_events transport.
24 */
25 function _send_exit_msg:long ()
26 %{ /* bpf */ /* unprivileged */
27 0x118, $perf_events_map, -, -, 1; /* BPF_LD_MAP_FD($perf_events_map, map1) */
28 alloc, $data, 8, align;
29 0x7a, $data, -, -, 0x0; /* stdw [$data+0], STP_EXIT */
30 call, $rc, perf_event_output, $ctx, $perf_events_map, BPF_F_CURRENT_CPU, $data, 8;
31 %}
32
33 /**
34 * function _send_error_msg
35 *
36 * Description: Communicate a hard error through perf_events transport.
37 */
38 function _send_error_msg:long ()
39 %{ /* bpf */ /* unprivileged */
40 0x118, $perf_events_map, -, -, 1; /* BPF_LD_MAP_FD($perf_events_map, map1) */
41 alloc, $data, 8, align;
42 0x7a, $data, 0, 0, 1; /* stdw [$data+0], STP_ERROR */
43 call, $rc, perf_event_output, $ctx, $perf_events_map, BPF_F_CURRENT_CPU, $data, 8;
44 %}
45
46 /**
47 * function _jump_to_catch
48 *
49 * Description: Wrapper for the jump_to_catch statement. Checks if there is a catch
50 * block that can be jumped to, and jumps if there is a valid block. It also passes
51 * the error message during compile time for the creation of the catch block.
52 */
53 function _jump_to_catch(msg:string)
54 %{ /* bpf */ /* unprivileged */
55 jump_to_catch, $msg;
56 %}
57
58 /**
59 * function _register_error
60 *
61 * Description: Wrapper for the register_error statement. This function only runs after
62 * the program encounters an error outside try blocks. During runtime, it will increment
63 * the total error count and check that against the limit provided with -D. It will also
64 * pass the error message to the userspace during runtime for printing in the epilogue.
65 */
66 function _register_error(msg:string)
67 %{ /* bpf */ /* unprivileged */
68 register_error, $msg;
69 %}
70
71 /**
72 * function _terminate
73 *
74 * Description: Wrapper for the terminate statement. Short-circuit's the program to exit.
75 */
76 function _terminate()
77 %{ /* bpf */ /* unpriviledged */
78 terminate;
79 %}