LTTNG_ERR_LOAD_IO_FAIL = 88, /* IO error while reading a session configuration */
LTTNG_ERR_LOAD_SESSION_NOENT = 89, /* Session file not found */
LTTNG_ERR_MAX_SIZE_INVALID = 90, /* Snapshot max size is invalid. */
- /* 91 */
- /* 92 */
+ LTTNG_ERR_MI_OUTPUT_TYPE = 91, /* Invalid MI output format */
+ LTTNG_ERR_MI_IO_FAIL = 92, /* IO error while writing machine interface output */
+ LTTNG_ERR_MI_NOT_IMPLEMENTED = 93, /* Mi feature not implemented */
/* 93 */
/* 94 */
/* 95 */
LTTNG_CALIBRATE_FUNCTION = 0,
};
+/* Machine interface output type */
+enum lttng_mi_output_type {
+ LTTNG_MI_XML = 1 /* XML output */
+};
+
#define LTTNG_CALIBRATE_PADDING1 16
struct lttng_calibrate {
enum lttng_calibrate_type type;
/* 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 */
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);
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;
}
}
+ /* 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;
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();
}
}
+ /* 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");
}
}
+ /* 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");
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:
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;
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:
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:
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:
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:
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:
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:
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:
#include <unistd.h>
#include <config.h>
+#include <common/mi-lttng.h>
+
#include "../command.h"
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},
fprintf(ofp, "\n");
}
+/*
+ * 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 the machine interface output of this command.
+ */
+static int print_mi()
+{
+ int ret = CMD_SUCCESS;
+ 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) {
+ ret = CMD_ERROR;
+ goto error;
+ }
+
+ /* Beginning of output */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_command_output);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto error;
+ }
+
+ /* Print the machine interface of version */
+ ret = mi_lttng_version(writer, &version,
+ VERSION_DESCRIPTION, lttng_license);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto error;
+ }
+
+ /* Close the output element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto error;
+ }
+
+ /* Close the command */
+ ret = mi_lttng_writer_command_close(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ }
+
+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
*/
}
}
- MSG("lttng version " FULL_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 " FULL_VERSION " - " VERSION_NAME);
+ MSG("\n" VERSION_DESCRIPTION "\n");
+ MSG("Web site: http://lttng.org");
+ MSG("\n%s", lttng_license);
+ }
end:
poptFreeContext(pc);
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:
{"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},
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");
progname);
}
+/*
+ * Find the MI output type enum from a string. This function is for the support
+ * of machine interface output.
+ */
+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
*
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);
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;
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 -lrt
+libcommon_la_LIBADD = \
+ -luuid \
+ -lrt \
+ $(top_builddir)/src/common/config/libconfig.la
# Consumer library
noinst_LTLIBRARIES += libconsumer.la
[ ERROR_INDEX(LTTNG_ERR_LOAD_IO_FAIL) ] = "IO error while reading a session configuration",
[ ERROR_INDEX(LTTNG_ERR_LOAD_SESSION_NOENT) ] = "Session file not found",
[ ERROR_INDEX(LTTNG_ERR_MAX_SIZE_INVALID) ] = "Snapshot max size is invalid",
+ [ ERROR_INDEX(LTTNG_ERR_MI_OUTPUT_TYPE) ] = "Invalid MI output format",
+ [ ERROR_INDEX(LTTNG_ERR_MI_IO_FAIL) ] = "IO error while writing MI output",
+ [ ERROR_INDEX(LTTNG_ERR_MI_NOT_IMPLEMENTED) ] = "Mi feature not implemented",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
extern int lttng_opt_quiet;
extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
/* Error type. */
#define PRINT_ERR 0x1
/*
* 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) || \
--- /dev/null
+/*
+ * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
+ * - Olivier Cotte <olivier.cotte@polymtl.ca>
+ *
+ * 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;
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 - Jonathan Rajotte <jonathan.r.julien@gmail.com>
+ * - Olivier Cotte <olivier.cotte@polymtl.ca>
+ *
+ * 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 <stdint.h>
+
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/config/config.h>
+#include <lttng/lttng.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 */
*/
int lttng_opt_quiet;
int lttng_opt_verbose;
+int lttng_opt_mi;
/*
* Copy string from src to dst and enforce null terminated byte.
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)
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
+int lttng_opt_mi;
int ust_consumerd32_fd;
int ust_consumerd64_fd;
/* 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;
/* 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
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
+int lttng_opt_mi;
int ust_consumerd32_fd;
int ust_consumerd64_fd;
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
+int lttng_opt_mi;
struct valid_test_input {
char *input;
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
+int lttng_opt_mi;
struct valid_test_input {
char *input;