Skip to contentSkip to conversation

Mi: mi backend + mi for command version

RFC David Goulet 2 participants 3 messages Apr 14, 2014 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20140406193032.GA24869@psrcode-MS-7693

#1 lore raw

I've fixed some minor things and prepared this one for a merge.

Once the full patch set is ready to be merged, I'll be pushing them all at once.

Thanks!
David

Quoted 1,311 lines · Jonathan Rajotte

Hi,

These patches add machine interface functionality to command version and list. At the same time they procure a base architecture of the machine interface.

The first patch cover the version command and add the base for the machine interface.(mostly the same as last week mi patch) p.s: David if you want to pull this one [1].

The second patch provide full machine interface functionality to the list command. You will find attached a little script that demonstrate the mi functionality of list. The script need a root sessiond and need to be at the base of lttng-tool directory. Outputs will be generated in ./mi_test_output/ .

The third patch provide an xsd to validate the mi output of list and version command.

Voilà!

Jonathan

[1] https://github.com/PSRCode/lttng-tools-dev/commits/list_release

    commit: add4aa1a79247749cb823ec68ab1067beda937d0

--Patch--

The machine interface option is now available for version. Other commands will shortly follow.
Mi backend is expected to grow with addition of mi support to other commands.

How to use:

	lttng --mi <mi_output_type> <command>

This syntax will be the same for all commands. Currently *only xml is supported as machine interface output.*

As for errors handling, if an error/warning occurs while using mi it will be reported on stderr as normal. The integrity of the mi output cannot be guaranteed if an error/warning occurs.
The error output format is consistent and easy for a machine client to parse. Thus no mi output format is required for error output.

Example:

	lttng --mi xml version

Output:
<?xml version="1.0" encoding="UTF-8"?>
<command>
<name>version</name>
<output>
<string>2.4.0-rc2</string>
<major>2</major>
<minor>4</minor>
<patchLevel>0</patchLevel>
<name>Époque Opaque</name>
<description>The Époque Opaque is a black IPA from Trou du Diable brewery. The nose is eerily reminiscent of the coffee crisp candy from of our childhood. These strong mocha accents are present on the palate, which are quickly subdued by Japanese and Australian hops leading to a final state of satisfaction enjoyable for any fan of bitter beer.</description>
<url>http://lttng.org</url>
<license>lttng is free software and under the GPL license and part LGPL</license>
</output>
</command>

---
 include/lttng/lttng-error.h               |   6 +-
 include/lttng/lttng.h                     |   5 +
 src/bin/lttng-consumerd/lttng-consumerd.c |   2 +
 src/bin/lttng/commands/add_context.c      |   7 +
 src/bin/lttng/commands/calibrate.c        |   7 +
 src/bin/lttng/commands/create.c           |   7 +
 src/bin/lttng/commands/destroy.c          |   7 +
 src/bin/lttng/commands/disable_channels.c |   7 +
 src/bin/lttng/commands/disable_events.c   |   7 +
 src/bin/lttng/commands/enable_channels.c  |   7 +
 src/bin/lttng/commands/enable_events.c    |   7 +
 src/bin/lttng/commands/list.c             |   7 +
 src/bin/lttng/commands/load.c             |   7 +
 src/bin/lttng/commands/save.c             |   7 +
 src/bin/lttng/commands/set_session.c      |   7 +
 src/bin/lttng/commands/snapshot.c         |   7 +
 src/bin/lttng/commands/start.c            |   7 +
 src/bin/lttng/commands/stop.c             |   7 +
 src/bin/lttng/commands/version.c          |  88 ++++++++-
 src/bin/lttng/commands/view.c             |   4 +
 src/bin/lttng/lttng.c                     |  32 +++-
 src/common/Makefile.am                    |   5 +-
 src/common/error.h                        |  11 +-
 src/common/mi-lttng.c                     | 284 ++++++++++++++++++++++++++++++
 src/common/mi-lttng.h                     | 230 ++++++++++++++++++++++++
 src/lib/lttng-ctl/lttng-ctl.c             |   1 +
 tests/unit/ini_config/ini_config.c        |   1 +
 tests/unit/test_kernel_data.c             |   1 +
 tests/unit/test_session.c                 |   1 +
 tests/unit/test_uri.c                     |   1 +
 tests/unit/test_ust_data.c                |   1 +
 tests/unit/test_utils_expand_path.c       |   1 +
 tests/unit/test_utils_parse_size_suffix.c |   1 +
 33 files changed, 769 insertions(+), 11 deletions(-)
 create mode 100644 src/common/mi-lttng.c
 create mode 100644 src/common/mi-lttng.h
include/lttng/lttng-error.h +3 -3
index 06baa04..1594ba9 100644
@@ -120,9 +120,9 @@ enum lttng_error_code {
 	LTTNG_ERR_LOAD_INVALID_CONFIG    = 87,  /* Invalid session configuration */
 	LTTNG_ERR_LOAD_IO_FAIL           = 88,  /* IO error while reading a session configuration */
 	LTTNG_ERR_LOAD_SESSION_NOENT     = 89,  /* Session file not found */
-	/* 90 */
-	/* 91 */
-	/* 92 */
+	LTTNG_ERR_MI_OUTPUT_TYPE         = 90, /* Invalid MI output format */
+	LTTNG_ERR_MI_IO_FAIL             = 91, /* IO error while writing machine interface output */
+	LTTNG_ERR_MI_NOT_IMPLEMENTED     = 92, /* Mi feature not implemented */
 	/* 93 */
 	/* 94 */
 	/* 95 */
include/lttng/lttng.h +5 -0
index f0be224..9449161 100644
@@ -170,6 +170,11 @@ enum lttng_buffer_type {
 	LTTNG_BUFFER_GLOBAL,	/* Only supported by the Kernel. */
 };
 
+/* Machine interface output type */
+enum lttng_mi_output_type {
+	LTTNG_MI_XML                          = 1 /* XML output */
+};
+
 /*
  * The structures should be initialized to zero before use.
  */
src/bin/lttng-consumerd/lttng-consumerd.c +2 -0
index e226ebc..0ce163e 100644
@@ -65,6 +65,8 @@ static int sigintcount = 0;
 /* Argument variables */
 int lttng_opt_quiet;    /* not static in error.h */
 int lttng_opt_verbose;  /* not static in error.h */
+int lttng_opt_mi;       /* not static in error.h */
+
 static int opt_daemon;
 static const char *progname;
 static char command_sock_path[PATH_MAX]; /* Global command socket path */
src/bin/lttng/commands/add_context.c +7 -0
index 6483c98..2eb0e90 100644
@@ -446,6 +446,13 @@ int cmd_add_context(int argc, const char **argv)
 		goto end;
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
src/bin/lttng/commands/calibrate.c +7 -0
index 092632c..7d4de29 100644
@@ -133,6 +133,13 @@ static int calibrate_lttng(void)
 		goto error;
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto error;
+	}
+
 	handle = lttng_create_handle(NULL, &dom);
 	if (handle == NULL) {
 		ret = CMD_ERROR;
src/bin/lttng/commands/create.c +7 -0
index e02b141..c43ce59 100644
@@ -515,6 +515,13 @@ int cmd_create(int argc, const char **argv)
 		}
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	if (opt_no_consumer) {
 		MSG("The option --no-consumer is obsolete. Use --no-output now.");
 		ret = CMD_WARNING;
src/bin/lttng/commands/destroy.c +7 -0
index 3fb5fb2..26548b9 100644
@@ -148,6 +148,13 @@ int cmd_destroy(int argc, const char **argv)
 		goto end;
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	/* Ignore session name in case all sessions are to be destroyed */
 	if (opt_destroy_all) {
 		ret = destroy_all_sessions();
src/bin/lttng/commands/disable_channels.c +7 -0
index 1aa3916..da53d25 100644
@@ -167,6 +167,13 @@ int cmd_disable_channels(int argc, const char **argv)
 		}
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	opt_channels = (char*) poptGetArg(pc);
 	if (opt_channels == NULL) {
 		ERR("Missing channel name(s).\n");
src/bin/lttng/commands/disable_events.c +7 -0
index e712343..fb96b80 100644
@@ -212,6 +212,13 @@ int cmd_disable_events(int argc, const char **argv)
 		}
 	}
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	opt_event_list = (char*) poptGetArg(pc);
 	if (opt_event_list == NULL && opt_disable_all == 0) {
 		ERR("Missing event name(s).\n");
src/bin/lttng/commands/enable_channels.c +7 -0
index 55fbae6..8ea405e 100644
@@ -327,6 +327,13 @@ int cmd_enable_channels(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/enable_events.c +7 -0
index bd2d997..8c7a73e 100644
@@ -968,6 +968,13 @@ int cmd_enable_events(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	/* Default event type */
 	opt_event_type = LTTNG_EVENT_ALL;
 
src/bin/lttng/commands/list.c +7 -0
index f69b3ba..bbd674c 100644
@@ -850,6 +850,13 @@ int cmd_list(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/load.c +7 -0
index e732baa..2cfc698 100644
@@ -77,6 +77,13 @@ int cmd_load(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, load_opts, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/save.c +7 -0
index e8a4565..1aeb9f2 100644
@@ -73,6 +73,13 @@ int cmd_save(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, save_opts, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/set_session.c +7 -0
index 4238016..54320df 100644
@@ -92,6 +92,13 @@ int cmd_set_session(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/snapshot.c +7 -0
index c704eee..21b5a05 100644
@@ -446,6 +446,13 @@ int cmd_snapshot(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, snapshot_opts, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/start.c +7 -0
index 82122cc..82b3f5f 100644
@@ -118,6 +118,13 @@ int cmd_start(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/stop.c +7 -0
index 60a1dac..5de96d8 100644
@@ -122,6 +122,13 @@ int cmd_stop(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	/* TODO: mi support */
+	if (lttng_opt_mi) {
+		ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+		ERR("mi option not supported");
+		goto end;
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/commands/version.c +84 -4
index 7f69de3..5c7ebbf 100644
@@ -25,6 +25,8 @@
 #include <unistd.h>
 #include <config.h>
 
+#include <common/mi-lttng.h>
+
 #include "../command.h"
 
 enum {
@@ -32,6 +34,8 @@ enum {
 	OPT_LIST_OPTIONS,
 };
 
+static const char *lttng_license = "lttng is free software and under the GPL license and part LGPL";
+
 static struct poptOption long_options[] = {
 	/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
 	{"help",      'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
@@ -53,6 +57,78 @@ static void usage(FILE *ofp)
 }
 
 /*
+ *  create_version
+ */
+static void create_version(struct mi_lttng_version *version)
+{
+	strncpy(version->version, VERSION, NAME_MAX);
+	version->version_major = VERSION_MAJOR;
+	version->version_minor = VERSION_MINOR;
+	version->version_patchlevel = VERSION_PATCHLEVEL;
+	strncpy(version->version_name, VERSION_NAME, NAME_MAX);
+	strncpy(version->package_url, PACKAGE_URL, NAME_MAX);
+}
+
+/*
+ *  print_mi
+ */
+static int print_mi()
+{
+	int ret;
+	struct mi_writer *writer = NULL;
+	struct mi_lttng_version version;
+
+	create_version(&version);
+
+	writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
+
+	if (!writer) {
+		ret = -LTTNG_ERR_NOMEM;
+		goto end;
+	}
+
+	/* Open the command element */
+	ret = mi_lttng_writer_command_open(writer,
+			mi_lttng_element_command_version);
+	if (ret) {
+		goto error;
+	}
+
+	/* Beginning of output */
+	ret = mi_lttng_writer_open_element(writer,
+			mi_lttng_element_command_output);
+	if (ret) {
+		goto error;
+	}
+
+	/* Print the machine interface of version */
+	ret = mi_lttng_version(writer, &version,
+			VERSION_DESCRIPTION, lttng_license);
+	if (ret) {
+		goto error;
+	}
+
+	/* Close the output element */
+	ret = mi_lttng_writer_close_element(writer);
+	if (ret) {
+		goto error;
+	}
+
+	/* Close the command  */
+	ret = mi_lttng_writer_command_close(writer);
+
+error:
+	/* Cleanup */
+	if (writer && mi_lttng_writer_destroy(writer)) {
+		/* Preserve original error code */
+		ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
+	}
+
+end:
+	return ret;
+}
+
+/*
  *  cmd_version
  */
 int cmd_version(int argc, const char **argv)
@@ -78,10 +154,14 @@ int cmd_version(int argc, const char **argv)
 		}
 	}
 
-	MSG("lttng version " VERSION " - " VERSION_NAME);
-	MSG("\n" VERSION_DESCRIPTION "\n");
-	MSG("Web site: http://lttng.org");
-	MSG("\nlttng is free software and under the GPL license and part LGPL");
+	if (lttng_opt_mi) {
+		ret = print_mi();
+	} else {
+		MSG("lttng version " VERSION " - " VERSION_NAME);
+		MSG("\n" VERSION_DESCRIPTION "\n");
+		MSG("Web site: http://lttng.org");
+		MSG("\n%s", lttng_license);
+	}
 
 end:
 	poptFreeContext(pc);
src/bin/lttng/commands/view.c +4 -0
index adedf29..dcd4d66 100644
@@ -445,6 +445,10 @@ int cmd_view(int argc, const char **argv)
 	pc = poptGetContext(NULL, argc, argv, long_options, 0);
 	poptReadDefaultConfig(pc, 0);
 
+	if (lttng_opt_mi) {
+		WARN("mi does not apply to view command");
+	}
+
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
 		case OPT_HELP:
src/bin/lttng/lttng.c +31 -1
index bc7577d..4510057 100644
@@ -55,6 +55,7 @@ static struct option long_options[] = {
 	{"group",            1, NULL, 'g'},
 	{"verbose",          0, NULL, 'v'},
 	{"quiet",            0, NULL, 'q'},
+	{"mi",               1, NULL, 'm'},
 	{"no-sessiond",      0, NULL, 'n'},
 	{"sessiond-path",    1, NULL, OPT_SESSION_PATH},
 	{"relayd-path",      1, NULL, OPT_RELAYD_PATH},
@@ -99,6 +100,8 @@ static void usage(FILE *ofp)
 	fprintf(ofp, "      --list-commands        Simple listing of lttng commands\n");
 	fprintf(ofp, "  -v, --verbose              Increase verbosity\n");
 	fprintf(ofp, "  -q, --quiet                Quiet mode\n");
+	fprintf(ofp, "  -m, --mi TYPE              Machine Interface mode.\n");
+	fprintf(ofp, "                                 Type: xml\n");
 	fprintf(ofp, "  -g, --group NAME           Unix tracing group name. (default: tracing)\n");
 	fprintf(ofp, "  -n, --no-sessiond          Don't spawn a session daemon\n");
 	fprintf(ofp, "      --sessiond-path PATH   Session daemon full path\n");
@@ -136,6 +139,26 @@ static void version(FILE *ofp)
 }
 
 /*
+ * mi_output_type
+ *
+ * Find the MI output type enum from a string
+ * This function is for the support of
+ * new output language.
+ */
+static int mi_output_type(const char *output_type)
+{
+	int ret = 0;
+	if (!strncasecmp("xml", output_type, 3)) {
+		ret = LTTNG_MI_XML;
+	} else {
+		/* Invalid output format */
+		ERR("MI output format not supported");
+		ret = -LTTNG_ERR_MI_OUTPUT_TYPE;
+	}
+	return ret;
+}
+
+/*
  *  list_options
  *
  *  List options line by line. This is mostly for bash auto completion and to
@@ -426,7 +449,7 @@ static int parse_args(int argc, char **argv)
 		clean_exit(EXIT_FAILURE);
 	}
 
-	while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'V':
 			version(stdout);
@@ -442,6 +465,13 @@ static int parse_args(int argc, char **argv)
 		case 'q':
 			lttng_opt_quiet = 1;
 			break;
+		case 'm':
+			lttng_opt_mi = mi_output_type(optarg);
+			if (lttng_opt_mi < 0) {
+				ret = lttng_opt_mi;
+				goto error;
+			}
+			break;
 		case 'g':
 			lttng_set_tracing_group(optarg);
 			break;
src/common/Makefile.am +4 -1
index 1a764ae..dffab06 100644
@@ -16,8 +16,11 @@ noinst_LTLIBRARIES = libcommon.la
 libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h \
                        common.h futex.c futex.h uri.c uri.h defaults.c \
                        pipe.c pipe.h readwrite.c readwrite.h \
+                       mi-lttng.h mi-lttng.c \
                        daemonize.c daemonize.h
-libcommon_la_LIBADD = -luuid
+libcommon_la_LIBADD = \
+		-luuid \
+		$(top_builddir)/src/common/config/libconfig.la
 
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
src/common/error.h +9 -2
index f8c0a1d..4e096b3 100644
@@ -36,6 +36,7 @@
 
 extern int lttng_opt_quiet;
 extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
 
 /* Error type. */
 #define PRINT_ERR   0x1
@@ -48,12 +49,18 @@ extern int lttng_opt_verbose;
 
 /*
  * Macro for printing message depending on command line option and verbosity.
+ *
+ * Machine interface:
+ * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
+ * want any nested msg to show up when printing mi to stdout(if it's the case).
+ * All warnings and errors should be printed to stderr as normal.
  */
 #define __lttng_print(type, fmt, args...)                           \
 	do {                                                            \
-		if (lttng_opt_quiet == 0 && type == PRINT_MSG) {            \
+		if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&            \
+				type == PRINT_MSG) {                                \
 			fprintf(stdout, fmt, ## args);                          \
-		} else if (lttng_opt_quiet == 0 &&                          \
+		} else if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&     \
 				(((type & PRINT_DBG) && lttng_opt_verbose == 1) ||  \
 				((type & (PRINT_DBG | PRINT_DBG2)) &&               \
 					lttng_opt_verbose == 2) ||                      \
src/common/mi-lttng.c new file +284 -0
new file mode 100644
index 0000000..bbec2c5
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]>
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <include/config.h>
+#include <common/config/config.h>
+#include "mi-lttng.h"
+
+/* Strings related to command */
+const char * const mi_lttng_element_command = "command";
+const char * const mi_lttng_element_command_version = "version";
+const char * const mi_lttng_element_command_list = "list";
+const char * const mi_lttng_element_command_name = "name";
+const char * const mi_lttng_element_command_output = "output";
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version = "version";
+const char * const mi_lttng_element_version_str = "string";
+const char * const mi_lttng_element_version_web = "url";
+const char * const mi_lttng_element_version_major = "major";
+const char * const mi_lttng_element_version_minor = "minor";
+const char * const mi_lttng_element_version_license = "license";
+const char * const mi_lttng_element_version_patch_level = "patchLevel";
+const char * const mi_lttng_element_version_description = "description";
+
+LTTNG_HIDDEN
+struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type)
+{
+	struct mi_writer *mi_writer;
+
+	mi_writer = zmalloc(sizeof(struct mi_writer));
+	if (!mi_writer) {
+		PERROR("zmalloc mi_writer_create");
+		goto end;
+	}
+	if (mi_output_type == LTTNG_MI_XML) {
+		mi_writer->writer = config_writer_create(fd_output);
+		if (!mi_writer->writer) {
+			goto err_destroy;
+		}
+		mi_writer->type = LTTNG_MI_XML;
+	} else {
+		goto err_destroy;
+	}
+
+end:
+	return mi_writer;
+
+err_destroy:
+	free(mi_writer);
+	return NULL;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_destroy(struct mi_writer *writer)
+{
+	int ret;
+
+	if (!writer) {
+		ret = -EINVAL;
+		goto end;
+	}
+
+	ret = config_writer_destroy(writer->writer);
+	if (ret < 0) {
+		goto end;
+	}
+
+	free(writer);
+end:
+	return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command)
+{
+	int ret;
+	ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command);
+	if (ret) {
+		goto end;
+	}
+	ret = mi_lttng_writer_write_element_string(writer,
+			mi_lttng_element_command_name, command);
+end:
+	return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_close(struct mi_writer *writer)
+{
+	return mi_lttng_writer_close_element(writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+		const char *element_name)
+{
+	return config_writer_open_element(writer->writer, element_name);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_close_element(struct mi_writer *writer)
+{
+	return config_writer_close_element(writer->writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+		const char *element_name, uint64_t value)
+{
+	return config_writer_write_element_unsigned_int(writer->writer,
+			element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+		const char *element_name, int64_t value)
+{
+	return config_writer_write_element_signed_int(writer->writer,
+			element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+		const char *element_name, int value)
+{
+	return config_writer_write_element_bool(writer->writer,
+			element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+		const char *element_name, const char *value)
+{
+	return config_writer_write_element_string(writer->writer,
+			element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
+	const char *lttng_description, const char *lttng_license)
+{
+	int ret;
+
+	/* Open version */
+	ret = mi_lttng_writer_open_element(writer, mi_lttng_element_version);
+	if (ret) {
+		goto end;
+	}
+
+	/* Version string (contain info like rc etc.) */
+	ret = mi_lttng_writer_write_element_string(writer,
+			mi_lttng_element_version_str, VERSION);
+	if (ret) {
+		goto end;
+	}
+
+	/* Major version number */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			mi_lttng_element_version_major, version->version_major);
+	if (ret) {
+		goto end;
+	}
+
+	/* Minor version number */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			mi_lttng_element_version_minor, version->version_minor);
+	if (ret) {
+		goto end;
+	}
+
+	/* Patch number */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			mi_lttng_element_version_patch_level, version->version_patchlevel);
+	if (ret) {
+		goto end;
+	}
+
+	/* Name of the version */
+	ret = mi_lttng_writer_write_element_string(writer,
+			config_element_name, version->version_name);
+	if (ret) {
+		goto end;
+	}
+
+	/* Description mostly related to beer... */
+	ret = mi_lttng_writer_write_element_string(writer,
+			mi_lttng_element_version_description, lttng_description);
+	if (ret) {
+		goto end;
+	}
+
+	/* url */
+	ret = mi_lttng_writer_write_element_string(writer,
+			mi_lttng_element_version_web, version->package_url);
+	if (ret) {
+		goto end;
+	}
+
+	/* License: free as in free beer...no...*speech* */
+	ret = mi_lttng_writer_write_element_string(writer,
+			mi_lttng_element_version_license, lttng_license);
+	if (ret) {
+		goto end;
+	}
+
+	/* Close version element */
+	ret = mi_lttng_writer_close_element(writer);
+
+end:
+	return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_session(struct mi_writer *writer,
+		struct lttng_session *session, int is_open)
+{
+	int ret;
+
+	/* open sessions element */
+	ret = mi_lttng_writer_open_element(writer,
+			config_element_session);
+	if (ret) {
+		goto end;
+	}
+
+	/* Name of the session */
+	ret = mi_lttng_writer_write_element_string(writer,
+			config_element_name, session->name);
+	if (ret) {
+		goto end;
+	}
+
+	/* path */
+	ret = mi_lttng_writer_write_element_string(writer,
+			config_element_path, session->path);
+	if (ret) {
+		goto end;
+	}
+
+	/* enabled ? */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			config_element_enabled, session->enabled);
+	if (ret) {
+		goto end;
+	}
+
+	/* snapshot mode */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			config_element_snapshot_mode, session->snapshot_mode);
+	if (ret) {
+		goto end;
+	}
+
+	/* live timer interval in usec */
+	ret = mi_lttng_writer_write_element_unsigned_int(writer,
+			config_element_live_timer_interval,
+			session->live_timer_interval);
+	if (ret) {
+		goto end;
+	}
+
+	if (!is_open) {
+		/* Closing session element */
+		ret = mi_lttng_writer_close_element(writer);
+	}
+end:
+	return ret;
+
+}
src/common/mi-lttng.h new file +230 -0
new file mode 100644
index 0000000..69ec0f5
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]>
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MI_LTTNG_H
+#define _MI_LTTNG_H
+
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/config/config.h>
+
+#include <lttng/lttng.h>
+
+#include <stdint.h>
+
+
+/* Instance of a machine interface writer. */
+struct mi_writer {
+	struct config_writer *writer;
+	enum lttng_mi_output_type type;
+};
+
+/*
+ * Version information for the machine interface.
+ */
+struct mi_lttng_version {
+	char version[NAME_MAX]; /* Version number of package */
+	uint32_t version_major; /* LTTng-Tools major version number */
+	uint32_t version_minor; /* LTTng-Tools minor version number */
+	uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
+	char version_name[NAME_MAX];
+	char package_url[NAME_MAX]; /* Define to the home page for this package. */
+};
+
+/* Strings related to command */
+const char * const mi_lttng_element_command;
+const char * const mi_lttng_element_command_version;
+const char * const mi_lttng_element_command_list;
+const char * const mi_lttng_element_command_name;
+const char * const mi_lttng_element_command_output;
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version;
+const char * const mi_lttng_element_version_str;
+const char * const mi_lttng_element_version_web;
+const char * const mi_lttng_element_version_major;
+const char * const mi_lttng_element_version_minor;
+const char * const mi_lttng_element_version_license;
+const char * const mi_lttng_element_version_patch_level;
+const char * const mi_lttng_element_version_description;
+
+/*
+ * Create an instance of a machine interface writer.
+ *
+ * fd_output File to which the XML content must be written. The file will be
+ * closed once the mi_writer has been destroyed.
+ *
+ * Returns an instance of a machine interface writer on success, NULL on
+ * error.
+ */
+struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
+
+/*
+ * Destroy an instance of a machine interface writer.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative values
+ * indicate an error.
+ */
+int mi_lttng_writer_destroy(struct mi_writer *writer);
+
+/*
+ * Open a command tag and add it's name node.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * command The command name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
+
+/*
+ * Close a command tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_close(struct mi_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+		const char *element_name);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_close_element(struct mi_writer *writer);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+		const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Signed int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+		const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Boolean value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+		const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value String value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+		const char *element_name, const char *value);
+
+/*
+ * Machine interface of struct version.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * version Version struct.
+ *
+ * lttng_description String value of the version description.
+ *
+ * lttng_license String value of the version license.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,
+		const char *lttng_description, const char *lttng_license);
+
+/*
+ * Machine interface of struct session.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * session An instance of a session
+ *
+ * isOpen Define if we close the session element
+ *        This should be use carefully and the client
+ *        need to close the session element.
+ *        Use case: nested addition information on a session
+ *                  ex: domain,channel event.
+ *        0-> False
+ *        1-> True
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_session(struct mi_writer *writer,
+		struct lttng_session *session, int isOpen);
+
+#endif /* _MI_LTTNG_H */
src/lib/lttng-ctl/lttng-ctl.c +1 -0
index 100e587..7dd9828 100644
@@ -74,6 +74,7 @@ static int connected;
  */
 int lttng_opt_quiet;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 /*
  * Copy string from src to dst and enforce null terminated byte.
tests/unit/ini_config/ini_config.c +1 -0
index 38fe5f4..29935ef 100644
@@ -31,6 +31,7 @@ struct state {
 
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int entry_handler(const struct config_entry *entry,
 		struct state *state)
tests/unit/test_kernel_data.c +1 -0
index e2182e9..2639be4 100644
@@ -38,6 +38,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_session.c +1 -0
index a0e84e9..4f90c33 100644
@@ -46,6 +46,7 @@ static struct ltt_session_list *session_list;
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_uri.c +1 -0
index 7cac95d..432e2b3 100644
@@ -25,6 +25,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 /* Number of TAP tests in this file */
 #define NUM_TESTS 11
tests/unit/test_ust_data.c +1 -0
index 150d5da..dd00089 100644
@@ -44,6 +44,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_utils_expand_path.c +1 -0
index fe709ac..f863b5d 100644
@@ -31,6 +31,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
 	char *input;
tests/unit/test_utils_parse_size_suffix.c +1 -0
index 990aa1b..f81278d 100644
@@ -26,6 +26,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
 	char *input;
Signature · 8 lines
1.8.3.2



_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): 20140414152631.GA32712@thessa

#3 lore raw

We will also provide patches for snapshot + regression test.

Could you send me the minor modifications? I wouldn't like to make the same mistakes twice.

Thanks

Quoted 1,410 lines · David Goulet

I've fixed some minor things and prepared this one for a merge.

Once the full patch set is ready to be merged, I'll be pushing them all at once.

Thanks!
David

Quoted 3 lines · Jonathan Rajotte

Hi,

These patches add machine interface functionality to command version and

list.

Quoted 29 lines

At the same time they procure a base architecture of the machine interface.

The first patch cover the version command and add the base for the machine interface.(mostly the same as last week mi patch) p.s: David if you want to pull this one [1].

The second patch provide full machine interface functionality to the list command. You will find attached a little script that demonstrate the mi functionality of list. The script need a root sessiond and need to be at the base of lttng-tool directory. Outputs will be generated in ./mi_test_output/ .

The third patch provide an xsd to validate the mi output of list and version command.

Voilà!

Jonathan

[1] https://github.com/PSRCode/lttng-tools-dev/commits/list_release

    commit: add4aa1a79247749cb823ec68ab1067beda937d0

--Patch--

The machine interface option is now available for version. Other commands will shortly follow.
Mi backend is expected to grow with addition of mi support to other commands.

Quoted 7 lines

How to use:

      lttng --mi <mi_output_type> <command>

This syntax will be the same for all commands. Currently *only xml is supported as machine interface output.*

As for errors handling, if an error/warning occurs while using mi it

will be

Quoted 3 lines

reported on stderr as normal. The integrity of the mi output cannot be guaranteed if an error/warning occurs.
The error output format is consistent and easy for a machine client to

parse.

Quoted 16 lines

Thus no mi output format is required for error output.

Example:

      lttng --mi xml version
Output:
<?xml version="1.0" encoding="UTF-8"?>
  <command>
    <name>version</name>
    <output>
      <string>2.4.0-rc2</string>
      <major>2</major>
      <minor>4</minor>
      <patchLevel>0</patchLevel>
      <name>Époque Opaque</name>
      <description>The Époque Opaque is a black IPA from Trou du Diable
      brewery. The nose is eerily reminiscent of the coffee crisp candy

from

Quoted 1 line

of our childhood. These strong mocha accents are present on the

palate,

Quoted 1 line

which are quickly subdued by Japanese and Australian hops leading

to a

Quoted 27 lines

final state of satisfaction enjoyable for any fan of bitter beer.</description>
<url>http://lttng.org</url>
<license>lttng is free software and under the GPL license and part LGPL</license>
</output>
</command>

---
 include/lttng/lttng-error.h               |   6 +-
 include/lttng/lttng.h                     |   5 +
 src/bin/lttng-consumerd/lttng-consumerd.c |   2 +
 src/bin/lttng/commands/add_context.c      |   7 +
 src/bin/lttng/commands/calibrate.c        |   7 +
 src/bin/lttng/commands/create.c           |   7 +
 src/bin/lttng/commands/destroy.c          |   7 +
 src/bin/lttng/commands/disable_channels.c |   7 +
 src/bin/lttng/commands/disable_events.c   |   7 +
 src/bin/lttng/commands/enable_channels.c  |   7 +
 src/bin/lttng/commands/enable_events.c    |   7 +
 src/bin/lttng/commands/list.c             |   7 +
 src/bin/lttng/commands/load.c             |   7 +
 src/bin/lttng/commands/save.c             |   7 +
 src/bin/lttng/commands/set_session.c      |   7 +
 src/bin/lttng/commands/snapshot.c         |   7 +
Quoted 8 lines
 src/bin/lttng/commands/start.c            |   7 +
 src/bin/lttng/commands/stop.c             |   7 +
 src/bin/lttng/commands/version.c          |  88 ++++++++-
 src/bin/lttng/commands/view.c             |   4 +
 src/bin/lttng/lttng.c                     |  32 +++-
 src/common/Makefile.am                    |   5 +-
 src/common/error.h                        |  11 +-
 src/common/mi-lttng.c                     | 284

++++++++++++++++++++++++++++++

Quoted 18 lines
 src/common/mi-lttng.h                     | 230 ++++++++++++++++++++++++
 src/lib/lttng-ctl/lttng-ctl.c             |   1 +
 tests/unit/ini_config/ini_config.c        |   1 +
 tests/unit/test_kernel_data.c             |   1 +
 tests/unit/test_session.c                 |   1 +
 tests/unit/test_uri.c                     |   1 +
 tests/unit/test_ust_data.c                |   1 +
 tests/unit/test_utils_expand_path.c       |   1 +
 tests/unit/test_utils_parse_size_suffix.c |   1 +
 33 files changed, 769 insertions(+), 11 deletions(-)
 create mode 100644 src/common/mi-lttng.c
 create mode 100644 src/common/mi-lttng.h
include/lttng/lttng-error.h +0 -0
index 06baa04..1594ba9 100644

include/lttng/lttng-error.h enum lttng_error_code { · line 120

Quoted 1 line
include/lttng/lttng-error.h +0 -0
@@ -120,9 +120,9 @@ enum lttng_error_code {
      LTTNG_ERR_LOAD_INVALID_CONFIG    = 87,  /* Invalid session

configuration */

include/lttng/lttng-error.h enum lttng_error_code { · line 121

Quoted 1 line
include/lttng/lttng-error.h +0 -0
      LTTNG_ERR_LOAD_IO_FAIL           = 88,  /* IO error while reading

a session configuration */

include/lttng/lttng-error.h enum lttng_error_code { · line 122

Quoted 1 line
include/lttng/lttng-error.h +0 -0
      LTTNG_ERR_LOAD_SESSION_NOENT     = 89,  /* Session file not found

*/

include/lttng/lttng-error.h enum lttng_error_code { · line 123

Quoted 4 lines
include/lttng/lttng-error.h +1 -3
-     /* 90 */
-     /* 91 */
-     /* 92 */
+     LTTNG_ERR_MI_OUTPUT_TYPE         = 90, /* Invalid MI output format

*/

include/lttng/lttng-error.h enum lttng_error_code { · line 124

Quoted 1 line
include/lttng/lttng-error.h +1 -0
+     LTTNG_ERR_MI_IO_FAIL             = 91, /* IO error while writing

machine interface output */

include/lttng/lttng-error.h enum lttng_error_code { · line 125

Quoted 1 line
include/lttng/lttng-error.h +1 -0
+     LTTNG_ERR_MI_NOT_IMPLEMENTED     = 92, /* Mi feature not

implemented */

Review

Quoted 20 lines
include/lttng/lttng-error.h +0 -0
      /* 93 */
      /* 94 */
      /* 95 */
include/lttng/lttng.h +5 -0
index f0be224..9449161 100644
@@ -170,6 +170,11 @@ enum lttng_buffer_type {
      LTTNG_BUFFER_GLOBAL,    /* Only supported by the Kernel. */
 };
 
+/* Machine interface output type */
+enum lttng_mi_output_type {
+     LTTNG_MI_XML                          = 1 /* XML output */
+};
+
 /*
  * The structures should be initialized to zero before use.
  */
(quoted diff) +0 -0

b/src/bin/lttng-consumerd/lttng-consumerd.c

src/bin/lttng-consumerd/lttng-consumerd.c static int sigintcount = 0; · line 72

Quoted 12 lines

index e226ebc..0ce163e 100644

src/bin/lttng-consumerd/lttng-consumerd.c +2 -0
@@ -65,6 +65,8 @@ static int sigintcount = 0;
 /* Argument variables */
 int lttng_opt_quiet;    /* not static in error.h */
 int lttng_opt_verbose;  /* not static in error.h */
+int lttng_opt_mi;       /* not static in error.h */
+
 static int opt_daemon;
 static const char *progname;
 static char command_sock_path[PATH_MAX]; /* Global command socket path

*/

Review

Quoted 1 line
(quoted diff) +0 -0

b/src/bin/lttng/commands/add_context.c

Review

Quoted 18 lines

index 6483c98..2eb0e90 100644

src/bin/lttng/commands/add_context.c +7 -0
@@ -446,6 +446,13 @@ int cmd_add_context(int argc, const char **argv)
              goto end;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
(quoted diff) +0 -0

b/src/bin/lttng/commands/calibrate.c

Review

Quoted 18 lines

index 092632c..7d4de29 100644

src/bin/lttng/commands/calibrate.c +7 -0
@@ -133,6 +133,13 @@ static int calibrate_lttng(void)
              goto error;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto error;
+     }
+
      handle = lttng_create_handle(NULL, &dom);
      if (handle == NULL) {
              ret = CMD_ERROR;
(quoted diff) +0 -0

b/src/bin/lttng/commands/create.c

Quoted 6 lines

index e02b141..c43ce59 100644

src/bin/lttng/commands/create.c +0 -0
@@ -515,6 +515,13 @@ int cmd_create(int argc, const char **argv)
              }
      }

src/bin/lttng/commands/create.c int cmd_create(int argc, const char **argv) · line 526

Quoted 10 lines
src/bin/lttng/commands/create.c +7 -0
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      if (opt_no_consumer) {
              MSG("The option --no-consumer is obsolete. Use --no-output

now.");

Review

Quoted 2 lines
src/bin/lttng/commands/create.c +0 -0
              ret = CMD_WARNING;
(quoted diff) +0 -0

b/src/bin/lttng/commands/destroy.c

Review

Quoted 18 lines

index 3fb5fb2..26548b9 100644

src/bin/lttng/commands/destroy.c +7 -0
@@ -148,6 +148,13 @@ int cmd_destroy(int argc, const char **argv)
              goto end;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      /* Ignore session name in case all sessions are to be destroyed */
      if (opt_destroy_all) {
              ret = destroy_all_sessions();
(quoted diff) +0 -0

b/src/bin/lttng/commands/disable_channels.c

src/bin/lttng/commands/disable_channels.c int cmd_disable_channels(int argc, const char

Quoted 4 lines

index 1aa3916..da53d25 100644

src/bin/lttng/commands/disable_channels.c +0 -0
@@ -167,6 +167,13 @@ int cmd_disable_channels(int argc, const char

**argv)

Review

Quoted 14 lines
src/bin/lttng/commands/disable_channels.c +7 -0
              }
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      opt_channels = (char*) poptGetArg(pc);
      if (opt_channels == NULL) {
              ERR("Missing channel name(s).\n");
(quoted diff) +0 -0

b/src/bin/lttng/commands/disable_events.c

Review

Quoted 18 lines

index e712343..fb96b80 100644

src/bin/lttng/commands/disable_events.c +7 -0
@@ -212,6 +212,13 @@ int cmd_disable_events(int argc, const char **argv)
              }
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      opt_event_list = (char*) poptGetArg(pc);
      if (opt_event_list == NULL && opt_disable_all == 0) {
              ERR("Missing event name(s).\n");
(quoted diff) +0 -0

b/src/bin/lttng/commands/enable_channels.c

Review

Quoted 18 lines

index 55fbae6..8ea405e 100644

src/bin/lttng/commands/enable_channels.c +7 -0
@@ -327,6 +327,13 @@ int cmd_enable_channels(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/enable_events.c

Review

Quoted 18 lines

index bd2d997..8c7a73e 100644

src/bin/lttng/commands/enable_events.c +7 -0
@@ -968,6 +968,13 @@ int cmd_enable_events(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      /* Default event type */
      opt_event_type = LTTNG_EVENT_ALL;
 
(quoted diff) +0 -0

b/src/bin/lttng/commands/list.c

Review

Quoted 18 lines

index f69b3ba..bbd674c 100644

src/bin/lttng/commands/list.c +7 -0
@@ -850,6 +850,13 @@ int cmd_list(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/load.c

Review

Quoted 18 lines

index e732baa..2cfc698 100644

src/bin/lttng/commands/load.c +7 -0
@@ -77,6 +77,13 @@ int cmd_load(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, load_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/save.c

Review

Quoted 18 lines

index e8a4565..1aeb9f2 100644

src/bin/lttng/commands/save.c +7 -0
@@ -73,6 +73,13 @@ int cmd_save(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, save_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/set_session.c

Review

Quoted 18 lines

index 4238016..54320df 100644

src/bin/lttng/commands/set_session.c +7 -0
@@ -92,6 +92,13 @@ int cmd_set_session(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/snapshot.c

Review

Quoted 18 lines

index c704eee..21b5a05 100644

src/bin/lttng/commands/snapshot.c +7 -0
@@ -446,6 +446,13 @@ int cmd_snapshot(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, snapshot_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/start.c

Review

Quoted 18 lines

index 82122cc..82b3f5f 100644

src/bin/lttng/commands/start.c +7 -0
@@ -118,6 +118,13 @@ int cmd_start(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/stop.c

Review

Quoted 18 lines

index 60a1dac..5de96d8 100644

src/bin/lttng/commands/stop.c +7 -0
@@ -122,6 +122,13 @@ int cmd_stop(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/version.c

Quoted 13 lines

index 7f69de3..5c7ebbf 100644

src/bin/lttng/commands/version.c +2 -0
@@ -25,6 +25,8 @@
 #include <unistd.h>
 #include <config.h>
 
+#include <common/mi-lttng.h>
+
 #include "../command.h"
 
 enum {

src/bin/lttng/commands/version.c enum { · line 37

Quoted 4 lines
src/bin/lttng/commands/version.c +1 -0
@@ -32,6 +34,8 @@ enum {
      OPT_LIST_OPTIONS,
 };
 
+static const char *lttng_license = "lttng is free software and under

the GPL license and part LGPL";

Quoted 84 lines
src/bin/lttng/commands/version.c +73 -0
+
 static struct poptOption long_options[] = {
      /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
      {"help",      'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
@@ -53,6 +57,78 @@ static void usage(FILE *ofp)
 }
 
 /*
+ *  create_version
+ */
+static void create_version(struct mi_lttng_version *version)
+{
+     strncpy(version->version, VERSION, NAME_MAX);
+     version->version_major = VERSION_MAJOR;
+     version->version_minor = VERSION_MINOR;
+     version->version_patchlevel = VERSION_PATCHLEVEL;
+     strncpy(version->version_name, VERSION_NAME, NAME_MAX);
+     strncpy(version->package_url, PACKAGE_URL, NAME_MAX);
+}
+
+/*
+ *  print_mi
+ */
+static int print_mi()
+{
+     int ret;
+     struct mi_writer *writer = NULL;
+     struct mi_lttng_version version;
+
+     create_version(&version);
+
+     writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
+
+     if (!writer) {
+             ret = -LTTNG_ERR_NOMEM;
+             goto end;
+     }
+
+     /* Open the command element */
+     ret = mi_lttng_writer_command_open(writer,
+                     mi_lttng_element_command_version);
+     if (ret) {
+             goto error;
+     }
+
+     /* Beginning of output */
+     ret = mi_lttng_writer_open_element(writer,
+                     mi_lttng_element_command_output);
+     if (ret) {
+             goto error;
+     }
+
+     /* Print the machine interface of version */
+     ret = mi_lttng_version(writer, &version,
+                     VERSION_DESCRIPTION, lttng_license);
+     if (ret) {
+             goto error;
+     }
+
+     /* Close the output element */
+     ret = mi_lttng_writer_close_element(writer);
+     if (ret) {
+             goto error;
+     }
+
+     /* Close the command  */
+     ret = mi_lttng_writer_command_close(writer);
+
+error:
+     /* Cleanup */
+     if (writer && mi_lttng_writer_destroy(writer)) {
+             /* Preserve original error code */
+             ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
+     }
+
+end:
+     return ret;
+}
+
+/*
  *  cmd_version
  */
 int cmd_version(int argc, const char **argv)

src/bin/lttng/commands/version.c int cmd_version(int argc, const char **argv) · line 84

Quoted 7 lines
src/bin/lttng/commands/version.c +0 -4
@@ -78,10 +154,14 @@ int cmd_version(int argc, const char **argv)
              }
      }
 
-     MSG("lttng version " VERSION " - " VERSION_NAME);
-     MSG("\n" VERSION_DESCRIPTION "\n");
-     MSG("Web site: http://lttng.org");
-     MSG("\nlttng is free software and under the GPL license and part

LGPL");

Review

Quoted 12 lines
src/bin/lttng/commands/version.c +8 -0
+     if (lttng_opt_mi) {
+             ret = print_mi();
+     } else {
+             MSG("lttng version " VERSION " - " VERSION_NAME);
+             MSG("\n" VERSION_DESCRIPTION "\n");
+             MSG("Web site: http://lttng.org");
+             MSG("\n%s", lttng_license);
+     }
 
 end:
      poptFreeContext(pc);
(quoted diff) +0 -0

b/src/bin/lttng/commands/view.c

Quoted 27 lines

index adedf29..dcd4d66 100644

src/bin/lttng/commands/view.c +4 -0
@@ -445,6 +445,10 @@ int cmd_view(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     if (lttng_opt_mi) {
+             WARN("mi does not apply to view command");
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
src/bin/lttng/lttng.c +1 -0
index bc7577d..4510057 100644
@@ -55,6 +55,7 @@ static struct option long_options[] = {
      {"group",            1, NULL, 'g'},
      {"verbose",          0, NULL, 'v'},
      {"quiet",            0, NULL, 'q'},
+     {"mi",               1, NULL, 'm'},
      {"no-sessiond",      0, NULL, 'n'},
      {"sessiond-path",    1, NULL, OPT_SESSION_PATH},
      {"relayd-path",      1, NULL, OPT_RELAYD_PATH},

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 100

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
@@ -99,6 +100,8 @@ static void usage(FILE *ofp)
      fprintf(ofp, "      --list-commands        Simple listing of lttng

commands\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 103

Quoted 3 lines
src/bin/lttng/lttng.c +1 -0
      fprintf(ofp, "  -v, --verbose              Increase verbosity\n");
      fprintf(ofp, "  -q, --quiet                Quiet mode\n");
+     fprintf(ofp, "  -m, --mi TYPE              Machine Interface

mode.\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 105

Quoted 2 lines
src/bin/lttng/lttng.c +1 -0
+     fprintf(ofp, "                                 Type: xml\n");
      fprintf(ofp, "  -g, --group NAME           Unix tracing group

name. (default: tracing)\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 106

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
      fprintf(ofp, "  -n, --no-sessiond          Don't spawn a session

daemon\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 107

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
      fprintf(ofp, "      --sessiond-path PATH   Session daemon full

path\n");

Quoted 17 lines
src/bin/lttng/lttng.c +13 -0
@@ -136,6 +139,26 @@ static void version(FILE *ofp)
 }
 
 /*
+ * mi_output_type
+ *
+ * Find the MI output type enum from a string
+ * This function is for the support of
+ * new output language.
+ */
+static int mi_output_type(const char *output_type)
+{
+     int ret = 0;
+     if (!strncasecmp("xml", output_type, 3)) {
+             ret = LTTNG_MI_XML;
+     } else {
+             /* Invalid output format */

src/bin/lttng/lttng.c static void version(FILE *ofp) · line 164

Quoted 10 lines
src/bin/lttng/lttng.c +7 -0
+             ERR("MI output format not supported");
+             ret = -LTTNG_ERR_MI_OUTPUT_TYPE;
+     }
+     return ret;
+}
+
+/*
  *  list_options
  *
  *  List options line by line. This is mostly for bash auto completion

and to

src/bin/lttng/lttng.c static int parse_args(int argc, char **argv) · line 429

Quoted 5 lines
src/bin/lttng/lttng.c +0 -1
@@ -426,7 +449,7 @@ static int parse_args(int argc, char **argv)
              clean_exit(EXIT_FAILURE);
      }
 
-     while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options,

NULL)) != -1) {

src/bin/lttng/lttng.c static int parse_args(int argc, char **argv) · line 452

Quoted 1 line
src/bin/lttng/lttng.c +1 -0
+     while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options,

NULL)) != -1) {

Quoted 47 lines
src/bin/lttng/lttng.c +7 -0
              switch (opt) {
              case 'V':
                      version(stdout);
@@ -442,6 +465,13 @@ static int parse_args(int argc, char **argv)
              case 'q':
                      lttng_opt_quiet = 1;
                      break;
+             case 'm':
+                     lttng_opt_mi = mi_output_type(optarg);
+                     if (lttng_opt_mi < 0) {
+                             ret = lttng_opt_mi;
+                             goto error;
+                     }
+                     break;
              case 'g':
                      lttng_set_tracing_group(optarg);
                      break;
src/common/Makefile.am +4 -1
index 1a764ae..dffab06 100644
@@ -16,8 +16,11 @@ noinst_LTLIBRARIES = libcommon.la
 libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h \
                        common.h futex.c futex.h uri.c uri.h defaults.c \
                        pipe.c pipe.h readwrite.c readwrite.h \
+                       mi-lttng.h mi-lttng.c \
                        daemonize.c daemonize.h
-libcommon_la_LIBADD = -luuid
+libcommon_la_LIBADD = \
+             -luuid \
+             $(top_builddir)/src/common/config/libconfig.la
 
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
src/common/error.h +1 -0
index f8c0a1d..4e096b3 100644
@@ -36,6 +36,7 @@
 
 extern int lttng_opt_quiet;
 extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
 
 /* Error type. */
 #define PRINT_ERR   0x1

src/common/error.h extern int lttng_opt_verbose; · line 51

Quoted 3 lines
src/common/error.h +0 -0
@@ -48,12 +49,18 @@ extern int lttng_opt_verbose;
 
 /*
  * Macro for printing message depending on command line option and

verbosity.

src/common/error.h extern int lttng_opt_verbose; · line 55

Quoted 4 lines
src/common/error.h +4 -0
+ *
+ * Machine interface:
+ * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
+ * want any nested msg to show up when printing mi to stdout(if it's

the case).

src/common/error.h extern int lttng_opt_verbose; · line 54

Quoted 5 lines
src/common/error.h +1 -1
+ * All warnings and errors should be printed to stderr as normal.
  */
 #define __lttng_print(type, fmt, args...)                           \
      do {                                                            \
-             if (lttng_opt_quiet == 0 && type == PRINT_MSG) {

\

src/common/error.h extern int lttng_opt_verbose; · line 60

Quoted 1 line
src/common/error.h +1 -0
+             if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 61

Quoted 1 line
src/common/error.h +1 -0
+                             type == PRINT_MSG) {
         \

src/common/error.h extern int lttng_opt_verbose; · line 62

Quoted 1 line
src/common/error.h +0 -0
                      fprintf(stdout, fmt, ## args);
     \

src/common/error.h extern int lttng_opt_verbose; · line 56

Quoted 1 line
src/common/error.h +0 -1
-             } else if (lttng_opt_quiet == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 63

Quoted 1 line
src/common/error.h +1 -0
+             } else if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 64

Quoted 1 line
src/common/error.h +0 -0
                              (((type & PRINT_DBG) && lttng_opt_verbose

== 1) || \

src/common/error.h extern int lttng_opt_verbose; · line 65

Quoted 1 line
src/common/error.h +0 -0
                              ((type & (PRINT_DBG | PRINT_DBG2)) &&
          \

src/common/error.h extern int lttng_opt_verbose; · line 66

Quoted 1 line
src/common/error.h +0 -0
                                      lttng_opt_verbose == 2) ||
             \

src/common/mi-lttng.c

Quoted 12 lines
src/common/mi-lttng.c new file +5 -0
new file mode 100644
index 0000000..bbec2c5
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]
 
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify

it

Quoted 4 lines

+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but

WITHOUT

Quoted 2 lines

+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

for

Quoted 3 lines

+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License

along with

Quoted 17 lines

+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */

src/common/mi-lttng.c new file +14 -0
+
+#include <include/config.h>
+#include <common/config/config.h>
+#include "mi-lttng.h"
+
+/* Strings related to command */
+const char * const mi_lttng_element_command = "command";
+const char * const mi_lttng_element_command_version = "version";
+const char * const mi_lttng_element_command_list = "list";
+const char * const mi_lttng_element_command_name = "name";
+const char * const mi_lttng_element_command_output = "output";
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version = "version";

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+const char * const mi_lttng_element_version_str = "string";
+const char * const mi_lttng_element_version_web = "url";
+const char * const mi_lttng_element_version_major = "major";
+const char * const mi_lttng_element_version_minor = "minor";
+const char * const mi_lttng_element_version_license = "license";
+const char * const mi_lttng_element_version_patch_level = "patchLevel";
+const char * const mi_lttng_element_version_description = "description";
+
+LTTNG_HIDDEN
+struct mi_writer *mi_lttng_writer_create(int fd_output, int

mi_output_type)

Quoted 38 lines
src/common/mi-lttng.c new file +38 -0
+{
+     struct mi_writer *mi_writer;
+
+     mi_writer = zmalloc(sizeof(struct mi_writer));
+     if (!mi_writer) {
+             PERROR("zmalloc mi_writer_create");
+             goto end;
+     }
+     if (mi_output_type == LTTNG_MI_XML) {
+             mi_writer->writer = config_writer_create(fd_output);
+             if (!mi_writer->writer) {
+                     goto err_destroy;
+             }
+             mi_writer->type = LTTNG_MI_XML;
+     } else {
+             goto err_destroy;
+     }
+
+end:
+     return mi_writer;
+
+err_destroy:
+     free(mi_writer);
+     return NULL;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_destroy(struct mi_writer *writer)
+{
+     int ret;
+
+     if (!writer) {
+             ret = -EINVAL;
+             goto end;
+     }
+
+     ret = config_writer_destroy(writer->writer);
+     if (ret < 0) {

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+             goto end;
+     }
+
+     free(writer);
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char

*command)

src/common/mi-lttng.c

Quoted 3 lines
src/common/mi-lttng.c new file +3 -0
+{
+     int ret;
+     ret = mi_lttng_writer_open_element(writer,

mi_lttng_element_command);

Quoted 52 lines
src/common/mi-lttng.c new file +52 -0
+     if (ret) {
+             goto end;
+     }
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_command_name, command);
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_close(struct mi_writer *writer)
+{
+     return mi_lttng_writer_close_element(writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+             const char *element_name)
+{
+     return config_writer_open_element(writer->writer, element_name);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_close_element(struct mi_writer *writer)
+{
+     return config_writer_close_element(writer->writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+             const char *element_name, uint64_t value)
+{
+     return config_writer_write_element_unsigned_int(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+             const char *element_name, int64_t value)
+{
+     return config_writer_write_element_signed_int(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+             const char *element_name, int value)
+{
+     return config_writer_write_element_bool(writer->writer,
+                     element_name, value);
+}
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+             const char *element_name, const char *value)
+{
+     return config_writer_write_element_string(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version

*version,

src/common/mi-lttng.c

Quoted 6 lines
src/common/mi-lttng.c new file +6 -0
+     const char *lttng_description, const char *lttng_license)
+{
+     int ret;
+
+     /* Open version */
+     ret = mi_lttng_writer_open_element(writer,

mi_lttng_element_version);

Quoted 4 lines
src/common/mi-lttng.c new file +4 -0
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* Version string (contain info like rc etc.) */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_str, VERSION);
+     if (ret) {
+             goto end;
+     }
+
+     /* Major version number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_major,

version->version_major);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* Minor version number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_minor,

version->version_minor);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* Patch number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_patch_level,

version->version_patchlevel);

Quoted 4 lines
src/common/mi-lttng.c new file +4 -0
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* Name of the version */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_name, version->version_name);
+     if (ret) {
+             goto end;
+     }
+
+     /* Description mostly related to beer... */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_description,

lttng_description);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* url */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_web,

version->package_url);

Quoted 45 lines
src/common/mi-lttng.c new file +45 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* License: free as in free beer...no...*speech* */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_license, lttng_license);
+     if (ret) {
+             goto end;
+     }
+
+     /* Close version element */
+     ret = mi_lttng_writer_close_element(writer);
+
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_session(struct mi_writer *writer,
+             struct lttng_session *session, int is_open)
+{
+     int ret;
+
+     /* open sessions element */
+     ret = mi_lttng_writer_open_element(writer,
+                     config_element_session);
+     if (ret) {
+             goto end;
+     }
+
+     /* Name of the session */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_name, session->name);
+     if (ret) {
+             goto end;
+     }
+
+     /* path */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_path, session->path);
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* enabled ? */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_enabled, session->enabled);
+     if (ret) {
+             goto end;
+     }
+
+     /* snapshot mode */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_snapshot_mode,

session->snapshot_mode);

Quoted 26 lines
src/common/mi-lttng.c new file +20 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* live timer interval in usec */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_live_timer_interval,
+                     session->live_timer_interval);
+     if (ret) {
+             goto end;
+     }
+
+     if (!is_open) {
+             /* Closing session element */
+             ret = mi_lttng_writer_close_element(writer);
+     }
+end:
+     return ret;
+
+}
src/common/mi-lttng.h new file +0 -0
new file mode 100644
index 0000000..69ec0f5

src/common/mi-lttng.h

Quoted 6 lines
src/common/mi-lttng.h new file +5 -0
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]
 
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify

it

Quoted 4 lines

+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but

WITHOUT

Quoted 2 lines

+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

for

Quoted 3 lines

+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License

along with

Quoted 20 lines

+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */

src/common/mi-lttng.h new file +17 -0
+
+#ifndef _MI_LTTNG_H
+#define _MI_LTTNG_H
+
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/config/config.h>
+
+#include <lttng/lttng.h>
+
+#include <stdint.h>
+
+
+/* Instance of a machine interface writer. */
+struct mi_writer {
+     struct config_writer *writer;
+     enum lttng_mi_output_type type;

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+};
+
+/*
+ * Version information for the machine interface.
+ */
+struct mi_lttng_version {
+     char version[NAME_MAX]; /* Version number of package */
+     uint32_t version_major; /* LTTng-Tools major version number */
+     uint32_t version_minor; /* LTTng-Tools minor version number */
+     uint32_t version_patchlevel; /* LTTng-Tools patchlevel version

number */

src/common/mi-lttng.h

Quoted 2 lines
src/common/mi-lttng.h new file +2 -0
+     char version_name[NAME_MAX];
+     char package_url[NAME_MAX]; /* Define to the home page for this

package. */

Quoted 13 lines
src/common/mi-lttng.h new file +13 -0
+};
+
+/* Strings related to command */
+const char * const mi_lttng_element_command;
+const char * const mi_lttng_element_command_version;
+const char * const mi_lttng_element_command_list;
+const char * const mi_lttng_element_command_name;
+const char * const mi_lttng_element_command_output;
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version;
+const char * const mi_lttng_element_version_str;
+const char * const mi_lttng_element_version_web;

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+const char * const mi_lttng_element_version_major;
+const char * const mi_lttng_element_version_minor;
+const char * const mi_lttng_element_version_license;
+const char * const mi_lttng_element_version_patch_level;
+const char * const mi_lttng_element_version_description;
+
+/*
+ * Create an instance of a machine interface writer.
+ *
+ * fd_output File to which the XML content must be written. The file

will be

Quoted 6 lines

+ * closed once the mi_writer has been destroyed.
+ *
+ * Returns an instance of a machine interface writer on success, NULL on
+ * error.
+ */
+struct mi_writer *mi_lttng_writer_create(int fd_output, int

mi_output_type);

src/common/mi-lttng.h

Quoted 7 lines
src/common/mi-lttng.h new file +7 -0
+
+/*
+ * Destroy an instance of a machine interface writer.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative

values

Quoted 5 lines

+ * indicate an error.
+ */

src/common/mi-lttng.h new file +3 -0
+int mi_lttng_writer_destroy(struct mi_writer *writer);
+
+/*

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+ * Open a command tag and add it's name node.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * command The command name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char

*command);

Quoted 99 lines
src/common/mi-lttng.h new file +99 -0
+
+/*
+ * Close a command tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_close(struct mi_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+             const char *element_name);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_close_element(struct mi_writer *writer);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+             const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Signed int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+             const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Boolean value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+             const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value String value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+             const char *element_name, const char *value);
+
+/*
+ * Machine interface of struct version.
+ *
+ * writer An instance of a machine interface writer.
+ *

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+ * version Version struct.
+ *
+ * lttng_description String value of the version description.
+ *
+ * lttng_license String value of the version license.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version

*version,

Review

Quoted 25 lines
src/common/mi-lttng.h new file +24 -0
+             const char *lttng_description, const char *lttng_license);
+
+/*
+ * Machine interface of struct session.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * session An instance of a session
+ *
+ * isOpen Define if we close the session element
+ *        This should be use carefully and the client
+ *        need to close the session element.
+ *        Use case: nested addition information on a session
+ *                  ex: domain,channel event.
+ *        0-> False
+ *        1-> True
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_session(struct mi_writer *writer,
+             struct lttng_session *session, int isOpen);
+
+#endif /* _MI_LTTNG_H */
(quoted diff) +0 -0

b/src/lib/lttng-ctl/lttng-ctl.c

Review

Quoted 12 lines

index 100e587..7dd9828 100644

src/lib/lttng-ctl/lttng-ctl.c +1 -0
@@ -74,6 +74,7 @@ static int connected;
  */
 int lttng_opt_quiet;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 /*
  * Copy string from src to dst and enforce null terminated byte.
(quoted diff) +0 -0

b/tests/unit/ini_config/ini_config.c

Review

Quoted 12 lines

index 38fe5f4..29935ef 100644

tests/unit/ini_config/ini_config.c +1 -0
@@ -31,6 +31,7 @@ struct state {
 
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int entry_handler(const struct config_entry *entry,
              struct state *state)
(quoted diff) +0 -0

b/tests/unit/test_kernel_data.c

Review

Quoted 48 lines

index e2182e9..2639be4 100644

tests/unit/test_kernel_data.c +1 -0
@@ -38,6 +38,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_session.c +1 -0
index a0e84e9..4f90c33 100644
@@ -46,6 +46,7 @@ static struct ltt_session_list *session_list;
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_uri.c +1 -0
index 7cac95d..432e2b3 100644
@@ -25,6 +25,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 /* Number of TAP tests in this file */
 #define NUM_TESTS 11
tests/unit/test_ust_data.c +1 -0
index 150d5da..dd00089 100644
@@ -44,6 +44,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
(quoted diff) +0 -0

b/tests/unit/test_utils_expand_path.c

Review

Quoted 12 lines

index fe709ac..f863b5d 100644

tests/unit/test_utils_expand_path.c +1 -0
@@ -31,6 +31,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
      char *input;
(quoted diff) +0 -0

b/tests/unit/test_utils_parse_size_suffix.c

Quoted 20 lines

index 990aa1b..f81278d 100644

tests/unit/test_utils_parse_size_suffix.c +1 -1
@@ -26,6 +26,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
      char *input;
--

1.8.3.2

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 3 lines
Jonathan Rajotte Julien
Chargé de laboratoire, INF1995
Polytechnique Montréal

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CAF4oYfF51hSeAhCFALyKoajhbLEaU_RD91DQY0Yqg1P114JkJw@mail.gmail.com

#5 lore raw
Quoted 4 lines · Jonathan Rajotte

We will also provide patches for snapshot + regression test.

Could you send me the minor modifications? I wouldn't like to make the same mistakes twice.

You can based you next patches and also 2/3 and 3/3 on this dev. branch that I'm staging for merging upstream.

https://github.com/dgoulet/lttng-tools-dev.git (branch: mi)

Cheers!
David

Quoted 1,410 lines

Thanks

Quoted 1,404 lines · David Goulet

I've fixed some minor things and prepared this one for a merge.

Once the full patch set is ready to be merged, I'll be pushing them all at once.

Thanks!
David

Quoted 3 lines · Jonathan Rajotte

Hi,

These patches add machine interface functionality to command version and

list.

Quoted 29 lines

At the same time they procure a base architecture of the machine interface.

The first patch cover the version command and add the base for the machine interface.(mostly the same as last week mi patch) p.s: David if you want to pull this one [1].

The second patch provide full machine interface functionality to the list command. You will find attached a little script that demonstrate the mi functionality of list. The script need a root sessiond and need to be at the base of lttng-tool directory. Outputs will be generated in ./mi_test_output/ .

The third patch provide an xsd to validate the mi output of list and version command.

Voilà!

Jonathan

[1] https://github.com/PSRCode/lttng-tools-dev/commits/list_release

    commit: add4aa1a79247749cb823ec68ab1067beda937d0

--Patch--

The machine interface option is now available for version. Other commands will shortly follow.
Mi backend is expected to grow with addition of mi support to other commands.

Quoted 7 lines

How to use:

      lttng --mi <mi_output_type> <command>

This syntax will be the same for all commands. Currently *only xml is supported as machine interface output.*

As for errors handling, if an error/warning occurs while using mi it

will be

Quoted 3 lines

reported on stderr as normal. The integrity of the mi output cannot be guaranteed if an error/warning occurs.
The error output format is consistent and easy for a machine client to

parse.

Quoted 16 lines

Thus no mi output format is required for error output.

Example:

      lttng --mi xml version
Output:
<?xml version="1.0" encoding="UTF-8"?>
  <command>
    <name>version</name>
    <output>
      <string>2.4.0-rc2</string>
      <major>2</major>
      <minor>4</minor>
      <patchLevel>0</patchLevel>
      <name>Époque Opaque</name>
      <description>The Époque Opaque is a black IPA from Trou du Diable
      brewery. The nose is eerily reminiscent of the coffee crisp candy

from

Quoted 1 line

of our childhood. These strong mocha accents are present on the

palate,

Quoted 1 line

which are quickly subdued by Japanese and Australian hops leading

to a

Quoted 27 lines

final state of satisfaction enjoyable for any fan of bitter beer.</description>
<url>http://lttng.org</url>
<license>lttng is free software and under the GPL license and part LGPL</license>
</output>
</command>

---
 include/lttng/lttng-error.h               |   6 +-
 include/lttng/lttng.h                     |   5 +
 src/bin/lttng-consumerd/lttng-consumerd.c |   2 +
 src/bin/lttng/commands/add_context.c      |   7 +
 src/bin/lttng/commands/calibrate.c        |   7 +
 src/bin/lttng/commands/create.c           |   7 +
 src/bin/lttng/commands/destroy.c          |   7 +
 src/bin/lttng/commands/disable_channels.c |   7 +
 src/bin/lttng/commands/disable_events.c   |   7 +
 src/bin/lttng/commands/enable_channels.c  |   7 +
 src/bin/lttng/commands/enable_events.c    |   7 +
 src/bin/lttng/commands/list.c             |   7 +
 src/bin/lttng/commands/load.c             |   7 +
 src/bin/lttng/commands/save.c             |   7 +
 src/bin/lttng/commands/set_session.c      |   7 +
 src/bin/lttng/commands/snapshot.c         |   7 +
Quoted 8 lines
 src/bin/lttng/commands/start.c            |   7 +
 src/bin/lttng/commands/stop.c             |   7 +
 src/bin/lttng/commands/version.c          |  88 ++++++++-
 src/bin/lttng/commands/view.c             |   4 +
 src/bin/lttng/lttng.c                     |  32 +++-
 src/common/Makefile.am                    |   5 +-
 src/common/error.h                        |  11 +-
 src/common/mi-lttng.c                     | 284

++++++++++++++++++++++++++++++

Quoted 18 lines
 src/common/mi-lttng.h                     | 230 ++++++++++++++++++++++++
 src/lib/lttng-ctl/lttng-ctl.c             |   1 +
 tests/unit/ini_config/ini_config.c        |   1 +
 tests/unit/test_kernel_data.c             |   1 +
 tests/unit/test_session.c                 |   1 +
 tests/unit/test_uri.c                     |   1 +
 tests/unit/test_ust_data.c                |   1 +
 tests/unit/test_utils_expand_path.c       |   1 +
 tests/unit/test_utils_parse_size_suffix.c |   1 +
 33 files changed, 769 insertions(+), 11 deletions(-)
 create mode 100644 src/common/mi-lttng.c
 create mode 100644 src/common/mi-lttng.h
include/lttng/lttng-error.h +0 -0
index 06baa04..1594ba9 100644

include/lttng/lttng-error.h enum lttng_error_code { · line 120

Quoted 1 line
include/lttng/lttng-error.h +0 -0
@@ -120,9 +120,9 @@ enum lttng_error_code {
      LTTNG_ERR_LOAD_INVALID_CONFIG    = 87,  /* Invalid session

configuration */

include/lttng/lttng-error.h enum lttng_error_code { · line 121

Quoted 1 line
include/lttng/lttng-error.h +0 -0
      LTTNG_ERR_LOAD_IO_FAIL           = 88,  /* IO error while reading

a session configuration */

include/lttng/lttng-error.h enum lttng_error_code { · line 122

Quoted 1 line
include/lttng/lttng-error.h +0 -0
      LTTNG_ERR_LOAD_SESSION_NOENT     = 89,  /* Session file not found

*/

include/lttng/lttng-error.h enum lttng_error_code { · line 123

Quoted 4 lines
include/lttng/lttng-error.h +1 -3
-     /* 90 */
-     /* 91 */
-     /* 92 */
+     LTTNG_ERR_MI_OUTPUT_TYPE         = 90, /* Invalid MI output format

*/

include/lttng/lttng-error.h enum lttng_error_code { · line 124

Quoted 1 line
include/lttng/lttng-error.h +1 -0
+     LTTNG_ERR_MI_IO_FAIL             = 91, /* IO error while writing

machine interface output */

include/lttng/lttng-error.h enum lttng_error_code { · line 125

Quoted 1 line
include/lttng/lttng-error.h +1 -0
+     LTTNG_ERR_MI_NOT_IMPLEMENTED     = 92, /* Mi feature not

implemented */

Review

Quoted 20 lines
include/lttng/lttng-error.h +0 -0
      /* 93 */
      /* 94 */
      /* 95 */
include/lttng/lttng.h +5 -0
index f0be224..9449161 100644
@@ -170,6 +170,11 @@ enum lttng_buffer_type {
      LTTNG_BUFFER_GLOBAL,    /* Only supported by the Kernel. */
 };
 
+/* Machine interface output type */
+enum lttng_mi_output_type {
+     LTTNG_MI_XML                          = 1 /* XML output */
+};
+
 /*
  * The structures should be initialized to zero before use.
  */
(quoted diff) +0 -0

b/src/bin/lttng-consumerd/lttng-consumerd.c

src/bin/lttng-consumerd/lttng-consumerd.c static int sigintcount = 0; · line 72

Quoted 12 lines

index e226ebc..0ce163e 100644

src/bin/lttng-consumerd/lttng-consumerd.c +2 -0
@@ -65,6 +65,8 @@ static int sigintcount = 0;
 /* Argument variables */
 int lttng_opt_quiet;    /* not static in error.h */
 int lttng_opt_verbose;  /* not static in error.h */
+int lttng_opt_mi;       /* not static in error.h */
+
 static int opt_daemon;
 static const char *progname;
 static char command_sock_path[PATH_MAX]; /* Global command socket path

*/

Review

Quoted 1 line
(quoted diff) +0 -0

b/src/bin/lttng/commands/add_context.c

Review

Quoted 18 lines

index 6483c98..2eb0e90 100644

src/bin/lttng/commands/add_context.c +7 -0
@@ -446,6 +446,13 @@ int cmd_add_context(int argc, const char **argv)
              goto end;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
(quoted diff) +0 -0

b/src/bin/lttng/commands/calibrate.c

Review

Quoted 18 lines

index 092632c..7d4de29 100644

src/bin/lttng/commands/calibrate.c +7 -0
@@ -133,6 +133,13 @@ static int calibrate_lttng(void)
              goto error;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto error;
+     }
+
      handle = lttng_create_handle(NULL, &dom);
      if (handle == NULL) {
              ret = CMD_ERROR;
(quoted diff) +0 -0

b/src/bin/lttng/commands/create.c

Quoted 6 lines

index e02b141..c43ce59 100644

src/bin/lttng/commands/create.c +0 -0
@@ -515,6 +515,13 @@ int cmd_create(int argc, const char **argv)
              }
      }

src/bin/lttng/commands/create.c int cmd_create(int argc, const char **argv) · line 526

Quoted 10 lines
src/bin/lttng/commands/create.c +7 -0
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      if (opt_no_consumer) {
              MSG("The option --no-consumer is obsolete. Use --no-output

now.");

Review

Quoted 2 lines
src/bin/lttng/commands/create.c +0 -0
              ret = CMD_WARNING;
(quoted diff) +0 -0

b/src/bin/lttng/commands/destroy.c

Review

Quoted 18 lines

index 3fb5fb2..26548b9 100644

src/bin/lttng/commands/destroy.c +7 -0
@@ -148,6 +148,13 @@ int cmd_destroy(int argc, const char **argv)
              goto end;
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      /* Ignore session name in case all sessions are to be destroyed */
      if (opt_destroy_all) {
              ret = destroy_all_sessions();
(quoted diff) +0 -0

b/src/bin/lttng/commands/disable_channels.c

src/bin/lttng/commands/disable_channels.c int cmd_disable_channels(int argc, const char

Quoted 4 lines

index 1aa3916..da53d25 100644

src/bin/lttng/commands/disable_channels.c +0 -0
@@ -167,6 +167,13 @@ int cmd_disable_channels(int argc, const char

**argv)

Review

Quoted 14 lines
src/bin/lttng/commands/disable_channels.c +7 -0
              }
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      opt_channels = (char*) poptGetArg(pc);
      if (opt_channels == NULL) {
              ERR("Missing channel name(s).\n");
(quoted diff) +0 -0

b/src/bin/lttng/commands/disable_events.c

Review

Quoted 18 lines

index e712343..fb96b80 100644

src/bin/lttng/commands/disable_events.c +7 -0
@@ -212,6 +212,13 @@ int cmd_disable_events(int argc, const char **argv)
              }
      }
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      opt_event_list = (char*) poptGetArg(pc);
      if (opt_event_list == NULL && opt_disable_all == 0) {
              ERR("Missing event name(s).\n");
(quoted diff) +0 -0

b/src/bin/lttng/commands/enable_channels.c

Review

Quoted 18 lines

index 55fbae6..8ea405e 100644

src/bin/lttng/commands/enable_channels.c +7 -0
@@ -327,6 +327,13 @@ int cmd_enable_channels(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/enable_events.c

Review

Quoted 18 lines

index bd2d997..8c7a73e 100644

src/bin/lttng/commands/enable_events.c +7 -0
@@ -968,6 +968,13 @@ int cmd_enable_events(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      /* Default event type */
      opt_event_type = LTTNG_EVENT_ALL;
 
(quoted diff) +0 -0

b/src/bin/lttng/commands/list.c

Review

Quoted 18 lines

index f69b3ba..bbd674c 100644

src/bin/lttng/commands/list.c +7 -0
@@ -850,6 +850,13 @@ int cmd_list(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/load.c

Review

Quoted 18 lines

index e732baa..2cfc698 100644

src/bin/lttng/commands/load.c +7 -0
@@ -77,6 +77,13 @@ int cmd_load(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, load_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/save.c

Review

Quoted 18 lines

index e8a4565..1aeb9f2 100644

src/bin/lttng/commands/save.c +7 -0
@@ -73,6 +73,13 @@ int cmd_save(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, save_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/set_session.c

Review

Quoted 18 lines

index 4238016..54320df 100644

src/bin/lttng/commands/set_session.c +7 -0
@@ -92,6 +92,13 @@ int cmd_set_session(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/snapshot.c

Review

Quoted 18 lines

index c704eee..21b5a05 100644

src/bin/lttng/commands/snapshot.c +7 -0
@@ -446,6 +446,13 @@ int cmd_snapshot(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, snapshot_opts, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/start.c

Review

Quoted 18 lines

index 82122cc..82b3f5f 100644

src/bin/lttng/commands/start.c +7 -0
@@ -118,6 +118,13 @@ int cmd_start(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/stop.c

Review

Quoted 18 lines

index 60a1dac..5de96d8 100644

src/bin/lttng/commands/stop.c +7 -0
@@ -122,6 +122,13 @@ int cmd_stop(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     /* TODO: mi support */
+     if (lttng_opt_mi) {
+             ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+             ERR("mi option not supported");
+             goto end;
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
(quoted diff) +0 -0

b/src/bin/lttng/commands/version.c

Quoted 13 lines

index 7f69de3..5c7ebbf 100644

src/bin/lttng/commands/version.c +2 -0
@@ -25,6 +25,8 @@
 #include <unistd.h>
 #include <config.h>
 
+#include <common/mi-lttng.h>
+
 #include "../command.h"
 
 enum {

src/bin/lttng/commands/version.c enum { · line 37

Quoted 4 lines
src/bin/lttng/commands/version.c +1 -0
@@ -32,6 +34,8 @@ enum {
      OPT_LIST_OPTIONS,
 };
 
+static const char *lttng_license = "lttng is free software and under

the GPL license and part LGPL";

Quoted 84 lines
src/bin/lttng/commands/version.c +73 -0
+
 static struct poptOption long_options[] = {
      /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
      {"help",      'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
@@ -53,6 +57,78 @@ static void usage(FILE *ofp)
 }
 
 /*
+ *  create_version
+ */
+static void create_version(struct mi_lttng_version *version)
+{
+     strncpy(version->version, VERSION, NAME_MAX);
+     version->version_major = VERSION_MAJOR;
+     version->version_minor = VERSION_MINOR;
+     version->version_patchlevel = VERSION_PATCHLEVEL;
+     strncpy(version->version_name, VERSION_NAME, NAME_MAX);
+     strncpy(version->package_url, PACKAGE_URL, NAME_MAX);
+}
+
+/*
+ *  print_mi
+ */
+static int print_mi()
+{
+     int ret;
+     struct mi_writer *writer = NULL;
+     struct mi_lttng_version version;
+
+     create_version(&version);
+
+     writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
+
+     if (!writer) {
+             ret = -LTTNG_ERR_NOMEM;
+             goto end;
+     }
+
+     /* Open the command element */
+     ret = mi_lttng_writer_command_open(writer,
+                     mi_lttng_element_command_version);
+     if (ret) {
+             goto error;
+     }
+
+     /* Beginning of output */
+     ret = mi_lttng_writer_open_element(writer,
+                     mi_lttng_element_command_output);
+     if (ret) {
+             goto error;
+     }
+
+     /* Print the machine interface of version */
+     ret = mi_lttng_version(writer, &version,
+                     VERSION_DESCRIPTION, lttng_license);
+     if (ret) {
+             goto error;
+     }
+
+     /* Close the output element */
+     ret = mi_lttng_writer_close_element(writer);
+     if (ret) {
+             goto error;
+     }
+
+     /* Close the command  */
+     ret = mi_lttng_writer_command_close(writer);
+
+error:
+     /* Cleanup */
+     if (writer && mi_lttng_writer_destroy(writer)) {
+             /* Preserve original error code */
+             ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;
+     }
+
+end:
+     return ret;
+}
+
+/*
  *  cmd_version
  */
 int cmd_version(int argc, const char **argv)

src/bin/lttng/commands/version.c int cmd_version(int argc, const char **argv) · line 84

Quoted 7 lines
src/bin/lttng/commands/version.c +0 -4
@@ -78,10 +154,14 @@ int cmd_version(int argc, const char **argv)
              }
      }
 
-     MSG("lttng version " VERSION " - " VERSION_NAME);
-     MSG("\n" VERSION_DESCRIPTION "\n");
-     MSG("Web site: http://lttng.org");
-     MSG("\nlttng is free software and under the GPL license and part

LGPL");

Review

Quoted 12 lines
src/bin/lttng/commands/version.c +8 -0
+     if (lttng_opt_mi) {
+             ret = print_mi();
+     } else {
+             MSG("lttng version " VERSION " - " VERSION_NAME);
+             MSG("\n" VERSION_DESCRIPTION "\n");
+             MSG("Web site: http://lttng.org");
+             MSG("\n%s", lttng_license);
+     }
 
 end:
      poptFreeContext(pc);
(quoted diff) +0 -0

b/src/bin/lttng/commands/view.c

Quoted 27 lines

index adedf29..dcd4d66 100644

src/bin/lttng/commands/view.c +4 -0
@@ -445,6 +445,10 @@ int cmd_view(int argc, const char **argv)
      pc = poptGetContext(NULL, argc, argv, long_options, 0);
      poptReadDefaultConfig(pc, 0);
 
+     if (lttng_opt_mi) {
+             WARN("mi does not apply to view command");
+     }
+
      while ((opt = poptGetNextOpt(pc)) != -1) {
              switch (opt) {
              case OPT_HELP:
src/bin/lttng/lttng.c +1 -0
index bc7577d..4510057 100644
@@ -55,6 +55,7 @@ static struct option long_options[] = {
      {"group",            1, NULL, 'g'},
      {"verbose",          0, NULL, 'v'},
      {"quiet",            0, NULL, 'q'},
+     {"mi",               1, NULL, 'm'},
      {"no-sessiond",      0, NULL, 'n'},
      {"sessiond-path",    1, NULL, OPT_SESSION_PATH},
      {"relayd-path",      1, NULL, OPT_RELAYD_PATH},

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 100

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
@@ -99,6 +100,8 @@ static void usage(FILE *ofp)
      fprintf(ofp, "      --list-commands        Simple listing of lttng

commands\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 103

Quoted 3 lines
src/bin/lttng/lttng.c +1 -0
      fprintf(ofp, "  -v, --verbose              Increase verbosity\n");
      fprintf(ofp, "  -q, --quiet                Quiet mode\n");
+     fprintf(ofp, "  -m, --mi TYPE              Machine Interface

mode.\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 105

Quoted 2 lines
src/bin/lttng/lttng.c +1 -0
+     fprintf(ofp, "                                 Type: xml\n");
      fprintf(ofp, "  -g, --group NAME           Unix tracing group

name. (default: tracing)\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 106

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
      fprintf(ofp, "  -n, --no-sessiond          Don't spawn a session

daemon\n");

src/bin/lttng/lttng.c static void usage(FILE *ofp) · line 107

Quoted 1 line
src/bin/lttng/lttng.c +0 -0
      fprintf(ofp, "      --sessiond-path PATH   Session daemon full

path\n");

Quoted 17 lines
src/bin/lttng/lttng.c +13 -0
@@ -136,6 +139,26 @@ static void version(FILE *ofp)
 }
 
 /*
+ * mi_output_type
+ *
+ * Find the MI output type enum from a string
+ * This function is for the support of
+ * new output language.
+ */
+static int mi_output_type(const char *output_type)
+{
+     int ret = 0;
+     if (!strncasecmp("xml", output_type, 3)) {
+             ret = LTTNG_MI_XML;
+     } else {
+             /* Invalid output format */

src/bin/lttng/lttng.c static void version(FILE *ofp) · line 164

Quoted 10 lines
src/bin/lttng/lttng.c +7 -0
+             ERR("MI output format not supported");
+             ret = -LTTNG_ERR_MI_OUTPUT_TYPE;
+     }
+     return ret;
+}
+
+/*
  *  list_options
  *
  *  List options line by line. This is mostly for bash auto completion

and to

src/bin/lttng/lttng.c static int parse_args(int argc, char **argv) · line 429

Quoted 5 lines
src/bin/lttng/lttng.c +0 -1
@@ -426,7 +449,7 @@ static int parse_args(int argc, char **argv)
              clean_exit(EXIT_FAILURE);
      }
 
-     while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options,

NULL)) != -1) {

src/bin/lttng/lttng.c static int parse_args(int argc, char **argv) · line 452

Quoted 1 line
src/bin/lttng/lttng.c +1 -0
+     while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options,

NULL)) != -1) {

Quoted 47 lines
src/bin/lttng/lttng.c +7 -0
              switch (opt) {
              case 'V':
                      version(stdout);
@@ -442,6 +465,13 @@ static int parse_args(int argc, char **argv)
              case 'q':
                      lttng_opt_quiet = 1;
                      break;
+             case 'm':
+                     lttng_opt_mi = mi_output_type(optarg);
+                     if (lttng_opt_mi < 0) {
+                             ret = lttng_opt_mi;
+                             goto error;
+                     }
+                     break;
              case 'g':
                      lttng_set_tracing_group(optarg);
                      break;
src/common/Makefile.am +4 -1
index 1a764ae..dffab06 100644
@@ -16,8 +16,11 @@ noinst_LTLIBRARIES = libcommon.la
 libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h \
                        common.h futex.c futex.h uri.c uri.h defaults.c \
                        pipe.c pipe.h readwrite.c readwrite.h \
+                       mi-lttng.h mi-lttng.c \
                        daemonize.c daemonize.h
-libcommon_la_LIBADD = -luuid
+libcommon_la_LIBADD = \
+             -luuid \
+             $(top_builddir)/src/common/config/libconfig.la
 
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
src/common/error.h +1 -0
index f8c0a1d..4e096b3 100644
@@ -36,6 +36,7 @@
 
 extern int lttng_opt_quiet;
 extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
 
 /* Error type. */
 #define PRINT_ERR   0x1

src/common/error.h extern int lttng_opt_verbose; · line 51

Quoted 3 lines
src/common/error.h +0 -0
@@ -48,12 +49,18 @@ extern int lttng_opt_verbose;
 
 /*
  * Macro for printing message depending on command line option and

verbosity.

src/common/error.h extern int lttng_opt_verbose; · line 55

Quoted 4 lines
src/common/error.h +4 -0
+ *
+ * Machine interface:
+ * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
+ * want any nested msg to show up when printing mi to stdout(if it's

the case).

src/common/error.h extern int lttng_opt_verbose; · line 54

Quoted 5 lines
src/common/error.h +1 -1
+ * All warnings and errors should be printed to stderr as normal.
  */
 #define __lttng_print(type, fmt, args...)                           \
      do {                                                            \
-             if (lttng_opt_quiet == 0 && type == PRINT_MSG) {

\

src/common/error.h extern int lttng_opt_verbose; · line 60

Quoted 1 line
src/common/error.h +1 -0
+             if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 61

Quoted 1 line
src/common/error.h +1 -0
+                             type == PRINT_MSG) {
         \

src/common/error.h extern int lttng_opt_verbose; · line 62

Quoted 1 line
src/common/error.h +0 -0
                      fprintf(stdout, fmt, ## args);
     \

src/common/error.h extern int lttng_opt_verbose; · line 56

Quoted 1 line
src/common/error.h +0 -1
-             } else if (lttng_opt_quiet == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 63

Quoted 1 line
src/common/error.h +1 -0
+             } else if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 &&

\

src/common/error.h extern int lttng_opt_verbose; · line 64

Quoted 1 line
src/common/error.h +0 -0
                              (((type & PRINT_DBG) && lttng_opt_verbose

== 1) || \

src/common/error.h extern int lttng_opt_verbose; · line 65

Quoted 1 line
src/common/error.h +0 -0
                              ((type & (PRINT_DBG | PRINT_DBG2)) &&
          \

src/common/error.h extern int lttng_opt_verbose; · line 66

Quoted 1 line
src/common/error.h +0 -0
                                      lttng_opt_verbose == 2) ||
             \

src/common/mi-lttng.c

Quoted 12 lines
src/common/mi-lttng.c new file +5 -0
new file mode 100644
index 0000000..bbec2c5
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]
 
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify

it

Quoted 4 lines

+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but

WITHOUT

Quoted 2 lines

+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

for

Quoted 3 lines

+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License

along with

Quoted 17 lines

+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */

src/common/mi-lttng.c new file +14 -0
+
+#include <include/config.h>
+#include <common/config/config.h>
+#include "mi-lttng.h"
+
+/* Strings related to command */
+const char * const mi_lttng_element_command = "command";
+const char * const mi_lttng_element_command_version = "version";
+const char * const mi_lttng_element_command_list = "list";
+const char * const mi_lttng_element_command_name = "name";
+const char * const mi_lttng_element_command_output = "output";
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version = "version";

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+const char * const mi_lttng_element_version_str = "string";
+const char * const mi_lttng_element_version_web = "url";
+const char * const mi_lttng_element_version_major = "major";
+const char * const mi_lttng_element_version_minor = "minor";
+const char * const mi_lttng_element_version_license = "license";
+const char * const mi_lttng_element_version_patch_level = "patchLevel";
+const char * const mi_lttng_element_version_description = "description";
+
+LTTNG_HIDDEN
+struct mi_writer *mi_lttng_writer_create(int fd_output, int

mi_output_type)

Quoted 38 lines
src/common/mi-lttng.c new file +38 -0
+{
+     struct mi_writer *mi_writer;
+
+     mi_writer = zmalloc(sizeof(struct mi_writer));
+     if (!mi_writer) {
+             PERROR("zmalloc mi_writer_create");
+             goto end;
+     }
+     if (mi_output_type == LTTNG_MI_XML) {
+             mi_writer->writer = config_writer_create(fd_output);
+             if (!mi_writer->writer) {
+                     goto err_destroy;
+             }
+             mi_writer->type = LTTNG_MI_XML;
+     } else {
+             goto err_destroy;
+     }
+
+end:
+     return mi_writer;
+
+err_destroy:
+     free(mi_writer);
+     return NULL;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_destroy(struct mi_writer *writer)
+{
+     int ret;
+
+     if (!writer) {
+             ret = -EINVAL;
+             goto end;
+     }
+
+     ret = config_writer_destroy(writer->writer);
+     if (ret < 0) {

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+             goto end;
+     }
+
+     free(writer);
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char

*command)

src/common/mi-lttng.c

Quoted 3 lines
src/common/mi-lttng.c new file +3 -0
+{
+     int ret;
+     ret = mi_lttng_writer_open_element(writer,

mi_lttng_element_command);

Quoted 52 lines
src/common/mi-lttng.c new file +52 -0
+     if (ret) {
+             goto end;
+     }
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_command_name, command);
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_command_close(struct mi_writer *writer)
+{
+     return mi_lttng_writer_close_element(writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+             const char *element_name)
+{
+     return config_writer_open_element(writer->writer, element_name);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_close_element(struct mi_writer *writer)
+{
+     return config_writer_close_element(writer->writer);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+             const char *element_name, uint64_t value)
+{
+     return config_writer_write_element_unsigned_int(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+             const char *element_name, int64_t value)
+{
+     return config_writer_write_element_signed_int(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+             const char *element_name, int value)
+{
+     return config_writer_write_element_bool(writer->writer,
+                     element_name, value);
+}
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+LTTNG_HIDDEN
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+             const char *element_name, const char *value)
+{
+     return config_writer_write_element_string(writer->writer,
+                     element_name, value);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version

*version,

src/common/mi-lttng.c

Quoted 6 lines
src/common/mi-lttng.c new file +6 -0
+     const char *lttng_description, const char *lttng_license)
+{
+     int ret;
+
+     /* Open version */
+     ret = mi_lttng_writer_open_element(writer,

mi_lttng_element_version);

Quoted 4 lines
src/common/mi-lttng.c new file +4 -0
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* Version string (contain info like rc etc.) */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_str, VERSION);
+     if (ret) {
+             goto end;
+     }
+
+     /* Major version number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_major,

version->version_major);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* Minor version number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_minor,

version->version_minor);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* Patch number */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     mi_lttng_element_version_patch_level,

version->version_patchlevel);

Quoted 4 lines
src/common/mi-lttng.c new file +4 -0
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* Name of the version */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_name, version->version_name);
+     if (ret) {
+             goto end;
+     }
+
+     /* Description mostly related to beer... */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_description,

lttng_description);

src/common/mi-lttng.c

Quoted 7 lines
src/common/mi-lttng.c new file +7 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* url */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_web,

version->package_url);

Quoted 45 lines
src/common/mi-lttng.c new file +45 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* License: free as in free beer...no...*speech* */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     mi_lttng_element_version_license, lttng_license);
+     if (ret) {
+             goto end;
+     }
+
+     /* Close version element */
+     ret = mi_lttng_writer_close_element(writer);
+
+end:
+     return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_session(struct mi_writer *writer,
+             struct lttng_session *session, int is_open)
+{
+     int ret;
+
+     /* open sessions element */
+     ret = mi_lttng_writer_open_element(writer,
+                     config_element_session);
+     if (ret) {
+             goto end;
+     }
+
+     /* Name of the session */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_name, session->name);
+     if (ret) {
+             goto end;
+     }
+
+     /* path */
+     ret = mi_lttng_writer_write_element_string(writer,
+                     config_element_path, session->path);
+     if (ret) {
+             goto end;
+     }
+

src/common/mi-lttng.c

Quoted 10 lines
src/common/mi-lttng.c new file +10 -0
+     /* enabled ? */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_enabled, session->enabled);
+     if (ret) {
+             goto end;
+     }
+
+     /* snapshot mode */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_snapshot_mode,

session->snapshot_mode);

Quoted 26 lines
src/common/mi-lttng.c new file +20 -0
+     if (ret) {
+             goto end;
+     }
+
+     /* live timer interval in usec */
+     ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                     config_element_live_timer_interval,
+                     session->live_timer_interval);
+     if (ret) {
+             goto end;
+     }
+
+     if (!is_open) {
+             /* Closing session element */
+             ret = mi_lttng_writer_close_element(writer);
+     }
+end:
+     return ret;
+
+}
src/common/mi-lttng.h new file +0 -0
new file mode 100644
index 0000000..69ec0f5

src/common/mi-lttng.h

Quoted 6 lines
src/common/mi-lttng.h new file +5 -0
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2014   - Jonathan Rajotte <[email protected]
 
+ *                      - Olivier Cotte <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify

it

Quoted 4 lines

+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but

WITHOUT

Quoted 2 lines

+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

for

Quoted 3 lines

+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License

along with

Quoted 20 lines

+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */

src/common/mi-lttng.h new file +17 -0
+
+#ifndef _MI_LTTNG_H
+#define _MI_LTTNG_H
+
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/config/config.h>
+
+#include <lttng/lttng.h>
+
+#include <stdint.h>
+
+
+/* Instance of a machine interface writer. */
+struct mi_writer {
+     struct config_writer *writer;
+     enum lttng_mi_output_type type;

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+};
+
+/*
+ * Version information for the machine interface.
+ */
+struct mi_lttng_version {
+     char version[NAME_MAX]; /* Version number of package */
+     uint32_t version_major; /* LTTng-Tools major version number */
+     uint32_t version_minor; /* LTTng-Tools minor version number */
+     uint32_t version_patchlevel; /* LTTng-Tools patchlevel version

number */

src/common/mi-lttng.h

Quoted 2 lines
src/common/mi-lttng.h new file +2 -0
+     char version_name[NAME_MAX];
+     char package_url[NAME_MAX]; /* Define to the home page for this

package. */

Quoted 13 lines
src/common/mi-lttng.h new file +13 -0
+};
+
+/* Strings related to command */
+const char * const mi_lttng_element_command;
+const char * const mi_lttng_element_command_version;
+const char * const mi_lttng_element_command_list;
+const char * const mi_lttng_element_command_name;
+const char * const mi_lttng_element_command_output;
+
+/* Strings related to command: version */
+const char * const mi_lttng_element_version;
+const char * const mi_lttng_element_version_str;
+const char * const mi_lttng_element_version_web;

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+const char * const mi_lttng_element_version_major;
+const char * const mi_lttng_element_version_minor;
+const char * const mi_lttng_element_version_license;
+const char * const mi_lttng_element_version_patch_level;
+const char * const mi_lttng_element_version_description;
+
+/*
+ * Create an instance of a machine interface writer.
+ *
+ * fd_output File to which the XML content must be written. The file

will be

Quoted 6 lines

+ * closed once the mi_writer has been destroyed.
+ *
+ * Returns an instance of a machine interface writer on success, NULL on
+ * error.
+ */
+struct mi_writer *mi_lttng_writer_create(int fd_output, int

mi_output_type);

src/common/mi-lttng.h

Quoted 7 lines
src/common/mi-lttng.h new file +7 -0
+
+/*
+ * Destroy an instance of a machine interface writer.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative

values

Quoted 5 lines

+ * indicate an error.
+ */

src/common/mi-lttng.h new file +3 -0
+int mi_lttng_writer_destroy(struct mi_writer *writer);
+
+/*

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+ * Open a command tag and add it's name node.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * command The command name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char

*command);

Quoted 99 lines
src/common/mi-lttng.h new file +99 -0
+
+/*
+ * Close a command tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_close(struct mi_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+             const char *element_name);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_close_element(struct mi_writer *writer);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+             const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Signed int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+             const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value Boolean value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
+             const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * element_name Element name.
+ *
+ * value String value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_string(struct mi_writer *writer,
+             const char *element_name, const char *value);
+
+/*
+ * Machine interface of struct version.
+ *
+ * writer An instance of a machine interface writer.
+ *

src/common/mi-lttng.h

Quoted 10 lines
src/common/mi-lttng.h new file +10 -0
+ * version Version struct.
+ *
+ * lttng_description String value of the version description.
+ *
+ * lttng_license String value of the version license.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version

*version,

Review

Quoted 25 lines
src/common/mi-lttng.h new file +24 -0
+             const char *lttng_description, const char *lttng_license);
+
+/*
+ * Machine interface of struct session.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * session An instance of a session
+ *
+ * isOpen Define if we close the session element
+ *        This should be use carefully and the client
+ *        need to close the session element.
+ *        Use case: nested addition information on a session
+ *                  ex: domain,channel event.
+ *        0-> False
+ *        1-> True
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_session(struct mi_writer *writer,
+             struct lttng_session *session, int isOpen);
+
+#endif /* _MI_LTTNG_H */
(quoted diff) +0 -0

b/src/lib/lttng-ctl/lttng-ctl.c

Review

Quoted 12 lines

index 100e587..7dd9828 100644

src/lib/lttng-ctl/lttng-ctl.c +1 -0
@@ -74,6 +74,7 @@ static int connected;
  */
 int lttng_opt_quiet;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 /*
  * Copy string from src to dst and enforce null terminated byte.
(quoted diff) +0 -0

b/tests/unit/ini_config/ini_config.c

Review

Quoted 12 lines

index 38fe5f4..29935ef 100644

tests/unit/ini_config/ini_config.c +1 -0
@@ -31,6 +31,7 @@ struct state {
 
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int entry_handler(const struct config_entry *entry,
              struct state *state)
(quoted diff) +0 -0

b/tests/unit/test_kernel_data.c

Review

Quoted 48 lines

index e2182e9..2639be4 100644

tests/unit/test_kernel_data.c +1 -0
@@ -38,6 +38,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_session.c +1 -0
index a0e84e9..4f90c33 100644
@@ -46,6 +46,7 @@ static struct ltt_session_list *session_list;
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 0;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
tests/unit/test_uri.c +1 -0
index 7cac95d..432e2b3 100644
@@ -25,6 +25,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 /* Number of TAP tests in this file */
 #define NUM_TESTS 11
tests/unit/test_ust_data.c +1 -0
index 150d5da..dd00089 100644
@@ -44,6 +44,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
+int lttng_opt_mi;
 
 int ust_consumerd32_fd;
 int ust_consumerd64_fd;
(quoted diff) +0 -0

b/tests/unit/test_utils_expand_path.c

Review

Quoted 12 lines

index fe709ac..f863b5d 100644

tests/unit/test_utils_expand_path.c +1 -0
@@ -31,6 +31,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
      char *input;
(quoted diff) +0 -0

b/tests/unit/test_utils_parse_size_suffix.c

Quoted 14 lines

index 990aa1b..f81278d 100644

tests/unit/test_utils_parse_size_suffix.c +1 -1
@@ -26,6 +26,7 @@
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose = 3;
+int lttng_opt_mi;
 
 struct valid_test_input {
      char *input;
--

1.8.3.2

Quoted 12 lines
Quoted 6 lines
Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 3 lines
Jonathan Rajotte Julien
Chargé de laboratoire, INF1995
Polytechnique Montréal

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev