* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
#include <include/config.h>
#include <common/config/config.h>
-
#include "mi-lttng.h"
+#include <assert.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_version_patch_level = "patchLevel";
const char * const mi_lttng_element_version_description = "description";
+/* Strings related to pid */
+const char * const mi_lttng_element_pids = "pids";
+const char * const mi_lttng_element_pid = "pid";
+const char * const mi_lttng_element_pid_id = "id";
+
+/* String related to a lttng_event_field */
+const char * const mi_lttng_element_event_field = "event_field";
+const char * const mi_lttng_element_event_fields = "event_fields";
+
+/* General elements of mi_lttng */
+const char * const mi_lttng_element_type_other = "OTHER";
+const char * const mi_lttng_element_type_integer = "INTEGER";
+const char * const mi_lttng_element_type_enum = "ENUM";
+const char * const mi_lttng_element_type_float = "FLOAT";
+const char * const mi_lttng_element_type_string = "STRING";
+const char * const mi_lttng_element_nowrite = "nowrite";
+
+/* String related to loglevel */
+const char * const mi_lttng_loglevel_str_alert = "TRACE_ALERT";
+const char * const mi_lttng_loglevel_str_crit = "TRACE_CRIT";
+const char * const mi_lttng_loglevel_str_debug = "TRACE_DEBUG";
+const char * const mi_lttng_loglevel_str_debug_function = "TRACE_DEBUG_FUNCTION";
+const char * const mi_lttng_loglevel_str_debug_line = "TRACE_DEBUG_LINE";
+const char * const mi_lttng_loglevel_str_debug_module = "TRACE_DEBUG_MODULE";
+const char * const mi_lttng_loglevel_str_debug_process = "TRACE_DEBUG_PROCESS";
+const char * const mi_lttng_loglevel_str_debug_program = "TRACE_DEBUG_PROGRAM";
+const char * const mi_lttng_loglevel_str_debug_system = "TRACE_DEBUG_SYSTEM";
+const char * const mi_lttng_loglevel_str_debug_unit = "TRACE_DEBUG_UNIT";
+const char * const mi_lttng_loglevel_str_emerg = "TRACE_EMERG";
+const char * const mi_lttng_loglevel_str_err = "TRACE_ERR";
+const char * const mi_lttng_loglevel_str_info = "TRACE_INFO";
+const char * const mi_lttng_loglevel_str_notice = "TRACE_NOTICE";
+const char * const mi_lttng_loglevel_str_unknown = "UNKNOWN";
+const char * const mi_lttng_loglevel_str_warning = "TRACE_WARNING";
+
+const char * const mi_lttng_loglevel_type_all = "ALL";
+const char * const mi_lttng_loglevel_type_range = "RANGE";
+const char * const mi_lttng_loglevel_type_single = "SINGLE";
+const char * const mi_lttng_loglevel_type_unknown = "UNKNOWN";
+
+const char * const mi_lttng_element_empty = "";
+
+const char *mi_lttng_loglevel_string(int value)
+{
+ switch (value) {
+ case -1:
+ return mi_lttng_element_empty;
+ case LTTNG_LOGLEVEL_EMERG:
+ return mi_lttng_loglevel_str_emerg;
+ case LTTNG_LOGLEVEL_ALERT:
+ return mi_lttng_loglevel_str_alert;
+ case LTTNG_LOGLEVEL_CRIT:
+ return mi_lttng_loglevel_str_crit;
+ case LTTNG_LOGLEVEL_ERR:
+ return mi_lttng_loglevel_str_err;
+ case LTTNG_LOGLEVEL_WARNING:
+ return mi_lttng_loglevel_str_warning;
+ case LTTNG_LOGLEVEL_NOTICE:
+ return mi_lttng_loglevel_str_notice;
+ case LTTNG_LOGLEVEL_INFO:
+ return mi_lttng_loglevel_str_info;
+ case LTTNG_LOGLEVEL_DEBUG_SYSTEM:
+ return mi_lttng_loglevel_str_debug_system;
+ case LTTNG_LOGLEVEL_DEBUG_PROGRAM:
+ return mi_lttng_loglevel_str_debug_program;
+ case LTTNG_LOGLEVEL_DEBUG_PROCESS:
+ return mi_lttng_loglevel_str_debug_process;
+ case LTTNG_LOGLEVEL_DEBUG_MODULE:
+ return mi_lttng_loglevel_str_debug_module;
+ case LTTNG_LOGLEVEL_DEBUG_UNIT:
+ return mi_lttng_loglevel_str_debug_unit;
+ case LTTNG_LOGLEVEL_DEBUG_FUNCTION:
+ return mi_lttng_loglevel_str_debug_function;
+ case LTTNG_LOGLEVEL_DEBUG_LINE:
+ return mi_lttng_loglevel_str_debug_line;
+ case LTTNG_LOGLEVEL_DEBUG:
+ return mi_lttng_loglevel_str_debug;
+ default:
+ return mi_lttng_loglevel_str_unknown;
+ }
+}
+
+const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value)
+{
+ switch (value) {
+ case LTTNG_EVENT_LOGLEVEL_ALL:
+ return mi_lttng_loglevel_type_all;
+ case LTTNG_EVENT_LOGLEVEL_RANGE:
+ return mi_lttng_loglevel_type_range;
+ case LTTNG_EVENT_LOGLEVEL_SINGLE:
+ return mi_lttng_loglevel_type_single;
+ default:
+ return mi_lttng_loglevel_type_unknown;
+ }
+}
+
+const char *mi_lttng_eventtype_string(enum lttng_event_type value)
+{
+ switch (value) {
+ case LTTNG_EVENT_ALL:
+ return config_event_type_all;
+ case LTTNG_EVENT_TRACEPOINT:
+ return config_event_type_tracepoint;
+ case LTTNG_EVENT_PROBE:
+ return config_event_type_probe;
+ case LTTNG_EVENT_FUNCTION:
+ return config_event_type_function;
+ case LTTNG_EVENT_FUNCTION_ENTRY:
+ return config_event_type_function_entry;
+ case LTTNG_EVENT_SYSCALL:
+ return config_event_type_syscall;
+ case LTTNG_EVENT_NOOP:
+ return config_event_type_noop;
+ default:
+ return mi_lttng_element_empty;
+ }
+}
+
+const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type val)
+{
+ switch (val) {
+ case(LTTNG_EVENT_FIELD_INTEGER):
+ return mi_lttng_element_type_integer;
+ case(LTTNG_EVENT_FIELD_ENUM):
+ return mi_lttng_element_type_enum;
+ case(LTTNG_EVENT_FIELD_FLOAT):
+ return mi_lttng_element_type_float;
+ case(LTTNG_EVENT_FIELD_STRING):
+ return mi_lttng_element_type_string;
+ default:
+ return mi_lttng_element_type_other;
+ }
+}
+
+const char *mi_lttng_domaintype_string(enum lttng_domain_type value)
+{
+ /* Note: This is a *duplicate* of get_domain_str from bin/lttng/utils.c */
+ switch (value) {
+ case LTTNG_DOMAIN_KERNEL:
+ return config_domain_type_kernel;
+ case LTTNG_DOMAIN_UST:
+ return config_domain_type_ust;
+ case LTTNG_DOMAIN_JUL:
+ return config_domain_type_jul;
+ default:
+ /* Should not have an unknown domain */
+ assert(0);
+ }
+}
+
+const char *mi_lttng_buffertype_string(enum lttng_buffer_type value)
+{
+ switch (value) {
+ case LTTNG_BUFFER_PER_PID:
+ return config_buffer_type_per_pid;
+ case LTTNG_BUFFER_PER_UID:
+ return config_buffer_type_per_uid;
+ case LTTNG_BUFFER_GLOBAL:
+ return config_buffer_type_global;
+ default:
+ /* Should not have an unknow buffer type */
+ assert(0);
+ }
+}
+
LTTNG_HIDDEN
struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type)
{
return config_writer_close_element(writer->writer);
}
+LTTNG_HIDDEN
+int mi_lttng_close_multi_element(struct mi_writer *writer,
+ unsigned int nb_element)
+{
+ int ret, i;
+
+ if (nb_element < 1) {
+ ret = 0;
+ goto end;
+ }
+ for (i = 0; i < nb_element; i++) {
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+ }
+end:
+ return ret;
+}
+
LTTNG_HIDDEN
int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
const char *element_name, uint64_t value)
return ret;
}
+LTTNG_HIDDEN
+int mi_lttng_sessions_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, config_element_sessions);
+}
+
LTTNG_HIDDEN
int mi_lttng_session(struct mi_writer *writer,
struct lttng_session *session, int is_open)
{
int ret;
- /* open sessions element */
+ assert(session);
+
+ /* Open sessions element */
ret = mi_lttng_writer_open_element(writer,
config_element_session);
if (ret) {
goto end;
}
- /* path */
+ /* 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,
+ /* Enabled ? */
+ ret = mi_lttng_writer_write_element_bool(writer,
config_element_enabled, session->enabled);
if (ret) {
goto end;
}
- /* snapshot mode */
+ /* 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 */
+ /* Live timer interval in usec */
ret = mi_lttng_writer_write_element_unsigned_int(writer,
config_element_live_timer_interval,
session->live_timer_interval);
return ret;
}
+
+LTTNG_HIDDEN
+int mi_lttng_domains_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, config_element_domains);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_domain(struct mi_writer *writer,
+ struct lttng_domain *domain, int is_open)
+{
+ int ret = 0;
+ const char *str_domain;
+ const char *str_buffer;
+
+ assert(domain);
+
+ /* Open domain element */
+ ret = mi_lttng_writer_open_element(writer, config_element_domain);
+ if (ret) {
+ goto end;
+ }
+
+ /* Domain Type */
+ str_domain = mi_lttng_domaintype_string(domain->type);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_type,
+ str_domain);
+ if (ret) {
+ goto end;
+ }
+
+ /* Buffer Type */
+ str_buffer= mi_lttng_buffertype_string(domain->buf_type);
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_buffer_type, str_buffer);
+ if (ret) {
+ goto end;
+ }
+
+ /* TODO: attr... not sure how to use the union.... */
+
+ if (!is_open) {
+ /* Closing domain element */
+ ret = mi_lttng_writer_close_element(writer);
+ }
+
+end:
+ return ret;
+
+}
+
+LTTNG_HIDDEN
+int mi_lttng_channels_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, config_element_channels);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_channel(struct mi_writer *writer,
+ struct lttng_channel *channel, int is_open)
+{
+ int ret = 0;
+
+ assert(channel);
+
+ /* Opening channel element */
+ ret = mi_lttng_writer_open_element(writer, config_element_channel);
+ if (ret) {
+ goto end;
+ }
+
+ /* Name */
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name,
+ channel->name);
+ if (ret) {
+ goto end;
+ }
+
+ /* Enabled ? */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ config_element_enabled, channel->enabled);
+ if (ret) {
+ goto end;
+ }
+
+ /* Attribute */
+ ret = mi_lttng_channel_attr(writer, &channel->attr);
+ if (ret) {
+ goto end;
+ }
+
+ if (!is_open) {
+ /* Closing channel element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+ }
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_channel_attr(struct mi_writer *writer,
+ struct lttng_channel_attr *attr)
+{
+ int ret = 0;
+
+ assert(attr);
+
+ /* Opening Attributes */
+ ret = mi_lttng_writer_open_element(writer, config_element_attributes);
+ if (ret) {
+ goto end;
+ }
+
+ /* Overwrite */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_overwrite_mode,
+ attr->overwrite ? config_overwrite_mode_overwrite :
+ config_overwrite_mode_discard);
+ if (ret) {
+ goto end;
+ }
+
+ /* Sub buffer size in byte */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_subbuf_size, attr->subbuf_size);
+ if (ret) {
+ goto end;
+ }
+
+ /* Number of subbuffer (power of two) */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_num_subbuf,
+ attr->num_subbuf);
+ if (ret) {
+ goto end;
+ }
+
+ /* Switch timer interval in usec */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_switch_timer_interval,
+ attr->switch_timer_interval);
+ if (ret) {
+ goto end;
+ }
+
+ /* Read timer interval in usec */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_read_timer_interval,
+ attr->read_timer_interval);
+ if (ret) {
+ goto end;
+ }
+
+ /* Event output */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_output_type,
+ attr->output == LTTNG_EVENT_SPLICE ?
+ config_output_type_splice : config_output_type_mmap);
+ if (ret) {
+ goto end;
+ }
+
+ /* Tracefile size in bytes */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_tracefile_size, attr->tracefile_size);
+ if (ret) {
+ goto end;
+ }
+
+ /* Count of tracefiles */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_tracefile_count,
+ attr->tracefile_count);
+ if (ret) {
+ goto end;
+ }
+
+ /* Live timer interval in usec*/
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_live_timer_interval,
+ attr->live_timer_interval);
+ if (ret) {
+ goto end;
+ }
+
+ /* Closing attributes */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto end;
+ }
+end:
+ return ret;
+
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_common_attributes(struct mi_writer *writer,
+ struct lttng_event *event)
+{
+ int ret;
+
+ /* Open event element */
+ ret = mi_lttng_writer_open_element(writer, config_element_event);
+ if (ret) {
+ goto end;
+ }
+
+ /* event name */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_name, event->name);
+ if (ret) {
+ goto end;
+ }
+
+ /* event type */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_type, mi_lttng_eventtype_string(event->type));
+ if (ret) {
+ goto end;
+ }
+
+ /* is event enabled */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ config_element_enabled, event->enabled);
+ if (ret) {
+ goto end;
+ }
+
+ /* event filter enabled? */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ config_element_filter, event->filter);
+
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
+ struct lttng_event *event)
+{
+ int ret;
+
+ /* event loglevel */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_loglevel, mi_lttng_loglevel_string(event->loglevel));
+ if (ret) {
+ goto end;
+ }
+
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_loglevel_type,
+ mi_lttng_logleveltype_string(event->loglevel_type));
+ if (ret) {
+ goto end;
+ }
+
+ /* event exclusion filter */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ config_element_exclusion, event->exclusion);
+ if (ret) {
+ goto end;
+ }
+
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
+ struct lttng_event *event)
+{
+ /* event exclusion filter */
+ return mi_lttng_writer_write_element_bool(writer,
+ config_element_exclusion, event->exclusion);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_function_probe(struct mi_writer *writer,
+ struct lttng_event *event)
+{
+ int ret;
+
+ if (event->attr.probe.addr != 0) {
+ /* event probe address */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_address, event->attr.probe.addr);
+ if (ret) {
+ goto end;
+ }
+ } else {
+ /* event probe offset */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ config_element_offset, event->attr.probe.offset);
+ if (ret) {
+ goto end;
+ }
+
+ /* event probe symbol_name */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_symbol_name, event->attr.probe.symbol_name);
+ if (ret) {
+ goto end;
+ }
+ }
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_function_entry(struct mi_writer *writer,
+ struct lttng_event *event)
+{
+ /* event probe symbol_name */
+ return mi_lttng_writer_write_element_string(writer,
+ config_element_symbol_name, event->attr.ftrace.symbol_name);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_events_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, config_element_events);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event(struct mi_writer *writer,
+ struct lttng_event *event, int is_open)
+{
+ int ret;
+
+ ret = mi_lttng_event_common_attributes(writer, event);
+ if (ret) {
+ goto end;
+ }
+
+ switch (event->type) {
+ case LTTNG_EVENT_ALL:
+ /* We should never have "all" events in list. */
+ assert(0);
+ break;
+ case LTTNG_EVENT_TRACEPOINT:
+ {
+ if (event->loglevel != -1) {
+ ret = mi_lttng_event_tracepoint_loglevel(writer, event);
+ } else {
+ ret = mi_lttng_event_tracepoint_no_loglevel(writer, event);
+ }
+ break;
+ }
+ case LTTNG_EVENT_PROBE:
+ ret = mi_lttng_event_function_probe(writer, event);
+ break;
+ case LTTNG_EVENT_FUNCTION_ENTRY:
+ ret = mi_lttng_event_function_entry(writer, event);
+ break;
+ default:
+ break;
+ }
+
+ if (!is_open) {
+ ret = mi_lttng_writer_close_element(writer);
+ }
+
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_pids_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, mi_lttng_element_pids);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *cmdline,
+ int is_open)
+{
+ int ret;
+
+ /* Open element pid */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_pid);
+ if (ret) {
+ goto end;
+ }
+
+ /* Writing pid number */
+ ret = mi_lttng_writer_write_element_signed_int(writer,
+ mi_lttng_element_pid_id, (int)pid);
+ if (ret) {
+ goto end;
+ }
+
+ /* Writing name of the process */
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name,
+ cmdline);
+ if (ret) {
+ goto end;
+ }
+
+ if (!is_open) {
+ /* Closing Pid */
+ ret = mi_lttng_writer_close_element(writer);
+ }
+
+end:
+ return ret;
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_fields_open(struct mi_writer *writer)
+{
+ return mi_lttng_writer_open_element(writer, mi_lttng_element_event_fields);
+}
+
+LTTNG_HIDDEN
+int mi_lttng_event_field(struct mi_writer *writer,
+ struct lttng_event_field *field)
+{
+ int ret;
+
+ if (!field->field_name[0]) {
+ /* To Review: not sure if legal david ?
+ * how should this be handle ?
+ */
+ ret = 0;
+ goto end;
+ }
+
+ /* Open field */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_field);
+ if (ret) {
+ goto end;
+ }
+
+ if (!field->field_name[0]) {
+ goto close;
+ }
+
+ /* Name */
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name,
+ field->field_name);
+ if (ret) {
+ goto end;
+ }
+
+ /* Type */
+ ret = mi_lttng_writer_write_element_string(writer, config_element_type,
+ mi_lttng_eventfieldtype_string(field->type));
+ if (ret) {
+ goto end;
+ }
+
+ /* nowrite */
+ ret = mi_lttng_writer_write_element_signed_int(writer,
+ mi_lttng_element_nowrite, field->nowrite);
+ if (ret) {
+ goto end;
+ }
+
+close:
+ /* Close field element */
+ ret = mi_lttng_writer_close_element(writer);
+
+end:
+ return ret;
+}
const char * const mi_lttng_element_version_patch_level;
const char * const mi_lttng_element_version_description;
+/* String related to a lttng_event_field */
+const char * const mi_lttng_element_event_field;
+const char * const mi_lttng_element_event_fields;
+
+/* Strings related to pid */
+const char * const mi_lttng_element_pids;
+const char * const mi_lttng_element_pid;
+const char * const mi_lttng_element_pid_id;
+
+/* General element of mi_lttng */
+const char * const mi_lttng_element_type_other;
+const char * const mi_lttng_element_type_integer;
+const char * const mi_lttng_element_type_enum;
+const char * const mi_lttng_element_type_float;
+const char * const mi_lttng_element_type_string;
+const char * const mi_lttng_element_nowrite;
+
+/* String related to loglevel */
+const char * const mi_lttng_loglevel_str_alert;
+const char * const mi_lttng_loglevel_str_crit;
+const char * const mi_lttng_loglevel_str_debug;
+const char * const mi_lttng_loglevel_str_debug_function;
+const char * const mi_lttng_loglevel_str_debug_line;
+const char * const mi_lttng_loglevel_str_debug_module;
+const char * const mi_lttng_loglevel_str_debug_process;
+const char * const mi_lttng_loglevel_str_debug_program;
+const char * const mi_lttng_loglevel_str_debug_system;
+const char * const mi_lttng_loglevel_str_debug_unit;
+const char * const mi_lttng_loglevel_str_emerg;
+const char * const mi_lttng_loglevel_str_err;
+const char * const mi_lttng_loglevel_str_info;
+const char * const mi_lttng_loglevel_str_notice;
+const char * const mi_lttng_loglevel_str_unknown;
+const char * const mi_lttng_loglevel_str_warning;
+
+const char * const mi_lttng_loglevel_type_all;
+const char * const mi_lttng_loglevel_type_range;
+const char * const mi_lttng_loglevel_type_single;
+const char * const mi_lttng_loglevel_type_unknown;
+
+/* Utility string function */
+const char *mi_lttng_loglevel_string(int value);
+const char *mi_lttng_logleveltype_string(enum lttng_loglevel_type value);
+const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type value);
+const char *mi_lttng_domaintype_string(enum lttng_domain_type value);
+const char *mi_lttng_buffertype_string(enum lttng_buffer_type value);
+
/*
* Create an instance of a machine interface 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.
* 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.
int mi_lttng_writer_close_element(struct mi_writer *writer);
/*
- * Write an element of type unsigned int.
+ * Close multiple element.
*
* writer An instance of a machine interface writer.
+ * nb_element Number of elements.
*
- * element_name Element name.
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_close_multi_element(struct mi_writer *writer,
+ unsigned int nb_element);
+
+/*
+ * 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.
* 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
+ * value Signed int value of the element.
*
* Returns zero if the element's value could be written.
* Negative values indicate an error.
* Write an element of type boolean.
*
* writer An instance of a machine interface writer.
- *
* element_name Element name.
- *
- * value Boolean value of the element
+ * value Boolean value of the element.
*
* Returns zero if the element's value could be written.
* Negative values indicate an error.
* Write an element of type string.
*
* writer An instance of a machine interface writer.
- *
* element_name Element name.
- *
- * value String value of the element
+ * value String value of the element.
*
* Returns zero if the element's value could be written.
* Negative values indicate an error.
* 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.
const char *lttng_description, const char *lttng_license);
/*
- * Machine interface of struct session.
+ * Machine interface: open a sessions element.
*
- * writer An instance of a machine interface writer
+ * writer An instance of a machine interface writer.
*
- * session An instance of a session
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_sessions_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct 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
+ * writer An instance of a machine interface writer.
+ * session An instance of a session.
+ * is_open Defines whether or not the session element shall be closed.
+ * This should be used carefully and the client
+ * must close the session element.
+ * Use case: nested addtionnal 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);
+ struct lttng_session *session, int is_open);
+
+/*
+ * Machine interface: open a domains element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_domains_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct domain.
+ *
+ * writer An instance of a machine interface writer.
+ * domain An instance of a domain.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ * This should be used carefully and the client
+ * must close the domain element.
+ * Use case: nested addition information on a domain
+ * ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_domain(struct mi_writer *writer,
+ struct lttng_domain *domain, int is_open);
+
+/*
+ * Machine interface: open a channels element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channels_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct channel.
+ *
+ * writer An instance of a machine interface writer.
+ * channel An instance of a channel.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ * This should be used carefully and the client
+ * must close the channel element.
+ * Use case: nested addition information on a channel.
+ * ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channel(struct mi_writer *writer,
+ struct lttng_channel *channel, int is_open);
+
+/*
+ * Machine interface of struct channel_attr.
+ *
+ * writer An instance of a machine interface writer.
+ * attr An instance of a channel_attr struct.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_channel_attr(struct mi_writer *writer,
+ struct lttng_channel_attr *attr);
+
+/*
+* Machine interface for event common attributes.
+*
+* writer An instance of a mi writer.
+* event single trace event.
+*
+* The common attribute are:
+* - mi event element
+* - event name
+* - event type
+* - enabled tag
+* - event filter
+*
+* Returns zero if the element's value could be written.
+* Negative values indicate an error.
+*/
+int mi_lttng_event_common_attributes(struct mi_writer *writer,
+ struct lttng_event *event);
+
+/*
+ * Machine interface for kernel tracepoint event with a loglevel.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
+ struct lttng_event *event);
+
+/*
+ * Machine interface for kernel tracepoint event with no loglevel.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
+ struct lttng_event *event);
+
+/*
+ * Machine interface for kernel function and probe event.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_function_probe(struct mi_writer *writer,
+ struct lttng_event *event);
+
+/*
+ * Machine interface for kernel function entry event.
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_function_entry(struct mi_writer *writer,
+ struct lttng_event *event);
+
+/*
+ * Machine interface: open an events element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_events_open(struct mi_writer *writer);
+
+/*
+ * Machine interface for printing an event.
+ * The trace event type currently supported are:
+ * TRACEPOINT,
+ * PROBE,
+ * FUNCTION,
+ * FUNCTION_ENTRY,
+ * SYSCALL
+ *
+ * writer An instance of a mi writer.
+ * event single trace event.
+ * is_open Defines whether or not the session element shall be closed.
+ * This should be used carefully and the client
+ * must close the event element.
+ * Use case: nested additional information
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event(struct mi_writer *writer, struct lttng_event *event,
+ int is_open);
+
+/*
+ * Machine interface for struct lttng_event_field.
+ *
+ * writer An instance of a mi writer.
+ * field An event_field instance.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_field(struct mi_writer *writer,
+ struct lttng_event_field *field);
+
+/*
+ * Machine interface: open a event_fields element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_fields_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a PIDs element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_pids_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of a PID.
+ *
+ * writer An instance of a machine interface writer.
+ * pid A PID.
+ *
+ * is_open Defines whether or not the session element shall be closed.
+ * This should be used carefully and the client
+ * must close the pid element.
+ * Use case: nested addition information on a domain
+ * ex: channel event.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *cmdline,
+ int is_open);
#endif /* _MI_LTTNG_H */