| 1 | /* |
| 2 | * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_KERNEL_PROBE_INTERNAL_H |
| 9 | #define LTTNG_KERNEL_PROBE_INTERNAL_H |
| 10 | |
| 11 | #include <common/fd-handle.h> |
| 12 | #include <common/macros.h> |
| 13 | #include <lttng/kernel-probe.h> |
| 14 | #include <stdbool.h> |
| 15 | #include <stdint.h> |
| 16 | #include <sys/types.h> |
| 17 | |
| 18 | struct lttng_payload; |
| 19 | struct lttng_payload_view; |
| 20 | struct lttng_dynamic_buffer; |
| 21 | |
| 22 | typedef bool (*kernel_probe_location_equal_cb)( |
| 23 | const struct lttng_kernel_probe_location *a, |
| 24 | const struct lttng_kernel_probe_location *b); |
| 25 | typedef int (*kernel_probe_location_serialize_cb)( |
| 26 | const struct lttng_kernel_probe_location *kernel_probe_location, |
| 27 | struct lttng_payload *payload); |
| 28 | typedef bool (*kernel_probe_location_equal_cb)( |
| 29 | const struct lttng_kernel_probe_location *a, |
| 30 | const struct lttng_kernel_probe_location *b); |
| 31 | typedef ssize_t (*kernel_probe_location_create_from_payload_cb)( |
| 32 | struct lttng_payload_view *view, |
| 33 | struct lttng_kernel_probe_location **kernel_probe_location); |
| 34 | |
| 35 | struct lttng_kernel_probe_location_comm { |
| 36 | /* enum lttng_kernel_probe_location_type */ |
| 37 | int8_t type; |
| 38 | /* |
| 39 | * Payload is composed of, in that order, |
| 40 | * - type-specific payload |
| 41 | */ |
| 42 | char payload[]; |
| 43 | } LTTNG_PACKED; |
| 44 | |
| 45 | struct lttng_kernel_probe_location_symbol_comm { |
| 46 | /* Includes the trailing \0. */ |
| 47 | uint32_t symbol_len; |
| 48 | /* The offset from the symbol. */ |
| 49 | uint64_t offset; |
| 50 | /* |
| 51 | * Payload is composed of, in that order, |
| 52 | * - symbol name (with trailing \0). |
| 53 | */ |
| 54 | char payload[]; |
| 55 | } LTTNG_PACKED; |
| 56 | |
| 57 | struct lttng_kernel_probe_location_address_comm { |
| 58 | uint64_t address; |
| 59 | } LTTNG_PACKED; |
| 60 | |
| 61 | /* Common ancestor of all kernel probe locations. */ |
| 62 | struct lttng_kernel_probe_location { |
| 63 | enum lttng_kernel_probe_location_type type; |
| 64 | kernel_probe_location_equal_cb equal; |
| 65 | kernel_probe_location_serialize_cb serialize; |
| 66 | }; |
| 67 | |
| 68 | struct lttng_kernel_probe_location_symbol { |
| 69 | struct lttng_kernel_probe_location parent; |
| 70 | char *symbol_name; |
| 71 | uint64_t offset; |
| 72 | }; |
| 73 | |
| 74 | struct lttng_kernel_probe_location_address { |
| 75 | struct lttng_kernel_probe_location parent; |
| 76 | uint64_t address; |
| 77 | }; |
| 78 | |
| 79 | LTTNG_HIDDEN |
| 80 | int lttng_kernel_probe_location_serialize( |
| 81 | const struct lttng_kernel_probe_location *location, |
| 82 | struct lttng_payload *payload); |
| 83 | |
| 84 | LTTNG_HIDDEN |
| 85 | ssize_t lttng_kernel_probe_location_create_from_payload( |
| 86 | struct lttng_payload_view *view, |
| 87 | struct lttng_kernel_probe_location **probe_location); |
| 88 | |
| 89 | LTTNG_HIDDEN |
| 90 | bool lttng_kernel_probe_location_is_equal( |
| 91 | const struct lttng_kernel_probe_location *a, |
| 92 | const struct lttng_kernel_probe_location *b); |
| 93 | |
| 94 | #endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */ |