Add SDT userspace probe location
[lttng-tools.git] / include / lttng / userspace-probe-internal.h
CommitLineData
1ce46cfe
JG
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 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
20#define LTTNG_USERSPACE_PROBE_INTERNAL_H
21
22#include <lttng/userspace-probe.h>
23#include <common/macros.h>
24#include <common/dynamic-buffer.h>
25#include <common/buffer-view.h>
26
27/*
28 * No elf-specific comm structure is defined since no elf-specific payload is
29 * currently needed.
30 */
31struct lttng_userspace_probe_location_lookup_method_comm {
32 /* enum lttng_userspace_probe_location_lookup_method_type */
33 int8_t type;
34 /* type-specific payload */
35 char payload[];
36};
37
38/* Common ancestor of all userspace probe location lookup methods. */
39struct lttng_userspace_probe_location_lookup_method {
40 enum lttng_userspace_probe_location_lookup_method_type type;
41};
42
43struct lttng_userspace_probe_location_lookup_method_elf {
44 struct lttng_userspace_probe_location_lookup_method parent;
45};
46
f4d0bb2e
FD
47struct lttng_userspace_probe_location_lookup_method_sdt {
48 struct lttng_userspace_probe_location_lookup_method parent;
49};
50
1ce46cfe
JG
51struct lttng_userspace_probe_location_comm {
52 /* enum lttng_userspace_probe_location_type */
53 int8_t type;
54 /*
55 * Payload is composed of, in that order,
56 * - type-specific payload
57 * - struct lttng_userspace_probe_location_lookup_method_comm
58 */
59 char payload[];
60};
61
62struct lttng_userspace_probe_location_function_comm {
63 /* Both lengths include the trailing \0. */
64 uint32_t function_name_len;
65 uint32_t binary_path_len;
66 /*
67 * Payload is composed of, in that order,
68 * - function name (with trailing \0),
69 * - absolute binary path (with trailing \0)
70 */
71 char payload[];
72} LTTNG_PACKED;
73
f4d0bb2e
FD
74struct lttng_userspace_probe_location_tracepoint_comm {
75 /* The three lengths include the trailing \0. */
76 uint32_t probe_name_len;
77 uint32_t provider_name_len;
78 uint32_t binary_path_len;
79 /*
80 * Payload is composed of, in that order,
81 * - probe name (with trailing \0),
82 * - provider name (with trailing \0),
83 * - absolute binary path (with trailing \0)
84 */
85 char payload[];
86} LTTNG_PACKED;
87
1ce46cfe
JG
88/* Common ancestor of all userspace probe locations. */
89struct lttng_userspace_probe_location {
90 enum lttng_userspace_probe_location_type type;
91 struct lttng_userspace_probe_location_lookup_method *lookup_method;
92};
93
94struct lttng_userspace_probe_location_function {
95 struct lttng_userspace_probe_location parent;
96 char *function_name;
97 char *binary_path;
98 /*
99 * binary_fd is a file descriptor to the executable file. It's open
100 * early on to keep the backing inode valid over the course of the
101 * intrumentation and use. It prevents deletion and reuse races.
102 * Set to -1 if not open.
103 */
104 int binary_fd;
105};
106
f4d0bb2e
FD
107struct lttng_userspace_probe_location_tracepoint {
108 struct lttng_userspace_probe_location parent;
109 char *probe_name;
110 char *provider_name;
111 char *binary_path;
112 /*
113 * binary_fd is a file descriptor to the executable file. It's open
114 * early on to keep the backing inode valid over the course of the
115 * intrumentation and use. It prevents deletion and reuse races.
116 * Set to -1 if not open.
117 */
118 int binary_fd;
119};
120
1ce46cfe
JG
121LTTNG_HIDDEN
122int lttng_userspace_probe_location_serialize(
123 const struct lttng_userspace_probe_location *location,
124 struct lttng_dynamic_buffer *buffer,
125 int *binary_fd);
126
127LTTNG_HIDDEN
128int lttng_userspace_probe_location_create_from_buffer(
129 const struct lttng_buffer_view *buffer,
130 struct lttng_userspace_probe_location **probe_location);
131
132LTTNG_HIDDEN
133int lttng_userspace_probe_location_function_set_binary_fd(
134 struct lttng_userspace_probe_location *location, int binary_fd);
135
f4d0bb2e
FD
136LTTNG_HIDDEN
137int lttng_userspace_probe_location_tracepoint_set_binary_fd(
138 struct lttng_userspace_probe_location *location, int binary_fd);
139
1ce46cfe
JG
140/*
141 * Returns a version of the location that is serialized to a contiguous region
142 * of memory. Pass NULL to buffer to only get the storage requirement of the
143 * flattened userspace probe location.
144 */
145LTTNG_HIDDEN
146int lttng_userspace_probe_location_flatten(
147 const struct lttng_userspace_probe_location *location,
148 struct lttng_dynamic_buffer *buffer);
149
394357fe
FD
150LTTNG_HIDDEN
151struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
152 const struct lttng_userspace_probe_location *location);
153
1ce46cfe 154#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.041509 seconds and 4 git commands to generate.