Coverity warning: sessiond: uncaught exception in main
[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
28f23191
JG
128int lttng_userspace_probe_location_serialize(const struct lttng_userspace_probe_location *location,
129 struct lttng_payload *payload);
1ce46cfe 130
e368fb43 131int lttng_userspace_probe_location_create_from_payload(
28f23191 132 struct lttng_payload_view *view, struct lttng_userspace_probe_location **probe_location);
1ce46cfe 133
1ce46cfe
JG
134/*
135 * Returns a version of the location that is serialized to a contiguous region
136 * of memory. Pass NULL to buffer to only get the storage requirement of the
137 * flattened userspace probe location.
138 */
28f23191
JG
139int lttng_userspace_probe_location_flatten(const struct lttng_userspace_probe_location *location,
140 struct lttng_dynamic_buffer *buffer);
1ce46cfe 141
28f23191
JG
142struct lttng_userspace_probe_location *
143lttng_userspace_probe_location_copy(const struct lttng_userspace_probe_location *location);
394357fe 144
dfcfa983 145bool lttng_userspace_probe_location_lookup_method_is_equal(
28f23191
JG
146 const struct lttng_userspace_probe_location_lookup_method *a,
147 const struct lttng_userspace_probe_location_lookup_method *b);
dfcfa983 148
28f23191
JG
149bool lttng_userspace_probe_location_is_equal(const struct lttng_userspace_probe_location *a,
150 const struct lttng_userspace_probe_location *b);
dfcfa983 151
28f23191
JG
152unsigned long
153lttng_userspace_probe_location_hash(const struct lttng_userspace_probe_location *location);
959e3c66 154
28f23191
JG
155enum lttng_error_code
156lttng_userspace_probe_location_mi_serialize(const struct lttng_userspace_probe_location *location,
157 struct mi_writer *writer);
6a751b95 158
1ce46cfe 159#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.053215 seconds and 4 git commands to generate.