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>
18 * No elf-specific comm structure is defined since no elf-specific payload is
21 struct lttng_userspace_probe_location_lookup_method_comm
{
22 /* enum lttng_userspace_probe_location_lookup_method_type */
24 /* type-specific payload */
28 /* Common ancestor of all userspace probe location lookup methods. */
29 struct lttng_userspace_probe_location_lookup_method
{
30 enum lttng_userspace_probe_location_lookup_method_type type
;
33 struct lttng_userspace_probe_location_lookup_method_elf
{
34 struct lttng_userspace_probe_location_lookup_method parent
;
37 struct lttng_userspace_probe_location_lookup_method_sdt
{
38 struct lttng_userspace_probe_location_lookup_method parent
;
41 struct lttng_userspace_probe_location_comm
{
42 /* enum lttng_userspace_probe_location_type */
45 * Payload is composed of, in that order,
46 * - type-specific payload
47 * - struct lttng_userspace_probe_location_lookup_method_comm
52 struct lttng_userspace_probe_location_function_comm
{
53 /* Both lengths include the trailing \0. */
54 uint32_t function_name_len
;
55 uint32_t binary_path_len
;
57 * Payload is composed of, in that order,
58 * - function name (with trailing \0),
59 * - absolute binary path (with trailing \0)
64 struct lttng_userspace_probe_location_tracepoint_comm
{
65 /* The three lengths include the trailing \0. */
66 uint32_t probe_name_len
;
67 uint32_t provider_name_len
;
68 uint32_t binary_path_len
;
70 * Payload is composed of, in that order,
71 * - probe name (with trailing \0),
72 * - provider name (with trailing \0),
73 * - absolute binary path (with trailing \0)
78 /* Common ancestor of all userspace probe locations. */
79 struct lttng_userspace_probe_location
{
80 enum lttng_userspace_probe_location_type type
;
81 struct lttng_userspace_probe_location_lookup_method
*lookup_method
;
84 struct lttng_userspace_probe_location_function
{
85 struct lttng_userspace_probe_location parent
;
89 * binary_fd is a file descriptor to the executable file. It's open
90 * early on to keep the backing inode valid over the course of the
91 * intrumentation and use. It prevents deletion and reuse races.
92 * Set to -1 if not open.
95 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type
;
98 struct lttng_userspace_probe_location_tracepoint
{
99 struct lttng_userspace_probe_location parent
;
104 * binary_fd is a file descriptor to the executable file. It's open
105 * early on to keep the backing inode valid over the course of the
106 * intrumentation and use. It prevents deletion and reuse races.
107 * Set to -1 if not open.
113 int lttng_userspace_probe_location_serialize(
114 const struct lttng_userspace_probe_location
*location
,
115 struct lttng_dynamic_buffer
*buffer
,
119 int lttng_userspace_probe_location_create_from_buffer(
120 const struct lttng_buffer_view
*buffer
,
121 struct lttng_userspace_probe_location
**probe_location
);
124 int lttng_userspace_probe_location_function_set_binary_fd(
125 struct lttng_userspace_probe_location
*location
, int binary_fd
);
128 int lttng_userspace_probe_location_tracepoint_set_binary_fd(
129 struct lttng_userspace_probe_location
*location
, int binary_fd
);
132 * Returns a version of the location that is serialized to a contiguous region
133 * of memory. Pass NULL to buffer to only get the storage requirement of the
134 * flattened userspace probe location.
137 int lttng_userspace_probe_location_flatten(
138 const struct lttng_userspace_probe_location
*location
,
139 struct lttng_dynamic_buffer
*buffer
);
142 struct lttng_userspace_probe_location
*lttng_userspace_probe_location_copy(
143 const struct lttng_userspace_probe_location
*location
);
145 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */