Commit | Line | Data |
---|---|---|
826d496d | 1 | /* |
b7384347 DG |
2 | * lttng.h |
3 | * | |
4 | * Linux Trace Toolkit Control Library Header File | |
5 | * | |
826d496d | 6 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> |
fac6795d DG |
7 | * |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version 2 | |
11 | * of the License, or (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
fac6795d DG |
21 | */ |
22 | ||
b7384347 DG |
23 | #ifndef _LTTNG_H |
24 | #define _LTTNG_H | |
fac6795d | 25 | |
f3ed775e DG |
26 | #include <asm/types.h> |
27 | #include <stdint.h> | |
57167058 DG |
28 | #include <limits.h> |
29 | ||
b7384347 DG |
30 | /* Default unix group name for tracing. */ |
31 | #define LTTNG_DEFAULT_TRACING_GROUP "tracing" | |
fac6795d | 32 | |
b7384347 | 33 | /* Environment variable to set session daemon binary path. */ |
5b8719f5 DG |
34 | #define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH" |
35 | ||
58a97671 DG |
36 | /* Default trace output directory name */ |
37 | #define LTTNG_DEFAULT_TRACE_DIR_NAME "lttng-traces" | |
38 | ||
b7384347 | 39 | /* |
e6ddca71 | 40 | * Event symbol length. Copied from LTTng kernel ABI. |
1657e9bb | 41 | */ |
f3ed775e DG |
42 | #define LTTNG_SYMBOL_NAME_LEN 128 |
43 | ||
e6ddca71 DG |
44 | /* |
45 | * Every lttng_event_* structure both apply to kernel event and user-space | |
46 | * event. | |
47 | * | |
48 | * Every lttng_kernel_* is copied from the LTTng kernel ABI. | |
49 | */ | |
50 | ||
f3ed775e | 51 | enum lttng_event_type { |
e6ddca71 DG |
52 | LTTNG_EVENT_TRACEPOINT, |
53 | LTTNG_EVENT_KPROBE, | |
f3ed775e | 54 | LTTNG_EVENT_FUNCTION, |
1657e9bb DG |
55 | }; |
56 | ||
e6ddca71 DG |
57 | /* |
58 | * LTTng consumer mode | |
59 | */ | |
60 | enum lttng_event_output { | |
61 | /* Using splice(2) */ | |
62 | LTTNG_EVENT_SPLICE = 0, | |
63 | /* Using mmap(2) */ | |
64 | LTTNG_EVENT_MMAP = 1, | |
65 | }; | |
66 | ||
d65106b1 DG |
67 | /* Kernel context possible type */ |
68 | enum lttng_kernel_context_type { | |
69 | LTTNG_KERNEL_CONTEXT_PID = 0, | |
70 | LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, | |
71 | LTTNG_KERNEL_CONTEXT_COMM = 2, | |
72 | LTTNG_KERNEL_CONTEXT_PRIO = 3, | |
73 | LTTNG_KERNEL_CONTEXT_NICE = 4, | |
74 | LTTNG_KERNEL_CONTEXT_VPID = 5, | |
75 | LTTNG_KERNEL_CONTEXT_TID = 6, | |
76 | LTTNG_KERNEL_CONTEXT_VTID = 7, | |
77 | LTTNG_KERNEL_CONTEXT_PPID = 8, | |
78 | LTTNG_KERNEL_CONTEXT_VPPID = 9, | |
79 | }; | |
80 | ||
81 | /* Perf counter attributes */ | |
82 | struct lttng_kernel_perf_counter_ctx { | |
83 | uint32_t type; | |
84 | uint64_t config; | |
85 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
86 | }; | |
87 | ||
88 | /* Event/Channel context */ | |
89 | struct lttng_kernel_context { | |
90 | enum lttng_kernel_context_type ctx; | |
91 | union { | |
92 | struct lttng_kernel_perf_counter_ctx perf_counter; | |
93 | } u; | |
94 | }; | |
95 | ||
b7384347 | 96 | /* |
f3ed775e | 97 | * Either addr is used or symbol_name and offset. |
57167058 | 98 | */ |
f3ed775e DG |
99 | struct lttng_event_kprobe_attr { |
100 | uint64_t addr; | |
101 | ||
102 | uint64_t offset; | |
103 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
57167058 DG |
104 | }; |
105 | ||
b7384347 | 106 | /* |
f3ed775e DG |
107 | * Function tracer |
108 | */ | |
109 | struct lttng_event_function_attr { | |
110 | char symbol_name[LTTNG_SYMBOL_NAME_LEN]; | |
111 | }; | |
112 | ||
113 | /* | |
114 | * Generic lttng event | |
115 | */ | |
116 | struct lttng_event { | |
117 | char name[LTTNG_SYMBOL_NAME_LEN]; | |
118 | enum lttng_event_type type; | |
119 | /* Per event type configuration */ | |
120 | union { | |
121 | struct lttng_event_kprobe_attr kprobe; | |
122 | struct lttng_event_function_attr ftrace; | |
123 | } attr; | |
124 | }; | |
125 | ||
e6ddca71 DG |
126 | /* |
127 | * Tracer channel attributes. For both kernel and user-space. | |
128 | */ | |
f3ed775e | 129 | struct lttng_channel_attr { |
8ce37aa5 DG |
130 | int overwrite; /* 1: overwrite, 0: discard */ |
131 | uint64_t subbuf_size; /* bytes */ | |
132 | uint64_t num_subbuf; /* power of 2 */ | |
133 | unsigned int switch_timer_interval; /* usec */ | |
134 | unsigned int read_timer_interval; /* usec */ | |
e6ddca71 | 135 | enum lttng_event_output output; /* splice, mmap */ |
f3ed775e DG |
136 | }; |
137 | ||
138 | /* | |
e6ddca71 | 139 | * Channel information structure. For both kernel and user-space. |
1657e9bb | 140 | */ |
e6ddca71 | 141 | struct lttng_channel { |
1657e9bb | 142 | char name[NAME_MAX]; |
e6ddca71 | 143 | struct lttng_channel_attr attr; |
f3ed775e DG |
144 | }; |
145 | ||
e6ddca71 DG |
146 | /* |
147 | * Basic session information. | |
148 | * | |
149 | * This is an 'output data' meaning that it only comes *from* the session | |
150 | * daemon *to* the lttng client. It's basically a 'human' representation of | |
151 | * tracing entities (here a session). | |
152 | */ | |
153 | struct lttng_session { | |
f3ed775e | 154 | char name[NAME_MAX]; |
e6ddca71 DG |
155 | /* The path where traces are written */ |
156 | char path[PATH_MAX]; | |
1657e9bb DG |
157 | }; |
158 | ||
b7384347 DG |
159 | /* |
160 | * Session daemon control | |
161 | */ | |
b7384347 | 162 | extern int lttng_connect_sessiond(void); |
f3ed775e DG |
163 | |
164 | extern int lttng_create_session(char *name, char *path); | |
165 | ||
166 | extern int lttng_destroy_session(char *name); | |
167 | ||
87378cf5 | 168 | extern int lttng_disconnect_sessiond(void); |
f3ed775e | 169 | |
e6ddca71 DG |
170 | /* |
171 | * Return a "lttng_session" array. Caller must free(3) the returned data. | |
172 | */ | |
ca95a216 | 173 | extern int lttng_list_sessions(struct lttng_session **sessions); |
f3ed775e | 174 | |
947308c4 | 175 | extern int lttng_session_daemon_alive(void); |
f3ed775e | 176 | |
b7384347 DG |
177 | /* Set tracing group for the current execution */ |
178 | extern int lttng_set_tracing_group(const char *name); | |
f3ed775e DG |
179 | |
180 | extern void lttng_set_session_name(char *name); | |
181 | ||
b7384347 DG |
182 | extern const char *lttng_get_readable_code(int code); |
183 | ||
f3ed775e DG |
184 | extern int lttng_start_tracing(char *session_name); |
185 | ||
186 | extern int lttng_stop_tracing(char *session_name); | |
187 | ||
b7384347 | 188 | /* |
f3ed775e | 189 | * LTTng Kernel tracer control |
b7384347 | 190 | */ |
d65106b1 DG |
191 | extern int lttng_kernel_add_context(struct lttng_kernel_context *ctx, |
192 | char *event_name, char *channel_name); | |
193 | ||
f3ed775e DG |
194 | extern int lttng_kernel_create_channel(struct lttng_channel *chan); |
195 | ||
196 | extern int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name); | |
197 | ||
198 | extern int lttng_kernel_enable_channel(char *name); | |
199 | ||
200 | extern int lttng_kernel_disable_event(char *name, char *channel_name); | |
201 | ||
202 | extern int lttng_kernel_disable_channel(char *name); | |
203 | ||
204 | extern int lttng_kernel_list_events(char **event_list); | |
fac6795d | 205 | |
1df4dedd | 206 | /* |
f3ed775e | 207 | * LTTng User-space tracer control |
1df4dedd | 208 | */ |
1df4dedd | 209 | |
e6ddca71 DG |
210 | //extern int lttng_ust_list_traceable_apps(pid_t **pids); |
211 | ||
b7384347 | 212 | #endif /* _LTTNG_H */ |