Commit | Line | Data |
---|---|---|
9f3fdbc6 MD |
1 | #ifndef _LTTNG_UST_ABI_H |
2 | #define _LTTNG_UST_ABI_H | |
3 | ||
4 | /* | |
4318ae1b | 5 | * lttng/ust-abi.h |
9f3fdbc6 | 6 | * |
9f3fdbc6 MD |
7 | * LTTng-UST ABI header |
8 | * | |
e92f3e28 MD |
9 | * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
10 | * | |
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
12 | * of this software and associated documentation files (the "Software"), to deal | |
13 | * in the Software without restriction, including without limitation the rights | |
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
15 | * copies of the Software, and to permit persons to whom the Software is | |
16 | * furnished to do so, subject to the following conditions: | |
a60d70e6 | 17 | * |
e92f3e28 MD |
18 | * The above copyright notice and this permission notice shall be included in |
19 | * all copies or substantial portions of the Software. | |
9f3fdbc6 MD |
20 | */ |
21 | ||
0a42beb6 MD |
22 | #include <stdint.h> |
23 | ||
f56cd1d5 | 24 | #define LTTNG_UST_SYM_NAME_LEN 256 |
9f3fdbc6 | 25 | |
1332bb04 MD |
26 | #define LTTNG_UST_COMM_VERSION_MAJOR 2 |
27 | #define LTTNG_UST_COMM_VERSION_MINOR 0 | |
b35d179d | 28 | |
9f3fdbc6 | 29 | enum lttng_ust_instrumentation { |
df854e41 MD |
30 | LTTNG_UST_TRACEPOINT = 0, |
31 | LTTNG_UST_PROBE = 1, | |
32 | LTTNG_UST_FUNCTION = 2, | |
6b0e60f1 MD |
33 | }; |
34 | ||
35 | enum lttng_ust_loglevel_type { | |
882a56d7 MD |
36 | LTTNG_UST_LOGLEVEL_ALL = 0, |
37 | LTTNG_UST_LOGLEVEL_RANGE = 1, | |
38 | LTTNG_UST_LOGLEVEL_SINGLE = 2, | |
9f3fdbc6 MD |
39 | }; |
40 | ||
9f3fdbc6 | 41 | enum lttng_ust_output { |
b35d179d | 42 | LTTNG_UST_MMAP = 0, |
9f3fdbc6 MD |
43 | }; |
44 | ||
b35d179d | 45 | struct lttng_ust_tracer_version { |
b728d87e MD |
46 | uint32_t major; |
47 | uint32_t minor; | |
b35d179d | 48 | uint32_t patchlevel; |
b35d179d | 49 | }; |
9f3fdbc6 | 50 | |
1332bb04 | 51 | #define LTTNG_UST_CHANNEL_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
9f3fdbc6 MD |
52 | struct lttng_ust_channel { |
53 | int overwrite; /* 1: overwrite, 0: discard */ | |
54 | uint64_t subbuf_size; /* in bytes */ | |
55 | uint64_t num_subbuf; | |
56 | unsigned int switch_timer_interval; /* usecs */ | |
57 | unsigned int read_timer_interval; /* usecs */ | |
b35d179d | 58 | enum lttng_ust_output output; /* output mode */ |
1332bb04 | 59 | char padding[LTTNG_UST_CHANNEL_PADDING]; |
9f3fdbc6 MD |
60 | }; |
61 | ||
1332bb04 MD |
62 | #define LTTNG_UST_STREAM_PADDING1 16 |
63 | #define LTTNG_UST_STREAM_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
381c0f1e | 64 | struct lttng_ust_stream { |
1332bb04 MD |
65 | char padding[LTTNG_UST_STREAM_PADDING1]; |
66 | ||
67 | union { | |
68 | char padding[LTTNG_UST_STREAM_PADDING2]; | |
69 | } u; | |
381c0f1e MD |
70 | }; |
71 | ||
1332bb04 MD |
72 | #define LTTNG_UST_EVENT_PADDING1 16 |
73 | #define LTTNG_UST_EVENT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
9f3fdbc6 | 74 | struct lttng_ust_event { |
9f3fdbc6 | 75 | enum lttng_ust_instrumentation instrumentation; |
6b0e60f1 MD |
76 | char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ |
77 | ||
78 | enum lttng_ust_loglevel_type loglevel_type; | |
882a56d7 | 79 | int loglevel; /* value, -1: all */ |
1332bb04 | 80 | char padding[LTTNG_UST_EVENT_PADDING1]; |
6b0e60f1 | 81 | |
9f3fdbc6 MD |
82 | /* Per instrumentation type configuration */ |
83 | union { | |
1332bb04 | 84 | char padding[LTTNG_UST_EVENT_PADDING2]; |
9f3fdbc6 MD |
85 | } u; |
86 | }; | |
87 | ||
06d4f27e MD |
88 | enum lttng_ust_field_type { |
89 | LTTNG_UST_FIELD_OTHER = 0, | |
90 | LTTNG_UST_FIELD_INTEGER = 1, | |
91 | LTTNG_UST_FIELD_ENUM = 2, | |
92 | LTTNG_UST_FIELD_FLOAT = 3, | |
93 | LTTNG_UST_FIELD_STRING = 4, | |
94 | }; | |
95 | ||
96 | #define LTTNG_UST_FIELD_ITER_PADDING LTTNG_UST_SYM_NAME_LEN + 32 | |
97 | struct lttng_ust_field_iter { | |
98 | char event_name[LTTNG_UST_SYM_NAME_LEN]; | |
99 | char field_name[LTTNG_UST_SYM_NAME_LEN]; | |
100 | enum lttng_ust_field_type type; | |
101 | int loglevel; /* event loglevel */ | |
102 | char padding[LTTNG_UST_FIELD_ITER_PADDING]; | |
103 | }; | |
104 | ||
9f3fdbc6 | 105 | enum lttng_ust_context_type { |
3b402b40 | 106 | LTTNG_UST_CONTEXT_VTID = 0, |
c1ef86f0 MD |
107 | LTTNG_UST_CONTEXT_VPID = 1, |
108 | LTTNG_UST_CONTEXT_PTHREAD_ID = 2, | |
4847e9bb | 109 | LTTNG_UST_CONTEXT_PROCNAME = 3, |
9f3fdbc6 MD |
110 | }; |
111 | ||
1332bb04 MD |
112 | #define LTTNG_UST_CONTEXT_PADDING1 16 |
113 | #define LTTNG_UST_CONTEXT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
9f3fdbc6 MD |
114 | struct lttng_ust_context { |
115 | enum lttng_ust_context_type ctx; | |
1332bb04 MD |
116 | char padding[LTTNG_UST_CONTEXT_PADDING1]; |
117 | ||
9f3fdbc6 | 118 | union { |
1332bb04 | 119 | char padding[LTTNG_UST_CONTEXT_PADDING2]; |
9f3fdbc6 MD |
120 | } u; |
121 | }; | |
122 | ||
92462b01 MD |
123 | /* |
124 | * Tracer channel attributes. | |
125 | */ | |
1332bb04 | 126 | #define LTTNG_UST_CHANNEL_ATTR_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
92462b01 MD |
127 | struct lttng_ust_channel_attr { |
128 | int overwrite; /* 1: overwrite, 0: discard */ | |
129 | uint64_t subbuf_size; /* bytes */ | |
130 | uint64_t num_subbuf; /* power of 2 */ | |
131 | unsigned int switch_timer_interval; /* usec */ | |
132 | unsigned int read_timer_interval; /* usec */ | |
133 | enum lttng_ust_output output; /* splice, mmap */ | |
1332bb04 | 134 | char padding[LTTNG_UST_CHANNEL_ATTR_PADDING]; |
92462b01 MD |
135 | }; |
136 | ||
1332bb04 | 137 | #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16 |
cbef6901 MD |
138 | struct lttng_ust_tracepoint_iter { |
139 | char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */ | |
882a56d7 | 140 | int loglevel; |
1332bb04 | 141 | char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING]; |
cbef6901 MD |
142 | }; |
143 | ||
1332bb04 | 144 | #define LTTNG_UST_OBJECT_DATA_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
92462b01 MD |
145 | struct lttng_ust_object_data { |
146 | int handle; | |
147 | int shm_fd; | |
148 | int wait_fd; | |
149 | uint64_t memory_map_size; | |
1332bb04 | 150 | char padding[LTTNG_UST_OBJECT_DATA_PADDING]; |
92462b01 MD |
151 | }; |
152 | ||
d9a9a33b MD |
153 | enum lttng_ust_calibrate_type { |
154 | LTTNG_UST_CALIBRATE_TRACEPOINT, | |
155 | }; | |
156 | ||
1332bb04 MD |
157 | #define LTTNG_UST_CALIBRATE_PADDING1 16 |
158 | #define LTTNG_UST_CALIBRATE_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
d9a9a33b MD |
159 | struct lttng_ust_calibrate { |
160 | enum lttng_ust_calibrate_type type; /* type (input) */ | |
1332bb04 MD |
161 | char padding[LTTNG_UST_CALIBRATE_PADDING1]; |
162 | ||
163 | union { | |
164 | char padding[LTTNG_UST_CALIBRATE_PADDING2]; | |
165 | } u; | |
d9a9a33b MD |
166 | }; |
167 | ||
cd54f6d9 | 168 | #define FILTER_BYTECODE_MAX_LEN 65535 |
2d78951a MD |
169 | struct lttng_ust_filter_bytecode { |
170 | uint16_t len; | |
cd54f6d9 | 171 | uint16_t reloc_offset; |
2d78951a MD |
172 | char data[0]; |
173 | }; | |
174 | ||
9f3fdbc6 MD |
175 | #define _UST_CMD(minor) (minor) |
176 | #define _UST_CMDR(minor, type) (minor) | |
177 | #define _UST_CMDW(minor, type) (minor) | |
178 | ||
46050b1a MD |
179 | /* Handled by object descriptor */ |
180 | #define LTTNG_UST_RELEASE _UST_CMD(0x1) | |
181 | ||
182 | /* Handled by object cmd */ | |
183 | ||
9f3fdbc6 MD |
184 | /* LTTng-UST commands */ |
185 | #define LTTNG_UST_SESSION _UST_CMD(0x40) | |
186 | #define LTTNG_UST_TRACER_VERSION \ | |
187 | _UST_CMDR(0x41, struct lttng_ust_tracer_version) | |
188 | #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42) | |
189 | #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43) | |
11ff9c7d | 190 | #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44) |
06d4f27e | 191 | #define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45) |
9f3fdbc6 | 192 | |
46050b1a | 193 | /* Session FD commands */ |
9f3fdbc6 MD |
194 | #define LTTNG_UST_METADATA \ |
195 | _UST_CMDW(0x50, struct lttng_ust_channel) | |
196 | #define LTTNG_UST_CHANNEL \ | |
197 | _UST_CMDW(0x51, struct lttng_ust_channel) | |
198 | #define LTTNG_UST_SESSION_START _UST_CMD(0x52) | |
199 | #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) | |
200 | ||
46050b1a | 201 | /* Channel FD commands */ |
9f3fdbc6 MD |
202 | #define LTTNG_UST_STREAM _UST_CMD(0x60) |
203 | #define LTTNG_UST_EVENT \ | |
204 | _UST_CMDW(0x61, struct lttng_ust_event) | |
205 | ||
46050b1a | 206 | /* Event and Channel FD commands */ |
9f3fdbc6 MD |
207 | #define LTTNG_UST_CONTEXT \ |
208 | _UST_CMDW(0x70, struct lttng_ust_context) | |
43d330a4 | 209 | #define LTTNG_UST_FLUSH_BUFFER \ |
43861eab | 210 | _UST_CMD(0x71) |
9f3fdbc6 | 211 | |
46050b1a | 212 | /* Event, Channel and Session commands */ |
9f3fdbc6 MD |
213 | #define LTTNG_UST_ENABLE _UST_CMD(0x80) |
214 | #define LTTNG_UST_DISABLE _UST_CMD(0x81) | |
215 | ||
51489cad MD |
216 | /* Tracepoint list commands */ |
217 | #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90) | |
06d4f27e | 218 | #define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91) |
51489cad | 219 | |
2d78951a MD |
220 | /* Event FD commands */ |
221 | #define LTTNG_UST_FILTER _UST_CMD(0xA0) | |
222 | ||
46050b1a MD |
223 | #define LTTNG_UST_ROOT_HANDLE 0 |
224 | ||
b61ce3b2 | 225 | struct lttng_ust_obj; |
46050b1a | 226 | |
ef9ff354 MD |
227 | union ust_args { |
228 | struct { | |
229 | int *shm_fd; | |
230 | int *wait_fd; | |
231 | uint64_t *memory_map_size; | |
232 | } channel; | |
233 | struct { | |
234 | int *shm_fd; | |
235 | int *wait_fd; | |
236 | uint64_t *memory_map_size; | |
237 | } stream; | |
40003310 MD |
238 | struct { |
239 | struct lttng_ust_field_iter entry; | |
240 | } field_list; | |
ef9ff354 MD |
241 | }; |
242 | ||
b61ce3b2 | 243 | struct lttng_ust_objd_ops { |
ef9ff354 MD |
244 | long (*cmd)(int objd, unsigned int cmd, unsigned long arg, |
245 | union ust_args *args); | |
46050b1a MD |
246 | int (*release)(int objd); |
247 | }; | |
248 | ||
249 | /* Create root handle. Always ID 0. */ | |
250 | int lttng_abi_create_root_handle(void); | |
251 | ||
b61ce3b2 | 252 | const struct lttng_ust_objd_ops *objd_ops(int id); |
d4419b81 | 253 | int lttng_ust_objd_unref(int id); |
46050b1a MD |
254 | |
255 | void lttng_ust_abi_exit(void); | |
003fedf4 | 256 | void lttng_ust_events_exit(void); |
b35d179d | 257 | |
9f3fdbc6 | 258 | #endif /* _LTTNG_UST_ABI_H */ |