Commit | Line | Data |
---|---|---|
c3e68e71 JR |
1 | /* |
2 | * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: LGPL-2.1-only | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef LTTNG_KERNEL_FUNCTION_INTERNAL_H | |
9 | #define LTTNG_KERNEL_FUNCTION_INTERNAL_H | |
10 | ||
11 | #include <stdbool.h> | |
12 | #include <stdint.h> | |
13 | #include <sys/types.h> | |
14 | ||
15 | #include <common/fd-handle.h> | |
16 | #include <common/macros.h> | |
17 | #include <lttng/kernel-function.h> | |
18 | ||
19 | struct lttng_payload; | |
20 | struct lttng_payload_view; | |
21 | struct lttng_dynamic_buffer; | |
22 | ||
23 | typedef bool (*kernel_function_location_equal_cb)( | |
24 | const struct lttng_kernel_function_location *a, | |
25 | const struct lttng_kernel_function_location *b); | |
26 | typedef int (*kernel_function_location_serialize_cb)( | |
27 | const struct lttng_kernel_function_location *kernel_function_location, | |
28 | struct lttng_payload *payload); | |
29 | typedef bool (*kernel_function_location_equal_cb)( | |
30 | const struct lttng_kernel_function_location *a, | |
31 | const struct lttng_kernel_function_location *b); | |
32 | typedef ssize_t (*kernel_function_location_create_from_payload_cb)( | |
33 | struct lttng_payload_view *view, | |
34 | struct lttng_kernel_function_location **kernel_function_location); | |
35 | typedef unsigned long (*kernel_function_location_hash_cb)( | |
36 | const struct lttng_kernel_function_location *location); | |
37 | ||
38 | struct lttng_kernel_function_location_comm { | |
39 | /* enum lttng_kernel_function_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_function_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_function_location_address_comm { | |
61 | uint64_t address; | |
62 | } LTTNG_PACKED; | |
63 | ||
64 | /* Common ancestor of all kernel function locations. */ | |
65 | struct lttng_kernel_function_location { | |
66 | enum lttng_kernel_function_location_type type; | |
67 | kernel_function_location_equal_cb equal; | |
68 | kernel_function_location_serialize_cb serialize; | |
69 | kernel_function_location_hash_cb hash; | |
70 | }; | |
71 | ||
72 | struct lttng_kernel_function_location_symbol { | |
73 | struct lttng_kernel_function_location parent; | |
74 | char *symbol_name; | |
75 | uint64_t offset; | |
76 | }; | |
77 | ||
78 | struct lttng_kernel_function_location_address { | |
79 | struct lttng_kernel_function_location parent; | |
80 | uint64_t address; | |
81 | }; | |
82 | ||
83 | LTTNG_HIDDEN | |
84 | int lttng_kernel_function_location_serialize( | |
85 | const struct lttng_kernel_function_location *location, | |
86 | struct lttng_payload *payload); | |
87 | ||
88 | LTTNG_HIDDEN | |
89 | ssize_t lttng_kernel_function_location_create_from_payload( | |
90 | struct lttng_payload_view *view, | |
91 | struct lttng_kernel_function_location **function_location); | |
92 | ||
93 | LTTNG_HIDDEN | |
94 | bool lttng_kernel_function_location_is_equal( | |
95 | const struct lttng_kernel_function_location *a, | |
96 | const struct lttng_kernel_function_location *b); | |
97 | ||
98 | LTTNG_HIDDEN | |
99 | struct lttng_kernel_function_location *lttng_kernel_function_location_copy( | |
100 | const struct lttng_kernel_function_location *location); | |
101 | ||
102 | LTTNG_HIDDEN | |
103 | unsigned long lttng_kernel_function_location_hash( | |
104 | const struct lttng_kernel_function_location *location); | |
105 | ||
106 | #endif /* LTTNG_KERNEL_FUNCTION_INTERNAL_H */ |