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/fd-handle.h>
18 struct lttng_payload_view
;
19 struct lttng_dynamic_buffer
;
21 typedef bool (*userspace_probe_location_equal_cb
)(
22 const struct lttng_userspace_probe_location
*a
,
23 const struct lttng_userspace_probe_location
*b
);
26 * No elf-specific comm structure is defined since no elf-specific payload is
29 struct lttng_userspace_probe_location_lookup_method_comm
{
30 /* enum lttng_userspace_probe_location_lookup_method_type */
32 /* type-specific payload */
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
;
41 struct lttng_userspace_probe_location_lookup_method_elf
{
42 struct lttng_userspace_probe_location_lookup_method parent
;
45 struct lttng_userspace_probe_location_lookup_method_sdt
{
46 struct lttng_userspace_probe_location_lookup_method parent
;
49 struct lttng_userspace_probe_location_comm
{
50 /* enum lttng_userspace_probe_location_type */
53 * Payload is composed of, in that order,
54 * - type-specific payload
55 * - struct lttng_userspace_probe_location_lookup_method_comm
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
;
65 * Payload is composed of, in that order,
66 * - function name (with trailing \0),
67 * - absolute binary path (with trailing \0)
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
;
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)
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
;
93 struct lttng_userspace_probe_location_function
{
94 struct lttng_userspace_probe_location parent
;
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.
102 struct fd_handle
*binary_fd_handle
;
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.
116 struct fd_handle
*binary_fd_handle
;
120 int lttng_userspace_probe_location_serialize(
121 const struct lttng_userspace_probe_location
*location
,
122 struct lttng_payload
*payload
);
125 int lttng_userspace_probe_location_create_from_payload(
126 struct lttng_payload_view
*view
,
127 struct lttng_userspace_probe_location
**probe_location
);
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.
135 int lttng_userspace_probe_location_flatten(
136 const struct lttng_userspace_probe_location
*location
,
137 struct lttng_dynamic_buffer
*buffer
);
140 struct lttng_userspace_probe_location
*lttng_userspace_probe_location_copy(
141 const struct lttng_userspace_probe_location
*location
);
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
);
149 bool lttng_userspace_probe_location_is_equal(
150 const struct lttng_userspace_probe_location
*a
,
151 const struct lttng_userspace_probe_location
*b
);
153 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */