From: David Goulet Date: Wed, 18 May 2011 16:06:02 +0000 (-0400) Subject: Import kernel control interface X-Git-Tag: v2.0-pre1~134 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1df4dedd9ed4253a944a1623bb40047ba599e0c4;p=lttng-tools.git Import kernel control interface Signed-off-by: David Goulet --- diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index e393397f3..39a6cbdad 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -73,4 +73,17 @@ extern int lttng_ust_create_trace(pid_t pid); extern int lttng_ust_start_trace(pid_t pid); extern int lttng_ust_stop_trace(pid_t pid); +/* + * Kernel tracer control + */ +extern int lttng_kernel_enable_event(char *event_name); +extern int lttng_kernel_disable_event(char *event_name); +extern int lttng_kernel_create_session(void); +extern int lttng_kernel_start_tracing(void); +extern int lttng_kernel_stop_tracing(void); +extern int lttng_kernel_create_channel(int overwrite, + uint64_t subbuf_size, uint64_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval); + #endif /* _LIBLTTNGCTL_H */ diff --git a/liblttngctl/liblttngctl.c b/liblttngctl/liblttngctl.c index e400775ea..a2934e63c 100644 --- a/liblttngctl/liblttngctl.c +++ b/liblttngctl/liblttngctl.c @@ -158,6 +158,86 @@ end: return ret; } +/* + * BEGIN KERNEL CONTROL + */ + +/* + * lttng_kernel_enable_event + * + * Enable an event in the kernel tracer. + */ +int lttng_kernel_enable_event(char *event_name) +{ + strncpy(lsm.u.event.event_name, event_name, NAME_MAX); + return ask_sessiond(KERNEL_ENABLE_EVENT, NULL); +} + +/* + * lttng_kernel_disable_event + * + * Disable an event in the kernel tracer. + */ +int lttng_kernel_disable_event(char *event_name) +{ + strncpy(lsm.u.event.event_name, event_name, NAME_MAX); + return ask_sessiond(KERNEL_DISABLE_EVENT, NULL); +} + +/* + * lttng_kernel_create_session + * + * Create a session in the kernel tracer. + */ +int lttng_kernel_create_session(void) +{ + return ask_sessiond(KERNEL_CREATE_SESSION, NULL); +} + +/* + * lttng_kernel_create_channel + * + * Create a channel in the kernel tracer. + */ +int lttng_kernel_create_channel(int overwrite, + u64 subbuf_size, u64 num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval) +{ + /* Write setting to the session message */ + lsm.u.create_channel.overwrite = overwrite; + lsm.u.create_channel.subbuf_size = subbuf_size; + lsm.u.create_channel.num_subbuf = num_subbuf; + lsm.u.create_channel.switch_timer_interval = switch_timer_interval; + lsm.u.create_channel.read_timer_interval = read_timer_interval; + + return ask_sessiond(KERNEL_CREATE_CHANNEL, NULL); +} + +/* + * lttng_kernel_start_tracing + * + * Start kernel tracing. + */ +int lttng_kernel_start_tracing(void) +{ + return ask_sessiond(KERNEL_START_TRACE, NULL); +} + +/* + * lttng_kernel_stop_tracing + * + * Stop kernel tracing. + */ +int lttng_kernel_stop_tracing(void) +{ + return ask_sessiond(KERNEL_STOP_TRACE, NULL); +} + +/* + * END KERNEL CONTROL + */ + /* * lttng_get_readable_code * diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index 8b505eb98..4e86cc547 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -48,6 +48,12 @@ #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) enum lttcomm_sessiond_command { + KERNEL_CREATE_CHANNEL, + KERNEL_CREATE_SESSION, + KERNEL_DISABLE_EVENT, + KERNEL_ENABLE_EVENT, + KERNEL_START_TRACE, + KERNEL_STOP_TRACE, LTTNG_CREATE_SESSION, LTTNG_DESTROY_SESSION, LTTNG_FORCE_SUBBUF_SWITCH, @@ -134,23 +140,16 @@ struct lttcomm_session_msg { } create_session; /* Marker data */ struct { - char channel[NAME_MAX]; - char marker[NAME_MAX]; - } marker; - /* SET_SOCK_PATH */ + char event_name[NAME_MAX]; + } event; + /* Create channel kernel */ struct { - char sock_path[PATH_MAX]; - } sock_path; - /* SET_SUBBUF_NUM */ - struct { - unsigned int subbuf_num; - char channel[NAME_MAX]; - } subbuf_num; - /* SET_SUBBUF_SIZE */ - struct { - unsigned int subbuf_size; - char channel[NAME_MAX]; - } subbuf_size; + int overwrite; + u64 subbuf_size; + u64 num_subbuf; + unsigned int switch_timer_interval; + unsigned int read_timer_interval; + } create_channel; } u; };