CLI: Add trace format mi to session mi
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 25 Apr 2022 17:44:34 +0000 (13:44 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 19 Aug 2022 16:06:06 +0000 (12:06 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I70f414dd5fdfdfa52e45cdc7a77284e74917ef30

src/common/mi-lttng-4.1.xsd
src/common/mi-lttng.cpp

index 7d68b2e8eb9332efe3b90e4948919ffb4a895d8e..557e3f19395c7a6577443e97240a86a1697647f4 100644 (file)
@@ -665,11 +665,40 @@ SPDX-License-Identifier: MIT
                </xs:sequence>
        </xs:complexType>
 
+       <!-- Maps to a lttng_event_rule. -->
+       <xs:complexType name="trace_format_descriptor_type">
+               <xs:all>
+                       <xs:element ref="tns:trace_format_descriptor_sub_type" minOccurs="1" />
+               </xs:all>
+       </xs:complexType>
+
+       <!-- Maps to a lttng_trace_format_descriptor subtypes -->
+       <xs:element name="trace_format_descriptor_sub_type" abstract="true"/>
+       <xs:element name="ctf1" type="tns:trace_format_descriptor_ctf1_type" substitutionGroup="tns:trace_format_descriptor_sub_type" />
+       <xs:element name="ctf2" type="tns:trace_format_descriptor_ctf2_type" substitutionGroup="tns:trace_format_descriptor_sub_type" />
+
+       <!-- Maps to a lttng_trace_format_ctf1_descriptor. -->
+       <xs:complexType name="trace_format_descriptor_ctf1_type">
+               <xs:all>
+                       <xs:element name="major" type="tns:uint64_type" minOccurs="1" />
+                       <xs:element name="minor" type="tns:uint64_type" minOccurs="1" />
+               </xs:all>
+       </xs:complexType>
+
+       <!-- Maps to a lttng_trace_format_ctf2_descriptor. -->
+       <xs:complexType name="trace_format_descriptor_ctf2_type">
+               <xs:all>
+                       <xs:element name="major" type="tns:uint64_type" minOccurs="1" />
+                       <xs:element name="minor" type="tns:uint64_type" minOccurs="1" />
+               </xs:all>
+       </xs:complexType>
+
        <!-- Maps to a lttng_session -->
        <xs:complexType name="session_type">
                <xs:all>
                        <xs:element name="name" type="tns:name_type" />
                        <xs:element name="path" type="xs:string" minOccurs="0" />
+                       <xs:element name="trace_format" type="tns:trace_format_descriptor_type" minOccurs="0" />
                        <xs:element name="enabled" type="xs:boolean" default="false" minOccurs="0" />
                        <xs:element name="snapshot_mode" type="tns:uint32_type" minOccurs="0" />
                        <xs:element name="live_timer_interval" type="tns:uint32_type" minOccurs="0" />
index 01e89b779811a62be5da524148ba41b21f3cb71a..5600e2ad4643dc0bac61c97fa9dac80371817bcf 100644 (file)
@@ -14,7 +14,7 @@
 #include <common/tracker.hpp>
 #include <lttng/channel.h>
 #include <lttng/snapshot-internal.hpp>
-
+#include <lttng/trace-format-descriptor-internal.hpp>
 
 #define MI_SCHEMA_MAJOR_VERSION 4
 #define MI_SCHEMA_MINOR_VERSION 1
@@ -1022,6 +1022,8 @@ int mi_lttng_session(struct mi_writer *writer,
                struct lttng_session *session, int is_open)
 {
        int ret;
+       lttng_error_code ret_code;
+       struct lttng_trace_format_descriptor *trace_format_descriptor = nullptr;
 
        LTTNG_ASSERT(session);
 
@@ -1068,11 +1070,25 @@ int mi_lttng_session(struct mi_writer *writer,
                goto end;
        }
 
+       ret_code = lttng_session_get_trace_format_descriptor(session, &trace_format_descriptor);
+       if (ret_code != LTTNG_OK) {
+               ret = -1;
+               goto end;
+       }
+
+       ret_code = reinterpret_cast<lttng::trace_format_descriptor *>(trace_format_descriptor)
+                                  ->mi_serialize(writer);
+       if (ret_code != LTTNG_OK) {
+               ret = -1;
+               goto end;
+       }
+
        if (!is_open) {
                /* Closing session element */
                ret = mi_lttng_writer_close_element(writer);
        }
 end:
+       lttng_trace_format_descriptor_destroy(trace_format_descriptor);
        return ret;
 
 }
This page took 0.031421 seconds and 5 git commands to generate.