Tests: ns_contexts: discarded events result in test failure
[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);
24
1ce46cfe
JG
25/*
26 * No elf-specific comm structure is defined since no elf-specific payload is
27 * currently needed.
28 */
29struct lttng_userspace_probe_location_lookup_method_comm {
30 /* enum lttng_userspace_probe_location_lookup_method_type */
31 int8_t type;
32 /* type-specific payload */
33 char payload[];
34};
35
36/* Common ancestor of all userspace probe location lookup methods. */
37struct lttng_userspace_probe_location_lookup_method {
38 enum lttng_userspace_probe_location_lookup_method_type type;
39};
40
41struct lttng_userspace_probe_location_lookup_method_elf {
42 struct lttng_userspace_probe_location_lookup_method parent;
43};
44
f4d0bb2e
FD
45struct lttng_userspace_probe_location_lookup_method_sdt {
46 struct lttng_userspace_probe_location_lookup_method parent;
47};
48
1ce46cfe
JG
49struct lttng_userspace_probe_location_comm {
50 /* enum lttng_userspace_probe_location_type */
51 int8_t type;
52 /*
53 * Payload is composed of, in that order,
54 * - type-specific payload
55 * - struct lttng_userspace_probe_location_lookup_method_comm
56 */
57 char payload[];
58};
59
60struct lttng_userspace_probe_location_function_comm {
61 /* Both lengths include the trailing \0. */
62 uint32_t function_name_len;
63 uint32_t binary_path_len;
64 /*
65 * Payload is composed of, in that order,
66 * - function name (with trailing \0),
67 * - absolute binary path (with trailing \0)
68 */
69 char payload[];
70} LTTNG_PACKED;
71
f4d0bb2e
FD
72struct lttng_userspace_probe_location_tracepoint_comm {
73 /* The three lengths include the trailing \0. */
74 uint32_t probe_name_len;
75 uint32_t provider_name_len;
76 uint32_t binary_path_len;
77 /*
78 * Payload is composed of, in that order,
79 * - probe name (with trailing \0),
80 * - provider name (with trailing \0),
81 * - absolute binary path (with trailing \0)
82 */
83 char payload[];
84} LTTNG_PACKED;
85
1ce46cfe
JG
86/* Common ancestor of all userspace probe locations. */
87struct lttng_userspace_probe_location {
88 enum lttng_userspace_probe_location_type type;
89 struct lttng_userspace_probe_location_lookup_method *lookup_method;
dfcfa983 90 userspace_probe_location_equal_cb equal;
1ce46cfe
JG
91};
92
93struct lttng_userspace_probe_location_function {
94 struct lttng_userspace_probe_location parent;
95 char *function_name;
96 char *binary_path;
97 /*
98 * binary_fd is a file descriptor to the executable file. It's open
99 * early on to keep the backing inode valid over the course of the
100 * intrumentation and use. It prevents deletion and reuse races.
1ce46cfe 101 */
2cde0510 102 struct fd_handle *binary_fd_handle;
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.
f4d0bb2e 115 */
2cde0510 116 struct fd_handle *binary_fd_handle;
f4d0bb2e
FD
117};
118
1ce46cfe
JG
119LTTNG_HIDDEN
120int lttng_userspace_probe_location_serialize(
121 const struct lttng_userspace_probe_location *location,
e368fb43 122 struct lttng_payload *payload);
1ce46cfe
JG
123
124LTTNG_HIDDEN
e368fb43
JG
125int lttng_userspace_probe_location_create_from_payload(
126 struct lttng_payload_view *view,
1ce46cfe
JG
127 struct lttng_userspace_probe_location **probe_location);
128
1ce46cfe
JG
129/*
130 * Returns a version of the location that is serialized to a contiguous region
131 * of memory. Pass NULL to buffer to only get the storage requirement of the
132 * flattened userspace probe location.
133 */
134LTTNG_HIDDEN
135int lttng_userspace_probe_location_flatten(
136 const struct lttng_userspace_probe_location *location,
137 struct lttng_dynamic_buffer *buffer);
138
394357fe
FD
139LTTNG_HIDDEN
140struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
141 const struct lttng_userspace_probe_location *location);
142
dfcfa983
JR
143LTTNG_HIDDEN
144bool lttng_userspace_probe_location_lookup_method_is_equal(
145 const struct lttng_userspace_probe_location_lookup_method *a,
146 const struct lttng_userspace_probe_location_lookup_method *b);
147
148LTTNG_HIDDEN
149bool lttng_userspace_probe_location_is_equal(
150 const struct lttng_userspace_probe_location *a,
151 const struct lttng_userspace_probe_location *b);
152
1ce46cfe 153#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.033876 seconds and 4 git commands to generate.