Fix: abort on unknown location type in destructor
[lttng-tools.git] / include / lttng / userspace-probe.h
CommitLineData
1ce46cfe
JG
1/*
2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18#ifndef LTTNG_USERSPACE_PROBE_H
19#define LTTNG_USERSPACE_PROBE_H
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*
26 * Userspace probe lookup methods specifies how the userspace probe location
27 * specified by the user should be interpreted.
28 */
29struct lttng_userspace_probe_location_lookup_method;
30
31enum lttng_userspace_probe_location_lookup_method_type {
32 LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_UNKNOWN = -1,
33 LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT = 0,
34 LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF = 1,
f4d0bb2e 35 LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT = 2,
1ce46cfe
JG
36};
37
38/*
39 * Get the type of a lookup method.
40 */
41extern enum lttng_userspace_probe_location_lookup_method_type
42lttng_userspace_probe_location_lookup_method_get_type(
43 const struct lttng_userspace_probe_location_lookup_method *lookup_method);
44
45/*
46 * Destroy a lookup method.
47 */
48extern void lttng_userspace_probe_location_lookup_method_destroy(
49 struct lttng_userspace_probe_location_lookup_method *lookup_method);
50
51/*
52 * Create a tracepoint ELF function lookup method struct.
53 * Return NULL on failure.
54 */
55extern struct lttng_userspace_probe_location_lookup_method *
56lttng_userspace_probe_location_lookup_method_function_elf_create(void);
57
f4d0bb2e
FD
58/*
59 * Create a tracepoint SDT tracepoint lookup method struct.
60 * Return NULL on failure.
61 */
62extern struct lttng_userspace_probe_location_lookup_method *
63lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(void);
64
1ce46cfe
JG
65
66/*
67 * Contains all the information needed to compute the instrumentation point in
68 * the binary. It is used in conjonction with a lookup method.
69 */
70struct lttng_userspace_probe_location;
71
72enum lttng_userspace_probe_location_type {
73 LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN = -1,
74 LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION = 0,
f4d0bb2e 75 LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT = 1,
1ce46cfe
JG
76};
77
78/*
79 * Get the type of the userspace probe location.
80 */
81extern enum lttng_userspace_probe_location_type
82lttng_userspace_probe_location_get_type(
83 const struct lttng_userspace_probe_location *location);
84
85/*
86 * Destroy the userspace probe location.
87 */
88extern void lttng_userspace_probe_location_destroy(
89 struct lttng_userspace_probe_location *location);
90
91/*
92 * Create a probe location of the function type.
93 * Receives the target binary file path and function to instrument.
94 * On failure, NULL is returned.
95 *
96 * The ownership of the lookup method is transferred to the created probe
97 * location.
98 */
99extern struct lttng_userspace_probe_location *
100lttng_userspace_probe_location_function_create(const char *binary_path,
101 const char *function_name,
102 struct lttng_userspace_probe_location_lookup_method *lookup_method);
103
104/*
105 * Get the target binary path of the probe location of the function type.
106 */
107extern const char *lttng_userspace_probe_location_function_get_binary_path(
108 const struct lttng_userspace_probe_location *location);
109
110/*
111 * Get the target function type of the probe location of the function type.
112 */
113extern const char *lttng_userspace_probe_location_function_get_function_name(
114 const struct lttng_userspace_probe_location *location);
115
394357fe
FD
116/*
117 * Get the FD to the target binary file to the probe location of the function
118 * type.
119 */
120extern int lttng_userspace_probe_location_function_get_binary_fd(
121 const struct lttng_userspace_probe_location *location);
122
1ce46cfe
JG
123/*
124 * Get the lookup method of the given userspace probe location.
125 * Returns NULL if the probe location type is unsupported.
126 *
127 * The ownership of the lookup method is NOT transferred to the caller.
128 */
87597c2c 129extern const struct lttng_userspace_probe_location_lookup_method *
1ce46cfe
JG
130lttng_userspace_probe_location_get_lookup_method(
131 const struct lttng_userspace_probe_location *location);
132
f4d0bb2e
FD
133/*
134 * Create a probe location of the tracepoint type.
135 * Receives the target binary file path, probename and probe provider to
136 * instrument.
137 * On failure, NULL is returned.
138 *
139 * The ownership of the lookup method is transferred to the created probe
140 * location.
141 */
142extern struct lttng_userspace_probe_location *
143lttng_userspace_probe_location_tracepoint_create(const char *binary_path,
144 const char *probe_name, const char *provider_name,
145 struct lttng_userspace_probe_location_lookup_method *lookup_method);
146
147/*
148 * Get the target binary path of the probe location of the tracepoint type.
149 */
150extern const char *lttng_userspace_probe_location_tracepoint_get_binary_path(
151 const struct lttng_userspace_probe_location *location);
152
153/*
154 * Get the target probe name of the probe location of the tracepoint type.
155 */
156extern const char *lttng_userspace_probe_location_tracepoint_get_probe_name(
157 const struct lttng_userspace_probe_location *location);
158
159/*
160 * Get the target probe provider name of the probe location of the tracepoint
161 * type.
162 */
163extern const char *lttng_userspace_probe_location_tracepoint_get_provider_name(
164 const struct lttng_userspace_probe_location *location);
165
166/*
167 * Get the FD to the target binary file to the probe location of the tracepoint
168 * type.
169 */
170extern int lttng_userspace_probe_location_tracepoint_get_binary_fd(
171 const struct lttng_userspace_probe_location *location);
172
1ce46cfe
JG
173#ifdef __cplusplus
174}
175#endif
176
177#endif /* LTTNG_USERSPACE_PROBE_H */
This page took 0.030068 seconds and 4 git commands to generate.