uprobe: transmit binary file descritptor through lttng_payload
[lttng-tools.git] / include / lttng / userspace-probe-internal.h
CommitLineData
1ce46cfe 1/*
ab5be9fa
MJ
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
1ce46cfe 4 *
ab5be9fa 5 * SPDX-License-Identifier: LGPL-2.1-only
1ce46cfe 6 *
1ce46cfe
JG
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>
e368fb43
JG
14#include <stdbool.h>
15
16struct lttng_payload;
17struct lttng_payload_view;
18struct lttng_dynamic_buffer;
1ce46cfe 19
dfcfa983
JR
20typedef bool (*userspace_probe_location_equal_cb)(
21 const struct lttng_userspace_probe_location *a,
22 const struct lttng_userspace_probe_location *b);
23
1ce46cfe
JG
24/*
25 * No elf-specific comm structure is defined since no elf-specific payload is
26 * currently needed.
27 */
28struct lttng_userspace_probe_location_lookup_method_comm {
29 /* enum lttng_userspace_probe_location_lookup_method_type */
30 int8_t type;
31 /* type-specific payload */
32 char payload[];
33};
34
35/* Common ancestor of all userspace probe location lookup methods. */
36struct lttng_userspace_probe_location_lookup_method {
37 enum lttng_userspace_probe_location_lookup_method_type type;
38};
39
40struct lttng_userspace_probe_location_lookup_method_elf {
41 struct lttng_userspace_probe_location_lookup_method parent;
42};
43
f4d0bb2e
FD
44struct lttng_userspace_probe_location_lookup_method_sdt {
45 struct lttng_userspace_probe_location_lookup_method parent;
46};
47
1ce46cfe
JG
48struct lttng_userspace_probe_location_comm {
49 /* enum lttng_userspace_probe_location_type */
50 int8_t type;
51 /*
52 * Payload is composed of, in that order,
53 * - type-specific payload
54 * - struct lttng_userspace_probe_location_lookup_method_comm
55 */
56 char payload[];
57};
58
59struct 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;
63 /*
64 * Payload is composed of, in that order,
65 * - function name (with trailing \0),
66 * - absolute binary path (with trailing \0)
67 */
68 char payload[];
69} LTTNG_PACKED;
70
f4d0bb2e
FD
71struct 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;
76 /*
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)
81 */
82 char payload[];
83} LTTNG_PACKED;
84
1ce46cfe
JG
85/* Common ancestor of all userspace probe locations. */
86struct lttng_userspace_probe_location {
87 enum lttng_userspace_probe_location_type type;
88 struct lttng_userspace_probe_location_lookup_method *lookup_method;
dfcfa983 89 userspace_probe_location_equal_cb equal;
1ce46cfe
JG
90};
91
92struct lttng_userspace_probe_location_function {
93 struct lttng_userspace_probe_location parent;
94 char *function_name;
95 char *binary_path;
96 /*
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.
101 */
102 int binary_fd;
9d3981b5 103 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
1ce46cfe
JG
104};
105
f4d0bb2e
FD
106struct 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 * Set to -1 if not open.
116 */
117 int binary_fd;
118};
119
1ce46cfe
JG
120LTTNG_HIDDEN
121int lttng_userspace_probe_location_serialize(
122 const struct lttng_userspace_probe_location *location,
e368fb43 123 struct lttng_payload *payload);
1ce46cfe
JG
124
125LTTNG_HIDDEN
e368fb43
JG
126int lttng_userspace_probe_location_create_from_payload(
127 struct lttng_payload_view *view,
1ce46cfe
JG
128 struct lttng_userspace_probe_location **probe_location);
129
130LTTNG_HIDDEN
131int lttng_userspace_probe_location_function_set_binary_fd(
132 struct lttng_userspace_probe_location *location, int binary_fd);
133
f4d0bb2e
FD
134LTTNG_HIDDEN
135int lttng_userspace_probe_location_tracepoint_set_binary_fd(
136 struct lttng_userspace_probe_location *location, int binary_fd);
137
1ce46cfe
JG
138/*
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.
142 */
143LTTNG_HIDDEN
144int lttng_userspace_probe_location_flatten(
145 const struct lttng_userspace_probe_location *location,
146 struct lttng_dynamic_buffer *buffer);
147
394357fe
FD
148LTTNG_HIDDEN
149struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
150 const struct lttng_userspace_probe_location *location);
151
dfcfa983
JR
152LTTNG_HIDDEN
153bool 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);
156
157LTTNG_HIDDEN
158bool lttng_userspace_probe_location_is_equal(
159 const struct lttng_userspace_probe_location *a,
160 const struct lttng_userspace_probe_location *b);
161
1ce46cfe 162#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.032364 seconds and 4 git commands to generate.