]> git.lttng.org Git - lttng-tools.git/commitdiff
lttng-ctl: Add session shm_path to extended session attributes
authorKienan Stewart <kstewart@efficios.com>
Fri, 8 Nov 2024 20:59:00 +0000 (15:59 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Dec 2024 18:35:00 +0000 (13:35 -0500)
Observed issue
==============

Once a session is created, any lttng clients have no way of checking
what the current shared memory path setting for a session is.

Solution
========

Expose the configure path via an attribute in the extended structure
of lttng sessions.

Known drawbacks
===============

None.

Change-Id: Ie257bcedfc913e09fc6a60e6b9387d2e8d4cb828
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/session-internal.hpp
include/lttng/session.h
src/bin/lttng-sessiond/cmd.cpp
src/lib/lttng-ctl/liblttng-ctl.sym
src/lib/lttng-ctl/lttng-ctl.cpp

index 61e65981c6e280e74b2789a1f80e2e453cf1de16..6d701389f34d9d9fb3763d104d75e2ea487277f6 100644 (file)
@@ -20,6 +20,9 @@ struct lttng_session_extended {
                uint64_t value;
                uint8_t is_set;
        } LTTNG_PACKED creation_time;
+       struct {
+               char value[LTTNG_PATH_MAX];
+       } LTTNG_PACKED shm_path;
 } LTTNG_PACKED;
 
 using lttng_session_uptr = std::unique_ptr<
index a6735edadeee1a03310b3a6fba9f60623f84b82b..a614ab494c3932d751752b6c19beccd753f4d5c0 100644 (file)
@@ -28,6 +28,12 @@ struct lttng_destruction_handle;
 
 #define LTTNG_SESSION_PADDING1 8
 
+enum lttng_get_session_shm_path_status {
+       LTTNG_GET_SESSION_SHM_PATH_STATUS_OK = 0,
+       LTTNG_GET_SESSION_SHM_PATH_STATUS_UNSET = 1,
+       LTTNG_GET_SESSION_SHM_PATH_STATUS_INVALID_PARAMETER = -1,
+};
+
 /*!
 @brief
     Recording session summary.
@@ -506,6 +512,26 @@ utility.
 */
 LTTNG_EXPORT extern int lttng_set_session_shm_path(const char *session_name, const char *shm_dir);
 
+/*!
+@brief
+    Gets the shm_path set for the given session.
+
+@param[in] session
+    Pointer to an struct lttng_session return by lttng_list_sessions.
+
+@param[out] shm_path
+    A pointer to the shm_path in the session structure.
+
+@param[out] set
+    True when the session's shm_path has been explicitly changed from the default.
+
+@lt_pre_conn
+@lt_pre_not_null{session}
+@lt_pre_not_null{shm_path}
+@lt_pre_not_null{set}
+*/
+LTTNG_EXPORT extern enum lttng_get_session_shm_path_status
+lttng_get_session_shm_path_override(const struct lttng_session *session, const char **shm_path);
 /// @}
 
 #ifdef __cplusplus
index 6f24d0ac59da56a489472fad8932c4114ffc820a..2151883fc23e9a6ff9569a6b074bbd6558081217 100644 (file)
@@ -4345,6 +4345,7 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions,
                sessions[i].live_timer_interval = session->live_timer;
                extended[i].creation_time.value = (uint64_t) session->creation_time;
                extended[i].creation_time.is_set = 1;
+               strncpy(extended[i].shm_path.value, session->shm_path, LTTNG_PATH_MAX);
                i++;
        }
 }
index ff1aa823de0ddd995bd41a49c8b87c8098fc60f2..3f702f6ddc32aa004052343861c2941b77791c0c 100644 (file)
@@ -320,6 +320,7 @@ lttng_event_rule_user_tracepoint_set_log_level_rule
 lttng_event_rule_user_tracepoint_set_name_pattern
 lttng_event_set_userspace_probe_location
 lttng_get_kernel_tracer_status
+lttng_get_session_shm_path_override
 lttng_health_create_consumerd
 lttng_health_create_relayd
 lttng_health_create_sessiond
index 029f0b0ef7722d3c3dcdbb5adc49156ce0bda20a..24733e82e006fa3a2cd6b0b1bd3da5cc5752c8f4 100644 (file)
@@ -2329,6 +2329,20 @@ end:
        return ret;
 }
 
+enum lttng_get_session_shm_path_status
+lttng_get_session_shm_path_override(const lttng_session *session, const char **shm_path)
+{
+       struct lttng_session_extended *extended;
+       if (!session || !shm_path || !session->extended.ptr) {
+               return LTTNG_GET_SESSION_SHM_PATH_STATUS_INVALID_PARAMETER;
+       }
+
+       extended = (lttng_session_extended *) session->extended.ptr;
+       *shm_path = extended->shm_path.value;
+       return strlen(*shm_path) == 0 ? LTTNG_GET_SESSION_SHM_PATH_STATUS_UNSET :
+                                       LTTNG_GET_SESSION_SHM_PATH_STATUS_OK;
+}
+
 int lttng_set_session_shm_path(const char *session_name, const char *shm_path)
 {
        int ret;
This page took 0.034766 seconds and 4 git commands to generate.