Clean-up: consumer: change space to tabs
[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 struct lttng_payload;
18 struct lttng_payload_view;
19 struct lttng_dynamic_buffer;
20
21 typedef bool (*userspace_probe_location_equal_cb)(
22 const struct lttng_userspace_probe_location *a,
23 const struct lttng_userspace_probe_location *b);
24
25 /*
26 * No elf-specific comm structure is defined since no elf-specific payload is
27 * currently needed.
28 */
29 struct lttng_userspace_probe_location_lookup_method_comm {
30 /* enum lttng_userspace_probe_location_lookup_method_type */
31 int8_t type;
32 /* type-specific payload */
33 char payload[];
34 };
35
36 /* Common ancestor of all userspace probe location lookup methods. */
37 struct lttng_userspace_probe_location_lookup_method {
38 enum lttng_userspace_probe_location_lookup_method_type type;
39 };
40
41 struct lttng_userspace_probe_location_lookup_method_elf {
42 struct lttng_userspace_probe_location_lookup_method parent;
43 };
44
45 struct lttng_userspace_probe_location_lookup_method_sdt {
46 struct lttng_userspace_probe_location_lookup_method parent;
47 };
48
49 struct lttng_userspace_probe_location_comm {
50 /* enum lttng_userspace_probe_location_type */
51 int8_t type;
52 /*
53 * Payload is composed of, in that order,
54 * - type-specific payload
55 * - struct lttng_userspace_probe_location_lookup_method_comm
56 */
57 char payload[];
58 };
59
60 struct lttng_userspace_probe_location_function_comm {
61 /* Both lengths include the trailing \0. */
62 uint32_t function_name_len;
63 uint32_t binary_path_len;
64 /*
65 * Payload is composed of, in that order,
66 * - function name (with trailing \0),
67 * - absolute binary path (with trailing \0)
68 */
69 char payload[];
70 } LTTNG_PACKED;
71
72 struct lttng_userspace_probe_location_tracepoint_comm {
73 /* The three lengths include the trailing \0. */
74 uint32_t probe_name_len;
75 uint32_t provider_name_len;
76 uint32_t binary_path_len;
77 /*
78 * Payload is composed of, in that order,
79 * - probe name (with trailing \0),
80 * - provider name (with trailing \0),
81 * - absolute binary path (with trailing \0)
82 */
83 char payload[];
84 } LTTNG_PACKED;
85
86 /* Common ancestor of all userspace probe locations. */
87 struct lttng_userspace_probe_location {
88 enum lttng_userspace_probe_location_type type;
89 struct lttng_userspace_probe_location_lookup_method *lookup_method;
90 userspace_probe_location_equal_cb equal;
91 };
92
93 struct lttng_userspace_probe_location_function {
94 struct lttng_userspace_probe_location parent;
95 char *function_name;
96 char *binary_path;
97 /*
98 * binary_fd is a file descriptor to the executable file. It's open
99 * early on to keep the backing inode valid over the course of the
100 * intrumentation and use. It prevents deletion and reuse races.
101 */
102 struct fd_handle *binary_fd_handle;
103 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
104 };
105
106 struct lttng_userspace_probe_location_tracepoint {
107 struct lttng_userspace_probe_location parent;
108 char *probe_name;
109 char *provider_name;
110 char *binary_path;
111 /*
112 * binary_fd is a file descriptor to the executable file. It's open
113 * early on to keep the backing inode valid over the course of the
114 * intrumentation and use. It prevents deletion and reuse races.
115 */
116 struct fd_handle *binary_fd_handle;
117 };
118
119 LTTNG_HIDDEN
120 int lttng_userspace_probe_location_serialize(
121 const struct lttng_userspace_probe_location *location,
122 struct lttng_payload *payload);
123
124 LTTNG_HIDDEN
125 int lttng_userspace_probe_location_create_from_payload(
126 struct lttng_payload_view *view,
127 struct lttng_userspace_probe_location **probe_location);
128
129 /*
130 * Returns a version of the location that is serialized to a contiguous region
131 * of memory. Pass NULL to buffer to only get the storage requirement of the
132 * flattened userspace probe location.
133 */
134 LTTNG_HIDDEN
135 int lttng_userspace_probe_location_flatten(
136 const struct lttng_userspace_probe_location *location,
137 struct lttng_dynamic_buffer *buffer);
138
139 LTTNG_HIDDEN
140 struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
141 const struct lttng_userspace_probe_location *location);
142
143 LTTNG_HIDDEN
144 bool lttng_userspace_probe_location_lookup_method_is_equal(
145 const struct lttng_userspace_probe_location_lookup_method *a,
146 const struct lttng_userspace_probe_location_lookup_method *b);
147
148 LTTNG_HIDDEN
149 bool lttng_userspace_probe_location_is_equal(
150 const struct lttng_userspace_probe_location *a,
151 const struct lttng_userspace_probe_location *b);
152
153 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.032437 seconds and 5 git commands to generate.