From 710b8ee36eec50c00e72cb61e146357130e1d94c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 14 Apr 2016 15:13:05 -0400 Subject: [PATCH] Implement statedump command in UST Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-abi.h | 1 + include/lttng/ust-events.h | 1 + liblttng-ust/lttng-events.c | 15 +++++++++++++-- liblttng-ust/lttng-ust-abi.c | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/lttng/ust-abi.h b/include/lttng/ust-abi.h index 8cae00e6..379e0231 100644 --- a/include/lttng/ust-abi.h +++ b/include/lttng/ust-abi.h @@ -273,6 +273,7 @@ struct lttng_ust_event_exclusion { _UST_CMDW(0x51, struct lttng_ust_channel) #define LTTNG_UST_SESSION_START _UST_CMD(0x52) #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) +#define LTTNG_UST_SESSION_STATEDUMP _UST_CMD(0x54) /* Channel FD commands */ #define LTTNG_UST_STREAM _UST_CMD(0x60) diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 9f6aa062..039b2ccb 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -606,6 +606,7 @@ struct lttng_transport { struct lttng_session *lttng_session_create(void); int lttng_session_enable(struct lttng_session *session); int lttng_session_disable(struct lttng_session *session); +int lttng_session_statedump(struct lttng_session *session); void lttng_session_destroy(struct lttng_session *session); struct lttng_channel *lttng_channel_create(struct lttng_session *session, diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index d09c97ca..373995d0 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -384,6 +384,16 @@ int lttng_create_all_ctx_enums(size_t nr_fields, return 0; } +/* + * Ensure that a state-dump will be performed for this session at the end + * of the current handle_message(). + */ +int lttng_session_statedump(struct lttng_session *session) +{ + session->statedump_pending = 1; + lttng_ust_sockinfo_session_enabled(session->owner); + return 0; +} int lttng_session_enable(struct lttng_session *session) { @@ -453,8 +463,9 @@ int lttng_session_enable(struct lttng_session *session) CMM_ACCESS_ONCE(session->active) = 1; CMM_ACCESS_ONCE(session->been_active) = 1; - session->statedump_pending = 1; - lttng_ust_sockinfo_session_enabled(session->owner); + ret = lttng_session_statedump(session); + if (ret) + return ret; end: return ret; } diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index 762c9017..d8150b6b 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -573,6 +573,8 @@ long lttng_session_cmd(int objd, unsigned int cmd, unsigned long arg, case LTTNG_UST_SESSION_STOP: case LTTNG_UST_DISABLE: return lttng_session_disable(session); + case LTTNG_UST_SESSION_STATEDUMP: + return lttng_session_statedump(session); default: return -EINVAL; } -- 2.34.1