sessiond: lttng: Add command to check kernel tracer status
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.cpp
index b9311a07ef2051bfeb6243e071f381aef3f90379..22823d344bd1d556a3248ab63c0f093cd7cd7ac7 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#define COPY_DOMAIN_PACKED(dst, src)                             \
-       do {                                                     \
-               struct lttng_domain _tmp_domain;                 \
-                                                                 \
-               lttng_ctl_copy_lttng_domain(&_tmp_domain, &src); \
-               dst = _tmp_domain;                               \
+#define COPY_DOMAIN_PACKED(dst, src)                               \
+       do {                                                       \
+               struct lttng_domain _tmp_domain;                   \
+                                                                   \
+               lttng_ctl_copy_lttng_domain(&_tmp_domain, &(src)); \
+               (dst) = _tmp_domain;                               \
        } while (0)
 
 /* Socket to session daemon for communication */
@@ -2877,6 +2877,35 @@ end:
        return ret;
 }
 
+/*
+ * Get the status of the kernel tracer
+ *
+ * Sets the value of the argument
+ */
+enum lttng_error_code lttng_get_kernel_tracer_status(enum lttng_kernel_tracer_status *status)
+{
+       enum lttng_error_code ret = LTTNG_ERR_INVALID;
+
+       if (status == nullptr) {
+               return LTTNG_ERR_INVALID;
+       }
+
+       struct lttcomm_session_msg lsm = {};
+       lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_KERNEL_TRACER_STATUS;
+
+       uint32_t *u_status = nullptr;
+       const auto ask_ret = lttng_ctl_ask_sessiond(&lsm, (void **) &u_status);
+       if (ask_ret != 4) {
+               goto end;
+       }
+
+       *status = (enum lttng_kernel_tracer_status) * u_status;
+       ret = LTTNG_OK;
+end:
+       free(u_status);
+       return ret;
+}
+
 /*
  * Regenerate the metadata for a session.
  * Return 0 on success, a negative error code on error.
This page took 0.023411 seconds and 4 git commands to generate.