From: dgoulet@efficios.com (David Goulet)
Subject: [lttng-dev] [PATCH lttng-tools 1/5] Add --mi option to the list command
Date: Mon, 26 Aug 2013 14:42:15 -0400 [thread overview]
Message-ID: <521BA187.2010604@efficios.com> (raw)
In-Reply-To: <1376425585-31636-1-git-send-email-simon.marchi@polymtl.ca>
Like we spoke the other day on IRC, the --mi patch needs more work for the
output format so we come up with something standard and documented.
So I've merged the 3 other patches that do not uses --mi option.
Cheers!
David
simon.marchi at polymtl.ca:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> The --mi option is used to ask lttng to print information in a format
> easily understandable by another program. Currently, only session
> printing is affected: it prints session names one per line.
>
> The term mi stands for machine interface, and is stolen without any
> remorse from GDB's lexicon.
>
> Signed-off-by: Simon Marchi <simon.marchi at polymtl.ca>
> ---
> src/bin/lttng/commands/list.c | 35 ++++++++++++++++++++++++++---------
> 1 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c
> index 1c7085d..9e13e6b 100644
> --- a/src/bin/lttng/commands/list.c
> +++ b/src/bin/lttng/commands/list.c
> @@ -30,6 +30,7 @@ static int opt_kernel;
> static char *opt_channel;
> static int opt_domain;
> static int opt_fields;
> +static int opt_mi;
> #if 0
> /* Not implemented yet */
> static char *opt_cmd_name;
> @@ -44,6 +45,7 @@ enum {
> OPT_HELP = 1,
> OPT_USERSPACE,
> OPT_LIST_OPTIONS,
> + OPT_MI,
> };
>
> static struct lttng_handle *handle;
> @@ -63,6 +65,7 @@ static struct poptOption long_options[] = {
> {"domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
> {"fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0},
> {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
> + {"mi", 0, POPT_ARG_NONE, &opt_mi, 0, NULL, NULL},
> {0, 0, 0, 0, 0, 0, 0}
> };
>
> @@ -80,6 +83,7 @@ static void usage(FILE *ofp)
> fprintf(ofp, "\n");
> fprintf(ofp, " -h, --help Show this help\n");
> fprintf(ofp, " --list-options Simple listing of options\n");
> + fprintf(ofp, " --mi Prints data in a format suitable for parsing\n");
> fprintf(ofp, " -k, --kernel Select kernel domain\n");
> fprintf(ofp, " -u, --userspace Select user-space domain.\n");
> fprintf(ofp, " -f, --fields List event fields.\n");
> @@ -618,40 +622,53 @@ static int list_sessions(const char *session_name)
> ERR("%s", lttng_strerror(ret));
> goto error;
> } else if (count == 0) {
> - MSG("Currently no available tracing session");
> + if (!opt_mi) {
> + MSG("Currently no available tracing session");
> + }
> goto end;
> }
>
> - if (session_name == NULL) {
> + if (session_name == NULL && !opt_mi) {
> MSG("Available tracing sessions:");
> }
>
> for (i = 0; i < count; i++) {
> +
> if (session_name != NULL) {
> if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
> session_found = 1;
> - MSG("Tracing session %s: [%s%s]", session_name,
> +
> + if (opt_mi) {
> + MSG("%s", session_name);
> + } else {
> + MSG("Tracing session %s: [%s%s]", session_name,
> active_string(sessions[i].enabled),
> snapshot_string(sessions[i].snapshot_mode));
> - MSG("%sTrace path: %s\n", indent4, sessions[i].path);
> + MSG("%sTrace path: %s\n", indent4, sessions[i].path);
> + }
> +
> break;
> }
> } else {
> - MSG(" %d) %s (%s) [%s%s]", i + 1, sessions[i].name, sessions[i].path,
> - active_string(sessions[i].enabled),
> - snapshot_string(sessions[i].snapshot_mode));
> + if (opt_mi) {
> + MSG("%s", sessions[i].name);
> + } else {
> + MSG(" %d) %s (%s) [%s%s]", i + 1, sessions[i].name, sessions[i].path,
> + active_string(sessions[i].enabled),
> + snapshot_string(sessions[i].snapshot_mode));
> + }
> }
> }
>
> free(sessions);
>
> - if (!session_found && session_name != NULL) {
> + if (!session_found && session_name != NULL && !opt_mi) {
> ERR("Session '%s' not found", session_name);
> ret = CMD_ERROR;
> goto error;
> }
>
> - if (session_name == NULL) {
> + if (session_name == NULL && !opt_mi) {
> MSG("\nUse lttng list <session_name> for more details");
> }
>
parent reply other threads:[~2013-08-26 18:42 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1376425585-31636-1-git-send-email-simon.marchi@polymtl.ca>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=521BA187.2010604@efficios.com \
--to=dgoulet@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox