X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fmi-lttng.c;h=d5148bcb58376cc09e24978e2f5de06fee9c028f;hp=57678c1b8dbbab1b3d00e3d8a07d4ead219784d3;hb=0e5e4beb5ab69ee57134ec704f850f37a48cb48b;hpb=eded6438f3b15eccc391525f653e03293a890d32 diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index 57678c1b8..d5148bcb5 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -36,7 +36,7 @@ LTTNG_HIDDEN const char * const mi_lttng_w3_schema_uri = "http://www.w3.org/2001 LTTNG_HIDDEN const char * const mi_lttng_schema_location = "xsi:schemaLocation"; LTTNG_HIDDEN const char * const mi_lttng_schema_location_uri = DEFAULT_LTTNG_MI_NAMESPACE " " - "http://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION) + "https://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION) "/lttng-mi-" XSTR(MI_SCHEMA_MAJOR_VERSION) "." XSTR(MI_SCHEMA_MINOR_VERSION) ".xsd"; LTTNG_HIDDEN const char * const mi_lttng_schema_version = "schemaVersion"; @@ -47,7 +47,6 @@ LTTNG_HIDDEN const char * const mi_lttng_schema_version_value = XSTR(MI_SCHEMA_M const char * const mi_lttng_element_command = "command"; const char * const mi_lttng_element_command_action = "snapshot_action"; const char * const mi_lttng_element_command_add_context = "add-context"; -const char * const mi_lttng_element_command_calibrate = "calibrate"; const char * const mi_lttng_element_command_create = "create"; const char * const mi_lttng_element_command_destroy = "destroy"; const char * const mi_lttng_element_command_disable_channel = "disable-channel"; @@ -75,6 +74,9 @@ const char * const mi_lttng_element_command_success = "success"; const char * const mi_lttng_element_command_track = "track"; const char * const mi_lttng_element_command_untrack = "untrack"; const char * const mi_lttng_element_command_version = "version"; +const char * const mi_lttng_element_command_rotate = "rotate"; +const char * const mi_lttng_element_command_enable_rotation = "enable-rotation"; +const char * const mi_lttng_element_command_disable_rotation = "disable-rotation"; /* Strings related to version command */ const char * const mi_lttng_element_version = "version"; @@ -102,6 +104,8 @@ const char * const mi_lttng_element_save = "save"; /* Strings related to load command */ const char * const mi_lttng_element_load = "load"; +LTTNG_HIDDEN const char * const mi_lttng_element_load_overrides = "overrides"; +LTTNG_HIDDEN const char * const mi_lttng_element_load_override_url = "url"; /* General elements of mi_lttng */ const char * const mi_lttng_element_empty = ""; @@ -167,10 +171,6 @@ 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"; -/* String related to lttng_calibrate */ -const char * const mi_lttng_element_calibrate = "calibrate"; -const char * const mi_lttng_element_calibrate_function = "FUNCTION"; - /* String related to a lttng_snapshot_output */ const char * const mi_lttng_element_snapshot_ctrl_url = "ctrl_url"; const char * const mi_lttng_element_snapshot_data_url = "data_url"; @@ -182,12 +182,32 @@ const char * const mi_lttng_element_snapshots = "snapshots"; /* String related to track/untrack command */ const char * const mi_lttng_element_track_untrack_all_wildcard = "*"; +LTTNG_HIDDEN const char * const mi_lttng_element_session_name = "session_name"; + +/* String related to rotate command */ +LTTNG_HIDDEN const char * const mi_lttng_element_rotation = "rotation"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotate_status = "status"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule = "rotation_schedule"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedules = "rotation_schedules"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_result = "rotation_schedule_result"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_results = "rotation_schedule_results"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic = "periodic"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_periodic_time_us = "time_us"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold = "size_threshold"; +LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes = "bytes"; + +/* String related to add-context command */ +LTTNG_HIDDEN const char * const mi_lttng_element_context_symbol = "symbol"; + /* Deprecated symbols preserved for ABI compatibility. */ const char * const mi_lttng_context_type_perf_counter; const char * const mi_lttng_context_type_perf_cpu_counter; const char * const mi_lttng_context_type_perf_thread_counter; const char * const mi_lttng_element_track_untrack_pid_target; const char * const mi_lttng_element_track_untrack_targets; +const char * const mi_lttng_element_calibrate; +const char * const mi_lttng_element_calibrate_function; +const char * const mi_lttng_element_command_calibrate; /* This is a merge of jul loglevel and regular loglevel * Those should never overlap by definition @@ -375,6 +395,18 @@ const char *mi_lttng_event_contexttype_string(enum lttng_event_context_type val) return config_event_context_hostname; case LTTNG_EVENT_CONTEXT_IP: return config_event_context_ip; + case LTTNG_EVENT_CONTEXT_INTERRUPTIBLE: + return config_event_context_interruptible; + case LTTNG_EVENT_CONTEXT_PREEMPTIBLE: + return config_event_context_preemptible; + case LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE: + return config_event_context_need_reschedule; + case LTTNG_EVENT_CONTEXT_MIGRATABLE: + return config_event_context_migratable; + case LTTNG_EVENT_CONTEXT_CALLSTACK_USER: + return config_event_context_callstack_user; + case LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL: + return config_event_context_callstack_kernel; default: return NULL; } @@ -436,22 +468,6 @@ const char *mi_lttng_buffertype_string(enum lttng_buffer_type value) } } -LTTNG_HIDDEN -const char *mi_lttng_calibratetype_string(enum lttng_calibrate_type val) -{ - const char *ret; - - switch (val) { - case LTTNG_CALIBRATE_FUNCTION: - ret = mi_lttng_element_calibrate_function; - break; - default: - ret = mi_lttng_element_empty; - break; - } - return ret; -} - LTTNG_HIDDEN struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type) { @@ -878,7 +894,8 @@ int mi_lttng_channel_attr(struct mi_writer *writer, int ret = 0; struct lttng_channel *chan = caa_container_of(attr, struct lttng_channel, attr); - uint64_t discarded_events, lost_packets; + uint64_t discarded_events, lost_packets, monitor_timer_interval; + int64_t blocking_timeout; assert(attr); @@ -892,6 +909,18 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } + ret = lttng_channel_get_monitor_timer_interval(chan, + &monitor_timer_interval); + if (ret) { + goto end; + } + + ret = lttng_channel_get_blocking_timeout(chan, + &blocking_timeout); + if (ret) { + goto end; + } + /* Opening Attributes */ ret = mi_lttng_writer_open_element(writer, config_element_attributes); if (ret) { @@ -938,6 +967,22 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } + /* Monitor timer interval in usec */ + ret = mi_lttng_writer_write_element_unsigned_int(writer, + config_element_monitor_timer_interval, + monitor_timer_interval); + if (ret) { + goto end; + } + + /* Retry timeout in usec */ + ret = mi_lttng_writer_write_element_signed_int(writer, + config_element_blocking_timeout, + blocking_timeout); + if (ret) { + goto end; + } + /* Event output */ ret = mi_lttng_writer_write_element_string(writer, config_element_output_type, @@ -1425,31 +1470,6 @@ end: return ret; } -LTTNG_HIDDEN -int mi_lttng_calibrate(struct mi_writer *writer, - struct lttng_calibrate *calibrate) -{ - int ret; - - /* Open calibrate element */ - ret = mi_lttng_writer_open_element(writer, mi_lttng_element_calibrate); - if (ret) { - goto end; - } - - /* Calibration type */ - ret = mi_lttng_writer_write_element_string(writer, config_element_type, - mi_lttng_calibratetype_string(calibrate->type)); - if (ret) { - goto end; - } - - /* Closing calibrate element */ - ret = mi_lttng_writer_close_element(writer); -end: - return ret; -} - LTTNG_HIDDEN int mi_lttng_perf_counter_context(struct mi_writer *writer, struct lttng_event_perf_counter_ctx *perf_context) @@ -1823,3 +1843,108 @@ int mi_lttng_snapshot_record(struct mi_writer *writer, end: return ret; } + +LTTNG_HIDDEN +int mi_lttng_rotation_schedule(struct mi_writer *writer, + const struct lttng_rotation_schedule *schedule) +{ + int ret = 0; + enum lttng_rotation_status status; + uint64_t value; + const char *element_name; + const char *value_name; + bool empty_schedule = false; + + switch (lttng_rotation_schedule_get_type(schedule)) { + case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC: + status = lttng_rotation_schedule_periodic_get_period(schedule, + &value); + element_name = mi_lttng_element_rotation_schedule_periodic; + value_name = mi_lttng_element_rotation_schedule_periodic_time_us; + break; + case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD: + status = lttng_rotation_schedule_size_threshold_get_threshold( + schedule, &value); + element_name = mi_lttng_element_rotation_schedule_size_threshold; + value_name = mi_lttng_element_rotation_schedule_size_threshold_bytes; + break; + default: + ret = -1; + goto end; + } + + if (status != LTTNG_ROTATION_STATUS_OK) { + if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) { + empty_schedule = true; + } else { + ret = -1; + goto end; + } + } + + ret = mi_lttng_writer_open_element(writer, element_name); + if (ret) { + goto end; + } + + if (!empty_schedule) { + ret = mi_lttng_writer_write_element_unsigned_int(writer, + value_name, value); + if (ret) { + goto end; + } + } + + /* Close schedule descriptor element. */ + ret = mi_lttng_writer_close_element(writer); + if (ret) { + goto end; + } +end: + return ret; +} + +LTTNG_HIDDEN +int mi_lttng_rotation_schedule_result(struct mi_writer *writer, + const struct lttng_rotation_schedule *schedule, + bool success) +{ + int ret = 0; + + ret = mi_lttng_writer_open_element(writer, + mi_lttng_element_rotation_schedule_result); + if (ret) { + goto end; + } + + ret = mi_lttng_writer_open_element(writer, + mi_lttng_element_rotation_schedule); + if (ret) { + goto end; + } + + ret = mi_lttng_rotation_schedule(writer, schedule); + if (ret) { + goto end; + } + + /* Close rotation_schedule element */ + ret = mi_lttng_writer_close_element(writer); + if (ret) { + goto end; + } + + ret = mi_lttng_writer_write_element_bool(writer, + mi_lttng_element_command_success, success); + if (ret) { + goto end; + } + + /* Close rotation_schedule_result element */ + ret = mi_lttng_writer_close_element(writer); + if (ret) { + goto end; + } +end: + return ret; +}