/** * function _set_exit_status * * Description: Set exit flag. */ function _set_exit_status:long () %{ /* bpf */ /* unprivileged */ 0x118, 1, 0, 0, 0; /* BPF_LD_MAP_FD(r1, map0) */ 0x7a, 10, 0, -8, 1; /* *(u64 *)(r10 - 8) = 1 (map value) */ 0xbf, 3, 10, 0, 0; /* r3 = r10 */ 0x07, 3, 0, 0, -8; /* r3 += -8 */ 0x62, 10, 0, -12, 0; /* *(u32 *)(r10 - 12) = 0 (map key) */ 0xbf, 2, 10, 0, 0; /* r2 = r10 */ 0x07, 2, 0, 0, -12; /* r2 += -12 */ 0xb7, 4, 0, 0, 0; /* r4 = 0 (flags) */ 0x85, 0, 0, 0, 2; /* call bpf_map_update_elem */ 0xbf, $$, 0, 0, 0 /* return r0 */ %} /** * function _send_exit_msg * * Description: Send an exit request through perf_events transport. */ function _send_exit_msg:long () %{ /* bpf */ /* unprivileged */ 0x118, $perf_events_map, -, -, 1; /* BPF_LD_MAP_FD($perf_events_map, map1) */ alloc, $data, 8, align; 0x7a, $data, -, -, 0x0; /* stdw [$data+0], STP_EXIT */ call, $rc, perf_event_output, $ctx, $perf_events_map, BPF_F_CURRENT_CPU, $data, 8; %} /** * function _send_error_msg * * Description: Communicate a hard error through perf_events transport. */ function _send_error_msg:long () %{ /* bpf */ /* unprivileged */ 0x118, $perf_events_map, -, -, 1; /* BPF_LD_MAP_FD($perf_events_map, map1) */ alloc, $data, 8, align; 0x7a, $data, 0, 0, 1; /* stdw [$data+0], STP_ERROR */ call, $rc, perf_event_output, $ctx, $perf_events_map, BPF_F_CURRENT_CPU, $data, 8; %} /** * function _jump_to_catch * * Description: Wrapper for the jump_to_catch statement. Checks if there is a catch * block that can be jumped to, and jumps if there is a valid block. It also passes * the error message during compile time for the creation of the catch block. */ function _jump_to_catch(msg:string) %{ /* bpf */ /* unprivileged */ jump_to_catch, $msg; %} /** * function _register_error * * Description: Wrapper for the register_error statement. This function only runs after * the program encounters an error outside try blocks. During runtime, it will increment * the total error count and check that against the limit provided with -D. It will also * pass the error message to the userspace during runtime for printing in the epilogue. */ function _register_error(msg:string) %{ /* bpf */ /* unprivileged */ register_error, $msg; %} /** * function _terminate * * Description: Wrapper for the terminate statement. Short-circuit's the program to exit. */ function _terminate() %{ /* bpf */ /* unpriviledged */ terminate; %}