Commit | Line | Data |
---|---|---|
1ce46cfe | 1 | /* |
ab5be9fa MJ |
2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
3 | * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com> | |
1ce46cfe | 4 | * |
ab5be9fa | 5 | * SPDX-License-Identifier: LGPL-2.1-only |
1ce46cfe | 6 | * |
1ce46cfe JG |
7 | */ |
8 | ||
9 | #ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H | |
10 | #define LTTNG_USERSPACE_PROBE_INTERNAL_H | |
11 | ||
12 | #include <lttng/userspace-probe.h> | |
13 | #include <common/macros.h> | |
fe489250 | 14 | #include <common/fd-handle.h> |
e368fb43 JG |
15 | #include <stdbool.h> |
16 | ||
7966af57 SM |
17 | #ifdef __cplusplus |
18 | extern "C" { | |
19 | #endif | |
20 | ||
e368fb43 JG |
21 | struct lttng_payload; |
22 | struct lttng_payload_view; | |
23 | struct lttng_dynamic_buffer; | |
6a751b95 | 24 | struct mi_writer; |
1ce46cfe | 25 | |
dfcfa983 JR |
26 | typedef bool (*userspace_probe_location_equal_cb)( |
27 | const struct lttng_userspace_probe_location *a, | |
28 | const struct lttng_userspace_probe_location *b); | |
959e3c66 JR |
29 | typedef unsigned long (*userspace_probe_location_hash_cb)( |
30 | const struct lttng_userspace_probe_location *location); | |
6a751b95 JR |
31 | typedef enum lttng_error_code (*userspace_probe_location_mi)( |
32 | const struct lttng_userspace_probe_location *location, | |
33 | struct mi_writer); | |
dfcfa983 | 34 | |
1ce46cfe JG |
35 | /* |
36 | * No elf-specific comm structure is defined since no elf-specific payload is | |
37 | * currently needed. | |
38 | */ | |
39 | struct lttng_userspace_probe_location_lookup_method_comm { | |
40 | /* enum lttng_userspace_probe_location_lookup_method_type */ | |
41 | int8_t type; | |
42 | /* type-specific payload */ | |
43 | char payload[]; | |
44 | }; | |
45 | ||
46 | /* Common ancestor of all userspace probe location lookup methods. */ | |
47 | struct lttng_userspace_probe_location_lookup_method { | |
48 | enum lttng_userspace_probe_location_lookup_method_type type; | |
49 | }; | |
50 | ||
51 | struct lttng_userspace_probe_location_lookup_method_elf { | |
52 | struct lttng_userspace_probe_location_lookup_method parent; | |
53 | }; | |
54 | ||
f4d0bb2e FD |
55 | struct lttng_userspace_probe_location_lookup_method_sdt { |
56 | struct lttng_userspace_probe_location_lookup_method parent; | |
57 | }; | |
58 | ||
1ce46cfe JG |
59 | struct lttng_userspace_probe_location_comm { |
60 | /* enum lttng_userspace_probe_location_type */ | |
61 | int8_t type; | |
62 | /* | |
63 | * Payload is composed of, in that order, | |
64 | * - type-specific payload | |
65 | * - struct lttng_userspace_probe_location_lookup_method_comm | |
66 | */ | |
67 | char payload[]; | |
68 | }; | |
69 | ||
70 | struct lttng_userspace_probe_location_function_comm { | |
71 | /* Both lengths include the trailing \0. */ | |
72 | uint32_t function_name_len; | |
73 | uint32_t binary_path_len; | |
74 | /* | |
75 | * Payload is composed of, in that order, | |
76 | * - function name (with trailing \0), | |
77 | * - absolute binary path (with trailing \0) | |
78 | */ | |
79 | char payload[]; | |
80 | } LTTNG_PACKED; | |
81 | ||
f4d0bb2e FD |
82 | struct lttng_userspace_probe_location_tracepoint_comm { |
83 | /* The three lengths include the trailing \0. */ | |
84 | uint32_t probe_name_len; | |
85 | uint32_t provider_name_len; | |
86 | uint32_t binary_path_len; | |
87 | /* | |
88 | * Payload is composed of, in that order, | |
89 | * - probe name (with trailing \0), | |
90 | * - provider name (with trailing \0), | |
91 | * - absolute binary path (with trailing \0) | |
92 | */ | |
93 | char payload[]; | |
94 | } LTTNG_PACKED; | |
95 | ||
1ce46cfe JG |
96 | /* Common ancestor of all userspace probe locations. */ |
97 | struct lttng_userspace_probe_location { | |
98 | enum lttng_userspace_probe_location_type type; | |
99 | struct lttng_userspace_probe_location_lookup_method *lookup_method; | |
dfcfa983 | 100 | userspace_probe_location_equal_cb equal; |
959e3c66 | 101 | userspace_probe_location_hash_cb hash; |
6a751b95 | 102 | userspace_probe_location_hash_cb mi; |
1ce46cfe JG |
103 | }; |
104 | ||
105 | struct lttng_userspace_probe_location_function { | |
106 | struct lttng_userspace_probe_location parent; | |
107 | char *function_name; | |
108 | char *binary_path; | |
109 | /* | |
110 | * binary_fd is a file descriptor to the executable file. It's open | |
111 | * early on to keep the backing inode valid over the course of the | |
112 | * intrumentation and use. It prevents deletion and reuse races. | |
1ce46cfe | 113 | */ |
2cde0510 | 114 | struct fd_handle *binary_fd_handle; |
9d3981b5 | 115 | enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type; |
1ce46cfe JG |
116 | }; |
117 | ||
f4d0bb2e FD |
118 | struct lttng_userspace_probe_location_tracepoint { |
119 | struct lttng_userspace_probe_location parent; | |
120 | char *probe_name; | |
121 | char *provider_name; | |
122 | char *binary_path; | |
123 | /* | |
124 | * binary_fd is a file descriptor to the executable file. It's open | |
125 | * early on to keep the backing inode valid over the course of the | |
126 | * intrumentation and use. It prevents deletion and reuse races. | |
f4d0bb2e | 127 | */ |
2cde0510 | 128 | struct fd_handle *binary_fd_handle; |
f4d0bb2e FD |
129 | }; |
130 | ||
1ce46cfe JG |
131 | int lttng_userspace_probe_location_serialize( |
132 | const struct lttng_userspace_probe_location *location, | |
e368fb43 | 133 | struct lttng_payload *payload); |
1ce46cfe | 134 | |
e368fb43 JG |
135 | int lttng_userspace_probe_location_create_from_payload( |
136 | struct lttng_payload_view *view, | |
1ce46cfe JG |
137 | struct lttng_userspace_probe_location **probe_location); |
138 | ||
1ce46cfe JG |
139 | /* |
140 | * Returns a version of the location that is serialized to a contiguous region | |
141 | * of memory. Pass NULL to buffer to only get the storage requirement of the | |
142 | * flattened userspace probe location. | |
143 | */ | |
1ce46cfe JG |
144 | int lttng_userspace_probe_location_flatten( |
145 | const struct lttng_userspace_probe_location *location, | |
146 | struct lttng_dynamic_buffer *buffer); | |
147 | ||
394357fe FD |
148 | struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy( |
149 | const struct lttng_userspace_probe_location *location); | |
150 | ||
dfcfa983 JR |
151 | bool lttng_userspace_probe_location_lookup_method_is_equal( |
152 | const struct lttng_userspace_probe_location_lookup_method *a, | |
153 | const struct lttng_userspace_probe_location_lookup_method *b); | |
154 | ||
dfcfa983 JR |
155 | bool lttng_userspace_probe_location_is_equal( |
156 | const struct lttng_userspace_probe_location *a, | |
157 | const struct lttng_userspace_probe_location *b); | |
158 | ||
959e3c66 JR |
159 | unsigned long lttng_userspace_probe_location_hash( |
160 | const struct lttng_userspace_probe_location *location); | |
161 | ||
6a751b95 JR |
162 | enum lttng_error_code lttng_userspace_probe_location_mi_serialize( |
163 | const struct lttng_userspace_probe_location *location, | |
164 | struct mi_writer *writer); | |
165 | ||
7966af57 SM |
166 | #ifdef __cplusplus |
167 | } | |
168 | #endif | |
169 | ||
1ce46cfe | 170 | #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */ |