Fix: payload view: payload view always refers to parent's position
[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>
14#include <common/dynamic-buffer.h>
15#include <common/buffer-view.h>
16
dfcfa983
JR
17typedef bool (*userspace_probe_location_equal_cb)(
18 const struct lttng_userspace_probe_location *a,
19 const struct lttng_userspace_probe_location *b);
20
1ce46cfe
JG
21/*
22 * No elf-specific comm structure is defined since no elf-specific payload is
23 * currently needed.
24 */
25struct lttng_userspace_probe_location_lookup_method_comm {
26 /* enum lttng_userspace_probe_location_lookup_method_type */
27 int8_t type;
28 /* type-specific payload */
29 char payload[];
30};
31
32/* Common ancestor of all userspace probe location lookup methods. */
33struct lttng_userspace_probe_location_lookup_method {
34 enum lttng_userspace_probe_location_lookup_method_type type;
35};
36
37struct lttng_userspace_probe_location_lookup_method_elf {
38 struct lttng_userspace_probe_location_lookup_method parent;
39};
40
f4d0bb2e
FD
41struct lttng_userspace_probe_location_lookup_method_sdt {
42 struct lttng_userspace_probe_location_lookup_method parent;
43};
44
1ce46cfe
JG
45struct lttng_userspace_probe_location_comm {
46 /* enum lttng_userspace_probe_location_type */
47 int8_t type;
48 /*
49 * Payload is composed of, in that order,
50 * - type-specific payload
51 * - struct lttng_userspace_probe_location_lookup_method_comm
52 */
53 char payload[];
54};
55
56struct lttng_userspace_probe_location_function_comm {
57 /* Both lengths include the trailing \0. */
58 uint32_t function_name_len;
59 uint32_t binary_path_len;
60 /*
61 * Payload is composed of, in that order,
62 * - function name (with trailing \0),
63 * - absolute binary path (with trailing \0)
64 */
65 char payload[];
66} LTTNG_PACKED;
67
f4d0bb2e
FD
68struct lttng_userspace_probe_location_tracepoint_comm {
69 /* The three lengths include the trailing \0. */
70 uint32_t probe_name_len;
71 uint32_t provider_name_len;
72 uint32_t binary_path_len;
73 /*
74 * Payload is composed of, in that order,
75 * - probe name (with trailing \0),
76 * - provider name (with trailing \0),
77 * - absolute binary path (with trailing \0)
78 */
79 char payload[];
80} LTTNG_PACKED;
81
1ce46cfe
JG
82/* Common ancestor of all userspace probe locations. */
83struct lttng_userspace_probe_location {
84 enum lttng_userspace_probe_location_type type;
85 struct lttng_userspace_probe_location_lookup_method *lookup_method;
dfcfa983 86 userspace_probe_location_equal_cb equal;
1ce46cfe
JG
87};
88
89struct lttng_userspace_probe_location_function {
90 struct lttng_userspace_probe_location parent;
91 char *function_name;
92 char *binary_path;
93 /*
94 * binary_fd is a file descriptor to the executable file. It's open
95 * early on to keep the backing inode valid over the course of the
96 * intrumentation and use. It prevents deletion and reuse races.
97 * Set to -1 if not open.
98 */
99 int binary_fd;
9d3981b5 100 enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
1ce46cfe
JG
101};
102
f4d0bb2e
FD
103struct lttng_userspace_probe_location_tracepoint {
104 struct lttng_userspace_probe_location parent;
105 char *probe_name;
106 char *provider_name;
107 char *binary_path;
108 /*
109 * binary_fd is a file descriptor to the executable file. It's open
110 * early on to keep the backing inode valid over the course of the
111 * intrumentation and use. It prevents deletion and reuse races.
112 * Set to -1 if not open.
113 */
114 int binary_fd;
115};
116
1ce46cfe
JG
117LTTNG_HIDDEN
118int lttng_userspace_probe_location_serialize(
119 const struct lttng_userspace_probe_location *location,
120 struct lttng_dynamic_buffer *buffer,
121 int *binary_fd);
122
123LTTNG_HIDDEN
124int lttng_userspace_probe_location_create_from_buffer(
125 const struct lttng_buffer_view *buffer,
126 struct lttng_userspace_probe_location **probe_location);
127
128LTTNG_HIDDEN
129int lttng_userspace_probe_location_function_set_binary_fd(
130 struct lttng_userspace_probe_location *location, int binary_fd);
131
f4d0bb2e
FD
132LTTNG_HIDDEN
133int lttng_userspace_probe_location_tracepoint_set_binary_fd(
134 struct lttng_userspace_probe_location *location, int binary_fd);
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 */
141LTTNG_HIDDEN
142int lttng_userspace_probe_location_flatten(
143 const struct lttng_userspace_probe_location *location,
144 struct lttng_dynamic_buffer *buffer);
145
394357fe
FD
146LTTNG_HIDDEN
147struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
148 const struct lttng_userspace_probe_location *location);
149
dfcfa983
JR
150LTTNG_HIDDEN
151bool lttng_userspace_probe_location_lookup_method_is_equal(
152 const struct lttng_userspace_probe_location_lookup_method *a,
153 const struct lttng_userspace_probe_location_lookup_method *b);
154
155LTTNG_HIDDEN
156bool lttng_userspace_probe_location_is_equal(
157 const struct lttng_userspace_probe_location *a,
158 const struct lttng_userspace_probe_location *b);
159
1ce46cfe 160#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
This page took 0.039021 seconds and 5 git commands to generate.