X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fmi-lttng.c;h=c3ed1ce2d64975ea82c0b1e38f2678c5ae14cb57;hp=e2a5917e9c6a22fd09ddba5ba75c282c05112ff4;hb=54897b571f12970647556f1ad73fc8e30db2258d;hpb=a23cb78a01517b0a185df90fe173278e431b93e0 diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index e2a5917e9..c3ed1ce2d 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -19,7 +19,9 @@ #define _LGPL_SOURCE #include +#include #include +#include #include "mi-lttng.h" #include @@ -29,12 +31,11 @@ /* Machine interface namespace URI */ const char * const mi_lttng_xmlns = "xmlns"; -const char * const mi_lttng_ns_uri = "http://lttng.org/xml/ns/lttng-mi"; const char * const mi_lttng_xmlns_xsi = "xmlns:xsi"; const char * const mi_lttng_w3_schema_uri = "http://www.w3.org/2001/XMLSchema-instance"; const char * const mi_lttng_schema_location = "xsi:schemaLocation"; const char * const mi_lttng_schema_location_uri = - "http://lttng.org/xml/ns/lttng-mi" " " + DEFAULT_LTTNG_MI_NAMESPACE " " "http://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION) "/lttng-mi-" XSTR(MI_SCHEMA_MAJOR_VERSION) "." XSTR(MI_SCHEMA_MINOR_VERSION) ".xsd"; @@ -55,6 +56,8 @@ const char * const mi_lttng_element_command_enable_channels = "enable-channel"; const char * const mi_lttng_element_command_enable_event = "enable-event"; const char * const mi_lttng_element_command_list = "list"; const char * const mi_lttng_element_command_load = "load"; +const char * const mi_lttng_element_command_metadata = "metadata"; +const char * const mi_lttng_element_command_metadata_action = "metadata_action"; const char * const mi_lttng_element_command_name = "name"; const char * const mi_lttng_element_command_output = "output"; const char * const mi_lttng_element_command_save = "save"; @@ -506,7 +509,7 @@ int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command) } ret = config_writer_write_attribute(writer->writer, - mi_lttng_xmlns, mi_lttng_ns_uri); + mi_lttng_xmlns, DEFAULT_LTTNG_MI_NAMESPACE); if (ret) { goto end; } @@ -866,9 +869,22 @@ int mi_lttng_channel_attr(struct mi_writer *writer, struct lttng_channel_attr *attr) { int ret = 0; + struct lttng_channel *chan = caa_container_of(attr, + struct lttng_channel, attr); + uint64_t discarded_events, lost_packets; assert(attr); + ret = lttng_channel_get_discarded_event_count(chan, &discarded_events); + if (ret) { + goto end; + } + + ret = lttng_channel_get_lost_packet_count(chan, &lost_packets); + if (ret) { + goto end; + } + /* Opening Attributes */ ret = mi_lttng_writer_open_element(writer, config_element_attributes); if (ret) { @@ -947,6 +963,22 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } + /* Discarded events */ + ret = mi_lttng_writer_write_element_unsigned_int(writer, + config_element_discarded_events, + discarded_events); + if (ret) { + goto end; + } + + /* Lost packets */ + ret = mi_lttng_writer_write_element_unsigned_int(writer, + config_element_lost_packets, + lost_packets); + if (ret) { + goto end; + } + /* Closing attributes */ ret = mi_lttng_writer_close_element(writer); if (ret) { @@ -992,7 +1024,7 @@ int mi_lttng_event_common_attributes(struct mi_writer *writer, } /* Event filter expression */ - ret = lttng_event_get_filter_string(event, &filter_expression); + ret = lttng_event_get_filter_expression(event, &filter_expression); if (ret) { goto end; } @@ -1010,6 +1042,51 @@ end: return ret; } +static int write_event_exclusions(struct mi_writer *writer, + struct lttng_event *event) +{ + int i; + int ret; + int exclusion_count; + + /* Open event exclusions */ + ret = mi_lttng_writer_open_element(writer, config_element_exclusions); + if (ret) { + goto end; + } + + exclusion_count = lttng_event_get_exclusion_name_count(event); + if (exclusion_count < 0) { + ret = exclusion_count; + goto end; + } + + for (i = 0; i < exclusion_count; i++) { + const char *name; + + ret = lttng_event_get_exclusion_name(event, i, &name); + if (ret) { + /* Close exclusions */ + mi_lttng_writer_close_element(writer); + goto end; + } + + ret = mi_lttng_writer_write_element_string(writer, + config_element_exclusion, name); + if (ret) { + /* Close exclusions */ + mi_lttng_writer_close_element(writer); + goto end; + } + } + + /* Close exclusions */ + ret = mi_lttng_writer_close_element(writer); + +end: + return ret; +} + LTTNG_HIDDEN int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer, struct lttng_event *event, enum lttng_domain_type domain) @@ -1032,12 +1109,8 @@ int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer, goto end; } - /* event exclusion filter */ - ret = mi_lttng_writer_write_element_bool(writer, - config_element_exclusion, event->exclusion); - if (ret) { - goto end; - } + /* Event exclusions */ + ret = write_event_exclusions(writer, event); end: return ret; @@ -1048,8 +1121,7 @@ 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); + return write_event_exclusions(writer, event); } LTTNG_HIDDEN