bin: compile lttng-sessiond as C++
[lttng-tools.git] / include / lttng / userspace-probe-internal.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 *
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>
14 #include <common/fd-handle.h>
15 #include <stdbool.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 struct lttng_payload;
22 struct lttng_payload_view;
23 struct lttng_dynamic_buffer;
24 struct mi_writer;
25
26 typedef bool (*userspace_probe_location_equal_cb)(
27 const struct lttng_userspace_probe_location *a,
28 const struct lttng_userspace_probe_location *b);
29 typedef unsigned long (*userspace_probe_location_hash_cb)(
30 const struct lttng_userspace_probe_location *location);
31 typedef enum lttng_error_code (*userspace_probe_location_mi)(
32 const struct lttng_userspace_probe_location *location,
33 struct mi_writer);
34
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
55 struct lttng_userspace_probe_location_lookup_method_sdt {
56 struct lttng_userspace_probe_location_lookup_method parent;
57 };
58
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
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
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;
100 userspace_probe_location_equal_cb equal;
101 userspace_probe_location_hash_cb hash;
102 userspace_probe_location_hash_cb mi;
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.
113 */
114 struct fd_handle *binary_fd_handle;
115 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
116 };
117
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.
127 */
128 struct fd_handle *binary_fd_handle;
129 };
130
131 int lttng_userspace_probe_location_serialize(
132 const struct lttng_userspace_probe_location *location,
133 struct lttng_payload *payload);
134
135 int lttng_userspace_probe_location_create_from_payload(
136 struct lttng_payload_view *view,
137 struct lttng_userspace_probe_location **probe_location);
138
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 */
144 int lttng_userspace_probe_location_flatten(
145 const struct lttng_userspace_probe_location *location,
146 struct lttng_dynamic_buffer *buffer);
147
148 struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
149 const struct lttng_userspace_probe_location *location);
150
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
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
159 unsigned long lttng_userspace_probe_location_hash(
160 const struct lttng_userspace_probe_location *location);
161
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
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.031858 seconds and 4 git commands to generate.