Fix: use pid element instead of process element
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 4 Sep 2015 22:02:48 +0000 (18:02 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 5 Sep 2015 20:26:02 +0000 (16:26 -0400)
v2: Include change to xsd. Looks like I forgot to squash it. I'll have to make
an offering to the git reflog god on this one.

For stable 2.7

This revert part of changes introduced by [1] and [2].

The use of process element break the existing MI xml api.

[1] 46ef4d0715faeef52cd2242b5b895c74507e223a
[2] a585578f837d992f00eba4f090c8ba251d9de94e

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/list.c
src/common/mi-lttng.c
src/common/mi-lttng.h
src/common/mi_lttng.xsd
tests/regression/tools/mi/test_mi

index 13a5d91f3ca2668125369ca982e979b19f857514..18ae026c29e9eeb77010b8d1a1cb15cd4327e2d6 100644 (file)
@@ -340,8 +340,8 @@ static int mi_list_agent_ust_events(struct lttng_event *events, int count,
                goto end;
        }
 
                goto end;
        }
 
-       /* Open processes element */
-       ret = mi_lttng_processes_open(writer);
+       /* Open pids element element */
+       ret = mi_lttng_pids_open(writer);
        if (ret) {
                goto end;
        }
        if (ret) {
                goto end;
        }
@@ -366,7 +366,7 @@ static int mi_list_agent_ust_events(struct lttng_event *events, int count,
 
                        if (!pid_element_open) {
                                /* Open and write a pid element */
 
                        if (!pid_element_open) {
                                /* Open and write a pid element */
-                               ret = mi_lttng_process(writer, cur_pid, cmdline, 1);
+                               ret = mi_lttng_pid(writer, cur_pid, cmdline, 1);
                                if (ret) {
                                        goto error;
                                }
                                if (ret) {
                                        goto error;
                                }
@@ -389,7 +389,7 @@ static int mi_list_agent_ust_events(struct lttng_event *events, int count,
                }
        }
 
                }
        }
 
-       /* Close processes */
+       /* Close pids */
        ret = mi_lttng_writer_close_element(writer);
        if (ret) {
                goto end;
        ret = mi_lttng_writer_close_element(writer);
        if (ret) {
                goto end;
@@ -577,8 +577,8 @@ static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
                goto end;
        }
 
                goto end;
        }
 
-       /* Open processes element */
-       ret = mi_lttng_processes_open(writer);
+       /* Open pids element */
+       ret = mi_lttng_pids_open(writer);
        if (ret) {
                goto end;
        }
        if (ret) {
                goto end;
        }
@@ -606,8 +606,8 @@ static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
                        cur_pid = fields[i].event.pid;
                        cmdline = get_cmdline_by_pid(cur_pid);
                        if (!pid_element_open) {
                        cur_pid = fields[i].event.pid;
                        cmdline = get_cmdline_by_pid(cur_pid);
                        if (!pid_element_open) {
-                               /* Open and write a process element */
-                               ret = mi_lttng_process(writer, cur_pid, cmdline, 1);
+                               /* Open and write a pid element */
+                               ret = mi_lttng_pid(writer, cur_pid, cmdline, 1);
                                if (ret) {
                                        goto error;
                                }
                                if (ret) {
                                        goto error;
                                }
@@ -661,7 +661,7 @@ static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
                }
        }
 
                }
        }
 
-       /* Close processes, domain, domains */
+       /* Close pid, domain, domains */
        ret = mi_lttng_close_multi_element(writer, 3);
 end:
        return ret;
        ret = mi_lttng_close_multi_element(writer, 3);
 end:
        return ret;
index e2181f692d65c9beebe4890b256123c27b6336ef..7662c110619fc214edb6387a7aaa92dfcea6890c 100644 (file)
@@ -78,8 +78,7 @@ const char * const mi_lttng_context_type_perf_thread_counter = "PERF_THREAD_COUN
 const char * const mi_lttng_element_perf_counter_context = "perf_counter_context";
 
 /* Strings related to pid */
 const char * const mi_lttng_element_perf_counter_context = "perf_counter_context";
 
 /* Strings related to pid */
-const char * const mi_lttng_element_processes = "processes";
-const char * const mi_lttng_element_process = "process";
+const char * const mi_lttng_element_pid_id = "id";
 
 /* Strings related to save command */
 const char * const mi_lttng_element_save = "save";
 
 /* Strings related to save command */
 const char * const mi_lttng_element_save = "save";
@@ -1153,27 +1152,25 @@ int mi_lttng_pids_open(struct mi_writer *writer)
        return mi_lttng_writer_open_element(writer, config_element_pids);
 }
 
        return mi_lttng_writer_open_element(writer, config_element_pids);
 }
 
+/*
+ * TODO: move the listing of pid for user agent to process semantic on
+ * mi api bump. The use of process element break the mi api.
+ */
 LTTNG_HIDDEN
 LTTNG_HIDDEN
-int mi_lttng_processes_open(struct mi_writer *writer)
-{
-       return mi_lttng_writer_open_element(writer, mi_lttng_element_processes);
-}
-
-LTTNG_HIDDEN
-int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
                int is_open)
 {
        int ret;
 
                int is_open)
 {
        int ret;
 
-       /* Open element process */
-       ret = mi_lttng_writer_open_element(writer, mi_lttng_element_process);
+       /* Open pid process */
+       ret = mi_lttng_writer_open_element(writer, config_element_pid);
        if (ret) {
                goto end;
        }
 
        /* Writing pid number */
        ret = mi_lttng_writer_write_element_signed_int(writer,
        if (ret) {
                goto end;
        }
 
        /* Writing pid number */
        ret = mi_lttng_writer_write_element_signed_int(writer,
-                       config_element_pid, (int)pid);
+                       mi_lttng_element_pid_id, (int)pid);
        if (ret) {
                goto end;
        }
        if (ret) {
                goto end;
        }
index 3722e54e2a39dd2997438b181926343fe19fa5d9..c3976681e76fcfe6a90adf134a50aa4c05bec971 100644 (file)
@@ -101,8 +101,6 @@ extern const char * const mi_lttng_context_type_perf_thread_counter;
 extern const char * const mi_lttng_element_perf_counter_context;
 
 /* Strings related to pid */
 extern const char * const mi_lttng_element_perf_counter_context;
 
 /* Strings related to pid */
-extern const char * const mi_lttng_element_processes;
-extern const char * const mi_lttng_element_process;
 extern const char * const mi_lttng_element_pid_id;
 
 /* Strings related to save command */
 extern const char * const mi_lttng_element_pid_id;
 
 /* Strings related to save command */
@@ -617,6 +615,25 @@ int mi_lttng_processes_open(struct mi_writer *writer);
  */
 int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
                int is_open);
  */
 int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
                int is_open);
+
+/*
+ * TODO: move pid of lttng list -u to process semantic on mi api bump
+ * Machine interface of a Process.
+ *
+ * writer An instance of a machine interface writer.
+ * pid A PID.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ *         This should be used carefully and the client
+ *         must close the pid element.
+ *         Use case: nested addition information on a domain
+ *                  ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
+               int is_open);
 /*
  * Machine interface: open a targets element.
  *
 /*
  * Machine interface: open a targets element.
  *
index 11d60d047b15cae09bd1f5105830e66684c5700d..efb62a20bb8613d70958eb872cc0f8877414d4e6 100644 (file)
@@ -263,27 +263,19 @@ THE SOFTWARE.
                </xs:restriction>
        </xs:simpleType>
 
                </xs:restriction>
        </xs:simpleType>
 
-       <!-- Maps to a process -->
-       <xs:complexType name="process_type">
+       <!-- map to a pid -->
+       <xs:complexType name="pid_type">
                <xs:all>
                <xs:all>
-                       <xs:element name="pid" type="xs:int" />
-                       <xs:element name="name" type="name_type" minOccurs="0" />
+                       <xs:element name="id" type="xs:int" />
+                       <xs:element name="name" type="name_type" />
                        <xs:element name="events" type="event_list_type" minOccurs="0" />
                        <xs:element name="events" type="event_list_type" minOccurs="0" />
-                       <xs:element name="success" type="xs:boolean" default="false" minOccurs="0" />
                </xs:all>
        </xs:complexType>
 
                </xs:all>
        </xs:complexType>
 
-       <!-- Maps to an array of pid -->
+       <!-- maps to an array of pid -->
        <xs:complexType name="pids_type">
                <xs:sequence>
        <xs:complexType name="pids_type">
                <xs:sequence>
-                       <xs:element name="pid" type="xs:int" minOccurs="0" maxOccurs="unbounded" />
-               </xs:sequence>
-       </xs:complexType>
-
-       <!-- Maps to an array of processes -->
-       <xs:complexType name="processes_type">
-               <xs:sequence>
-                       <xs:element name="process" type="process_type" minOccurs="0" maxOccurs="unbounded" />
+                       <xs:element name="pid" type="pid_type" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
        </xs:complexType>
 
                </xs:sequence>
        </xs:complexType>
 
@@ -339,7 +331,7 @@ THE SOFTWARE.
                <xs:all>
                        <xs:element name="type" type="domain_type_type" />
                        <xs:element name="buffer_type" type="domain_buffer_type" />
                <xs:all>
                        <xs:element name="type" type="domain_type_type" />
                        <xs:element name="buffer_type" type="domain_buffer_type" />
-                       <xs:element name="processes" type="processes_type" minOccurs="0" />
+                       <xs:element name="pids" type="pids_type" minOccurs="0" />
                        <xs:element name="channels" type="channels_type" minOccurs="0" />
                        <xs:element name="events" type="event_list_type" minOccurs="0" />
                        <xs:element name="trackers" type="trackers_type" minOccurs="0" />
                        <xs:element name="channels" type="channels_type" minOccurs="0" />
                        <xs:element name="events" type="event_list_type" minOccurs="0" />
                        <xs:element name="trackers" type="trackers_type" minOccurs="0" />
index 7f22ee16a623a7096a2205c5b3835c33c1fbaaf2..47ec1b16a4c1d98bce5fbc36157a703bf9bc508e 100755 (executable)
@@ -48,7 +48,7 @@ XPATH_ENABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/events/event/success/text()"
 XPATH_DISABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/channel/events/event/success/text()"
 XPATH_LIST_DOMAIN="$XPATH_CMD_OUTPUT/sessions/session/domains/domain"
 XPATH_LIST_CHANNEL="$XPATH_CMD_OUTPUT/sessions/session/domains/domain/channels/channel"
 XPATH_DISABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/channel/events/event/success/text()"
 XPATH_LIST_DOMAIN="$XPATH_CMD_OUTPUT/sessions/session/domains/domain"
 XPATH_LIST_CHANNEL="$XPATH_CMD_OUTPUT/sessions/session/domains/domain/channels/channel"
-XPATH_LIST_UST_EVENT="$XPATH_CMD_OUTPUT/domains/domain[./type ='UST']/processes/process/events/event"
+XPATH_LIST_UST_EVENT="$XPATH_CMD_OUTPUT/domains/domain[./type ='UST']/pids/pid/events/event"
 XPATH_SNAPSHOT_ADD_SNAPSHOT="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'add-output']/output"
 XPATH_SNAPSHOT_LIST="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'list-output']/output"
 XPATH_SNAPSHOT_DEL="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'del-output']/output"
 XPATH_SNAPSHOT_ADD_SNAPSHOT="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'add-output']/output"
 XPATH_SNAPSHOT_LIST="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'list-output']/output"
 XPATH_SNAPSHOT_DEL="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'del-output']/output"
This page took 0.033061 seconds and 5 git commands to generate.