| 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 | struct mi_writer; |
| 22 | |
| 23 | typedef bool (*kernel_probe_location_equal_cb)( |
| 24 | const struct lttng_kernel_probe_location *a, |
| 25 | const struct lttng_kernel_probe_location *b); |
| 26 | typedef int (*kernel_probe_location_serialize_cb)( |
| 27 | const struct lttng_kernel_probe_location *kernel_probe_location, |
| 28 | struct lttng_payload *payload); |
| 29 | typedef bool (*kernel_probe_location_equal_cb)( |
| 30 | const struct lttng_kernel_probe_location *a, |
| 31 | const struct lttng_kernel_probe_location *b); |
| 32 | typedef ssize_t (*kernel_probe_location_create_from_payload_cb)( |
| 33 | struct lttng_payload_view *view, |
| 34 | struct lttng_kernel_probe_location **kernel_probe_location); |
| 35 | typedef unsigned long (*kernel_probe_location_hash_cb)( |
| 36 | const struct lttng_kernel_probe_location *location); |
| 37 | typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)( |
| 38 | const struct lttng_kernel_probe_location *location, |
| 39 | struct mi_writer *writer); |
| 40 | |
| 41 | struct lttng_kernel_probe_location_comm { |
| 42 | /* enum lttng_kernel_probe_location_type */ |
| 43 | int8_t type; |
| 44 | /* |
| 45 | * Payload is composed of, in that order, |
| 46 | * - type-specific payload |
| 47 | */ |
| 48 | char payload[]; |
| 49 | } LTTNG_PACKED; |
| 50 | |
| 51 | struct lttng_kernel_probe_location_symbol_comm { |
| 52 | /* Includes the trailing \0. */ |
| 53 | uint32_t symbol_len; |
| 54 | /* The offset from the symbol. */ |
| 55 | uint64_t offset; |
| 56 | /* |
| 57 | * Payload is composed of, in that order, |
| 58 | * - symbol name (with trailing \0). |
| 59 | */ |
| 60 | char payload[]; |
| 61 | } LTTNG_PACKED; |
| 62 | |
| 63 | struct lttng_kernel_probe_location_address_comm { |
| 64 | uint64_t address; |
| 65 | } LTTNG_PACKED; |
| 66 | |
| 67 | /* Common ancestor of all kernel probe locations. */ |
| 68 | struct lttng_kernel_probe_location { |
| 69 | enum lttng_kernel_probe_location_type type; |
| 70 | kernel_probe_location_equal_cb equal; |
| 71 | kernel_probe_location_serialize_cb serialize; |
| 72 | kernel_probe_location_hash_cb hash; |
| 73 | kernel_probe_location_mi_serialize_cb mi_serialize; |
| 74 | }; |
| 75 | |
| 76 | struct lttng_kernel_probe_location_symbol { |
| 77 | struct lttng_kernel_probe_location parent; |
| 78 | char *symbol_name; |
| 79 | uint64_t offset; |
| 80 | }; |
| 81 | |
| 82 | struct lttng_kernel_probe_location_address { |
| 83 | struct lttng_kernel_probe_location parent; |
| 84 | uint64_t address; |
| 85 | }; |
| 86 | |
| 87 | int lttng_kernel_probe_location_serialize( |
| 88 | const struct lttng_kernel_probe_location *location, |
| 89 | struct lttng_payload *payload); |
| 90 | |
| 91 | ssize_t lttng_kernel_probe_location_create_from_payload( |
| 92 | struct lttng_payload_view *view, |
| 93 | struct lttng_kernel_probe_location **probe_location); |
| 94 | |
| 95 | bool lttng_kernel_probe_location_is_equal( |
| 96 | const struct lttng_kernel_probe_location *a, |
| 97 | const struct lttng_kernel_probe_location *b); |
| 98 | |
| 99 | struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy( |
| 100 | const struct lttng_kernel_probe_location *location); |
| 101 | |
| 102 | unsigned long lttng_kernel_probe_location_hash( |
| 103 | const struct lttng_kernel_probe_location *location); |
| 104 | |
| 105 | enum lttng_error_code lttng_kernel_probe_location_mi_serialize( |
| 106 | const struct lttng_kernel_probe_location *location, |
| 107 | struct mi_writer *writer); |
| 108 | |
| 109 | #endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */ |