bd76eeb58cc7e68053ac53cb582b94177b039766
4 * Oumarou Dicko <oumarou.dicko@polymtl.ca>
5 * Michael Sills-Lavoie <michael.sills-lavoie@polymtl.ca>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
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.
26 * This structure contains the data associated with the channel file descriptor.
27 * The lib user can use user_data to store the data associated to the specified
28 * channel. The lib user can read but MUST NOT change the other attributes.
32 * This is the channel file descriptor.
37 * This is the number of subbuffer for this channel.
42 * This is the subbuffer size for this channel.
44 unsigned int max_sb_size
;
52 * This is a mutex for internal library usage.
54 pthread_mutex_t mutex
;
63 * This structure contains the necessary callbacks for a tracing session. The
64 * user can set the unnecessary functions to NULL if he does not need them.
66 struct liblttd_callbacks
{
68 * This callback is called after a channel file is open.
70 * @args data This argument is a pointeur to the callbacks struct that
71 * has been passed to the lib.
72 * @args pair This structure contains the data associated with the
73 * channel file descriptor. The lib user can use user_data to
74 * store the data associated to the specified channel.
75 * @args relative_channel_path This argument represents a relative path
76 * to the channel file. This path is relative to the root
77 * folder of the trace channels.
79 * @return Should return 0 if the callback succeeds else not 0.
81 int(*on_open_channel
)(struct liblttd_callbacks
*data
,
82 struct fd_pair
*pair
, char *relative_channel_path
);
85 * This callback is called after a channel file is closed.
87 * @remarks After a channel file has been closed, it will never be read
90 * @args data This argument is a pointeur to the callbacks struct that
91 * has been passed to the lib.
92 * @args pair This structure contains the data associated with the
93 * channel file descriptor. The lib user should clean
94 * user_data at this time.
96 * @return Should return 0 if the callback succeeds else not 0.
98 int(*on_close_channel
)(struct liblttd_callbacks
*data
,
99 struct fd_pair
*pair
);
103 * This callback is called when the library enter in a new subfolder
104 * while it is scanning the trace channel tree. It can be used to create
105 * the output file structure of the trace.
107 * @args data This argument is a pointeur to the callbacks struct that
108 * has been passed to the lib.
109 * @args relative_folder_path This argument represents a relative path
110 * to the channel folder. This path is relative to the root
111 * folder of the trace channels.
113 * @return Should return 0 if the callback succeeds else not 0.
115 int(*on_new_channels_folder
)(struct liblttd_callbacks
*data
,
116 char *relative_folder_path
);
119 * This callback is called after a subbuffer is a reserved.
121 * @attention It has to be thread safe, it'll be called by many threads.
123 * @args data This argument is a pointeur to the callbacks struct that
124 * has been passed to the lib.
125 * @args pair This structure contains the data associated with the
126 * channel file descriptor. The lib user should clean
127 * user_data at this time.
128 * @args len This argument represents the length the data that has to be
131 * @return Should return 0 if the callback succeeds else not 0.
133 int(*on_read_subbuffer
)(struct liblttd_callbacks
*data
,
134 struct fd_pair
*pair
, unsigned int len
);
137 * This callback is called at the very end of the tracing session. At
138 * this time, all the channels have been closed and the threads have been
141 * @remarks After this callback is called, no other callback will be
144 * @attention It has to be thread safe, it'll be called by many threads.
146 * @args data This argument is a pointeur to the callbacks struct that
147 * has been passed to the lib.
149 * @return Should return 0 if the callback succeeds else not 0.
151 int(*on_trace_end
)(struct liblttd_callbacks
*data
);
154 * This callback is called after a new thread has been created.
156 * @attention It has to be thread safe, it'll be called by many threads.
158 * @args data This argument is a pointeur to the callbacks struct that
159 * has been passed to the lib.
160 * @args thread_num This argument represents the id of the thread.
162 * @return Should return 0 if the callback succeeds else not 0.
164 int(*on_new_thread
)(struct liblttd_callbacks
*data
,
165 unsigned long thread_num
);
168 * This callback is called just before a thread is destroyed.
170 * @attention It has to be thread safe, it'll be called by many threads.
172 * @args data This argument is a pointeur to the callbacks struct that
173 * has been passed to the lib.
174 * @args thread_num This argument represents the number of the thread.
176 * @return Should return 0 if the callback succeeds else not 0.
178 int(*on_close_thread
)(struct liblttd_callbacks
*data
,
179 unsigned long thread_num
);
182 * This is where the user can put the library's data.
188 * This function is called to start a new tracing session.
190 * @attention It has to be thread safe, it'll be called by many threads.
192 * @args channel_path This argument is a path to the root folder of the trace's
194 * @args n_threads This argument represents the number of threads that will be
195 * used by the library.
196 * @args flight_only If this argument to set to 1, only the channel that are in
197 * flight recorder mode will be recorded.
198 * @args normal_only If this argument to set to 1, only the channel that are in
199 * normal mode will be recorded.
200 * @args verbose If this argument to set to 1, more informations will be printed.
201 * @args user_data This argument is a pointeur to the callbacks struct that
202 * contains the user's functions.
204 * @return Return 0 if the function succeeds else not 0.
206 int liblttd_start(char *channel_path
, unsigned long n_threads
,
207 int flight_only
, int normal_only
, int verbose
,
208 struct liblttd_callbacks
*user_data
);
211 * This function is called to stop a tracing session.
213 * @return Return 0 if the function succeeds.
217 #endif /*_LIBLTTD_H */
This page took 0.032888 seconds and 3 git commands to generate.