Close stream and channel file descriptors as soon as passed to sessiond
[lttng-ust.git] / include / lttng / ust-abi.h
1 #ifndef _LTTNG_UST_ABI_H
2 #define _LTTNG_UST_ABI_H
3
4 /*
5 * lttng/ust-abi.h
6 *
7 * Copyright 2010-2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * LTTng-UST ABI header
10 *
11 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
12 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
13 *
14 * Permission is hereby granted to use or copy this program
15 * for any purpose, provided the above notices are retained on all copies.
16 * Permission to modify the code and to distribute modified code is granted,
17 * provided the above notices are retained, and a notice that the code was
18 * modified is included with the above copyright notice.
19 */
20
21 #include <stdint.h>
22
23 #define LTTNG_UST_SYM_NAME_LEN 256
24
25 #define LTTNG_UST_COMM_VERSION_MAJOR 0
26 #define LTTNG_UST_COMM_VERSION_MINOR 1
27
28 enum lttng_ust_instrumentation {
29 LTTNG_UST_TRACEPOINT = 0,
30 LTTNG_UST_PROBE = 1,
31 LTTNG_UST_FUNCTION = 2,
32 LTTNG_UST_TRACEPOINT_LOGLEVEL = 3,
33 };
34
35 enum lttng_ust_output {
36 LTTNG_UST_MMAP = 0,
37 };
38
39 struct lttng_ust_tracer_version {
40 uint32_t major;
41 uint32_t minor;
42 uint32_t patchlevel;
43 };
44
45 struct lttng_ust_channel {
46 int overwrite; /* 1: overwrite, 0: discard */
47 uint64_t subbuf_size; /* in bytes */
48 uint64_t num_subbuf;
49 unsigned int switch_timer_interval; /* usecs */
50 unsigned int read_timer_interval; /* usecs */
51 enum lttng_ust_output output; /* output mode */
52 };
53
54 /*
55 * This structure is only used internally within UST. It is not per-se
56 * part of the communication between sessiond and UST.
57 */
58 struct lttng_ust_stream {
59 int shm_fd;
60 int wait_fd;
61 uint64_t memory_map_size;
62 };
63
64 struct lttng_ust_event {
65 char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */
66 enum lttng_ust_instrumentation instrumentation;
67 /* Per instrumentation type configuration */
68 union {
69 } u;
70 };
71
72 enum lttng_ust_context_type {
73 LTTNG_UST_CONTEXT_VTID = 0,
74 LTTNG_UST_CONTEXT_VPID = 1,
75 LTTNG_UST_CONTEXT_PTHREAD_ID = 2,
76 LTTNG_UST_CONTEXT_PROCNAME = 3,
77 };
78
79 struct lttng_ust_context {
80 enum lttng_ust_context_type ctx;
81 union {
82 } u;
83 };
84
85 /*
86 * Tracer channel attributes.
87 */
88 struct lttng_ust_channel_attr {
89 int overwrite; /* 1: overwrite, 0: discard */
90 uint64_t subbuf_size; /* bytes */
91 uint64_t num_subbuf; /* power of 2 */
92 unsigned int switch_timer_interval; /* usec */
93 unsigned int read_timer_interval; /* usec */
94 enum lttng_ust_output output; /* splice, mmap */
95 };
96
97 struct lttng_ust_tracepoint_iter {
98 char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */
99 char loglevel[LTTNG_UST_SYM_NAME_LEN]; /* loglevel */
100 int64_t loglevel_value;
101 };
102
103 struct lttng_ust_object_data {
104 int handle;
105 int shm_fd;
106 int wait_fd;
107 uint64_t memory_map_size;
108 };
109
110 #define _UST_CMD(minor) (minor)
111 #define _UST_CMDR(minor, type) (minor)
112 #define _UST_CMDW(minor, type) (minor)
113
114 /* Handled by object descriptor */
115 #define LTTNG_UST_RELEASE _UST_CMD(0x1)
116
117 /* Handled by object cmd */
118
119 /* LTTng-UST commands */
120 #define LTTNG_UST_SESSION _UST_CMD(0x40)
121 #define LTTNG_UST_TRACER_VERSION \
122 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
123 #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
124 #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
125 #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
126
127 /* Session FD commands */
128 #define LTTNG_UST_METADATA \
129 _UST_CMDW(0x50, struct lttng_ust_channel)
130 #define LTTNG_UST_CHANNEL \
131 _UST_CMDW(0x51, struct lttng_ust_channel)
132 #define LTTNG_UST_SESSION_START _UST_CMD(0x52)
133 #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
134
135 /* Channel FD commands */
136 #define LTTNG_UST_STREAM _UST_CMD(0x60)
137 #define LTTNG_UST_EVENT \
138 _UST_CMDW(0x61, struct lttng_ust_event)
139
140 /* Event and Channel FD commands */
141 #define LTTNG_UST_CONTEXT \
142 _UST_CMDW(0x70, struct lttng_ust_context)
143 #define LTTNG_UST_FLUSH_BUFFER \
144 _UST_CMD(0x71)
145
146 /* Event, Channel and Session commands */
147 #define LTTNG_UST_ENABLE _UST_CMD(0x80)
148 #define LTTNG_UST_DISABLE _UST_CMD(0x81)
149
150 /* Tracepoint list commands */
151 #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
152
153 #define LTTNG_UST_ROOT_HANDLE 0
154
155 struct lttng_ust_obj;
156
157 union ust_args {
158 struct {
159 int *shm_fd;
160 int *wait_fd;
161 uint64_t *memory_map_size;
162 } channel;
163 struct {
164 int *shm_fd;
165 int *wait_fd;
166 uint64_t *memory_map_size;
167 } stream;
168 };
169
170 struct lttng_ust_objd_ops {
171 long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
172 union ust_args *args);
173 int (*release)(int objd);
174 };
175
176 /* Create root handle. Always ID 0. */
177 int lttng_abi_create_root_handle(void);
178
179 const struct lttng_ust_objd_ops *objd_ops(int id);
180 int lttng_ust_objd_unref(int id);
181
182 void lttng_ust_abi_exit(void);
183 void lttng_ust_events_exit(void);
184
185 #endif /* _LTTNG_UST_ABI_H */
This page took 0.03231 seconds and 4 git commands to generate.