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