From 103d0bfb5f277d8e88a07fad9420ff9dd9ee3e5f Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Fri, 4 Sep 2015 18:02:48 -0400 Subject: [PATCH] Fix: use pid element instead of process element MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/list.c | 18 +++++++++--------- src/common/mi-lttng.c | 20 ++++++++------------ src/common/mi-lttng.h | 21 +++++++++++++++++++-- src/common/mi_lttng.xsd | 22 +++++++--------------- tests/regression/tools/mi/test_mi | 2 +- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 7d0781f6f..0c0a37a7a 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -340,8 +340,8 @@ static int mi_list_agent_ust_events(struct lttng_event *events, int count, 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; } @@ -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 */ - ret = mi_lttng_process(writer, cur_pid, cmdline, 1); + ret = mi_lttng_pid(writer, cur_pid, cmdline, 1); 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; @@ -577,8 +577,8 @@ static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count, goto end; } - /* Open processes element */ - ret = mi_lttng_processes_open(writer); + /* Open pids element */ + ret = mi_lttng_pids_open(writer); 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) { - /* 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; } @@ -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; diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index 9d6500ba4..40aec9d07 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -78,8 +78,6 @@ 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_processes = "processes"; -const char * const mi_lttng_element_process = "process"; const char * const mi_lttng_element_pid_id = "id"; /* Strings related to save command */ @@ -1156,27 +1154,25 @@ int mi_lttng_pids_open(struct mi_writer *writer) 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 -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; - /* 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, - config_element_pid, (int)pid); + mi_lttng_element_pid_id, (int)pid); if (ret) { goto end; } diff --git a/src/common/mi-lttng.h b/src/common/mi-lttng.h index 23b7810c4..1ff45de45 100644 --- a/src/common/mi-lttng.h +++ b/src/common/mi-lttng.h @@ -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_processes; -extern const char * const mi_lttng_element_process; extern const char * const mi_lttng_element_pid_id; /* Strings related to save command */ @@ -619,6 +617,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); + +/* + * 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. * diff --git a/src/common/mi_lttng.xsd b/src/common/mi_lttng.xsd index 11d60d047..efb62a20b 100644 --- a/src/common/mi_lttng.xsd +++ b/src/common/mi_lttng.xsd @@ -263,27 +263,19 @@ THE SOFTWARE. - - + + - - + + - - + - - - - - - - - + @@ -339,7 +331,7 @@ THE SOFTWARE. - + diff --git a/tests/regression/tools/mi/test_mi b/tests/regression/tools/mi/test_mi index 7f22ee16a..47ec1b16a 100755 --- a/tests/regression/tools/mi/test_mi +++ b/tests/regression/tools/mi/test_mi @@ -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_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" -- 2.34.1