| 1 | // SPDX-License-Identifier: MIT |
| 2 | /* |
| 3 | * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | */ |
| 5 | |
| 6 | #ifndef SIDE_ABI_VISITOR_H |
| 7 | #define SIDE_ABI_VISITOR_H |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | #include <side/macros.h> |
| 11 | #include <side/endian.h> |
| 12 | |
| 13 | /* |
| 14 | * SIDE ABI for visitor pattern. |
| 15 | * |
| 16 | * The visitor pattern is a double-dispatch visitor. Changing this ABI |
| 17 | * is a breaking ABI change. |
| 18 | * |
| 19 | * This ABI is a contract between the instrumented application and |
| 20 | * user-space tracers. Kernel tracers are not expected to interact with |
| 21 | * visitors directly: a proxy in libside should execute visitors to |
| 22 | * convert their output to other types which can be read by the kernel |
| 23 | * tracers. |
| 24 | */ |
| 25 | |
| 26 | struct side_arg; |
| 27 | struct side_arg_dynamic_field; |
| 28 | struct side_tracer_visitor_ctx; |
| 29 | struct side_tracer_dynamic_struct_visitor_ctx; |
| 30 | |
| 31 | typedef enum side_visitor_status (*side_write_elem_func)( |
| 32 | const struct side_tracer_visitor_ctx *tracer_ctx, |
| 33 | const struct side_arg *elem); |
| 34 | typedef enum side_visitor_status (*side_visitor_func)( |
| 35 | const struct side_tracer_visitor_ctx *tracer_ctx, |
| 36 | void *app_ctx); |
| 37 | |
| 38 | struct side_tracer_visitor_ctx { |
| 39 | side_write_elem_func write_elem; |
| 40 | void *priv; /* Private tracer context. */ |
| 41 | }; |
| 42 | |
| 43 | typedef enum side_visitor_status (*side_write_field_func)( |
| 44 | const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, |
| 45 | const struct side_arg_dynamic_field *dynamic_field); |
| 46 | typedef enum side_visitor_status (*side_dynamic_struct_visitor_func)( |
| 47 | const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, |
| 48 | void *app_ctx); |
| 49 | |
| 50 | struct side_tracer_dynamic_struct_visitor_ctx { |
| 51 | side_write_field_func write_field; |
| 52 | void *priv; /* Private tracer context. */ |
| 53 | }; |
| 54 | |
| 55 | #endif /* SIDE_ABI_VISITOR_H */ |