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>
14 #include <common/dynamic-buffer.h>
15 #include <common/buffer-view.h>
17 typedef bool (*userspace_probe_location_equal_cb
)(
18 const struct lttng_userspace_probe_location
*a
,
19 const struct lttng_userspace_probe_location
*b
);
22 * No elf-specific comm structure is defined since no elf-specific payload is
25 struct lttng_userspace_probe_location_lookup_method_comm
{
26 /* enum lttng_userspace_probe_location_lookup_method_type */
28 /* type-specific payload */
32 /* Common ancestor of all userspace probe location lookup methods. */
33 struct lttng_userspace_probe_location_lookup_method
{
34 enum lttng_userspace_probe_location_lookup_method_type type
;
37 struct lttng_userspace_probe_location_lookup_method_elf
{
38 struct lttng_userspace_probe_location_lookup_method parent
;
41 struct lttng_userspace_probe_location_lookup_method_sdt
{
42 struct lttng_userspace_probe_location_lookup_method parent
;
45 struct lttng_userspace_probe_location_comm
{
46 /* enum lttng_userspace_probe_location_type */
49 * Payload is composed of, in that order,
50 * - type-specific payload
51 * - struct lttng_userspace_probe_location_lookup_method_comm
56 struct lttng_userspace_probe_location_function_comm
{
57 /* Both lengths include the trailing \0. */
58 uint32_t function_name_len
;
59 uint32_t binary_path_len
;
61 * Payload is composed of, in that order,
62 * - function name (with trailing \0),
63 * - absolute binary path (with trailing \0)
68 struct lttng_userspace_probe_location_tracepoint_comm
{
69 /* The three lengths include the trailing \0. */
70 uint32_t probe_name_len
;
71 uint32_t provider_name_len
;
72 uint32_t binary_path_len
;
74 * Payload is composed of, in that order,
75 * - probe name (with trailing \0),
76 * - provider name (with trailing \0),
77 * - absolute binary path (with trailing \0)
82 /* Common ancestor of all userspace probe locations. */
83 struct lttng_userspace_probe_location
{
84 enum lttng_userspace_probe_location_type type
;
85 struct lttng_userspace_probe_location_lookup_method
*lookup_method
;
86 userspace_probe_location_equal_cb equal
;
89 struct lttng_userspace_probe_location_function
{
90 struct lttng_userspace_probe_location parent
;
94 * binary_fd is a file descriptor to the executable file. It's open
95 * early on to keep the backing inode valid over the course of the
96 * intrumentation and use. It prevents deletion and reuse races.
97 * Set to -1 if not open.
100 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type
;
103 struct lttng_userspace_probe_location_tracepoint
{
104 struct lttng_userspace_probe_location parent
;
109 * binary_fd is a file descriptor to the executable file. It's open
110 * early on to keep the backing inode valid over the course of the
111 * intrumentation and use. It prevents deletion and reuse races.
112 * Set to -1 if not open.
118 int lttng_userspace_probe_location_serialize(
119 const struct lttng_userspace_probe_location
*location
,
120 struct lttng_dynamic_buffer
*buffer
,
124 int lttng_userspace_probe_location_create_from_buffer(
125 const struct lttng_buffer_view
*buffer
,
126 struct lttng_userspace_probe_location
**probe_location
);
129 int lttng_userspace_probe_location_function_set_binary_fd(
130 struct lttng_userspace_probe_location
*location
, int binary_fd
);
133 int lttng_userspace_probe_location_tracepoint_set_binary_fd(
134 struct lttng_userspace_probe_location
*location
, int binary_fd
);
137 * Returns a version of the location that is serialized to a contiguous region
138 * of memory. Pass NULL to buffer to only get the storage requirement of the
139 * flattened userspace probe location.
142 int lttng_userspace_probe_location_flatten(
143 const struct lttng_userspace_probe_location
*location
,
144 struct lttng_dynamic_buffer
*buffer
);
147 struct lttng_userspace_probe_location
*lttng_userspace_probe_location_copy(
148 const struct lttng_userspace_probe_location
*location
);
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
);
156 bool lttng_userspace_probe_location_is_equal(
157 const struct lttng_userspace_probe_location
*a
,
158 const struct lttng_userspace_probe_location
*b
);
160 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */