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