From 1ece976622e22482aaf9eb13f8f68b8698c34332 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 21 Aug 2011 18:31:42 -0400 Subject: [PATCH] Update libust communication protocol Signed-off-by: Mathieu Desnoyers --- include/lttng-sessiond-comm.h | 117 ++++++++++++++++++++++------------ libust/lttng-ust-comm.c | 6 +- 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/include/lttng-sessiond-comm.h b/include/lttng-sessiond-comm.h index 25925cec..67c114e6 100644 --- a/include/lttng-sessiond-comm.h +++ b/include/lttng-sessiond-comm.h @@ -46,25 +46,33 @@ #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) enum lttcomm_ust_command { - /* Tracer command */ - LTTNG_ADD_CONTEXT, - LTTNG_CALIBRATE, - LTTNG_DISABLE_CHANNEL, - LTTNG_DISABLE_EVENT, - LTTNG_DISABLE_ALL_EVENT, - LTTNG_ENABLE_CHANNEL, - LTTNG_ENABLE_EVENT, - LTTNG_ENABLE_ALL_EVENT, - /* Session daemon command */ - LTTNG_CREATE_SESSION, - LTTNG_DESTROY_SESSION, - LTTNG_LIST_CHANNELS, - LTTNG_LIST_DOMAINS, - LTTNG_LIST_EVENTS, - LTTNG_LIST_SESSIONS, - LTTNG_LIST_TRACEPOINTS, - LTTNG_START_TRACE, - LTTNG_STOP_TRACE, + LTTNG_UST_CREATE_SESSION, + LTTNG_UST_RELEASE_SESSION, + LTTNG_UST_VERSION, + LTTNG_UST_LIST_TRACEPOINTS, + LTTNG_UST_WAIT_QUIESCENT, + LTTNG_UST_CALIBRATE, + + /* Apply on session handle */ + LTTNG_UST_METADATA, /* release with LTTNG_UST_RELEASE_CHANNEL */ + LTTNG_UST_CHANNEL, + LTTNG_UST_RELEASE_CHANNEL, + LTTNG_UST_SESSION_START, + LTTNG_UST_SESSION_STOP, + + /* Apply on channel handle */ + LTTNG_UST_STREAM, + LTTNG_UST_RELEASE_STREAM, + LTTNG_UST_EVENT, + LTTNG_UST_RELEASE_EVENT, + + /* Apply on event and channel handle */ + LTTNG_UST_CONTEXT, + LTTNG_UST_RELEASE_CONTEXT, + + /* Apply on event, channel and session handle */ + LTTNG_UST_ENABLE, + LTTNG_UST_DISABLE, }; /* @@ -127,12 +135,62 @@ enum lttcomm_return_code { LTTCOMM_NR, /* Last element */ }; +#define LTTNG_SYM_NAME_LEN 128 + +enum lttng_ust_instrumentation { + LTTNG_UST_TRACEPOINT = 0, + LTTNG_UST_PROBE = 1, + LTTNG_UST_FUNCTION = 2, +}; + +enum lttng_ust_output { + LTTNG_UST_MMAP = 0, +}; + +struct lttng_ust_tracer_version { + uint32_t version; + uint32_t patchlevel; + uint32_t sublevel; +}; + +struct lttng_ust_channel { + int overwrite; /* 1: overwrite, 0: discard */ + uint64_t subbuf_size; /* in bytes */ + uint64_t num_subbuf; + unsigned int switch_timer_interval; /* usecs */ + unsigned int read_timer_interval; /* usecs */ + enum lttng_ust_output output; /* output mode */ +}; + +struct lttng_ust_event { + char name[LTTNG_SYM_NAME_LEN]; /* event name */ + enum lttng_ust_instrumentation instrumentation; + /* Per instrumentation type configuration */ + union { + } u; +}; + +enum lttng_ust_context_type { + LTTNG_KERNEL_CONTEXT_VTID = 0, +}; + +struct lttng_ust_context { + enum lttng_ust_context_type ctx; + union { + } u; +}; + /* * Data structure for the commands sent from sessiond to UST. */ struct lttcomm_ust_msg { uint32_t cmd_type; /* enum lttcomm_ust_command */ + uint32_t handle; union { + struct lttng_ust_tracer_version version; + struct lttng_ust_channel channel; + struct lttng_ust_event event; + struct lttng_ust_context context; } u; }; @@ -143,30 +201,11 @@ struct lttcomm_ust_msg { struct lttcomm_ust_reply { uint32_t cmd_type; /* enum lttcomm_sessiond_command */ uint32_t ret_code; /* enum enum lttcomm_return_code */ + uint32_t ret_val; /* return value */ union { - struct { - uint32_t handle; /* session handle */ - } session; - struct { - uint32_t handle; /* channel handle */ - } channel; - struct { - uint32_t handle; /* event handle */ - } event; } u; }; -/* - * Data structures for the kconsumerd communications - * - * The header structure is sent to the kconsumerd daemon to inform - * how many lttcomm_kconsumerd_msg it is about to receive - */ -struct lttcomm_kconsumerd_header { - uint32_t payload_size; - uint32_t cmd_type; /* enum kconsumerd_command */ -}; - extern int lttcomm_create_unix_sock(const char *pathname); extern int lttcomm_connect_unix_sock(const char *pathname); extern int lttcomm_accept_unix_sock(int sock); diff --git a/libust/lttng-ust-comm.c b/libust/lttng-ust-comm.c index e28c39c6..5aaf29e9 100644 --- a/libust/lttng-ust-comm.c +++ b/libust/lttng-ust-comm.c @@ -75,13 +75,13 @@ int handle_message(int sock, struct lttcomm_ust_msg *lum) int ret; switch (lum->cmd_type) { - case LTTNG_CREATE_SESSION: + case LTTNG_UST_CREATE_SESSION: { struct lttcomm_ust_reply lur; DBG("Handling create session message"); memset(&lur, 0, sizeof(lur)); - lur.cmd_type = LTTNG_CREATE_SESSION; + lur.cmd_type = LTTNG_UST_CREATE_SESSION; /* ... */ ret = 0; @@ -90,7 +90,7 @@ int handle_message(int sock, struct lttcomm_ust_msg *lum) lur.ret_code = LTTCOMM_OK; else lur.ret_code = LTTCOMM_SESSION_FAIL; - lur.u.session.handle = 42; + lur.ret_val = 42; len = lttcomm_send_unix_sock(sock, &lur, sizeof(lur)); switch (len) { case sizeof(lur): -- 2.34.1