[ltt-dev] Create a new lttd library
Michael Sills Lavoie
michael.sills-lavoie at polymtl.ca
Thu Feb 11 00:14:59 EST 2010
Hey Mathieu,
We would like to create a library with lttd so we could share lttd
functionality with other program like the lttng tcf agent to send data over
the network. This way, every program would be maintain at the same time. If
you remember, we talked about how we could do that this summer at the end of
my internship.
This is what we would do based on our conversations :
1) Create a new library (liblttd) that would contain the basic functionality
of lttd.
2) Add a set of callbacks used to modified the behaviour of the program
while it gathers the data.
3) Create a new implementation of lttd that use the lib.
4) Modify the lttng-agent tcf implementation to use the new lib.
A callback stuct would be passed to the lib to start recolting the data : We
tough about this struct :
struct liblttd_callbacks {
int(*on_open_channel)(struct liblttd_callbacks *data, struct fd_pair *pair,
char *relative_channel_path);
int(*on_close_channel)(struct liblttd_callbacks *data, struct fd_pair
*pair);
int(*on_new_channels_folder)(struct liblttd_callbacks *data, char
*relative_folder_path);
/*on_read_subbuffer has to be reentrant, it'll be called by many threads*/
int(*on_read_subbuffer)(struct liblttd_callbacks *data, struct fd_pair
*pair, unsigned int len);
int(*on_trace_end)(struct liblttd_callbacks *data);
/*on_new_thread has to be reentrant, it'll be called by many threads*/
int(*on_new_thread)(struct liblttd_callbacks *data, unsigned long
thread_num);
/*on_close_thread has to be reentrant, it'll be called by many threads*/
int(*on_close_thread)(struct liblttd_callbacks *data, unsigned long
thread_num);
void *user_data;
};
int liblttd_start(char *channel_path, unsigned long n_threads,
int flight_only, int normal_only, int verbose,
struct liblttd_callbacks *user_data);
int liblttd_stop();
- on_[open,close,new_channel_folder] would be used by lttd to create the
trace structure (folders and files)
- on_read_subbuffer would be called by the lib when new data is available in
a subbuffer
- on_[new,close]_thread would be used to initialize some data related to the
different recolting thread (ex. thread_pipe)
etc.
In order to use the lib, a program would have to fill a callback struct with
its functions and data and pass it to the lib by calling liblttd_start.
That is it!
What do you think about it?
P.S. I think that it would be necessary for a program to have more than one
instance on a "deamon" running at the same time ??? In this case, what do
you think of an interface that give the possibility to create and to destroy
instance of the daemon? For example :
struct liblttd_instance * liblttd_get_new_instance()
int liblttd_delete_instance(struct liblttd_instance *instance)
(we could add different function to modify the instance parameter (ex.
thread number, flight recorder only,...))
int liblttd_set_callbacks(struct liblttd_instance *instance, struct
liblttd_callbacks *callbacks)
int liblttd_start_instance(struct liblttd_instance *instance)
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.casi.polymtl.ca/pipermail/lttng-dev/attachments/20100211/c2aa61c9/attachment-0003.htm>
More information about the lttng-dev
mailing list