From: Jonathan Rajotte Date: Wed, 16 Apr 2014 20:08:38 +0000 (-0400) Subject: Mi: add mi support for lttng struct X-Git-Tag: v2.6.0-rc1~132 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5e18ec73f48d06fd508fb74386d175d45606d7e2;p=lttng-tools.git Mi: add mi support for lttng struct Add mi-lttng support to the following struct: lttng_domain lttng_channel lttng_channel_attr lttng_event +multiple mi utility format: common attribute tracepoint_loglevel tracepoint_no_loglevel function probe function entry lttng_event_field mi-lttng other element pid element Rebase on master: Fix: remove extra linking due to add of mi-lttng to libcommon --- diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index 052b5425e..02500ff14 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -16,11 +16,13 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include #include - #include "mi-lttng.h" +#include + /* Strings related to command */ const char * const mi_lttng_element_command = "command"; const char * const mi_lttng_element_command_version = "version"; @@ -38,6 +40,171 @@ 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"; +/* 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) { @@ -120,6 +287,26 @@ int mi_lttng_writer_close_element(struct mi_writer *writer) 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) @@ -227,13 +414,21 @@ end: 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) { @@ -247,28 +442,28 @@ int mi_lttng_session(struct mi_writer *writer, 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); @@ -284,3 +479,471 @@ end: 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; +} diff --git a/src/common/mi-lttng.h b/src/common/mi-lttng.h index bdc4a052a..f033bd770 100644 --- a/src/common/mi-lttng.h +++ b/src/common/mi-lttng.h @@ -61,6 +61,53 @@ 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; +/* 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. * @@ -86,7 +133,6 @@ 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. @@ -108,7 +154,6 @@ 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. @@ -128,12 +173,22 @@ int mi_lttng_writer_open_element(struct mi_writer *writer, 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. @@ -146,10 +201,8 @@ int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer, * 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. @@ -161,10 +214,8 @@ int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer, * 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. @@ -176,10 +227,8 @@ int mi_lttng_writer_write_element_bool(struct mi_writer *writer, * 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. @@ -191,11 +240,8 @@ int mi_lttng_writer_write_element_string(struct mi_writer *writer, * 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. @@ -205,24 +251,247 @@ 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. + * 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 */ diff --git a/src/lib/lttng-ctl/Makefile.am b/src/lib/lttng-ctl/Makefile.am index d4a169dc6..d1b923e42 100644 --- a/src/lib/lttng-ctl/Makefile.am +++ b/src/lib/lttng-ctl/Makefile.am @@ -11,8 +11,7 @@ liblttng_ctl_la_LIBADD = \ $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ $(top_builddir)/src/common/libcommon.la \ $(top_builddir)/src/common/hashtable/libhashtable.la \ - $(top_builddir)/src/lib/lttng-ctl/filter/libfilter.la \ - $(top_builddir)/src/common/config/libconfig.la + $(top_builddir)/src/lib/lttng-ctl/filter/libfilter.la pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = lttng-ctl.pc