d7799780a793148bacb47e4aed8a9bf13ba32443
[lttng-tools.git] / include / lttng / lttng.h
1 /*
2 * lttng.h
3 *
4 * Linux Trace Toolkit Control Library Header File
5 *
6 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
21 */
22
23 #ifndef _LTTNG_H
24 #define _LTTNG_H
25
26 #include <asm/types.h>
27 #include <stdint.h>
28 #include <limits.h>
29
30 /* Default unix group name for tracing. */
31 #define LTTNG_DEFAULT_TRACING_GROUP "tracing"
32
33 /* Environment variable to set session daemon binary path. */
34 #define LTTNG_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
35
36 /*
37 * Event symbol length.
38 */
39 #define LTTNG_SYMBOL_NAME_LEN 128
40
41 enum lttng_event_type {
42 LTTNG_EVENT_TRACEPOINTS,
43 LTTNG_EVENT_KPROBES,
44 LTTNG_EVENT_FUNCTION,
45 };
46
47 /* Kernel context possible type */
48 enum lttng_kernel_context_type {
49 LTTNG_KERNEL_CONTEXT_PID = 0,
50 LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1,
51 LTTNG_KERNEL_CONTEXT_COMM = 2,
52 LTTNG_KERNEL_CONTEXT_PRIO = 3,
53 LTTNG_KERNEL_CONTEXT_NICE = 4,
54 LTTNG_KERNEL_CONTEXT_VPID = 5,
55 LTTNG_KERNEL_CONTEXT_TID = 6,
56 LTTNG_KERNEL_CONTEXT_VTID = 7,
57 LTTNG_KERNEL_CONTEXT_PPID = 8,
58 LTTNG_KERNEL_CONTEXT_VPPID = 9,
59 };
60
61 /* Perf counter attributes */
62 struct lttng_kernel_perf_counter_ctx {
63 uint32_t type;
64 uint64_t config;
65 char name[LTTNG_SYMBOL_NAME_LEN];
66 };
67
68 /* Event/Channel context */
69 struct lttng_kernel_context {
70 enum lttng_kernel_context_type ctx;
71 union {
72 struct lttng_kernel_perf_counter_ctx perf_counter;
73 } u;
74 };
75
76 /*
77 * Either addr is used or symbol_name and offset.
78 */
79 struct lttng_event_kprobe_attr {
80 uint64_t addr;
81
82 uint64_t offset;
83 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
84 };
85
86 /*
87 * Function tracer
88 */
89 struct lttng_event_function_attr {
90 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
91 };
92
93 /*
94 * Generic lttng event
95 */
96 struct lttng_event {
97 char name[LTTNG_SYMBOL_NAME_LEN];
98 enum lttng_event_type type;
99 /* Per event type configuration */
100 union {
101 struct lttng_event_kprobe_attr kprobe;
102 struct lttng_event_function_attr ftrace;
103 } attr;
104 };
105
106 /* Tracer channel attributes */
107 struct lttng_channel_attr {
108 int overwrite; /* 1: overwrite, 0: discard */
109 uint64_t subbuf_size; /* bytes */
110 uint64_t num_subbuf; /* power of 2 */
111 unsigned int switch_timer_interval; /* usec */
112 unsigned int read_timer_interval; /* usec */
113 };
114
115 /*
116 * Basic session information.
117 */
118 struct lttng_session {
119 char name[NAME_MAX];
120 char path[PATH_MAX];
121 };
122
123 /* Channel information structure */
124 struct lttng_channel {
125 char name[NAME_MAX];
126 struct lttng_channel_attr attr;
127 };
128
129 /*
130 * Session daemon control
131 */
132 extern int lttng_connect_sessiond(void);
133
134 extern int lttng_create_session(char *name, char *path);
135
136 extern int lttng_destroy_session(char *name);
137
138 extern int lttng_disconnect_sessiond(void);
139
140 /* Return an allocated array of lttng_session */
141 extern int lttng_list_sessions(struct lttng_session **sessions);
142
143 extern int lttng_session_daemon_alive(void);
144
145 /* Set tracing group for the current execution */
146 extern int lttng_set_tracing_group(const char *name);
147
148 extern void lttng_set_session_name(char *name);
149
150 extern const char *lttng_get_readable_code(int code);
151
152 extern int lttng_start_tracing(char *session_name);
153
154 extern int lttng_stop_tracing(char *session_name);
155
156 //extern int lttng_ust_list_traceable_apps(pid_t **pids);
157
158 /*
159 * LTTng Kernel tracer control
160 */
161 extern int lttng_kernel_add_context(struct lttng_kernel_context *ctx,
162 char *event_name, char *channel_name);
163
164 extern int lttng_kernel_create_channel(struct lttng_channel *chan);
165
166 extern int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name);
167
168 extern int lttng_kernel_enable_channel(char *name);
169
170 extern int lttng_kernel_disable_event(char *name, char *channel_name);
171
172 extern int lttng_kernel_disable_channel(char *name);
173
174 extern int lttng_kernel_list_events(char **event_list);
175
176 /*
177 * LTTng User-space tracer control
178 */
179
180 #endif /* _LTTNG_H */
This page took 0.046667 seconds and 3 git commands to generate.