Commit | Line | Data |
---|---|---|
808cb744 JR |
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 | ||
c9e313bc SM |
11 | #include <common/fd-handle.hpp> |
12 | #include <common/macros.hpp> | |
28f23191 | 13 | |
808cb744 | 14 | #include <lttng/kernel-probe.h> |
740da7d5 | 15 | #include <lttng/lttng-error.h> |
28f23191 | 16 | |
808cb744 JR |
17 | #include <stdbool.h> |
18 | #include <stdint.h> | |
19 | #include <sys/types.h> | |
20 | ||
21 | struct lttng_payload; | |
22 | struct lttng_payload_view; | |
23 | struct lttng_dynamic_buffer; | |
6a751b95 | 24 | struct mi_writer; |
808cb744 | 25 | |
e665dfbc JG |
26 | using kernel_probe_location_equal_cb = bool (*)(const struct lttng_kernel_probe_location *, |
27 | const struct lttng_kernel_probe_location *); | |
28 | using kernel_probe_location_serialize_cb = int (*)(const struct lttng_kernel_probe_location *, | |
29 | struct lttng_payload *); | |
30 | using kernel_probe_location_equal_cb = bool (*)(const struct lttng_kernel_probe_location *, | |
31 | const struct lttng_kernel_probe_location *); | |
32 | using kernel_probe_location_create_from_payload_cb = | |
33 | ssize_t (*)(struct lttng_payload_view *, struct lttng_kernel_probe_location **); | |
34 | using kernel_probe_location_hash_cb = unsigned long (*)(const struct lttng_kernel_probe_location *); | |
35 | using kernel_probe_location_mi_serialize_cb = | |
36 | enum lttng_error_code (*)(const struct lttng_kernel_probe_location *, struct mi_writer *); | |
808cb744 JR |
37 | |
38 | struct lttng_kernel_probe_location_comm { | |
39 | /* enum lttng_kernel_probe_location_type */ | |
40 | int8_t type; | |
41 | /* | |
42 | * Payload is composed of, in that order, | |
43 | * - type-specific payload | |
44 | */ | |
45 | char payload[]; | |
46 | } LTTNG_PACKED; | |
47 | ||
48 | struct lttng_kernel_probe_location_symbol_comm { | |
49 | /* Includes the trailing \0. */ | |
50 | uint32_t symbol_len; | |
51 | /* The offset from the symbol. */ | |
52 | uint64_t offset; | |
53 | /* | |
54 | * Payload is composed of, in that order, | |
55 | * - symbol name (with trailing \0). | |
56 | */ | |
57 | char payload[]; | |
58 | } LTTNG_PACKED; | |
59 | ||
60 | struct lttng_kernel_probe_location_address_comm { | |
61 | uint64_t address; | |
62 | } LTTNG_PACKED; | |
63 | ||
64 | /* Common ancestor of all kernel probe locations. */ | |
65 | struct lttng_kernel_probe_location { | |
66 | enum lttng_kernel_probe_location_type type; | |
67 | kernel_probe_location_equal_cb equal; | |
68 | kernel_probe_location_serialize_cb serialize; | |
959e3c66 | 69 | kernel_probe_location_hash_cb hash; |
6a751b95 | 70 | kernel_probe_location_mi_serialize_cb mi_serialize; |
808cb744 JR |
71 | }; |
72 | ||
73 | struct lttng_kernel_probe_location_symbol { | |
74 | struct lttng_kernel_probe_location parent; | |
75 | char *symbol_name; | |
76 | uint64_t offset; | |
77 | }; | |
78 | ||
79 | struct lttng_kernel_probe_location_address { | |
80 | struct lttng_kernel_probe_location parent; | |
81 | uint64_t address; | |
82 | }; | |
83 | ||
28f23191 JG |
84 | int lttng_kernel_probe_location_serialize(const struct lttng_kernel_probe_location *location, |
85 | struct lttng_payload *payload); | |
808cb744 | 86 | |
808cb744 | 87 | ssize_t lttng_kernel_probe_location_create_from_payload( |
28f23191 | 88 | struct lttng_payload_view *view, struct lttng_kernel_probe_location **probe_location); |
808cb744 | 89 | |
28f23191 JG |
90 | bool lttng_kernel_probe_location_is_equal(const struct lttng_kernel_probe_location *a, |
91 | const struct lttng_kernel_probe_location *b); | |
808cb744 | 92 | |
28f23191 JG |
93 | struct lttng_kernel_probe_location * |
94 | lttng_kernel_probe_location_copy(const struct lttng_kernel_probe_location *location); | |
077192fd | 95 | |
28f23191 | 96 | unsigned long lttng_kernel_probe_location_hash(const struct lttng_kernel_probe_location *location); |
959e3c66 | 97 | |
28f23191 JG |
98 | enum lttng_error_code |
99 | lttng_kernel_probe_location_mi_serialize(const struct lttng_kernel_probe_location *location, | |
100 | struct mi_writer *writer); | |
6a751b95 | 101 | |
808cb744 | 102 | #endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */ |