2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
5 * SPDX-License-Identifier: LGPL-2.1-only
9 #ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
10 #define LTTNG_USERSPACE_PROBE_INTERNAL_H
12 #include <lttng/userspace-probe.h>
13 #include <common/macros.h>
17 struct lttng_payload_view
;
18 struct lttng_dynamic_buffer
;
20 typedef bool (*userspace_probe_location_equal_cb
)(
21 const struct lttng_userspace_probe_location
*a
,
22 const struct lttng_userspace_probe_location
*b
);
25 * No elf-specific comm structure is defined since no elf-specific payload is
28 struct lttng_userspace_probe_location_lookup_method_comm
{
29 /* enum lttng_userspace_probe_location_lookup_method_type */
31 /* type-specific payload */
35 /* Common ancestor of all userspace probe location lookup methods. */
36 struct lttng_userspace_probe_location_lookup_method
{
37 enum lttng_userspace_probe_location_lookup_method_type type
;
40 struct lttng_userspace_probe_location_lookup_method_elf
{
41 struct lttng_userspace_probe_location_lookup_method parent
;
44 struct lttng_userspace_probe_location_lookup_method_sdt
{
45 struct lttng_userspace_probe_location_lookup_method parent
;
48 struct lttng_userspace_probe_location_comm
{
49 /* enum lttng_userspace_probe_location_type */
52 * Payload is composed of, in that order,
53 * - type-specific payload
54 * - struct lttng_userspace_probe_location_lookup_method_comm
59 struct lttng_userspace_probe_location_function_comm
{
60 /* Both lengths include the trailing \0. */
61 uint32_t function_name_len
;
62 uint32_t binary_path_len
;
64 * Payload is composed of, in that order,
65 * - function name (with trailing \0),
66 * - absolute binary path (with trailing \0)
71 struct lttng_userspace_probe_location_tracepoint_comm
{
72 /* The three lengths include the trailing \0. */
73 uint32_t probe_name_len
;
74 uint32_t provider_name_len
;
75 uint32_t binary_path_len
;
77 * Payload is composed of, in that order,
78 * - probe name (with trailing \0),
79 * - provider name (with trailing \0),
80 * - absolute binary path (with trailing \0)
85 /* Common ancestor of all userspace probe locations. */
86 struct lttng_userspace_probe_location
{
87 enum lttng_userspace_probe_location_type type
;
88 struct lttng_userspace_probe_location_lookup_method
*lookup_method
;
89 userspace_probe_location_equal_cb equal
;
92 struct lttng_userspace_probe_location_function
{
93 struct lttng_userspace_probe_location parent
;
97 * binary_fd is a file descriptor to the executable file. It's open
98 * early on to keep the backing inode valid over the course of the
99 * intrumentation and use. It prevents deletion and reuse races.
100 * Set to -1 if not open.
103 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type
;
106 struct lttng_userspace_probe_location_tracepoint
{
107 struct lttng_userspace_probe_location parent
;
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 * Set to -1 if not open.
121 int lttng_userspace_probe_location_serialize(
122 const struct lttng_userspace_probe_location
*location
,
123 struct lttng_payload
*payload
);
126 int lttng_userspace_probe_location_create_from_payload(
127 struct lttng_payload_view
*view
,
128 struct lttng_userspace_probe_location
**probe_location
);
131 int lttng_userspace_probe_location_function_set_binary_fd(
132 struct lttng_userspace_probe_location
*location
, int binary_fd
);
135 int lttng_userspace_probe_location_tracepoint_set_binary_fd(
136 struct lttng_userspace_probe_location
*location
, int binary_fd
);
139 * Returns a version of the location that is serialized to a contiguous region
140 * of memory. Pass NULL to buffer to only get the storage requirement of the
141 * flattened userspace probe location.
144 int lttng_userspace_probe_location_flatten(
145 const struct lttng_userspace_probe_location
*location
,
146 struct lttng_dynamic_buffer
*buffer
);
149 struct lttng_userspace_probe_location
*lttng_userspace_probe_location_copy(
150 const struct lttng_userspace_probe_location
*location
);
153 bool lttng_userspace_probe_location_lookup_method_is_equal(
154 const struct lttng_userspace_probe_location_lookup_method
*a
,
155 const struct lttng_userspace_probe_location_lookup_method
*b
);
158 bool lttng_userspace_probe_location_is_equal(
159 const struct lttng_userspace_probe_location
*a
,
160 const struct lttng_userspace_probe_location
*b
);
162 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */