Move test_action to its own file
[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>
fe489250 14#include <common/fd-handle.h>
e368fb43
JG
15#include <stdbool.h>
16
17struct lttng_payload;
18struct lttng_payload_view;
19struct lttng_dynamic_buffer;
1ce46cfe 20
dfcfa983
JR
21typedef bool (*userspace_probe_location_equal_cb)(
22 const struct lttng_userspace_probe_location *a,
23 const struct lttng_userspace_probe_location *b);
959e3c66
JR
24typedef unsigned long (*userspace_probe_location_hash_cb)(
25 const struct lttng_userspace_probe_location *location);
dfcfa983 26
1ce46cfe
JG
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;
dfcfa983 92 userspace_probe_location_equal_cb equal;
959e3c66 93 userspace_probe_location_hash_cb hash;
1ce46cfe
JG
94};
95
96struct lttng_userspace_probe_location_function {
97 struct lttng_userspace_probe_location parent;
98 char *function_name;
99 char *binary_path;
100 /*
101 * binary_fd is a file descriptor to the executable file. It's open
102 * early on to keep the backing inode valid over the course of the
103 * intrumentation and use. It prevents deletion and reuse races.
1ce46cfe 104 */
2cde0510 105 struct fd_handle *binary_fd_handle;
9d3981b5 106 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
1ce46cfe
JG
107};
108
f4d0bb2e
FD
109struct lttng_userspace_probe_location_tracepoint {
110 struct lttng_userspace_probe_location parent;
111 char *probe_name;
112 char *provider_name;
113 char *binary_path;
114 /*
115 * binary_fd is a file descriptor to the executable file. It's open
116 * early on to keep the backing inode valid over the course of the
117 * intrumentation and use. It prevents deletion and reuse races.
f4d0bb2e 118 */
2cde0510 119 struct fd_handle *binary_fd_handle;
f4d0bb2e
FD
120};
121
1ce46cfe
JG
122LTTNG_HIDDEN
123int lttng_userspace_probe_location_serialize(
124 const struct lttng_userspace_probe_location *location,
e368fb43 125 struct lttng_payload *payload);
1ce46cfe
JG
126
127LTTNG_HIDDEN
e368fb43
JG
128int lttng_userspace_probe_location_create_from_payload(
129 struct lttng_payload_view *view,
1ce46cfe
JG
130 struct lttng_userspace_probe_location **probe_location);
131
1ce46cfe
JG
132/*
133 * Returns a version of the location that is serialized to a contiguous region
134 * of memory. Pass NULL to buffer to only get the storage requirement of the
135 * flattened userspace probe location.
136 */
137LTTNG_HIDDEN
138int lttng_userspace_probe_location_flatten(
139 const struct lttng_userspace_probe_location *location,
140 struct lttng_dynamic_buffer *buffer);
141
394357fe
FD
142LTTNG_HIDDEN
143struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
144 const struct lttng_userspace_probe_location *location);
145
dfcfa983
JR
146LTTNG_HIDDEN
147bool lttng_userspace_probe_location_lookup_method_is_equal(
148 const struct lttng_userspace_probe_location_lookup_method *a,
149 const struct lttng_userspace_probe_location_lookup_method *b);
150
151LTTNG_HIDDEN
152bool lttng_userspace_probe_location_is_equal(
153 const struct lttng_userspace_probe_location *a,
154 const struct lttng_userspace_probe_location *b);
155
959e3c66
JR
156LTTNG_HIDDEN
157unsigned long lttng_userspace_probe_location_hash(
158 const struct lttng_userspace_probe_location *location);
159
1ce46cfe 160#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.034016 seconds and 4 git commands to generate.