Fix: accept 65536 bytes long bytecodes
[lttng-ust.git] / include / lttng / ust-abi.h
... / ...
CommitLineData
1#ifndef _LTTNG_UST_ABI_H
2#define _LTTNG_UST_ABI_H
3
4/*
5 * lttng/ust-abi.h
6 *
7 * LTTng-UST ABI header
8 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 */
21
22#include <stdint.h>
23
24#define LTTNG_UST_SYM_NAME_LEN 256
25
26/* Version for comm protocol between sessiond and ust */
27#define LTTNG_UST_COMM_VERSION_MAJOR 2
28#define LTTNG_UST_COMM_VERSION_MINOR 0
29
30/* Version for ABI between liblttng-ust, sessiond, consumerd */
31#define LTTNG_UST_INTERNAL_MAJOR_VERSION 3
32#define LTTNG_UST_INTERNAL_MINOR_VERSION 0
33#define LTTNG_UST_INTERNAL_PATCHLEVEL_VERSION 0
34
35enum lttng_ust_instrumentation {
36 LTTNG_UST_TRACEPOINT = 0,
37 LTTNG_UST_PROBE = 1,
38 LTTNG_UST_FUNCTION = 2,
39};
40
41enum lttng_ust_loglevel_type {
42 LTTNG_UST_LOGLEVEL_ALL = 0,
43 LTTNG_UST_LOGLEVEL_RANGE = 1,
44 LTTNG_UST_LOGLEVEL_SINGLE = 2,
45};
46
47enum lttng_ust_output {
48 LTTNG_UST_MMAP = 0,
49};
50
51struct lttng_ust_tracer_version {
52 uint32_t major;
53 uint32_t minor;
54 uint32_t patchlevel;
55};
56
57#define LTTNG_UST_CHANNEL_PADDING LTTNG_UST_SYM_NAME_LEN + 32
58struct lttng_ust_channel {
59 int overwrite; /* 1: overwrite, 0: discard */
60 uint64_t subbuf_size; /* in bytes */
61 uint64_t num_subbuf;
62 unsigned int switch_timer_interval; /* usecs */
63 unsigned int read_timer_interval; /* usecs */
64 enum lttng_ust_output output; /* output mode */
65 char padding[LTTNG_UST_CHANNEL_PADDING];
66};
67
68#define LTTNG_UST_STREAM_PADDING1 16
69#define LTTNG_UST_STREAM_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
70struct lttng_ust_stream {
71 char padding[LTTNG_UST_STREAM_PADDING1];
72
73 union {
74 char padding[LTTNG_UST_STREAM_PADDING2];
75 } u;
76};
77
78#define LTTNG_UST_EVENT_PADDING1 16
79#define LTTNG_UST_EVENT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
80struct lttng_ust_event {
81 enum lttng_ust_instrumentation instrumentation;
82 char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */
83
84 enum lttng_ust_loglevel_type loglevel_type;
85 int loglevel; /* value, -1: all */
86 char padding[LTTNG_UST_EVENT_PADDING1];
87
88 /* Per instrumentation type configuration */
89 union {
90 char padding[LTTNG_UST_EVENT_PADDING2];
91 } u;
92};
93
94enum lttng_ust_field_type {
95 LTTNG_UST_FIELD_OTHER = 0,
96 LTTNG_UST_FIELD_INTEGER = 1,
97 LTTNG_UST_FIELD_ENUM = 2,
98 LTTNG_UST_FIELD_FLOAT = 3,
99 LTTNG_UST_FIELD_STRING = 4,
100};
101
102#define LTTNG_UST_FIELD_ITER_PADDING LTTNG_UST_SYM_NAME_LEN + 32
103struct lttng_ust_field_iter {
104 char event_name[LTTNG_UST_SYM_NAME_LEN];
105 char field_name[LTTNG_UST_SYM_NAME_LEN];
106 enum lttng_ust_field_type type;
107 int loglevel; /* event loglevel */
108 char padding[LTTNG_UST_FIELD_ITER_PADDING];
109};
110
111enum lttng_ust_context_type {
112 LTTNG_UST_CONTEXT_VTID = 0,
113 LTTNG_UST_CONTEXT_VPID = 1,
114 LTTNG_UST_CONTEXT_PTHREAD_ID = 2,
115 LTTNG_UST_CONTEXT_PROCNAME = 3,
116};
117
118#define LTTNG_UST_CONTEXT_PADDING1 16
119#define LTTNG_UST_CONTEXT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
120struct lttng_ust_context {
121 enum lttng_ust_context_type ctx;
122 char padding[LTTNG_UST_CONTEXT_PADDING1];
123
124 union {
125 char padding[LTTNG_UST_CONTEXT_PADDING2];
126 } u;
127};
128
129/*
130 * Tracer channel attributes.
131 */
132#define LTTNG_UST_CHANNEL_ATTR_PADDING LTTNG_UST_SYM_NAME_LEN + 32
133struct lttng_ust_channel_attr {
134 int overwrite; /* 1: overwrite, 0: discard */
135 uint64_t subbuf_size; /* bytes */
136 uint64_t num_subbuf; /* power of 2 */
137 unsigned int switch_timer_interval; /* usec */
138 unsigned int read_timer_interval; /* usec */
139 enum lttng_ust_output output; /* splice, mmap */
140 char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
141};
142
143#define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
144struct lttng_ust_tracepoint_iter {
145 char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */
146 int loglevel;
147 char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
148};
149
150#define LTTNG_UST_OBJECT_DATA_PADDING LTTNG_UST_SYM_NAME_LEN + 32
151struct lttng_ust_object_data {
152 int handle;
153 int shm_fd;
154 int wait_fd;
155 uint64_t memory_map_size;
156 char padding[LTTNG_UST_OBJECT_DATA_PADDING];
157};
158
159enum lttng_ust_calibrate_type {
160 LTTNG_UST_CALIBRATE_TRACEPOINT,
161};
162
163#define LTTNG_UST_CALIBRATE_PADDING1 16
164#define LTTNG_UST_CALIBRATE_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
165struct lttng_ust_calibrate {
166 enum lttng_ust_calibrate_type type; /* type (input) */
167 char padding[LTTNG_UST_CALIBRATE_PADDING1];
168
169 union {
170 char padding[LTTNG_UST_CALIBRATE_PADDING2];
171 } u;
172};
173
174#define FILTER_BYTECODE_MAX_LEN 65536
175struct lttng_ust_filter_bytecode {
176 uint16_t len;
177 uint16_t reloc_offset;
178 char data[0];
179};
180
181#define _UST_CMD(minor) (minor)
182#define _UST_CMDR(minor, type) (minor)
183#define _UST_CMDW(minor, type) (minor)
184
185/* Handled by object descriptor */
186#define LTTNG_UST_RELEASE _UST_CMD(0x1)
187
188/* Handled by object cmd */
189
190/* LTTng-UST commands */
191#define LTTNG_UST_SESSION _UST_CMD(0x40)
192#define LTTNG_UST_TRACER_VERSION \
193 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
194#define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
195#define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
196#define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
197#define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45)
198
199/* Session FD commands */
200#define LTTNG_UST_METADATA \
201 _UST_CMDW(0x50, struct lttng_ust_channel)
202#define LTTNG_UST_CHANNEL \
203 _UST_CMDW(0x51, struct lttng_ust_channel)
204#define LTTNG_UST_SESSION_START _UST_CMD(0x52)
205#define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
206
207/* Channel FD commands */
208#define LTTNG_UST_STREAM _UST_CMD(0x60)
209#define LTTNG_UST_EVENT \
210 _UST_CMDW(0x61, struct lttng_ust_event)
211
212/* Event and Channel FD commands */
213#define LTTNG_UST_CONTEXT \
214 _UST_CMDW(0x70, struct lttng_ust_context)
215#define LTTNG_UST_FLUSH_BUFFER \
216 _UST_CMD(0x71)
217
218/* Event, Channel and Session commands */
219#define LTTNG_UST_ENABLE _UST_CMD(0x80)
220#define LTTNG_UST_DISABLE _UST_CMD(0x81)
221
222/* Tracepoint list commands */
223#define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
224#define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91)
225
226/* Event FD commands */
227#define LTTNG_UST_FILTER _UST_CMD(0xA0)
228
229#define LTTNG_UST_ROOT_HANDLE 0
230
231struct lttng_ust_obj;
232
233union ust_args {
234 struct {
235 int *shm_fd;
236 int *wait_fd;
237 uint64_t *memory_map_size;
238 } channel;
239 struct {
240 int *shm_fd;
241 int *wait_fd;
242 uint64_t *memory_map_size;
243 } stream;
244 struct {
245 struct lttng_ust_field_iter entry;
246 } field_list;
247};
248
249struct lttng_ust_objd_ops {
250 long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
251 union ust_args *args);
252 int (*release)(int objd);
253};
254
255/* Create root handle. Always ID 0. */
256int lttng_abi_create_root_handle(void);
257
258const struct lttng_ust_objd_ops *objd_ops(int id);
259int lttng_ust_objd_unref(int id);
260
261void lttng_ust_abi_exit(void);
262void lttng_ust_events_exit(void);
263
264#endif /* _LTTNG_UST_ABI_H */
This page took 0.023146 seconds and 4 git commands to generate.