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