8287954931791e21bf3b7e0e5f595c91e46f605d
[lttng-tools.git] / include / lttng / userspace-probe-internal.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 *
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>
14 #include <common/dynamic-buffer.h>
15 #include <common/buffer-view.h>
16
17 /*
18 * No elf-specific comm structure is defined since no elf-specific payload is
19 * currently needed.
20 */
21 struct lttng_userspace_probe_location_lookup_method_comm {
22 /* enum lttng_userspace_probe_location_lookup_method_type */
23 int8_t type;
24 /* type-specific payload */
25 char payload[];
26 };
27
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;
31 };
32
33 struct lttng_userspace_probe_location_lookup_method_elf {
34 struct lttng_userspace_probe_location_lookup_method parent;
35 };
36
37 struct lttng_userspace_probe_location_lookup_method_sdt {
38 struct lttng_userspace_probe_location_lookup_method parent;
39 };
40
41 struct lttng_userspace_probe_location_comm {
42 /* enum lttng_userspace_probe_location_type */
43 int8_t type;
44 /*
45 * Payload is composed of, in that order,
46 * - type-specific payload
47 * - struct lttng_userspace_probe_location_lookup_method_comm
48 */
49 char payload[];
50 };
51
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;
56 /*
57 * Payload is composed of, in that order,
58 * - function name (with trailing \0),
59 * - absolute binary path (with trailing \0)
60 */
61 char payload[];
62 } LTTNG_PACKED;
63
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;
69 /*
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)
74 */
75 char payload[];
76 } LTTNG_PACKED;
77
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;
82 };
83
84 struct lttng_userspace_probe_location_function {
85 struct lttng_userspace_probe_location parent;
86 char *function_name;
87 char *binary_path;
88 /*
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.
93 */
94 int binary_fd;
95 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
96 };
97
98 struct lttng_userspace_probe_location_tracepoint {
99 struct lttng_userspace_probe_location parent;
100 char *probe_name;
101 char *provider_name;
102 char *binary_path;
103 /*
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.
108 */
109 int binary_fd;
110 };
111
112 LTTNG_HIDDEN
113 int lttng_userspace_probe_location_serialize(
114 const struct lttng_userspace_probe_location *location,
115 struct lttng_dynamic_buffer *buffer,
116 int *binary_fd);
117
118 LTTNG_HIDDEN
119 int lttng_userspace_probe_location_create_from_buffer(
120 const struct lttng_buffer_view *buffer,
121 struct lttng_userspace_probe_location **probe_location);
122
123 LTTNG_HIDDEN
124 int lttng_userspace_probe_location_function_set_binary_fd(
125 struct lttng_userspace_probe_location *location, int binary_fd);
126
127 LTTNG_HIDDEN
128 int lttng_userspace_probe_location_tracepoint_set_binary_fd(
129 struct lttng_userspace_probe_location *location, int binary_fd);
130
131 /*
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.
135 */
136 LTTNG_HIDDEN
137 int lttng_userspace_probe_location_flatten(
138 const struct lttng_userspace_probe_location *location,
139 struct lttng_dynamic_buffer *buffer);
140
141 LTTNG_HIDDEN
142 struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
143 const struct lttng_userspace_probe_location *location);
144
145 #endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.047016 seconds and 4 git commands to generate.