Build fix: retrieve unix socket peer PID on non-unix platforms
[lttng-tools.git] / src / common / mi-lttng.h
index df7a68a02cdade0f8755c4c0f623945968cbd261..7fbf7b53ee82e0e6a57c08cc7ff11b8f78210e96 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
- *                    - Olivier Cotte <olivier.cotte@polymtl.ca>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
+ * Copyright (C) 2014 Olivier Cotte <olivier.cotte@polymtl.ca>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * 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.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * 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
@@ -49,10 +39,29 @@ struct mi_lttng_version {
        char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
 };
 
+/* Error query callbacks. */
+typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb)(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb)(
+               const struct lttng_trigger *trigger,
+               struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_action_cb)(
+               const struct lttng_trigger *trigger,
+               const struct lttng_action_path *action_path,
+               struct lttng_error_query_results **results);
+
+struct mi_lttng_error_query_callbacks {
+       mi_lttng_error_query_trigger_cb trigger_cb;
+       mi_lttng_error_query_condition_cb condition_cb;
+       mi_lttng_error_query_action_cb action_cb;
+};
+
 /* Strings related to command */
 extern const char * const mi_lttng_element_command;
 extern const char * const mi_lttng_element_command_action;
 extern const char * const mi_lttng_element_command_add_context;
+extern const char *const mi_lttng_element_command_add_trigger;
 extern const char * const mi_lttng_element_command_create;
 extern const char * const mi_lttng_element_command_destroy;
 extern const char * const mi_lttng_element_command_disable_channel;
@@ -60,6 +69,7 @@ extern const char * const mi_lttng_element_command_disable_event;
 extern const char * const mi_lttng_element_command_enable_channels;
 extern const char * const mi_lttng_element_command_enable_event;
 extern const char * const mi_lttng_element_command_list;
+extern const char *const mi_lttng_element_command_list_trigger;
 extern const char * const mi_lttng_element_command_load;
 extern const char * const mi_lttng_element_command_metadata;
 extern const char * const mi_lttng_element_command_metadata_action;
@@ -67,6 +77,7 @@ extern const char * const mi_lttng_element_command_regenerate;
 extern const char * const mi_lttng_element_command_regenerate_action;
 extern const char * const mi_lttng_element_command_name;
 extern const char * const mi_lttng_element_command_output;
+extern const char *const mi_lttng_element_command_remove_trigger;
 extern const char * const mi_lttng_element_command_save;
 extern const char * const mi_lttng_element_command_set_session;
 extern const char * const mi_lttng_element_command_snapshot;
@@ -83,6 +94,7 @@ extern const char * const mi_lttng_element_command_version;
 extern const char * const mi_lttng_element_command_rotate;
 extern const char * const mi_lttng_element_command_enable_rotation;
 extern const char * const mi_lttng_element_command_disable_rotation;
+extern const char * const mi_lttng_element_command_clear;
 
 /* Strings related to version command */
 extern const char * const mi_lttng_element_version;
@@ -110,8 +122,8 @@ extern const char * const mi_lttng_element_save;
 
 /* Strings related to load command */
 extern const char * const mi_lttng_element_load;
-LTTNG_HIDDEN const char * const mi_lttng_element_load_overrides;
-LTTNG_HIDDEN const char * const mi_lttng_element_load_override_url;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_load_overrides;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_load_override_url;
 
 /* General element of mi_lttng */
 extern const char * const mi_lttng_element_empty;
@@ -186,15 +198,204 @@ extern const char * const mi_lttng_element_snapshot_session_name;
 extern const char * const mi_lttng_element_snapshots;
 
 /* String related to track/untrack command */
-const char * const mi_lttng_element_track_untrack_all_wildcard;
+extern const char * const mi_lttng_element_track_untrack_all_wildcard;
 
-LTTNG_HIDDEN const char * const mi_lttng_element_session_name;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_session_name;
 
 /* String related to rotate command */
-LTTNG_HIDDEN const char * const mi_lttng_element_rotation;
-LTTNG_HIDDEN const char * const mi_lttng_element_rotations;
-LTTNG_HIDDEN const char * const mi_lttng_element_rotate_status;
-LTTNG_HIDDEN const char * const mi_lttng_element_rotation_schedule;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotate_status;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedules;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_result;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_schedule_results;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_state;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_host;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_control_port;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_data_port;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_protocol;
+LTTNG_HIDDEN extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
+
+/* String related to enum lttng_rotation_state */
+LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_ongoing;
+LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_completed;
+LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_expired;
+LTTNG_HIDDEN extern const char * const mi_lttng_rotation_state_str_error;
+
+/* String related to enum lttng_trace_archive_location_relay_protocol_type */
+LTTNG_HIDDEN extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
+
+/* String related to rate_policy elements */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy_every_n;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy_once_after_n;
+
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_rate_policy_every_n_interval;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_rate_policy_once_after_n_threshold;
+
+/* String related to action elements */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_list;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_notify;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_start_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_stop_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_rotate_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_snapshot_session;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_action_snapshot_session_output;
+
+/* String related to condition */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_buffer_usage_high;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_buffer_usage_low;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_event_rule_matches;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_session_consumed_size;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_session_rotation;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_session_rotation_completed;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_condition_session_rotation_ongoing;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_channel_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_threshold_ratio;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_threshold_bytes;
+
+/* String related to capture descriptor */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_capture_descriptor;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_capture_descriptors;
+
+/* String related to event expression */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_payload_field;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_expr_channel_context_field;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_expr_app_specific_context_field;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_expr_array_field_element;
+
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_provider_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_type_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_index;
+
+/* String related to event rule */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule;
+
+/* String related to lttng_event_rule */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_event_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_name_pattern;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_rule_filter_expression;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_jul_logging;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_syscall;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_rule_kernel_tracepoint;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_log4j_logging;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_python_logging;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_rule_user_tracepoint;
+
+/* String related to lttng_event_rule_kernel_syscall. */
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
+
+/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
+
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
+
+/* String related to log level rule. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule_exactly;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule_level;
+
+/* String related to kernel probe location. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_kernel_probe_location;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_kernel_probe_location_symbol_offset;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_kernel_probe_location_symbol_offset_name;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_kernel_probe_location_symbol_offset_offset;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_kernel_probe_location_address;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_kernel_probe_location_address_address;
+
+/* String related to userspace probe location. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_userspace_probe_location;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_userspace_probe_location_binary_path;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_userspace_probe_location_function;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_userspace_probe_location_function_name;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_userspace_probe_location_lookup_method;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_userspace_probe_location_tracepoint;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
+
+/* String related to enum
+ * lttng_userspace_probe_location_function_instrumentation_type */
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_element_userspace_probe_location_function_instrumentation_type;
+LTTNG_HIDDEN extern const char *const
+               mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+
+/* String related to trigger */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_triggers;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_trigger;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_trigger_owner_uid;
+
+/* String related to error_query. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_error_query_result_counter;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_error_query_result_counter_value;
+LTTNG_HIDDEN extern const char
+               *const mi_lttng_element_error_query_result_description;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result_type;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_results;
 
 /* String related to add-context command */
 LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol;
@@ -205,6 +406,9 @@ 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);
+const char *mi_lttng_rotation_state_string(enum lttng_rotation_state value);
+const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
+               enum lttng_trace_archive_location_relay_protocol_type value);
 
 /*
  * Create an instance of a machine interface writer.
@@ -334,6 +538,20 @@ int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
 int mi_lttng_writer_write_element_string(struct mi_writer *writer,
                const char *element_name, const char *value);
 
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Double 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_double(struct mi_writer *writer,
+               const char *element_name,
+               double value);
+
 /*
  * Machine interface of struct version.
  *
@@ -577,7 +795,7 @@ int mi_lttng_event_fields_open(struct mi_writer *writer);
 int mi_lttng_trackers_open(struct mi_writer *writer);
 
 /*
- * Machine interface: open a pid_tracker element.
+ * Machine interface: open a process attribute tracker element.
  *
  * writer An instance of a machine interface writer.
  *
@@ -586,7 +804,8 @@ int mi_lttng_trackers_open(struct mi_writer *writer);
  *
  * Note: A targets element is also opened for each tracker definition
  */
-int mi_lttng_pid_tracker_open(struct mi_writer *writer);
+int mi_lttng_process_attribute_tracker_open(
+               struct mi_writer *writer, enum lttng_process_attr process_attr);
 
 /*
  * Machine interface: open a PIDs element.
@@ -644,25 +863,54 @@ int mi_lttng_process(struct mi_writer *writer, pid_t pid , const char *name,
  */
 int mi_lttng_pid(struct mi_writer *writer, pid_t pid , const char *name,
                int is_open);
+
+/*
+ * Machine interface: open a process attribute values 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_process_attr_values_open(struct mi_writer *writer);
+
 /*
- * Machine interface: open a targets element.
+ * Machine interface for track/untrack of all process attribute values.
  *
  * 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_targets_open(struct mi_writer *writer);
+int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               bool is_open);
 
 /*
- * Machine interface for track/untrack a pid_target
+ * Machine interface for track/untrack of an integral process attribute value.
  *
  * 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_pid_target(struct mi_writer *writer, pid_t pid, int is_open);
+int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               int64_t value,
+               bool is_open);
+
+/*
+ * Machine interface for track/untrack of a string process attribute value.
+ *
+ * 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_string_process_attribute_value(struct mi_writer *writer,
+               enum lttng_process_attr process_attr,
+               const char *value,
+               bool is_open);
 
 /*
  * Machine interface of a context.
@@ -729,7 +977,7 @@ int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
  * Negative values indicate an error.
  */
 int mi_lttng_snapshot_list_output(struct mi_writer *writer,
-               struct lttng_snapshot_output *output);
+               const struct lttng_snapshot_output *output);
 
 /*
  * Machine interface of the output of the command snapshot del output
@@ -806,4 +1054,67 @@ int mi_lttng_snapshot_record(struct mi_writer *writer,
                const char *current_session_name, const char *url,
                const char *cmdline_ctrl_url, const char *cmdline_data_url);
 
+/*
+ * Machine interface representation of a session rotation schedule.
+ *
+ * The machine interface serializes the provided schedule as one of the choices
+ * from 'rotation_schedule_type'.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * schedule: An lttng rotation schedule descriptor object.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotation_schedule(struct mi_writer *writer,
+               const struct lttng_rotation_schedule *schedule);
+
+/*
+ * Machine interface of a session rotation schedule result.
+ * This is an element that is part of the output of the enable-rotation and
+ * disable-rotation commands.
+ *
+ * The machine interface provides the following information:
+ * - schedule: the session rotation schedule descriptor.
+ * - success: whether the sub-command succeeded.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * schedule: An lttng rotation schedule descriptor object.
+ *
+ * success: Whether the sub-command suceeded.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
+               const struct lttng_rotation_schedule *schedule,
+               bool success);
+
+/*
+ * Machine interface of a session rotation result.
+ * This is an element that is part of the output of the rotate command.
+ *
+ * The machine interface provides the following information:
+ * - session_name: the session to be rotated.
+ * - state: the session rotation state.
+ * - location: the location of the completed chunk archive.
+ *
+ * writer: An instance of a machine interface writer.
+ *
+ * session_name: The session to which the rotate command applies.
+ *
+ * location: A location descriptor object.
+ *
+ * success: Whether the sub-command suceeded.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_rotate(struct mi_writer *writer,
+               const char *session_name,
+               enum lttng_rotation_state rotation_state,
+               const struct lttng_trace_archive_location *location);
+
 #endif /* _MI_LTTNG_H */
This page took 0.028702 seconds and 4 git commands to generate.