#include <sys/time.h>
#include <time.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
static int print_capture(const struct lttng_condition *condition,
const struct lttng_event_field_value *capture,
lttng/event-rule/user-tracepoint.h
noinst_HEADERS = \
- lttng/action/action-internal.h \
- lttng/action/list-internal.h \
- lttng/action/notify-internal.h \
- lttng/action/path-internal.h \
- lttng/action/rotate-session-internal.h \
- lttng/action/snapshot-session-internal.h \
- lttng/action/start-session-internal.h \
- lttng/action/stop-session-internal.h \
- lttng/action/rate-policy-internal.h \
- lttng/channel-internal.h \
- lttng/condition/buffer-usage-internal.h \
- lttng/condition/condition-internal.h \
- lttng/condition/evaluation-internal.h \
- lttng/condition/event-rule-matches-internal.h \
- lttng/condition/session-consumed-size-internal.h \
- lttng/condition/session-rotation-internal.h \
- lttng/domain-internal.h \
- lttng/endpoint-internal.h \
- lttng/error-query-internal.h \
- lttng/event-expr-internal.h \
- lttng/event-field-value-internal.h \
- lttng/event-internal.h \
- lttng/event-rule/event-rule-internal.h \
- lttng/event-rule/jul-logging-internal.h \
- lttng/event-rule/kernel-kprobe-internal.h \
- lttng/event-rule/kernel-syscall-internal.h \
- lttng/event-rule/kernel-tracepoint-internal.h \
- lttng/event-rule/kernel-uprobe-internal.h \
- lttng/event-rule/log4j-logging-internal.h \
- lttng/event-rule/python-logging-internal.h \
- lttng/event-rule/user-tracepoint-internal.h \
- lttng/health-internal.h \
- lttng/kernel-probe-internal.h \
- lttng/load-internal.h \
- lttng/location-internal.h \
- lttng/log-level-rule-internal.h \
- lttng/notification/channel-internal.h \
- lttng/notification/notification-internal.h \
- lttng/ref-internal.h \
- lttng/rotate-internal.h \
- lttng/save-internal.h \
- lttng/session-descriptor-internal.h \
- lttng/session-internal.h \
- lttng/snapshot-internal.h \
- lttng/trigger/trigger-internal.h \
- lttng/userspace-probe-internal.h \
- version.h \
+ lttng/action/action-internal.hpp \
+ lttng/action/list-internal.hpp \
+ lttng/action/notify-internal.hpp \
+ lttng/action/path-internal.hpp \
+ lttng/action/rotate-session-internal.hpp \
+ lttng/action/snapshot-session-internal.hpp \
+ lttng/action/start-session-internal.hpp \
+ lttng/action/stop-session-internal.hpp \
+ lttng/action/rate-policy-internal.hpp \
+ lttng/channel-internal.hpp \
+ lttng/condition/buffer-usage-internal.hpp \
+ lttng/condition/condition-internal.hpp \
+ lttng/condition/evaluation-internal.hpp \
+ lttng/condition/event-rule-matches-internal.hpp \
+ lttng/condition/session-consumed-size-internal.hpp \
+ lttng/condition/session-rotation-internal.hpp \
+ lttng/domain-internal.hpp \
+ lttng/endpoint-internal.hpp \
+ lttng/error-query-internal.hpp \
+ lttng/event-expr-internal.hpp \
+ lttng/event-field-value-internal.hpp \
+ lttng/event-internal.hpp \
+ lttng/event-rule/event-rule-internal.hpp \
+ lttng/event-rule/jul-logging-internal.hpp \
+ lttng/event-rule/kernel-kprobe-internal.hpp \
+ lttng/event-rule/kernel-syscall-internal.hpp \
+ lttng/event-rule/kernel-tracepoint-internal.hpp \
+ lttng/event-rule/kernel-uprobe-internal.hpp \
+ lttng/event-rule/log4j-logging-internal.hpp \
+ lttng/event-rule/python-logging-internal.hpp \
+ lttng/event-rule/user-tracepoint-internal.hpp \
+ lttng/health-internal.hpp \
+ lttng/kernel-probe-internal.hpp \
+ lttng/load-internal.hpp \
+ lttng/location-internal.hpp \
+ lttng/log-level-rule-internal.hpp \
+ lttng/notification/channel-internal.hpp \
+ lttng/notification/notification-internal.hpp \
+ lttng/ref-internal.hpp \
+ lttng/rotate-internal.hpp \
+ lttng/save-internal.hpp \
+ lttng/session-descriptor-internal.hpp \
+ lttng/session-internal.hpp \
+ lttng/snapshot-internal.hpp \
+ lttng/trigger/trigger-internal.hpp \
+ lttng/userspace-probe-internal.hpp \
+ version.hpp \
version.i
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_INTERNAL_H
-#define LTTNG_ACTION_INTERNAL_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/lttng.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_rate_policy;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_trigger;
-
-typedef bool (*action_validate_cb)(struct lttng_action *action);
-typedef void (*action_destroy_cb)(struct lttng_action *action);
-typedef int (*action_serialize_cb)(struct lttng_action *action,
- struct lttng_payload *payload);
-typedef bool (*action_equal_cb)(const struct lttng_action *a,
- const struct lttng_action *b);
-typedef ssize_t (*action_create_from_payload_cb)(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
- const struct lttng_action *action);
-typedef enum lttng_action_status (*action_add_error_query_results_cb)(
- const struct lttng_action *action,
- struct lttng_error_query_results *results);
-typedef enum lttng_error_code (*action_mi_serialize_cb)(
- const struct lttng_action *condition, struct mi_writer *writer);
-
-struct lttng_action {
- struct urcu_ref ref;
- enum lttng_action_type type;
- action_validate_cb validate;
- action_serialize_cb serialize;
- action_equal_cb equal;
- action_destroy_cb destroy;
- action_get_rate_policy_cb get_rate_policy;
- action_add_error_query_results_cb add_error_query_results;
- action_mi_serialize_cb mi_serialize;
-
- /* Internal use only. */
-
- /* The number of time the actions was enqueued for execution. */
- uint64_t execution_request_counter;
- /*
- * The number of time the action was actually executed.
- * Action rate policy can impact on this number.
- * */
- uint64_t execution_counter;
- /*
- * The number of time the action execution failed.
- * An unsigned long is used to use a type which makes atomic
- * operations possible.
- */
- unsigned long execution_failure_counter;
-};
-
-struct lttng_action_comm {
- /* enum lttng_action_type */
- int8_t action_type;
-} LTTNG_PACKED;
-
-void lttng_action_init(struct lttng_action *action,
- enum lttng_action_type type,
- action_validate_cb validate,
- action_serialize_cb serialize,
- action_equal_cb equal,
- action_destroy_cb destroy,
- action_get_rate_policy_cb get_rate_policy,
- action_add_error_query_results_cb add_error_query_results,
- action_mi_serialize_cb mi);
-
-bool lttng_action_validate(struct lttng_action *action);
-
-int lttng_action_serialize(struct lttng_action *action,
- struct lttng_payload *buf);
-
-ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
- struct lttng_action **action);
-
-bool lttng_action_is_equal(const struct lttng_action *a,
- const struct lttng_action *b);
-
-void lttng_action_get(struct lttng_action *action);
-
-void lttng_action_put(struct lttng_action *action);
-
-const char* lttng_action_type_string(enum lttng_action_type action_type);
-
-void lttng_action_increase_execution_request_count(struct lttng_action *action);
-
-void lttng_action_increase_execution_count(struct lttng_action *action);
-
-void lttng_action_increase_execution_failure_count(struct lttng_action *action);
-
-bool lttng_action_should_execute(const struct lttng_action *action);
-
-enum lttng_action_status lttng_action_add_error_query_results(
- const struct lttng_action *action,
- struct lttng_error_query_results *results);
-
-/*
- * For use by the various lttng_action implementation. Implements the default
- * behavior to the generic error "execution failure counter" that all actions
- * (except list, which passes-through) provide.
- */
-enum lttng_action_status lttng_action_generic_add_error_query_results(
- const struct lttng_action *action,
- struct lttng_error_query_results *results);
-enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
- const struct lttng_action *action,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks,
- struct lttng_dynamic_array *action_path_indexes);
-
-#endif /* LTTNG_ACTION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_INTERNAL_H
+#define LTTNG_ACTION_INTERNAL_H
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/lttng.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_rate_policy;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
+
+typedef bool (*action_validate_cb)(struct lttng_action *action);
+typedef void (*action_destroy_cb)(struct lttng_action *action);
+typedef int (*action_serialize_cb)(struct lttng_action *action,
+ struct lttng_payload *payload);
+typedef bool (*action_equal_cb)(const struct lttng_action *a,
+ const struct lttng_action *b);
+typedef ssize_t (*action_create_from_payload_cb)(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
+ const struct lttng_action *action);
+typedef enum lttng_action_status (*action_add_error_query_results_cb)(
+ const struct lttng_action *action,
+ struct lttng_error_query_results *results);
+typedef enum lttng_error_code (*action_mi_serialize_cb)(
+ const struct lttng_action *condition, struct mi_writer *writer);
+
+struct lttng_action {
+ struct urcu_ref ref;
+ enum lttng_action_type type;
+ action_validate_cb validate;
+ action_serialize_cb serialize;
+ action_equal_cb equal;
+ action_destroy_cb destroy;
+ action_get_rate_policy_cb get_rate_policy;
+ action_add_error_query_results_cb add_error_query_results;
+ action_mi_serialize_cb mi_serialize;
+
+ /* Internal use only. */
+
+ /* The number of time the actions was enqueued for execution. */
+ uint64_t execution_request_counter;
+ /*
+ * The number of time the action was actually executed.
+ * Action rate policy can impact on this number.
+ * */
+ uint64_t execution_counter;
+ /*
+ * The number of time the action execution failed.
+ * An unsigned long is used to use a type which makes atomic
+ * operations possible.
+ */
+ unsigned long execution_failure_counter;
+};
+
+struct lttng_action_comm {
+ /* enum lttng_action_type */
+ int8_t action_type;
+} LTTNG_PACKED;
+
+void lttng_action_init(struct lttng_action *action,
+ enum lttng_action_type type,
+ action_validate_cb validate,
+ action_serialize_cb serialize,
+ action_equal_cb equal,
+ action_destroy_cb destroy,
+ action_get_rate_policy_cb get_rate_policy,
+ action_add_error_query_results_cb add_error_query_results,
+ action_mi_serialize_cb mi);
+
+bool lttng_action_validate(struct lttng_action *action);
+
+int lttng_action_serialize(struct lttng_action *action,
+ struct lttng_payload *buf);
+
+ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+bool lttng_action_is_equal(const struct lttng_action *a,
+ const struct lttng_action *b);
+
+void lttng_action_get(struct lttng_action *action);
+
+void lttng_action_put(struct lttng_action *action);
+
+const char* lttng_action_type_string(enum lttng_action_type action_type);
+
+void lttng_action_increase_execution_request_count(struct lttng_action *action);
+
+void lttng_action_increase_execution_count(struct lttng_action *action);
+
+void lttng_action_increase_execution_failure_count(struct lttng_action *action);
+
+bool lttng_action_should_execute(const struct lttng_action *action);
+
+enum lttng_action_status lttng_action_add_error_query_results(
+ const struct lttng_action *action,
+ struct lttng_error_query_results *results);
+
+/*
+ * For use by the various lttng_action implementation. Implements the default
+ * behavior to the generic error "execution failure counter" that all actions
+ * (except list, which passes-through) provide.
+ */
+enum lttng_action_status lttng_action_generic_add_error_query_results(
+ const struct lttng_action *action,
+ struct lttng_error_query_results *results);
+enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes);
+
+#endif /* LTTNG_ACTION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_LIST_INTERNAL_H
-#define LTTNG_ACTION_LIST_INTERNAL_H
-
-#include <sys/types.h>
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_dynamic_array;
-struct lttng_trigger;
-
-/*
- * Create an action list from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * list in `*list`. On failure, return -1.
- */
-extern ssize_t lttng_action_list_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **list);
-
-extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
- const struct lttng_action *list, unsigned int index);
-
-enum lttng_error_code lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
- const struct lttng_action *action,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks,
- struct lttng_dynamic_array *action_path_indexes);
-
-#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_LIST_INTERNAL_H
+#define LTTNG_ACTION_LIST_INTERNAL_H
+
+#include <sys/types.h>
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_dynamic_array;
+struct lttng_trigger;
+
+/*
+ * Create an action list from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * list in `*list`. On failure, return -1.
+ */
+extern ssize_t lttng_action_list_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **list);
+
+extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
+ const struct lttng_action *list, unsigned int index);
+
+enum lttng_error_code lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes);
+
+#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_NOTIFY_INTERNAL_H
-#define LTTNG_ACTION_NOTIFY_INTERNAL_H
-
-#include <lttng/action/notify.h>
-#include <lttng/action/action-internal.h>
-
-struct lttng_action_notify {
- struct lttng_action parent;
- struct lttng_rate_policy *policy;
-};
-
-ssize_t lttng_action_notify_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_NOTIFY_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_NOTIFY_INTERNAL_H
+#define LTTNG_ACTION_NOTIFY_INTERNAL_H
+
+#include <lttng/action/notify.h>
+#include <lttng/action/action-internal.hpp>
+
+struct lttng_action_notify {
+ struct lttng_action parent;
+ struct lttng_rate_policy *policy;
+};
+
+ssize_t lttng_action_notify_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_NOTIFY_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_PATH_INTERNAL_H
-#define LTTNG_ACTION_PATH_INTERNAL_H
-
-#include <lttng/action/path.h>
-#include <common/macros.h>
-#include <common/dynamic-array.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <sys/types.h>
-
-struct lttng_action_path {
- struct lttng_dynamic_array indexes;
-};
-
-/* Assumes that 'dst' is uninitialized. */
-int lttng_action_path_copy(const struct lttng_action_path *src,
- struct lttng_action_path *dst);
-
-ssize_t lttng_action_path_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action_path **action_path);
-
-int lttng_action_path_serialize(const struct lttng_action_path *action_path,
- struct lttng_payload *payload);
-
-#endif /* LTTNG_ACTION_PATH_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_PATH_INTERNAL_H
+#define LTTNG_ACTION_PATH_INTERNAL_H
+
+#include <lttng/action/path.h>
+#include <common/macros.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <sys/types.h>
+
+struct lttng_action_path {
+ struct lttng_dynamic_array indexes;
+};
+
+/* Assumes that 'dst' is uninitialized. */
+int lttng_action_path_copy(const struct lttng_action_path *src,
+ struct lttng_action_path *dst);
+
+ssize_t lttng_action_path_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action_path **action_path);
+
+int lttng_action_path_serialize(const struct lttng_action_path *action_path,
+ struct lttng_payload *payload);
+
+#endif /* LTTNG_ACTION_PATH_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_RATE_POLICY_INTERNAL_H
-#define LTTNG_RATE_POLICY_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <lttng/action/rate-policy.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-
-
-struct mi_writer;
-
-int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
- struct lttng_payload *buf);
-
-ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
- struct lttng_rate_policy **rate_policy);
-
-bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
- const struct lttng_rate_policy *b);
-
-const char *lttng_rate_policy_type_string(
- enum lttng_rate_policy_type rate_policy_type);
-
-struct lttng_rate_policy *lttng_rate_policy_copy(
- const struct lttng_rate_policy *source);
-
-bool lttng_rate_policy_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter);
-
-enum lttng_error_code lttng_rate_policy_mi_serialize(
- const struct lttng_rate_policy *policy,
- struct mi_writer *writer);
-
-#endif /* LTTNG_RATE_POLICY */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_RATE_POLICY_INTERNAL_H
+#define LTTNG_RATE_POLICY_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <lttng/action/rate-policy.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+
+
+struct mi_writer;
+
+int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
+ struct lttng_payload *buf);
+
+ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_rate_policy **rate_policy);
+
+bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
+ const struct lttng_rate_policy *b);
+
+const char *lttng_rate_policy_type_string(
+ enum lttng_rate_policy_type rate_policy_type);
+
+struct lttng_rate_policy *lttng_rate_policy_copy(
+ const struct lttng_rate_policy *source);
+
+bool lttng_rate_policy_should_execute(
+ const struct lttng_rate_policy *policy, uint64_t counter);
+
+enum lttng_error_code lttng_rate_policy_mi_serialize(
+ const struct lttng_rate_policy *policy,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_RATE_POLICY */
+++ /dev/null
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
-#define LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "rotate session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_rotate_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
+#define LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "rotate session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_rotate_session_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_ROTATE_SESSION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
-#define LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
-
-#include <sys/types.h>
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "snapshot session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_snapshot_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
+#define LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H
+
+#include <sys/types.h>
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "snapshot session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_snapshot_session_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_SNAPSHOT_SESSION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_START_SESSION_INTERNAL_H
-#define LTTNG_ACTION_START_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "start session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_start_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_START_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_START_SESSION_INTERNAL_H
+#define LTTNG_ACTION_START_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "start session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_start_session_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_START_SESSION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ACTION_STOP_SESSION_INTERNAL_H
-#define LTTNG_ACTION_STOP_SESSION_INTERNAL_H
-
-#include <common/macros.h>
-
-struct lttng_action;
-struct lttng_payload_view;
-
-/*
- * Create a "stop session" action from a payload view.
- *
- * On success, return the number of bytes consumed from `view`, and the created
- * action in `*action`. On failure, return -1.
- */
-extern ssize_t lttng_action_stop_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action);
-
-#endif /* LTTNG_ACTION_STOP_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ACTION_STOP_SESSION_INTERNAL_H
+#define LTTNG_ACTION_STOP_SESSION_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_action;
+struct lttng_payload_view;
+
+/*
+ * Create a "stop session" action from a payload view.
+ *
+ * On success, return the number of bytes consumed from `view`, and the created
+ * action in `*action`. On failure, return -1.
+ */
+extern ssize_t lttng_action_stop_session_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action);
+
+#endif /* LTTNG_ACTION_STOP_SESSION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CHANNEL_INTERNAL_H
-#define LTTNG_CHANNEL_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/channel.h>
-#include <lttng/lttng-error.h>
-
-struct lttng_dynamic_buffer;
-struct lttng_buffer_view;
-
-struct lttng_channel_extended {
- uint64_t discarded_events;
- uint64_t lost_packets;
- uint64_t monitor_timer_interval;
- int64_t blocking_timeout;
-} LTTNG_PACKED;
-
-struct lttng_channel_comm {
- /* Includes terminator `\0`. */
- uint32_t name_len;
- uint8_t enabled;
-
- /* attr */
- int8_t overwrite;
- uint64_t subbuf_size;
- uint64_t num_subbuf;
- uint32_t switch_timer_interval;
- uint32_t read_timer_interval;
- uint8_t output;
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- uint32_t live_timer_interval;
-
- /* Extended struct */
- uint64_t discarded_events;
- uint64_t lost_packets;
- uint64_t monitor_timer_interval;
- int64_t blocking_timeout;
-} LTTNG_PACKED;
-
-struct lttng_channel *lttng_channel_create_internal(void);
-
-struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src);
-
-ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view,
- struct lttng_channel **event);
-
-int lttng_channel_serialize(struct lttng_channel *channel,
- struct lttng_dynamic_buffer *buf);
-
-void lttng_channel_set_default_extended_attr(struct lttng_domain *domain,
- struct lttng_channel_extended *extended_attr);
-
-enum lttng_error_code lttng_channels_create_and_flatten_from_buffer(
- const struct lttng_buffer_view *view,
- unsigned int count,
- struct lttng_channel **channels);
-
-#endif /* LTTNG_CHANNEL_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CHANNEL_INTERNAL_H
+#define LTTNG_CHANNEL_INTERNAL_H
+
+#include <common/macros.hpp>
+
+struct lttng_channel_extended {
+ uint64_t discarded_events;
+ uint64_t lost_packets;
+ uint64_t monitor_timer_interval;
+ int64_t blocking_timeout;
+} LTTNG_PACKED;
+
+struct lttng_channel_comm {
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ uint8_t enabled;
+
+ /* attr */
+ int8_t overwrite;
+ uint64_t subbuf_size;
+ uint64_t num_subbuf;
+ uint32_t switch_timer_interval;
+ uint32_t read_timer_interval;
+ uint8_t output;
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ uint32_t live_timer_interval;
+
+ /* Extended struct */
+ uint64_t discarded_events;
+ uint64_t lost_packets;
+ uint64_t monitor_timer_interval;
+ int64_t blocking_timeout;
+} LTTNG_PACKED;
+
+struct lttng_channel *lttng_channel_create_internal(void);
+
+struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src);
+
+ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view,
+ struct lttng_channel **event);
+
+int lttng_channel_serialize(struct lttng_channel *channel,
+ struct lttng_dynamic_buffer *buf);
+
+void lttng_channel_set_default_extended_attr(struct lttng_domain *domain,
+ struct lttng_channel_extended *extended_attr);
+
+enum lttng_error_code lttng_channels_create_and_flatten_from_buffer(
+ const struct lttng_buffer_view *view,
+ unsigned int count,
+ struct lttng_channel **channels);
+
+#endif /* LTTNG_CHANNEL_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
-#define LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
-
-#include <lttng/condition/buffer-usage.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <lttng/domain.h>
-#include "common/buffer-view.h"
-#include <common/macros.h>
-
-struct lttng_condition_buffer_usage {
- struct lttng_condition parent;
- struct {
- bool set;
- uint64_t value;
- } threshold_bytes;
- struct {
- bool set;
- double value;
- } threshold_ratio;
- char *session_name;
- char *channel_name;
- struct {
- bool set;
- enum lttng_domain_type type;
- } domain;
-};
-
-struct lttng_condition_buffer_usage_comm {
- uint8_t threshold_set_in_bytes;
- uint64_t threshold_bytes;
- double threshold_ratio;
- /* Both lengths include the trailing \0. */
- uint32_t session_name_len;
- uint32_t channel_name_len;
- /* enum lttng_domain_type */
- int8_t domain_type;
- /* session and channel names. */
- char names[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_buffer_usage {
- struct lttng_evaluation parent;
- uint64_t buffer_use;
- uint64_t buffer_capacity;
-};
-
-struct lttng_evaluation_buffer_usage_comm {
- uint64_t buffer_use;
- uint64_t buffer_capacity;
-} LTTNG_PACKED;
-
-struct lttng_evaluation *lttng_evaluation_buffer_usage_create(
- enum lttng_condition_type type, uint64_t use,
- uint64_t capacity);
-
-ssize_t lttng_condition_buffer_usage_low_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-ssize_t lttng_condition_buffer_usage_high_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
+#define LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H
+
+#include <lttng/condition/buffer-usage.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <lttng/domain.h>
+#include "common/buffer-view.hpp"
+#include <common/macros.hpp>
+
+struct lttng_condition_buffer_usage {
+ struct lttng_condition parent;
+ struct {
+ bool set;
+ uint64_t value;
+ } threshold_bytes;
+ struct {
+ bool set;
+ double value;
+ } threshold_ratio;
+ char *session_name;
+ char *channel_name;
+ struct {
+ bool set;
+ enum lttng_domain_type type;
+ } domain;
+};
+
+struct lttng_condition_buffer_usage_comm {
+ uint8_t threshold_set_in_bytes;
+ uint64_t threshold_bytes;
+ double threshold_ratio;
+ /* Both lengths include the trailing \0. */
+ uint32_t session_name_len;
+ uint32_t channel_name_len;
+ /* enum lttng_domain_type */
+ int8_t domain_type;
+ /* session and channel names. */
+ char names[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_buffer_usage {
+ struct lttng_evaluation parent;
+ uint64_t buffer_use;
+ uint64_t buffer_capacity;
+};
+
+struct lttng_evaluation_buffer_usage_comm {
+ uint64_t buffer_use;
+ uint64_t buffer_capacity;
+} LTTNG_PACKED;
+
+struct lttng_evaluation *lttng_evaluation_buffer_usage_create(
+ enum lttng_condition_type type, uint64_t use,
+ uint64_t capacity);
+
+ssize_t lttng_condition_buffer_usage_low_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+ssize_t lttng_condition_buffer_usage_high_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_BUFFER_USAGE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_INTERNAL_H
-#define LTTNG_CONDITION_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/condition/condition.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-struct lttng_trigger;
-
-typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
-typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
-typedef int (*condition_serialize_cb)(
- const struct lttng_condition *condition,
- struct lttng_payload *payload);
-typedef bool (*condition_equal_cb)(const struct lttng_condition *a,
- const struct lttng_condition *b);
-typedef ssize_t (*condition_create_from_payload_cb)(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-typedef enum lttng_error_code (*condition_mi_serialize_cb)(
- const struct lttng_condition *condition,
- struct mi_writer *writer);
-
-struct lttng_condition {
- /* Reference counting is only exposed to internal users. */
- struct urcu_ref ref;
- enum lttng_condition_type type;
- condition_validate_cb validate;
- condition_serialize_cb serialize;
- condition_equal_cb equal;
- condition_destroy_cb destroy;
- condition_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_condition_comm {
- /* enum lttng_condition_type */
- int8_t condition_type;
- char payload[];
-};
-
-void lttng_condition_get(struct lttng_condition *condition);
-
-void lttng_condition_put(struct lttng_condition *condition);
-
-void lttng_condition_init(struct lttng_condition *condition,
- enum lttng_condition_type type);
-
-bool lttng_condition_validate(const struct lttng_condition *condition);
-
-ssize_t lttng_condition_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-int lttng_condition_serialize(const struct lttng_condition *condition,
- struct lttng_payload *payload);
-
-bool lttng_condition_is_equal(const struct lttng_condition *a,
- const struct lttng_condition *b);
-
-enum lttng_error_code lttng_condition_mi_serialize(
- const struct lttng_trigger *trigger,
- const struct lttng_condition *condition,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks);
-
-const char *lttng_condition_type_str(enum lttng_condition_type type);
-
-#endif /* LTTNG_CONDITION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_INTERNAL_H
+#define LTTNG_CONDITION_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/condition/condition.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
+
+typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
+typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
+typedef int (*condition_serialize_cb)(
+ const struct lttng_condition *condition,
+ struct lttng_payload *payload);
+typedef bool (*condition_equal_cb)(const struct lttng_condition *a,
+ const struct lttng_condition *b);
+typedef ssize_t (*condition_create_from_payload_cb)(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+typedef enum lttng_error_code (*condition_mi_serialize_cb)(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer);
+
+struct lttng_condition {
+ /* Reference counting is only exposed to internal users. */
+ struct urcu_ref ref;
+ enum lttng_condition_type type;
+ condition_validate_cb validate;
+ condition_serialize_cb serialize;
+ condition_equal_cb equal;
+ condition_destroy_cb destroy;
+ condition_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_condition_comm {
+ /* enum lttng_condition_type */
+ int8_t condition_type;
+ char payload[];
+};
+
+void lttng_condition_get(struct lttng_condition *condition);
+
+void lttng_condition_put(struct lttng_condition *condition);
+
+void lttng_condition_init(struct lttng_condition *condition,
+ enum lttng_condition_type type);
+
+bool lttng_condition_validate(const struct lttng_condition *condition);
+
+ssize_t lttng_condition_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+int lttng_condition_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload);
+
+bool lttng_condition_is_equal(const struct lttng_condition *a,
+ const struct lttng_condition *b);
+
+enum lttng_error_code lttng_condition_mi_serialize(
+ const struct lttng_trigger *trigger,
+ const struct lttng_condition *condition,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
+const char *lttng_condition_type_str(enum lttng_condition_type type);
+
+#endif /* LTTNG_CONDITION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVALUATION_INTERNAL_H
-#define LTTNG_EVALUATION_INTERNAL_H
-
-#include <lttng/condition/evaluation.h>
-#include <lttng/condition/condition.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-typedef void (*evaluation_destroy_cb)(struct lttng_evaluation *evaluation);
-typedef int (*evaluation_serialize_cb)(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload);
-
-struct lttng_evaluation_comm {
- /* enum lttng_condition_type type */
- int8_t type;
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation {
- enum lttng_condition_type type;
- evaluation_serialize_cb serialize;
- evaluation_destroy_cb destroy;
-};
-
-void lttng_evaluation_init(struct lttng_evaluation *evaluation,
- enum lttng_condition_type type);
-
-ssize_t lttng_evaluation_create_from_payload(
- const struct lttng_condition *condition,
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload);
-
-#endif /* LTTNG_EVALUATION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVALUATION_INTERNAL_H
+#define LTTNG_EVALUATION_INTERNAL_H
+
+#include <lttng/condition/evaluation.h>
+#include <lttng/condition/condition.h>
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+typedef void (*evaluation_destroy_cb)(struct lttng_evaluation *evaluation);
+typedef int (*evaluation_serialize_cb)(
+ const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload);
+
+struct lttng_evaluation_comm {
+ /* enum lttng_condition_type type */
+ int8_t type;
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation {
+ enum lttng_condition_type type;
+ evaluation_serialize_cb serialize;
+ evaluation_destroy_cb destroy;
+};
+
+void lttng_evaluation_init(struct lttng_evaluation *evaluation,
+ enum lttng_condition_type type);
+
+ssize_t lttng_evaluation_create_from_payload(
+ const struct lttng_condition *condition,
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload);
+
+#endif /* LTTNG_EVALUATION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
-#define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
-
-#include <lttng/condition/condition-internal.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <common/dynamic-array.h>
-#include <lttng/event-field-value.h>
-
-struct lttng_capture_descriptor {
- struct lttng_event_expr *event_expression;
- struct lttng_bytecode *bytecode;
-};
-
-struct lttng_condition_event_rule_matches {
- struct lttng_condition parent;
- struct lttng_event_rule *rule;
-
- /*
- * Internal use only.
- * Error accounting counter index.
- */
- LTTNG_OPTIONAL(uint64_t) error_counter_index;
-
- /* Array of `struct lttng_capture_descriptor *`. */
- struct lttng_dynamic_pointer_array capture_descriptors;
-};
-
-struct lttng_evaluation_event_rule_matches {
- struct lttng_evaluation parent;
-
- /* MessagePack-encoded captured event field values. */
- struct lttng_dynamic_buffer capture_payload;
-
- /*
- * The content of this array event field value is the decoded
- * version of `capture_payload` above.
- *
- * This is a cache: it's not serialized/deserialized in
- * communications from/to the library and the session daemon.
- */
- struct lttng_event_field_value *captured_values;
-};
-
-ssize_t lttng_condition_event_rule_matches_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-enum lttng_condition_status
-lttng_condition_event_rule_matches_borrow_rule_mutable(
- const struct lttng_condition *condition,
- struct lttng_event_rule **rule);
-
-void lttng_condition_event_rule_matches_set_error_counter_index(
- struct lttng_condition *condition,
- uint64_t error_counter_index);
-
-uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
- const struct lttng_condition *condition);
-
-struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
- const struct lttng_condition_event_rule_matches *condition,
- const char *capture_payload,
- size_t capture_payload_size,
- bool decode_capture_payload);
-
-ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
- const struct lttng_condition_event_rule_matches *condition,
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation);
-
-enum lttng_error_code
-lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
- struct lttng_condition *condition);
-
-const struct lttng_bytecode *
-lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
- const struct lttng_condition *condition, unsigned int index);
-
-#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
+#define LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H
+
+#include <lttng/condition/condition-internal.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <common/dynamic-array.hpp>
+#include <lttng/event-field-value.h>
+
+struct lttng_capture_descriptor {
+ struct lttng_event_expr *event_expression;
+ struct lttng_bytecode *bytecode;
+};
+
+struct lttng_condition_event_rule_matches {
+ struct lttng_condition parent;
+ struct lttng_event_rule *rule;
+
+ /*
+ * Internal use only.
+ * Error accounting counter index.
+ */
+ LTTNG_OPTIONAL(uint64_t) error_counter_index;
+
+ /* Array of `struct lttng_capture_descriptor *`. */
+ struct lttng_dynamic_pointer_array capture_descriptors;
+};
+
+struct lttng_evaluation_event_rule_matches {
+ struct lttng_evaluation parent;
+
+ /* MessagePack-encoded captured event field values. */
+ struct lttng_dynamic_buffer capture_payload;
+
+ /*
+ * The content of this array event field value is the decoded
+ * version of `capture_payload` above.
+ *
+ * This is a cache: it's not serialized/deserialized in
+ * communications from/to the library and the session daemon.
+ */
+ struct lttng_event_field_value *captured_values;
+};
+
+ssize_t lttng_condition_event_rule_matches_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+enum lttng_condition_status
+lttng_condition_event_rule_matches_borrow_rule_mutable(
+ const struct lttng_condition *condition,
+ struct lttng_event_rule **rule);
+
+void lttng_condition_event_rule_matches_set_error_counter_index(
+ struct lttng_condition *condition,
+ uint64_t error_counter_index);
+
+uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
+ const struct lttng_condition *condition);
+
+struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
+ const struct lttng_condition_event_rule_matches *condition,
+ const char *capture_payload,
+ size_t capture_payload_size,
+ bool decode_capture_payload);
+
+ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
+ const struct lttng_condition_event_rule_matches *condition,
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation);
+
+enum lttng_error_code
+lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
+ struct lttng_condition *condition);
+
+const struct lttng_bytecode *
+lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
+ const struct lttng_condition *condition, unsigned int index);
+
+#endif /* LTTNG_CONDITION_EVENT_RULE_MATCHES_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
-#define LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
-
-#include <lttng/condition/session-consumed-size.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-struct lttng_condition_session_consumed_size {
- struct lttng_condition parent;
- struct {
- bool set;
- uint64_t value;
- } consumed_threshold_bytes;
- char *session_name;
-};
-
-struct lttng_condition_session_consumed_size_comm {
- uint64_t consumed_threshold_bytes;
- /* Length includes the trailing \0. */
- uint32_t session_name_len;
- char session_name[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_session_consumed_size {
- struct lttng_evaluation parent;
- uint64_t session_consumed;
-};
-
-struct lttng_evaluation_session_consumed_size_comm {
- uint64_t session_consumed;
-} LTTNG_PACKED;
-
-struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(
- uint64_t consumed);
-
-ssize_t lttng_condition_session_consumed_size_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-ssize_t lttng_evaluation_session_consumed_size_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
+#define LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H
+
+#include <lttng/condition/session-consumed-size.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+struct lttng_condition_session_consumed_size {
+ struct lttng_condition parent;
+ struct {
+ bool set;
+ uint64_t value;
+ } consumed_threshold_bytes;
+ char *session_name;
+};
+
+struct lttng_condition_session_consumed_size_comm {
+ uint64_t consumed_threshold_bytes;
+ /* Length includes the trailing \0. */
+ uint32_t session_name_len;
+ char session_name[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_session_consumed_size {
+ struct lttng_evaluation parent;
+ uint64_t session_consumed;
+};
+
+struct lttng_evaluation_session_consumed_size_comm {
+ uint64_t session_consumed;
+} LTTNG_PACKED;
+
+struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(
+ uint64_t consumed);
+
+ssize_t lttng_condition_session_consumed_size_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+ssize_t lttng_evaluation_session_consumed_size_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_SESSION_CONSUMED_SIZE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
-#define LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
-
-#include <lttng/condition/session-rotation.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include "common/buffer-view.h"
-#include <lttng/location.h>
-#include <common/macros.h>
-
-struct lttng_condition_session_rotation {
- struct lttng_condition parent;
- char *session_name;
-};
-
-struct lttng_condition_session_rotation_comm {
- /* Length includes the trailing \0. */
- uint32_t session_name_len;
- char session_name[];
-} LTTNG_PACKED;
-
-struct lttng_evaluation_session_rotation {
- struct lttng_evaluation parent;
- uint64_t id;
- struct lttng_trace_archive_location *location;
-};
-
-struct lttng_evaluation_session_rotation_comm {
- uint64_t id;
- uint8_t has_location;
-} LTTNG_PACKED;
-
-ssize_t lttng_condition_session_rotation_ongoing_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-ssize_t lttng_condition_session_rotation_completed_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition);
-
-struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(
- uint64_t id);
-
-/* Ownership of location is transferred to the evaluation. */
-struct lttng_evaluation *lttng_evaluation_session_rotation_completed_create(
- uint64_t id,
- struct lttng_trace_archive_location *location);
-
-ssize_t lttng_evaluation_session_rotation_ongoing_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-ssize_t lttng_evaluation_session_rotation_completed_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation);
-
-#endif /* LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
+#define LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H
+
+#include <lttng/condition/session-rotation.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include "common/buffer-view.hpp"
+#include <lttng/location.h>
+#include <common/macros.hpp>
+
+struct lttng_condition_session_rotation {
+ struct lttng_condition parent;
+ char *session_name;
+};
+
+struct lttng_condition_session_rotation_comm {
+ /* Length includes the trailing \0. */
+ uint32_t session_name_len;
+ char session_name[];
+} LTTNG_PACKED;
+
+struct lttng_evaluation_session_rotation {
+ struct lttng_evaluation parent;
+ uint64_t id;
+ struct lttng_trace_archive_location *location;
+};
+
+struct lttng_evaluation_session_rotation_comm {
+ uint64_t id;
+ uint8_t has_location;
+} LTTNG_PACKED;
+
+ssize_t lttng_condition_session_rotation_ongoing_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+ssize_t lttng_condition_session_rotation_completed_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_condition **condition);
+
+struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(
+ uint64_t id);
+
+/* Ownership of location is transferred to the evaluation. */
+struct lttng_evaluation *lttng_evaluation_session_rotation_completed_create(
+ uint64_t id,
+ struct lttng_trace_archive_location *location);
+
+ssize_t lttng_evaluation_session_rotation_ongoing_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+ssize_t lttng_evaluation_session_rotation_completed_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation);
+
+#endif /* LTTNG_CONDITION_SESSION_ROTATION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DOMAIN_INTERNAL_H
-#define LTTNG_DOMAIN_INTERNAL_H
-
-#include "lttng/domain.h"
-#include "common/macros.h"
-
-const char *lttng_domain_type_str(enum lttng_domain_type domain_type);
-
-#endif /* LTTNG_DOMAIN_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DOMAIN_INTERNAL_H
+#define LTTNG_DOMAIN_INTERNAL_H
+
+#include "lttng/domain.h"
+#include "common/macros.hpp"
+
+const char *lttng_domain_type_str(enum lttng_domain_type domain_type);
+
+#endif /* LTTNG_DOMAIN_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ENDPOINT_INTERNAL_H
-#define LTTNG_ENDPOINT_INTERNAL_H
-
-#include <lttng/endpoint.h>
-#include <common/macros.h>
-
-enum lttng_endpoint_type {
- LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION = 0,
- LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_COMMAND = 1,
-};
-
-struct lttng_endpoint {
- enum lttng_endpoint_type type;
-};
-
-#endif /* LTTNG_ENDPOINT_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ENDPOINT_INTERNAL_H
+#define LTTNG_ENDPOINT_INTERNAL_H
+
+#include <lttng/endpoint.h>
+#include <common/macros.hpp>
+
+enum lttng_endpoint_type {
+ LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION = 0,
+ LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_COMMAND = 1,
+};
+
+struct lttng_endpoint {
+ enum lttng_endpoint_type type;
+};
+
+#endif /* LTTNG_ENDPOINT_INTERNAL_H */
+++ /dev/null
-/*
- * error-query-internal.h
- *
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ERROR_QUERY_INTERNAL_H
-#define LTTNG_ERROR_QUERY_INTERNAL_H
-
-#include <lttng/lttng.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-
-struct mi_writer;
-
-enum lttng_error_query_target_type {
- LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER,
- LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION,
- LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION,
-};
-
-enum lttng_error_query_target_type lttng_error_query_get_target_type(
- const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
- const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_condition_borrow_target(
- const struct lttng_error_query *query);
-
-const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
- const struct lttng_error_query *query);
-
-struct lttng_action *lttng_error_query_action_borrow_action_target(
- const struct lttng_error_query *query,
- struct lttng_trigger *trigger);
-
-int lttng_error_query_serialize(const struct lttng_error_query *query,
- struct lttng_payload *payload);
-
-ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view,
- struct lttng_error_query **query);
-
-int lttng_error_query_result_serialize(
- const struct lttng_error_query_result *result,
- struct lttng_payload *payload);
-
-ssize_t lttng_error_query_result_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_error_query_result **result);
-
-int lttng_error_query_results_serialize(
- const struct lttng_error_query_results *results,
- struct lttng_payload *payload);
-
-ssize_t lttng_error_query_results_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_error_query_results **results);
-
-struct lttng_error_query_result *
-lttng_error_query_result_counter_create(
- const char *name, const char *description, uint64_t value);
-
-void lttng_error_query_result_destroy(struct lttng_error_query_result *result);
-
-struct lttng_error_query_results *lttng_error_query_results_create(void);
-
-/* Ownership of `result` is transferred on success. */
-int lttng_error_query_results_add_result(
- struct lttng_error_query_results *results,
- struct lttng_error_query_result *result);
-
-enum lttng_error_code lttng_error_query_results_mi_serialize(
- const struct lttng_error_query_results *results,
- struct mi_writer *writer);
-
-#endif /* LTTNG_ERROR_QUERY_INTERNAL_H */
--- /dev/null
+/*
+ * error-query-internal.h
+ *
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ERROR_QUERY_INTERNAL_H
+#define LTTNG_ERROR_QUERY_INTERNAL_H
+
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+
+struct mi_writer;
+
+enum lttng_error_query_target_type {
+ LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER,
+ LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION,
+ LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION,
+};
+
+enum lttng_error_query_target_type lttng_error_query_get_target_type(
+ const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
+ const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_condition_borrow_target(
+ const struct lttng_error_query *query);
+
+const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
+ const struct lttng_error_query *query);
+
+struct lttng_action *lttng_error_query_action_borrow_action_target(
+ const struct lttng_error_query *query,
+ struct lttng_trigger *trigger);
+
+int lttng_error_query_serialize(const struct lttng_error_query *query,
+ struct lttng_payload *payload);
+
+ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_error_query **query);
+
+int lttng_error_query_result_serialize(
+ const struct lttng_error_query_result *result,
+ struct lttng_payload *payload);
+
+ssize_t lttng_error_query_result_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_error_query_result **result);
+
+int lttng_error_query_results_serialize(
+ const struct lttng_error_query_results *results,
+ struct lttng_payload *payload);
+
+ssize_t lttng_error_query_results_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_error_query_results **results);
+
+struct lttng_error_query_result *
+lttng_error_query_result_counter_create(
+ const char *name, const char *description, uint64_t value);
+
+void lttng_error_query_result_destroy(struct lttng_error_query_result *result);
+
+struct lttng_error_query_results *lttng_error_query_results_create(void);
+
+/* Ownership of `result` is transferred on success. */
+int lttng_error_query_results_add_result(
+ struct lttng_error_query_results *results,
+ struct lttng_error_query_result *result);
+
+enum lttng_error_code lttng_error_query_results_mi_serialize(
+ const struct lttng_error_query_results *results,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_ERROR_QUERY_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_EXPR_INTERNAL_H
-#define LTTNG_EVENT_EXPR_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/event-expr.h>
-
-struct lttng_bytecode;
-struct mi_writer;
-
-struct lttng_event_expr {
- enum lttng_event_expr_type type;
-};
-
-/*
- * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD` and
- * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`.
- */
-struct lttng_event_expr_field {
- struct lttng_event_expr parent;
- char *name;
-};
-
-/* `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD` */
-struct lttng_event_expr_app_specific_context_field {
- struct lttng_event_expr parent;
- char *provider_name;
- char *type_name;
-};
-
-/* `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT` */
-struct lttng_event_expr_array_field_element {
- struct lttng_event_expr parent;
-
- /* Owned by this */
- struct lttng_event_expr *array_field_expr;
-
- unsigned int index;
-};
-
-/*
- * Returns whether or not `expr` is an l-value (locator value).
- */
-static inline
-bool lttng_event_expr_is_lvalue(const struct lttng_event_expr *expr)
-{
- LTTNG_ASSERT(expr);
- return expr->type == LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD ||
- expr->type == LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD ||
- expr->type == LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD ||
- expr->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT;
-}
-
-int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
- struct lttng_bytecode **bytecode_out);
-
-enum lttng_error_code lttng_event_expr_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer);
-
-#endif /* LTTNG_EVENT_EXPR_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_EXPR_INTERNAL_H
+#define LTTNG_EVENT_EXPR_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <lttng/event-expr.h>
+
+struct lttng_bytecode;
+struct mi_writer;
+
+struct lttng_event_expr {
+ enum lttng_event_expr_type type;
+};
+
+/*
+ * `LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD` and
+ * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD`.
+ */
+struct lttng_event_expr_field {
+ struct lttng_event_expr parent;
+ char *name;
+};
+
+/* `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD` */
+struct lttng_event_expr_app_specific_context_field {
+ struct lttng_event_expr parent;
+ char *provider_name;
+ char *type_name;
+};
+
+/* `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT` */
+struct lttng_event_expr_array_field_element {
+ struct lttng_event_expr parent;
+
+ /* Owned by this */
+ struct lttng_event_expr *array_field_expr;
+
+ unsigned int index;
+};
+
+/*
+ * Returns whether or not `expr` is an l-value (locator value).
+ */
+static inline
+bool lttng_event_expr_is_lvalue(const struct lttng_event_expr *expr)
+{
+ LTTNG_ASSERT(expr);
+ return expr->type == LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD ||
+ expr->type == LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD ||
+ expr->type == LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD ||
+ expr->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT;
+}
+
+int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
+ struct lttng_bytecode **bytecode_out);
+
+enum lttng_error_code lttng_event_expr_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_EVENT_EXPR_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
-#define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
-
-#include <stdint.h>
-#include <lttng/event-field-value.h>
-#include <common/dynamic-array.h>
-
-struct lttng_event_field_value {
- enum lttng_event_field_value_type type;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
- */
-struct lttng_event_field_value_uint {
- struct lttng_event_field_value parent;
- uint64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
- */
-struct lttng_event_field_value_int {
- struct lttng_event_field_value parent;
- int64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
- */
-struct lttng_event_field_value_enum {
- struct lttng_event_field_value parent;
-
- /*
- * Array of `char *` (owned by this).
- */
- struct lttng_dynamic_pointer_array labels;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
- */
-struct lttng_event_field_value_enum_uint {
- struct lttng_event_field_value_enum parent;
- uint64_t val;
-};
-
-/*
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- */
-struct lttng_event_field_value_enum_int {
- struct lttng_event_field_value_enum parent;
- int64_t val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
-struct lttng_event_field_value_real {
- struct lttng_event_field_value parent;
- double val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
-struct lttng_event_field_value_string {
- struct lttng_event_field_value parent;
-
- /* Owned by this */
- char *val;
-};
-
-/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
-struct lttng_event_field_value_array {
- struct lttng_event_field_value parent;
-
- /*
- * Array of `struct lttng_event_field_value *` (owned by this).
- *
- * A `NULL` element means it's unavailable
- * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
- */
- struct lttng_dynamic_pointer_array elems;
-};
-
-/*
- * This is internal since the session daemon knows nothing about the
- * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
- * manages its own metadata which remains opaque to the rest of the toolchain.
- *
- * Enumerations could be supported for the user space tracer, but it is not the
- * case right now.
- */
-
-/*
- * Sets `*count` to the number of labels of the enumeration event field
- * value `field_val`.
- *
- * Returns:
- *
- * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
- * Success.
- *
- * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
- * * `field_val` is `NULL`.
- * * The type of `field_val` is not
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- * * `count` is `NULL`.
- */
-enum lttng_event_field_value_status
-lttng_event_field_value_enum_get_label_count(
- const struct lttng_event_field_value *field_val,
- unsigned int *count);
-
-/*
- * Returns the label at index `index` of the enumeration event field
- * value `field_val`, or `NULL` if:
- *
- * * `field_val` is `NULL`.
- * * The type of `field_val` is not
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
- * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
- * * `index` is greater than or equal to the label count of `field_val`,
- * as returned by lttng_event_field_value_enum_get_label_count().
- */
-const char *lttng_event_field_value_enum_get_label_at_index(
- const struct lttng_event_field_value *field_val,
- unsigned int index);
-
-struct lttng_event_field_value *lttng_event_field_value_uint_create(
- uint64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_int_create(
- int64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
- uint64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
- int64_t val);
-
-struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
-
-struct lttng_event_field_value *lttng_event_field_value_string_create(
- const char *val);
-
-struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
- const char *val, size_t size);
-
-struct lttng_event_field_value *lttng_event_field_value_array_create(void);
-
-int lttng_event_field_value_enum_append_label(
- struct lttng_event_field_value *field_val, const char *label);
-
-int lttng_event_field_value_enum_append_label_with_size(
- struct lttng_event_field_value *field_val, const char *label,
- size_t size);
-
-int lttng_event_field_value_array_append(
- struct lttng_event_field_value *array_field_val,
- struct lttng_event_field_value *field_val);
-
-int lttng_event_field_value_array_append_unavailable(
- struct lttng_event_field_value *array_field_val);
-
-void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
-
-#endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
+#define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
+
+#include <stdint.h>
+#include <lttng/event-field-value.h>
+#include <common/dynamic-array.hpp>
+
+struct lttng_event_field_value {
+ enum lttng_event_field_value_type type;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
+ */
+struct lttng_event_field_value_uint {
+ struct lttng_event_field_value parent;
+ uint64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
+ */
+struct lttng_event_field_value_int {
+ struct lttng_event_field_value parent;
+ int64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
+ */
+struct lttng_event_field_value_enum {
+ struct lttng_event_field_value parent;
+
+ /*
+ * Array of `char *` (owned by this).
+ */
+ struct lttng_dynamic_pointer_array labels;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
+ */
+struct lttng_event_field_value_enum_uint {
+ struct lttng_event_field_value_enum parent;
+ uint64_t val;
+};
+
+/*
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ */
+struct lttng_event_field_value_enum_int {
+ struct lttng_event_field_value_enum parent;
+ int64_t val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
+struct lttng_event_field_value_real {
+ struct lttng_event_field_value parent;
+ double val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
+struct lttng_event_field_value_string {
+ struct lttng_event_field_value parent;
+
+ /* Owned by this */
+ char *val;
+};
+
+/* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
+struct lttng_event_field_value_array {
+ struct lttng_event_field_value parent;
+
+ /*
+ * Array of `struct lttng_event_field_value *` (owned by this).
+ *
+ * A `NULL` element means it's unavailable
+ * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
+ */
+ struct lttng_dynamic_pointer_array elems;
+};
+
+/*
+ * This is internal since the session daemon knows nothing about the
+ * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
+ * manages its own metadata which remains opaque to the rest of the toolchain.
+ *
+ * Enumerations could be supported for the user space tracer, but it is not the
+ * case right now.
+ */
+
+/*
+ * Sets `*count` to the number of labels of the enumeration event field
+ * value `field_val`.
+ *
+ * Returns:
+ *
+ * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
+ * Success.
+ *
+ * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
+ * * `field_val` is `NULL`.
+ * * The type of `field_val` is not
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ * * `count` is `NULL`.
+ */
+enum lttng_event_field_value_status
+lttng_event_field_value_enum_get_label_count(
+ const struct lttng_event_field_value *field_val,
+ unsigned int *count);
+
+/*
+ * Returns the label at index `index` of the enumeration event field
+ * value `field_val`, or `NULL` if:
+ *
+ * * `field_val` is `NULL`.
+ * * The type of `field_val` is not
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
+ * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
+ * * `index` is greater than or equal to the label count of `field_val`,
+ * as returned by lttng_event_field_value_enum_get_label_count().
+ */
+const char *lttng_event_field_value_enum_get_label_at_index(
+ const struct lttng_event_field_value *field_val,
+ unsigned int index);
+
+struct lttng_event_field_value *lttng_event_field_value_uint_create(
+ uint64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_int_create(
+ int64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
+ uint64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
+ int64_t val);
+
+struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
+
+struct lttng_event_field_value *lttng_event_field_value_string_create(
+ const char *val);
+
+struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
+ const char *val, size_t size);
+
+struct lttng_event_field_value *lttng_event_field_value_array_create(void);
+
+int lttng_event_field_value_enum_append_label(
+ struct lttng_event_field_value *field_val, const char *label);
+
+int lttng_event_field_value_enum_append_label_with_size(
+ struct lttng_event_field_value *field_val, const char *label,
+ size_t size);
+
+int lttng_event_field_value_array_append(
+ struct lttng_event_field_value *array_field_val,
+ struct lttng_event_field_value *field_val);
+
+int lttng_event_field_value_array_append_unavailable(
+ struct lttng_event_field_value *array_field_val);
+
+void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
+
+#endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
+++ /dev/null
-/*
- * event-internal.h
- *
- * Linux Trace Toolkit Control Library
- *
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_INTERNAL_H
-#define LTTNG_EVENT_INTERNAL_H
-
-#include <common/macros.h>
-#include <lttng/event.h>
-#include <lttng/lttng-error.h>
-
-struct lttng_event_exclusion;
-struct lttng_userspace_probe_location;
-struct lttng_dynamic_buffer;
-struct lttng_buffer_view;
-
-struct lttng_event_comm {
- int8_t event_type;
- int8_t loglevel_type;
- int32_t loglevel;
- int8_t enabled;
- int32_t pid;
- uint32_t flags;
-
- /* Payload. */
- /* Includes terminator `\0`. */
- uint32_t name_len;
- uint32_t exclusion_count;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- uint32_t bytecode_len;
-
- /* Type specific payload. */
- uint32_t userspace_probe_location_len;
- uint32_t lttng_event_probe_attr_len;
- uint32_t lttng_event_function_attr_len;
-
- /*
- * Contain:
- * - name [name_len],
- * - exclusions if any
- * - char filter_expression[filter_expression_len],
- * - unsigned char filter_bytecode[bytecode_len],
- * - userspace probe location [userspace_probe_location_len],
- * - probe or ftrace based on event type.
- */
-
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_exclusion_comm {
- /* Includes terminator `\0`. */
- uint32_t len;
- char payload [];
-} LTTNG_PACKED;
-
-struct lttng_event_probe_attr_comm {
- uint64_t addr;
- uint64_t offset;
- /* Includes terminator `\0`. */
- uint32_t symbol_name_len;
-
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_function_attr_comm {
- /* Includes terminator `\0`. */
- uint32_t symbol_name_len;
-
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_comm {
- uint32_t type;
- /*
- * Depending on the type.
- * For:
- * - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
- *
- * -> struct lttng_event_context_app_comm
- *
- * For
- * - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
- * - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
- * - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
- *
- * -> struct lttng_event_context_perf_counter_comm
- *
- * Other type -> no payload.
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_perf_counter_comm {
- uint32_t type;
- uint64_t config;
- /* Includes terminator `\0`. */
- uint32_t name_len;
- /*
- * char name [name_len]
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_context_app_comm {
- /* Includes terminator `\0`. */
- uint32_t provider_name_len;
- /* Includes terminator `\0`. */
- uint32_t ctx_name_len;
- /*
- * provider name [provider_name_len]
- * ctx name [ctx_name_len]
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_field_comm {
- uint8_t type;
- uint8_t nowrite;
- /* Includes terminator `\0`. */
- uint32_t name_len;
- uint32_t event_len;
-
- /*
- * - name [name_len]
- * - lttng_event object
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_event_extended {
- /*
- * exclusions and filter_expression are only set when the lttng_event
- * was created/allocated by a list operation. These two elements must
- * not be free'd as they are part of the same contiguous buffer that
- * contains all events returned by the listing.
- */
- char *filter_expression;
- struct {
- unsigned int count;
- /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
- char *strings;
- } exclusions;
- struct lttng_userspace_probe_location *probe_location;
-};
-
-struct lttng_event *lttng_event_copy(const struct lttng_event *event);
-
-ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
- struct lttng_event **out_event,
- struct lttng_event_exclusion **out_exclusion,
- char **out_filter_expression,
- struct lttng_bytecode **out_bytecode);
-
-int lttng_event_serialize(const struct lttng_event *event,
- unsigned int exclusion_count,
- char **exclusion_list,
- char *filter_expression,
- size_t bytecode_len,
- struct lttng_bytecode *bytecode,
- struct lttng_payload *payload);
-
-ssize_t lttng_event_context_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_context **event_ctx);
-
-int lttng_event_context_serialize(struct lttng_event_context *context,
- struct lttng_payload *payload);
-
-void lttng_event_context_destroy(struct lttng_event_context *context);
-
-enum lttng_error_code lttng_events_create_and_flatten_from_payload(
- struct lttng_payload_view *view,
- unsigned int count,
- struct lttng_event **events);
-
-ssize_t lttng_event_field_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_field **field);
-
-int lttng_event_field_serialize(const struct lttng_event_field *field,
- struct lttng_payload *payload);
-
-enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
- struct lttng_payload_view *view,
- unsigned int count,
- struct lttng_event_field **fields);
-
-#endif /* LTTNG_EVENT_INTERNAL_H */
--- /dev/null
+/*
+ * event-internal.h
+ *
+ * Linux Trace Toolkit Control Library
+ *
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_INTERNAL_H
+#define LTTNG_EVENT_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <lttng/event.h>
+#include <lttng/lttng-error.h>
+
+struct lttng_event_exclusion;
+struct lttng_userspace_probe_location;
+struct lttng_dynamic_buffer;
+struct lttng_buffer_view;
+
+struct lttng_event_comm {
+ int8_t event_type;
+ int8_t loglevel_type;
+ int32_t loglevel;
+ int8_t enabled;
+ int32_t pid;
+ uint32_t flags;
+
+ /* Payload. */
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ uint32_t exclusion_count;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ uint32_t bytecode_len;
+
+ /* Type specific payload. */
+ uint32_t userspace_probe_location_len;
+ uint32_t lttng_event_probe_attr_len;
+ uint32_t lttng_event_function_attr_len;
+
+ /*
+ * Contain:
+ * - name [name_len],
+ * - exclusions if any
+ * - char filter_expression[filter_expression_len],
+ * - unsigned char filter_bytecode[bytecode_len],
+ * - userspace probe location [userspace_probe_location_len],
+ * - probe or ftrace based on event type.
+ */
+
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_exclusion_comm {
+ /* Includes terminator `\0`. */
+ uint32_t len;
+ char payload [];
+} LTTNG_PACKED;
+
+struct lttng_event_probe_attr_comm {
+ uint64_t addr;
+ uint64_t offset;
+ /* Includes terminator `\0`. */
+ uint32_t symbol_name_len;
+
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_function_attr_comm {
+ /* Includes terminator `\0`. */
+ uint32_t symbol_name_len;
+
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_comm {
+ uint32_t type;
+ /*
+ * Depending on the type.
+ * For:
+ * - LTTNG_EVENT_CONTEXT_APP_CONTEXT.
+ *
+ * -> struct lttng_event_context_app_comm
+ *
+ * For
+ * - LTTNG_EVENT_CONTEXT_PERF_COUNTER,
+ * - LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER,
+ * - LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER.
+ *
+ * -> struct lttng_event_context_perf_counter_comm
+ *
+ * Other type -> no payload.
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_perf_counter_comm {
+ uint32_t type;
+ uint64_t config;
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ /*
+ * char name [name_len]
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_context_app_comm {
+ /* Includes terminator `\0`. */
+ uint32_t provider_name_len;
+ /* Includes terminator `\0`. */
+ uint32_t ctx_name_len;
+ /*
+ * provider name [provider_name_len]
+ * ctx name [ctx_name_len]
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_field_comm {
+ uint8_t type;
+ uint8_t nowrite;
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ uint32_t event_len;
+
+ /*
+ * - name [name_len]
+ * - lttng_event object
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_event_extended {
+ /*
+ * exclusions and filter_expression are only set when the lttng_event
+ * was created/allocated by a list operation. These two elements must
+ * not be free'd as they are part of the same contiguous buffer that
+ * contains all events returned by the listing.
+ */
+ char *filter_expression;
+ struct {
+ unsigned int count;
+ /* Array of strings of fixed LTTNG_SYMBOL_NAME_LEN length. */
+ char *strings;
+ } exclusions;
+ struct lttng_userspace_probe_location *probe_location;
+};
+
+struct lttng_event *lttng_event_copy(const struct lttng_event *event);
+
+ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event **out_event,
+ struct lttng_event_exclusion **out_exclusion,
+ char **out_filter_expression,
+ struct lttng_bytecode **out_bytecode);
+
+int lttng_event_serialize(const struct lttng_event *event,
+ unsigned int exclusion_count,
+ char **exclusion_list,
+ char *filter_expression,
+ size_t bytecode_len,
+ struct lttng_bytecode *bytecode,
+ struct lttng_payload *payload);
+
+ssize_t lttng_event_context_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_context **event_ctx);
+
+int lttng_event_context_serialize(struct lttng_event_context *context,
+ struct lttng_payload *payload);
+
+void lttng_event_context_destroy(struct lttng_event_context *context);
+
+enum lttng_error_code lttng_events_create_and_flatten_from_payload(
+ struct lttng_payload_view *view,
+ unsigned int count,
+ struct lttng_event **events);
+
+ssize_t lttng_event_field_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_field **field);
+
+int lttng_event_field_serialize(const struct lttng_event_field *field,
+ struct lttng_payload *payload);
+
+enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
+ struct lttng_payload_view *view,
+ unsigned int count,
+ struct lttng_event_field **fields);
+
+#endif /* LTTNG_EVENT_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_INTERNAL_H
-#define LTTNG_EVENT_RULE_INTERNAL_H
-
-#include <common/macros.h>
-#include <common/credentials.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/domain.h>
-#include <lttng/event.h>
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct mi_writer;
-
-enum lttng_event_rule_generate_exclusions_status {
- LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
- LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
- LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
- LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
-};
-
-typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
-typedef bool (*event_rule_validate_cb)(
- const struct lttng_event_rule *event_rule);
-typedef int (*event_rule_serialize_cb)(
- const struct lttng_event_rule *event_rule,
- struct lttng_payload *payload);
-typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
- const struct lttng_event_rule *b);
-typedef ssize_t (*event_rule_create_from_payload_cb)(
- struct lttng_payload_view *view,
- struct lttng_event_rule **event_rule);
-typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
- struct lttng_event_rule *event_rule,
- const struct lttng_credentials *creds);
-typedef const char *(*event_rule_get_filter_cb)(
- const struct lttng_event_rule *event_rule);
-typedef const struct lttng_bytecode *(
- *event_rule_get_filter_bytecode_cb)(
- const struct lttng_event_rule *event_rule);
-typedef enum lttng_event_rule_generate_exclusions_status (
- *event_rule_generate_exclusions_cb)(
- const struct lttng_event_rule *event_rule,
- struct lttng_event_exclusion **exclusions);
-typedef unsigned long (*event_rule_hash_cb)(
- const struct lttng_event_rule *event_rule);
-typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
- const struct lttng_event_rule *event_rule);
-typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
- const struct lttng_event_rule *event_rule,
- struct mi_writer *writer);
-
-struct lttng_event_rule {
- struct urcu_ref ref;
- enum lttng_event_rule_type type;
- event_rule_validate_cb validate;
- event_rule_serialize_cb serialize;
- event_rule_equal_cb equal;
- event_rule_destroy_cb destroy;
- event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
- event_rule_get_filter_cb get_filter;
- event_rule_get_filter_bytecode_cb get_filter_bytecode;
- event_rule_generate_exclusions_cb generate_exclusions;
- event_rule_hash_cb hash;
- event_rule_generate_lttng_event_cb generate_lttng_event;
- event_rule_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_event_rule_comm {
- /* enum lttng_event_rule_type */
- int8_t event_rule_type;
- char payload[];
-};
-
-void lttng_event_rule_init(struct lttng_event_rule *event_rule,
- enum lttng_event_rule_type type);
-
-bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
-
-ssize_t lttng_event_rule_create_from_payload(
- struct lttng_payload_view *payload,
- struct lttng_event_rule **event_rule);
-
-int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
- struct lttng_payload *payload);
-
-bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
- const struct lttng_event_rule *b);
-
-bool lttng_event_rule_get(struct lttng_event_rule *rule);
-
-void lttng_event_rule_put(struct lttng_event_rule *rule);
-
-enum lttng_domain_type lttng_event_rule_get_domain_type(
- const struct lttng_event_rule *rule);
-
-enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds);
-
-/*
- * If not present/implemented returns NULL.
- * Caller DOES NOT own the returned object.
- */
-const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
-
-/*
- * If not present/implemented returns NULL.
- * Caller DOES NOT own the returned object.
- */
-const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
- const struct lttng_event_rule *rule);
-
-/*
- * If not present/implemented return NULL.
- * Caller OWNS the returned object.
- */
-enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
- struct lttng_event_exclusion **exclusions);
-
-const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
-
-unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
-
-/*
- * This is a compatibility helper allowing us to generate a sessiond-side (not
- * communication) `struct lttng_event` object from an event rule.
- *
- * This effectively bridges older parts of the code using those structures and
- * new event-rule based code.
- *
- * The caller owns the returned object.
- */
-struct lttng_event *lttng_event_rule_generate_lttng_event(
- const struct lttng_event_rule *rule);
-
-/* Test if an event rule targets an agent domain. */
-bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
-
-enum lttng_error_code lttng_event_rule_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer);
-
-#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_INTERNAL_H
+#define LTTNG_EVENT_RULE_INTERNAL_H
+
+#include <common/macros.hpp>
+#include <common/credentials.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/domain.h>
+#include <lttng/event.h>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct mi_writer;
+
+enum lttng_event_rule_generate_exclusions_status {
+ LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
+ LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE,
+ LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_ERROR,
+ LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
+};
+
+typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
+typedef bool (*event_rule_validate_cb)(
+ const struct lttng_event_rule *event_rule);
+typedef int (*event_rule_serialize_cb)(
+ const struct lttng_event_rule *event_rule,
+ struct lttng_payload *payload);
+typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
+ const struct lttng_event_rule *b);
+typedef ssize_t (*event_rule_create_from_payload_cb)(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **event_rule);
+typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
+ struct lttng_event_rule *event_rule,
+ const struct lttng_credentials *creds);
+typedef const char *(*event_rule_get_filter_cb)(
+ const struct lttng_event_rule *event_rule);
+typedef const struct lttng_bytecode *(
+ *event_rule_get_filter_bytecode_cb)(
+ const struct lttng_event_rule *event_rule);
+typedef enum lttng_event_rule_generate_exclusions_status (
+ *event_rule_generate_exclusions_cb)(
+ const struct lttng_event_rule *event_rule,
+ struct lttng_event_exclusion **exclusions);
+typedef unsigned long (*event_rule_hash_cb)(
+ const struct lttng_event_rule *event_rule);
+typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
+ const struct lttng_event_rule *event_rule);
+typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
+ const struct lttng_event_rule *event_rule,
+ struct mi_writer *writer);
+
+struct lttng_event_rule {
+ struct urcu_ref ref;
+ enum lttng_event_rule_type type;
+ event_rule_validate_cb validate;
+ event_rule_serialize_cb serialize;
+ event_rule_equal_cb equal;
+ event_rule_destroy_cb destroy;
+ event_rule_generate_filter_bytecode_cb generate_filter_bytecode;
+ event_rule_get_filter_cb get_filter;
+ event_rule_get_filter_bytecode_cb get_filter_bytecode;
+ event_rule_generate_exclusions_cb generate_exclusions;
+ event_rule_hash_cb hash;
+ event_rule_generate_lttng_event_cb generate_lttng_event;
+ event_rule_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_event_rule_comm {
+ /* enum lttng_event_rule_type */
+ int8_t event_rule_type;
+ char payload[];
+};
+
+void lttng_event_rule_init(struct lttng_event_rule *event_rule,
+ enum lttng_event_rule_type type);
+
+bool lttng_event_rule_validate(const struct lttng_event_rule *event_rule);
+
+ssize_t lttng_event_rule_create_from_payload(
+ struct lttng_payload_view *payload,
+ struct lttng_event_rule **event_rule);
+
+int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
+ struct lttng_payload *payload);
+
+bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
+ const struct lttng_event_rule *b);
+
+bool lttng_event_rule_get(struct lttng_event_rule *rule);
+
+void lttng_event_rule_put(struct lttng_event_rule *rule);
+
+enum lttng_domain_type lttng_event_rule_get_domain_type(
+ const struct lttng_event_rule *rule);
+
+enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
+ struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds);
+
+/*
+ * If not present/implemented returns NULL.
+ * Caller DOES NOT own the returned object.
+ */
+const char *lttng_event_rule_get_filter(const struct lttng_event_rule *rule);
+
+/*
+ * If not present/implemented returns NULL.
+ * Caller DOES NOT own the returned object.
+ */
+const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
+ const struct lttng_event_rule *rule);
+
+/*
+ * If not present/implemented return NULL.
+ * Caller OWNS the returned object.
+ */
+enum lttng_event_rule_generate_exclusions_status
+lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
+ struct lttng_event_exclusion **exclusions);
+
+const char *lttng_event_rule_type_str(enum lttng_event_rule_type type);
+
+unsigned long lttng_event_rule_hash(const struct lttng_event_rule *rule);
+
+/*
+ * This is a compatibility helper allowing us to generate a sessiond-side (not
+ * communication) `struct lttng_event` object from an event rule.
+ *
+ * This effectively bridges older parts of the code using those structures and
+ * new event-rule based code.
+ *
+ * The caller owns the returned object.
+ */
+struct lttng_event *lttng_event_rule_generate_lttng_event(
+ const struct lttng_event_rule *rule);
+
+/* Test if an event rule targets an agent domain. */
+bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
+
+enum lttng_error_code lttng_event_rule_mi_serialize(
+ const struct lttng_event_rule *rule, struct mi_writer *writer);
+
+#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_jul_logging {
- struct lttng_event_rule parent;
-
- /* Name pattern. */
- char *pattern;
-
- /* Filter. */
- char *filter_expression;
-
- /* Log level. */
- struct lttng_log_level_rule *log_level_rule;
-
- /* internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_jul_logging_comm {
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /* enum lttng_log_level_rule_comm + payload if any */
- uint32_t log_level_rule_len;
- /*
- * Payload is composed of, in that order:
- * - pattern (null terminated),
- * - filter expression (null terminated),
- * - log level rule serialized object,
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_jul_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_jul_logging {
+ struct lttng_event_rule parent;
+
+ /* Name pattern. */
+ char *pattern;
+
+ /* Filter. */
+ char *filter_expression;
+
+ /* Log level. */
+ struct lttng_log_level_rule *log_level_rule;
+
+ /* internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_jul_logging_comm {
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /* enum lttng_log_level_rule_comm + payload if any */
+ uint32_t log_level_rule_len;
+ /*
+ * Payload is composed of, in that order:
+ * - pattern (null terminated),
+ * - filter expression (null terminated),
+ * - log level rule serialized object,
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_jul_logging_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_JUL_LOGGING_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-kprobe.h>
-
-struct lttng_event_rule_kernel_kprobe {
- struct lttng_event_rule parent;
- char *name;
- struct lttng_kernel_probe_location *location;
-};
-
-struct lttng_event_rule_kernel_kprobe_comm {
- /* Includes terminator `\0`. */
- uint32_t name_len;
- uint32_t location_len;
- /*
- * Payload is composed of, in that order:
- * - name (null terminated),
- * - kernel probe location object.
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
- struct lttng_payload_view *payload,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-kprobe.h>
+
+struct lttng_event_rule_kernel_kprobe {
+ struct lttng_event_rule parent;
+ char *name;
+ struct lttng_kernel_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_kprobe_comm {
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ uint32_t location_len;
+ /*
+ * Payload is composed of, in that order:
+ * - name (null terminated),
+ * - kernel probe location object.
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
+ struct lttng_payload_view *payload,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_KPROBE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-syscall.h>
-
-struct lttng_event_rule_kernel_syscall {
- struct lttng_event_rule parent;
- enum lttng_event_rule_kernel_syscall_emission_site emission_site;
- char *pattern;
- char *filter_expression;
-
- /* Internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_kernel_syscall_comm {
- uint32_t emission_site;
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /*
- * Payload is composed of, in that order:
- * - Pattern (null terminated),
- * - Filter expression (null terminated).
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_syscall_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-const char *lttng_event_rule_kernel_syscall_emission_site_str(
- enum lttng_event_rule_kernel_syscall_emission_site emission_site);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-syscall.h>
+
+struct lttng_event_rule_kernel_syscall {
+ struct lttng_event_rule parent;
+ enum lttng_event_rule_kernel_syscall_emission_site emission_site;
+ char *pattern;
+ char *filter_expression;
+
+ /* Internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_kernel_syscall_comm {
+ uint32_t emission_site;
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /*
+ * Payload is composed of, in that order:
+ * - Pattern (null terminated),
+ * - Filter expression (null terminated).
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_syscall_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+const char *lttng_event_rule_kernel_syscall_emission_site_str(
+ enum lttng_event_rule_kernel_syscall_emission_site emission_site);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_SYSCALL_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event.h>
-
-struct lttng_event_rule_kernel_tracepoint {
- struct lttng_event_rule parent;
-
- /* Name pattern. */
- char *pattern;
-
- /* Filter. */
- char *filter_expression;
-
- /* internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_kernel_tracepoint_comm {
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /*
- * Payload is composed of, in that order:
- * - pattern (null terminated),
- * - filter expression (null terminated),
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint.h>
+#include <lttng/event.h>
+
+struct lttng_event_rule_kernel_tracepoint {
+ struct lttng_event_rule parent;
+
+ /* Name pattern. */
+ char *pattern;
+
+ /* Filter. */
+ char *filter_expression;
+
+ /* internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_kernel_tracepoint_comm {
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /*
+ * Payload is composed of, in that order:
+ * - pattern (null terminated),
+ * - filter expression (null terminated),
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_tracepoint_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_TRACEPOINT_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
-#define LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe.h>
-
-struct lttng_event_rule_kernel_uprobe {
- struct lttng_event_rule parent;
- char *name;
- struct lttng_userspace_probe_location *location;
-};
-
-struct lttng_event_rule_kernel_uprobe_comm {
- /* Includes terminator `\0`. */
- uint32_t name_len;
- /* Includes terminator `\0`. */
- uint32_t location_len;
- /*
- * Payload is composed of, in that order:
- * - name (null terminated),
- * - user space probe location object.
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-struct lttng_userspace_probe_location *
-lttng_event_rule_kernel_uprobe_get_location_mutable(
- const struct lttng_event_rule *rule);
-
-#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+#define LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe.h>
+
+struct lttng_event_rule_kernel_uprobe {
+ struct lttng_event_rule parent;
+ char *name;
+ struct lttng_userspace_probe_location *location;
+};
+
+struct lttng_event_rule_kernel_uprobe_comm {
+ /* Includes terminator `\0`. */
+ uint32_t name_len;
+ /* Includes terminator `\0`. */
+ uint32_t location_len;
+ /*
+ * Payload is composed of, in that order:
+ * - name (null terminated),
+ * - user space probe location object.
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+struct lttng_userspace_probe_location *
+lttng_event_rule_kernel_uprobe_get_location_mutable(
+ const struct lttng_event_rule *rule);
+
+#endif /* LTTNG_EVENT_RULE_KERNEL_UPROBE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/log4j-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_log4j_logging {
- struct lttng_event_rule parent;
-
- /* Name pattern. */
- char *pattern;
-
- /* Filter. */
- char *filter_expression;
-
- /* Log level. */
- struct lttng_log_level_rule *log_level_rule;
-
- /* internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_log4j_logging_comm {
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /* enum lttng_log_level_rule_comm + payload if any */
- uint32_t log_level_rule_len;
- /*
- * Payload is composed of, in that order:
- * - pattern (null terminated),
- * - filter expression (null terminated),
- * - log level rule serialized object,
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_log4j_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/log4j-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_log4j_logging {
+ struct lttng_event_rule parent;
+
+ /* Name pattern. */
+ char *pattern;
+
+ /* Filter. */
+ char *filter_expression;
+
+ /* Log level. */
+ struct lttng_log_level_rule *log_level_rule;
+
+ /* internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_log4j_logging_comm {
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /* enum lttng_log_level_rule_comm + payload if any */
+ uint32_t log_level_rule_len;
+ /*
+ * Payload is composed of, in that order:
+ * - pattern (null terminated),
+ * - filter expression (null terminated),
+ * - log level rule serialized object,
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_log4j_logging_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_LOG4J_LOGGING_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
-#define LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/python-logging.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_python_logging {
- struct lttng_event_rule parent;
-
- /* Name pattern. */
- char *pattern;
-
- /* Filter. */
- char *filter_expression;
-
- /* Log level. */
- struct lttng_log_level_rule *log_level_rule;
-
- /* internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_python_logging_comm {
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /* enum lttng_log_level_rule_comm + payload if any */
- uint32_t log_level_rule_len;
- /*
- * Payload is composed of, in that order:
- * - pattern (null terminated),
- * - filter expression (null terminated),
- * - log level rule serialized object,
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_python_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
+#define LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/python-logging.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_python_logging {
+ struct lttng_event_rule parent;
+
+ /* Name pattern. */
+ char *pattern;
+
+ /* Filter. */
+ char *filter_expression;
+
+ /* Log level. */
+ struct lttng_log_level_rule *log_level_rule;
+
+ /* internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_python_logging_comm {
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /* enum lttng_log_level_rule_comm + payload if any */
+ uint32_t log_level_rule_len;
+ /*
+ * Payload is composed of, in that order:
+ * - pattern (null terminated),
+ * - filter expression (null terminated),
+ * - log level rule serialized object,
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_python_logging_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_PYTHON_LOGGING_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
-#define LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
-
-#include <common/payload-view.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/domain.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/user-tracepoint.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule-internal.h>
-
-struct lttng_event_rule_user_tracepoint {
- struct lttng_event_rule parent;
-
- /* Name pattern. */
- char *pattern;
-
- /* Filter. */
- char *filter_expression;
-
- /* Log level. */
- struct lttng_log_level_rule *log_level_rule;
-
- /* Exclusions. */
- struct lttng_dynamic_pointer_array exclusions;
-
- /* internal use only. */
- struct {
- char *filter;
- struct lttng_bytecode *bytecode;
- } internal_filter;
-};
-
-struct lttng_event_rule_user_tracepoint_comm {
- /* Includes terminator `\0`. */
- uint32_t pattern_len;
- /* Includes terminator `\0`. */
- uint32_t filter_expression_len;
- /* enum lttng_log_level_rule_comm + payload if any */
- uint32_t log_level_rule_len;
- uint32_t exclusions_count;
- uint32_t exclusions_len;
- /*
- * Payload is composed of, in that order:
- * - pattern (null terminated),
- * - filter expression (null terminated),
- * - log level rule serialized object,
- * - exclusions (32 bit length + null terminated string).
- */
- char payload[];
-} LTTNG_PACKED;
-
-ssize_t lttng_event_rule_user_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **rule);
-
-#endif /* LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
+#define LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H
+
+#include <common/payload-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/domain.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/user-tracepoint.h>
+#include <lttng/event.h>
+#include <lttng/log-level-rule-internal.hpp>
+
+struct lttng_event_rule_user_tracepoint {
+ struct lttng_event_rule parent;
+
+ /* Name pattern. */
+ char *pattern;
+
+ /* Filter. */
+ char *filter_expression;
+
+ /* Log level. */
+ struct lttng_log_level_rule *log_level_rule;
+
+ /* Exclusions. */
+ struct lttng_dynamic_pointer_array exclusions;
+
+ /* internal use only. */
+ struct {
+ char *filter;
+ struct lttng_bytecode *bytecode;
+ } internal_filter;
+};
+
+struct lttng_event_rule_user_tracepoint_comm {
+ /* Includes terminator `\0`. */
+ uint32_t pattern_len;
+ /* Includes terminator `\0`. */
+ uint32_t filter_expression_len;
+ /* enum lttng_log_level_rule_comm + payload if any */
+ uint32_t log_level_rule_len;
+ uint32_t exclusions_count;
+ uint32_t exclusions_len;
+ /*
+ * Payload is composed of, in that order:
+ * - pattern (null terminated),
+ * - filter expression (null terminated),
+ * - log level rule serialized object,
+ * - exclusions (32 bit length + null terminated string).
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+ssize_t lttng_event_rule_user_tracepoint_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_event_rule **rule);
+
+#endif /* LTTNG_EVENT_RULE_USER_TRACEPOINT_INTERNAL_H */
+++ /dev/null
-#ifndef HEALTH_INTERNAL_H
-#define HEALTH_INTERNAL_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/compat/time.h>
-#include <pthread.h>
-#include <urcu/tls-compat.h>
-#include <urcu/uatomic.h>
-#include <urcu/list.h>
-#include <lttng/health.h>
-#include <common/macros.h>
-
-/*
- * These are the value added to the current state depending of the position in
- * the thread where is either waiting on a poll() or running in the code.
- */
-#define HEALTH_POLL_VALUE (1UL << 0)
-#define HEALTH_CODE_VALUE (1UL << 1)
-
-#define HEALTH_IS_IN_POLL(x) ((x) & HEALTH_POLL_VALUE)
-
-struct health_app;
-
-enum health_flags {
- HEALTH_ERROR = (1U << 0),
-};
-
-struct health_state {
- /*
- * last counter and last_time are only read and updated by the health_check
- * thread (single updater).
- */
- unsigned long last;
- struct timespec last_time;
-
- /*
- * current and flags are updated by multiple threads concurrently.
- */
- unsigned long current; /* progress counter, updated atomically */
- enum health_flags flags; /* other flags, updated atomically */
- int type; /* Indicates the nature of the thread. */
- /* Node of the global TLS state list. */
- struct cds_list_head node;
-};
-
-enum health_cmd {
- HEALTH_CMD_CHECK = 0,
-};
-
-struct health_comm_msg {
- uint32_t cmd; /* enum health_cmd */
-} LTTNG_PACKED;
-
-struct health_comm_reply {
- uint64_t ret_code; /* bitmask of threads in bad health */
-} LTTNG_PACKED;
-
-/* Declare TLS health state. */
-extern DECLARE_URCU_TLS(struct health_state, health_state);
-
-/*
- * Update current counter by 1 to indicate that the thread entered or left a
- * blocking state caused by a poll(). If the counter's value is not an even
- * number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
- */
-static inline void health_poll_entry(void)
-{
- /* Code MUST be in code execution state which is an even number. */
- LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state).current)
- & HEALTH_POLL_VALUE));
-
- uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
-}
-
-/*
- * Update current counter by 1 indicating the exit of a poll or blocking call.
- * If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
- * is raised.
- */
-static inline void health_poll_exit(void)
-{
- /* Code MUST be in poll execution state which is an odd number. */
- LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state).current)
- & HEALTH_POLL_VALUE);
-
- uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
-}
-
-/*
- * Update current counter by 2 indicates progress in execution of a
- * thread.
- */
-static inline void health_code_update(void)
-{
- uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
-}
-
-/*
- * Set health "error" flag.
- */
-static inline void health_error(void)
-{
- uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
-}
-
-struct health_app *health_app_create(int nr_types);
-void health_app_destroy(struct health_app *ha);
-int health_check_state(struct health_app *ha, int type);
-void health_register(struct health_app *ha, int type);
-void health_unregister(struct health_app *ha);
-
-#endif /* HEALTH_INTERNAL_H */
--- /dev/null
+#ifndef HEALTH_INTERNAL_H
+#define HEALTH_INTERNAL_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/compat/time.hpp>
+#include <pthread.h>
+#include <urcu/tls-compat.h>
+#include <urcu/uatomic.h>
+#include <urcu/list.h>
+#include <lttng/health.h>
+#include <common/macros.hpp>
+
+/*
+ * These are the value added to the current state depending of the position in
+ * the thread where is either waiting on a poll() or running in the code.
+ */
+#define HEALTH_POLL_VALUE (1UL << 0)
+#define HEALTH_CODE_VALUE (1UL << 1)
+
+#define HEALTH_IS_IN_POLL(x) ((x) & HEALTH_POLL_VALUE)
+
+struct health_app;
+
+enum health_flags {
+ HEALTH_ERROR = (1U << 0),
+};
+
+struct health_state {
+ /*
+ * last counter and last_time are only read and updated by the health_check
+ * thread (single updater).
+ */
+ unsigned long last;
+ struct timespec last_time;
+
+ /*
+ * current and flags are updated by multiple threads concurrently.
+ */
+ unsigned long current; /* progress counter, updated atomically */
+ enum health_flags flags; /* other flags, updated atomically */
+ int type; /* Indicates the nature of the thread. */
+ /* Node of the global TLS state list. */
+ struct cds_list_head node;
+};
+
+enum health_cmd {
+ HEALTH_CMD_CHECK = 0,
+};
+
+struct health_comm_msg {
+ uint32_t cmd; /* enum health_cmd */
+} LTTNG_PACKED;
+
+struct health_comm_reply {
+ uint64_t ret_code; /* bitmask of threads in bad health */
+} LTTNG_PACKED;
+
+/* Declare TLS health state. */
+extern DECLARE_URCU_TLS(struct health_state, health_state);
+
+/*
+ * Update current counter by 1 to indicate that the thread entered or left a
+ * blocking state caused by a poll(). If the counter's value is not an even
+ * number (meaning a code execution flow), an LTTNG_ASSERT() is raised.
+ */
+static inline void health_poll_entry(void)
+{
+ /* Code MUST be in code execution state which is an even number. */
+ LTTNG_ASSERT(!(uatomic_read(&URCU_TLS(health_state).current)
+ & HEALTH_POLL_VALUE));
+
+ uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
+}
+
+/*
+ * Update current counter by 1 indicating the exit of a poll or blocking call.
+ * If the counter's value is not an odd number (a poll execution), an LTTNG_ASSERT()
+ * is raised.
+ */
+static inline void health_poll_exit(void)
+{
+ /* Code MUST be in poll execution state which is an odd number. */
+ LTTNG_ASSERT(uatomic_read(&URCU_TLS(health_state).current)
+ & HEALTH_POLL_VALUE);
+
+ uatomic_add(&URCU_TLS(health_state).current, HEALTH_POLL_VALUE);
+}
+
+/*
+ * Update current counter by 2 indicates progress in execution of a
+ * thread.
+ */
+static inline void health_code_update(void)
+{
+ uatomic_add(&URCU_TLS(health_state).current, HEALTH_CODE_VALUE);
+}
+
+/*
+ * Set health "error" flag.
+ */
+static inline void health_error(void)
+{
+ uatomic_or(&URCU_TLS(health_state).flags, HEALTH_ERROR);
+}
+
+struct health_app *health_app_create(int nr_types);
+void health_app_destroy(struct health_app *ha);
+int health_check_state(struct health_app *ha, int type);
+void health_register(struct health_app *ha, int type);
+void health_unregister(struct health_app *ha);
+
+#endif /* HEALTH_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_KERNEL_PROBE_INTERNAL_H
-#define LTTNG_KERNEL_PROBE_INTERNAL_H
-
-#include <common/fd-handle.h>
-#include <common/macros.h>
-#include <lttng/lttng-error.h>
-#include <lttng/kernel-probe.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct lttng_dynamic_buffer;
-struct mi_writer;
-
-typedef bool (*kernel_probe_location_equal_cb)(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b);
-typedef int (*kernel_probe_location_serialize_cb)(
- const struct lttng_kernel_probe_location *kernel_probe_location,
- struct lttng_payload *payload);
-typedef bool (*kernel_probe_location_equal_cb)(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b);
-typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
- struct lttng_payload_view *view,
- struct lttng_kernel_probe_location **kernel_probe_location);
-typedef unsigned long (*kernel_probe_location_hash_cb)(
- const struct lttng_kernel_probe_location *location);
-typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer);
-
-struct lttng_kernel_probe_location_comm {
- /* enum lttng_kernel_probe_location_type */
- int8_t type;
- /*
- * Payload is composed of, in that order,
- * - type-specific payload
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_kernel_probe_location_symbol_comm {
- /* Includes the trailing \0. */
- uint32_t symbol_len;
- /* The offset from the symbol. */
- uint64_t offset;
- /*
- * Payload is composed of, in that order,
- * - symbol name (with trailing \0).
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_kernel_probe_location_address_comm {
- uint64_t address;
-} LTTNG_PACKED;
-
-/* Common ancestor of all kernel probe locations. */
-struct lttng_kernel_probe_location {
- enum lttng_kernel_probe_location_type type;
- kernel_probe_location_equal_cb equal;
- kernel_probe_location_serialize_cb serialize;
- kernel_probe_location_hash_cb hash;
- kernel_probe_location_mi_serialize_cb mi_serialize;
-};
-
-struct lttng_kernel_probe_location_symbol {
- struct lttng_kernel_probe_location parent;
- char *symbol_name;
- uint64_t offset;
-};
-
-struct lttng_kernel_probe_location_address {
- struct lttng_kernel_probe_location parent;
- uint64_t address;
-};
-
-int lttng_kernel_probe_location_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload);
-
-ssize_t lttng_kernel_probe_location_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_kernel_probe_location **probe_location);
-
-bool lttng_kernel_probe_location_is_equal(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b);
-
-struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
- const struct lttng_kernel_probe_location *location);
-
-unsigned long lttng_kernel_probe_location_hash(
- const struct lttng_kernel_probe_location *location);
-
-enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer);
-
-#endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_KERNEL_PROBE_INTERNAL_H
+#define LTTNG_KERNEL_PROBE_INTERNAL_H
+
+#include <common/fd-handle.hpp>
+#include <common/macros.hpp>
+#include <lttng/lttng-error.h>
+#include <lttng/kernel-probe.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct lttng_dynamic_buffer;
+struct mi_writer;
+
+typedef bool (*kernel_probe_location_equal_cb)(
+ const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b);
+typedef int (*kernel_probe_location_serialize_cb)(
+ const struct lttng_kernel_probe_location *kernel_probe_location,
+ struct lttng_payload *payload);
+typedef bool (*kernel_probe_location_equal_cb)(
+ const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b);
+typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
+ struct lttng_payload_view *view,
+ struct lttng_kernel_probe_location **kernel_probe_location);
+typedef unsigned long (*kernel_probe_location_hash_cb)(
+ const struct lttng_kernel_probe_location *location);
+typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
+struct lttng_kernel_probe_location_comm {
+ /* enum lttng_kernel_probe_location_type */
+ int8_t type;
+ /*
+ * Payload is composed of, in that order,
+ * - type-specific payload
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_kernel_probe_location_symbol_comm {
+ /* Includes the trailing \0. */
+ uint32_t symbol_len;
+ /* The offset from the symbol. */
+ uint64_t offset;
+ /*
+ * Payload is composed of, in that order,
+ * - symbol name (with trailing \0).
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_kernel_probe_location_address_comm {
+ uint64_t address;
+} LTTNG_PACKED;
+
+/* Common ancestor of all kernel probe locations. */
+struct lttng_kernel_probe_location {
+ enum lttng_kernel_probe_location_type type;
+ kernel_probe_location_equal_cb equal;
+ kernel_probe_location_serialize_cb serialize;
+ kernel_probe_location_hash_cb hash;
+ kernel_probe_location_mi_serialize_cb mi_serialize;
+};
+
+struct lttng_kernel_probe_location_symbol {
+ struct lttng_kernel_probe_location parent;
+ char *symbol_name;
+ uint64_t offset;
+};
+
+struct lttng_kernel_probe_location_address {
+ struct lttng_kernel_probe_location parent;
+ uint64_t address;
+};
+
+int lttng_kernel_probe_location_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload);
+
+ssize_t lttng_kernel_probe_location_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_kernel_probe_location **probe_location);
+
+bool lttng_kernel_probe_location_is_equal(
+ const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b);
+
+struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
+ const struct lttng_kernel_probe_location *location);
+
+unsigned long lttng_kernel_probe_location_hash(
+ const struct lttng_kernel_probe_location *location);
+
+enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOAD_INTERNAL_ABI_H
-#define LTTNG_LOAD_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-#include <common/config/session-config.h>
-
-/*
- * Object used by the load_session API. This is opaque to the public library.
- */
-struct lttng_load_session_attr {
- /* Name of the session to load, empty string means all. */
- char session_name[LTTNG_NAME_MAX];
- /* URL of the session configuration file to load. */
- char input_url[PATH_MAX];
- /* Overwrite the session if it exists. */
- uint32_t overwrite;
- /* The raw override url for getter */
- char *raw_override_url;
- /* The raw override path url for getter */
- char *raw_override_path_url;
- /* The raw override ctrl url for getter */
- char *raw_override_ctrl_url;
- /* The raw override data url for getter */
- char *raw_override_data_url;
- /* Override struct */
- struct config_load_session_override_attr *override_attr;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_LOAD_INTERNAL_ABI_H */
--- /dev/null
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOAD_INTERNAL_ABI_H
+#define LTTNG_LOAD_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+#include <common/config/session-config.hpp>
+
+/*
+ * Object used by the load_session API. This is opaque to the public library.
+ */
+struct lttng_load_session_attr {
+ /* Name of the session to load, empty string means all. */
+ char session_name[LTTNG_NAME_MAX];
+ /* URL of the session configuration file to load. */
+ char input_url[PATH_MAX];
+ /* Overwrite the session if it exists. */
+ uint32_t overwrite;
+ /* The raw override url for getter */
+ char *raw_override_url;
+ /* The raw override path url for getter */
+ char *raw_override_path_url;
+ /* The raw override ctrl url for getter */
+ char *raw_override_ctrl_url;
+ /* The raw override data url for getter */
+ char *raw_override_data_url;
+ /* Override struct */
+ struct config_load_session_override_attr *override_attr;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_LOAD_INTERNAL_ABI_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOCATION_INTERNAL_H
-#define LTTNG_LOCATION_INTERNAL_H
-
-#include <lttng/location.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/macros.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-/*
- * The public API assumes that trace archive locations are always
- * provided as "constant". This means that the user of liblttng-ctl never
- * has to destroy a trace archive location. Hence, users of liblttng-ctl
- * have no visibility of the reference counting of archive locations.
- */
-struct lttng_trace_archive_location {
- struct urcu_ref ref;
- enum lttng_trace_archive_location_type type;
- union {
- struct {
- char *absolute_path;
- } local;
- struct {
- char *host;
- enum lttng_trace_archive_location_relay_protocol_type protocol;
- struct {
- uint16_t control, data;
- } ports;
- char *relative_path;
- } relay;
- } types;
-};
-
-struct lttng_trace_archive_location_comm {
- /* A value from enum lttng_trace_archive_location_type */
- int8_t type;
- union {
- struct {
- /* Includes the trailing \0. */
- uint32_t absolute_path_len;
- } LTTNG_PACKED local;
- struct {
- /* Includes the trailing \0. */
- uint32_t hostname_len;
- /*
- * A value from
- * enum lttng_trace_archive_location_relay_protocol_type.
- */
- int8_t protocol;
- struct {
- uint16_t control, data;
- } ports;
- /* Includes the trailing \0. */
- uint32_t relative_path_len;
- } LTTNG_PACKED relay;
- } LTTNG_PACKED types;
- /*
- * Payload is composed of:
- * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL
- * - absolute path, including \0
- * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY
- * - hostname, including \0
- * - relative path, including \0
- */
- char payload[];
-} LTTNG_PACKED;
-
-
-struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
- const char *path);
-
-struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
- const char *host,
- enum lttng_trace_archive_location_relay_protocol_type protocol,
- uint16_t control_port, uint16_t data_port,
- const char *relative_path);
-
-ssize_t lttng_trace_archive_location_create_from_buffer(
- const struct lttng_buffer_view *buffer,
- struct lttng_trace_archive_location **location);
-
-ssize_t lttng_trace_archive_location_serialize(
- const struct lttng_trace_archive_location *location,
- struct lttng_dynamic_buffer *buffer);
-
-void lttng_trace_archive_location_get(
- struct lttng_trace_archive_location *location);
-
-void lttng_trace_archive_location_put(
- struct lttng_trace_archive_location *location);
-
-#endif /* LTTNG_LOCATION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOCATION_INTERNAL_H
+#define LTTNG_LOCATION_INTERNAL_H
+
+#include <lttng/location.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+/*
+ * The public API assumes that trace archive locations are always
+ * provided as "constant". This means that the user of liblttng-ctl never
+ * has to destroy a trace archive location. Hence, users of liblttng-ctl
+ * have no visibility of the reference counting of archive locations.
+ */
+struct lttng_trace_archive_location {
+ struct urcu_ref ref;
+ enum lttng_trace_archive_location_type type;
+ union {
+ struct {
+ char *absolute_path;
+ } local;
+ struct {
+ char *host;
+ enum lttng_trace_archive_location_relay_protocol_type protocol;
+ struct {
+ uint16_t control, data;
+ } ports;
+ char *relative_path;
+ } relay;
+ } types;
+};
+
+struct lttng_trace_archive_location_comm {
+ /* A value from enum lttng_trace_archive_location_type */
+ int8_t type;
+ union {
+ struct {
+ /* Includes the trailing \0. */
+ uint32_t absolute_path_len;
+ } LTTNG_PACKED local;
+ struct {
+ /* Includes the trailing \0. */
+ uint32_t hostname_len;
+ /*
+ * A value from
+ * enum lttng_trace_archive_location_relay_protocol_type.
+ */
+ int8_t protocol;
+ struct {
+ uint16_t control, data;
+ } ports;
+ /* Includes the trailing \0. */
+ uint32_t relative_path_len;
+ } LTTNG_PACKED relay;
+ } LTTNG_PACKED types;
+ /*
+ * Payload is composed of:
+ * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL
+ * - absolute path, including \0
+ * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY
+ * - hostname, including \0
+ * - relative path, including \0
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+
+struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
+ const char *path);
+
+struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
+ const char *host,
+ enum lttng_trace_archive_location_relay_protocol_type protocol,
+ uint16_t control_port, uint16_t data_port,
+ const char *relative_path);
+
+ssize_t lttng_trace_archive_location_create_from_buffer(
+ const struct lttng_buffer_view *buffer,
+ struct lttng_trace_archive_location **location);
+
+ssize_t lttng_trace_archive_location_serialize(
+ const struct lttng_trace_archive_location *location,
+ struct lttng_dynamic_buffer *buffer);
+
+void lttng_trace_archive_location_get(
+ struct lttng_trace_archive_location *location);
+
+void lttng_trace_archive_location_put(
+ struct lttng_trace_archive_location *location);
+
+#endif /* LTTNG_LOCATION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_LOG_LEVEL_RULE_INTERNAL_H
-#define LTTNG_LOG_LEVEL_RULE_INTERNAL_H
-
-#include <stdint.h>
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/event.h>
-#include <lttng/log-level-rule.h>
-#include <lttng/lttng-error.h>
-
-struct mi_writer;
-
-/*
- * For now only a single backing struct is used for both type of log level
- * rule (exactly, as_severe) since both only have require "level" as property.
- */
-struct lttng_log_level_rule {
- enum lttng_log_level_rule_type type;
- int level;
-};
-
-struct lttng_log_level_rule_comm {
- /* enum lttng_log_level_rule_type */
- int8_t type;
- int32_t level;
-};
-
-ssize_t lttng_log_level_rule_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_log_level_rule **rule);
-
-int lttng_log_level_rule_serialize(const struct lttng_log_level_rule *rule,
- struct lttng_payload *payload);
-
-bool lttng_log_level_rule_is_equal(const struct lttng_log_level_rule *a,
- const struct lttng_log_level_rule *b);
-
-struct lttng_log_level_rule *lttng_log_level_rule_copy(
- const struct lttng_log_level_rule *source);
-
-void lttng_log_level_rule_to_loglevel(
- const struct lttng_log_level_rule *log_level_rule,
- enum lttng_loglevel_type *loglevel_type,
- int *loglevel_value);
-
-unsigned long lttng_log_level_rule_hash(
- const struct lttng_log_level_rule *log_level_rule);
-
-enum lttng_error_code lttng_log_level_rule_mi_serialize(
- const struct lttng_log_level_rule *rule,
- struct mi_writer *writer);
-
-#endif /* LTTNG_LOG_LEVEL_RULE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOG_LEVEL_RULE_INTERNAL_H
+#define LTTNG_LOG_LEVEL_RULE_INTERNAL_H
+
+#include <stdint.h>
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
+#include <lttng/lttng-error.h>
+
+struct mi_writer;
+
+/*
+ * For now only a single backing struct is used for both type of log level
+ * rule (exactly, as_severe) since both only have require "level" as property.
+ */
+struct lttng_log_level_rule {
+ enum lttng_log_level_rule_type type;
+ int level;
+};
+
+struct lttng_log_level_rule_comm {
+ /* enum lttng_log_level_rule_type */
+ int8_t type;
+ int32_t level;
+};
+
+ssize_t lttng_log_level_rule_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_log_level_rule **rule);
+
+int lttng_log_level_rule_serialize(const struct lttng_log_level_rule *rule,
+ struct lttng_payload *payload);
+
+bool lttng_log_level_rule_is_equal(const struct lttng_log_level_rule *a,
+ const struct lttng_log_level_rule *b);
+
+struct lttng_log_level_rule *lttng_log_level_rule_copy(
+ const struct lttng_log_level_rule *source);
+
+void lttng_log_level_rule_to_loglevel(
+ const struct lttng_log_level_rule *log_level_rule,
+ enum lttng_loglevel_type *loglevel_type,
+ int *loglevel_value);
+
+unsigned long lttng_log_level_rule_hash(
+ const struct lttng_log_level_rule *log_level_rule);
+
+enum lttng_error_code lttng_log_level_rule_mi_serialize(
+ const struct lttng_log_level_rule *rule,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_LOG_LEVEL_RULE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
-#define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
-
-#include <lttng/notification/channel.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <pthread.h>
-#include <urcu/list.h>
-
-/*
- * Protocol version change log:
- * - v1.0
- * - Initial implementation of the notification channel protocol,
- * - Supported conditions are LOW/HIGH buffer usage conditions,
- * - v1.1
- * - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
- * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
- * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
- */
-#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
-#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
-
-enum lttng_notification_channel_message_type {
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN = -1,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE = 0,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE = 1,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE = 2,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY = 3,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION = 4,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED = 5,
-};
-
-struct lttng_notification_channel_message {
- /* enum lttng_notification_channel_message_type */
- int8_t type;
- /* Size of the payload following this field. */
- uint32_t size;
- /* Number of FDs sent. */
- uint32_t fds;
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_notification_channel_command_handshake {
- uint8_t major;
- uint8_t minor;
-} LTTNG_PACKED;
-
-struct lttng_notification_channel_command_reply {
- /* enum lttng_notification_channel_status */
- int8_t status;
-} LTTNG_PACKED;
-
-struct pending_notification {
- /* NULL means "notification dropped". */
- struct lttng_notification *notification;
- struct cds_list_head node;
-};
-
-/*
- * The notification channel protocol is bidirectional and accommodates
- * synchronous and asynchronous communication modes:
- *
- * - Synchronous: commands emitted by the client to which a reply is expected
- * (e.g. subscribing/unsubscribing to conditions),
- * - Asynchronous: notifications which are sent by the lttng_endpoint to the
- * client as one of the subscribed condition has occurred.
- *
- * The nature of this hybrid communication mode means that asynchronous messages
- * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
- * command and its reply).
- *
- * Notifications that are received between a command and its reply and enqueued
- * in the pending_notifications list.
- */
-struct lttng_notification_channel {
- pthread_mutex_t lock;
- int socket;
- struct {
- /* Count of pending notifications. */
- unsigned int count;
- /* List of struct pending_notification. */
- struct cds_list_head list;
- } pending_notifications;
- struct lttng_payload reception_payload;
- /* Sessiond notification protocol version. */
- struct {
- bool set;
- int8_t major, minor;
- } version;
-};
-
-#endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
+#define LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H
+
+#include <lttng/notification/channel.h>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <stdint.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include <urcu/list.h>
+
+/*
+ * Protocol version change log:
+ * - v1.0
+ * - Initial implementation of the notification channel protocol,
+ * - Supported conditions are LOW/HIGH buffer usage conditions,
+ * - v1.1
+ * - New condition type "LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE" added,
+ * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING" added,
+ * - New condition type "LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED" added,
+ */
+#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR 1
+#define LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR 1
+
+enum lttng_notification_channel_message_type {
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN = -1,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE = 0,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE = 1,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE = 2,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY = 3,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION = 4,
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED = 5,
+};
+
+struct lttng_notification_channel_message {
+ /* enum lttng_notification_channel_message_type */
+ int8_t type;
+ /* Size of the payload following this field. */
+ uint32_t size;
+ /* Number of FDs sent. */
+ uint32_t fds;
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_notification_channel_command_handshake {
+ uint8_t major;
+ uint8_t minor;
+} LTTNG_PACKED;
+
+struct lttng_notification_channel_command_reply {
+ /* enum lttng_notification_channel_status */
+ int8_t status;
+} LTTNG_PACKED;
+
+struct pending_notification {
+ /* NULL means "notification dropped". */
+ struct lttng_notification *notification;
+ struct cds_list_head node;
+};
+
+/*
+ * The notification channel protocol is bidirectional and accommodates
+ * synchronous and asynchronous communication modes:
+ *
+ * - Synchronous: commands emitted by the client to which a reply is expected
+ * (e.g. subscribing/unsubscribing to conditions),
+ * - Asynchronous: notifications which are sent by the lttng_endpoint to the
+ * client as one of the subscribed condition has occurred.
+ *
+ * The nature of this hybrid communication mode means that asynchronous messages
+ * (e.g. notifications) may be interleaved between synchronous messages (e.g. a
+ * command and its reply).
+ *
+ * Notifications that are received between a command and its reply and enqueued
+ * in the pending_notifications list.
+ */
+struct lttng_notification_channel {
+ pthread_mutex_t lock;
+ int socket;
+ struct {
+ /* Count of pending notifications. */
+ unsigned int count;
+ /* List of struct pending_notification. */
+ struct cds_list_head list;
+ } pending_notifications;
+ struct lttng_payload reception_payload;
+ /* Sessiond notification protocol version. */
+ struct {
+ bool set;
+ int8_t major, minor;
+ } version;
+};
+
+#endif /* LTTNG_NOTIFICATION_CHANNEL_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_NOTIFICATION_INTERNAL_H
-#define LTTNG_NOTIFICATION_INTERNAL_H
-
-#include <lttng/notification/notification.h>
-#include <common/macros.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-
-struct lttng_notification {
- struct lttng_trigger *trigger;
- struct lttng_evaluation *evaluation;
-};
-
-struct lttng_notification_comm {
- /* Size of the payload following this field. */
- uint32_t length;
- /* Trigger and evaluation objects follow. */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_notification *lttng_notification_create(
- struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation);
-
-int lttng_notification_serialize(const struct lttng_notification *notification,
- struct lttng_payload *payload);
-
-ssize_t lttng_notification_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_notification **notification);
-
-#endif /* LTTNG_NOTIFICATION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_NOTIFICATION_INTERNAL_H
+#define LTTNG_NOTIFICATION_INTERNAL_H
+
+#include <lttng/notification/notification.h>
+#include <common/macros.hpp>
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+
+struct lttng_notification {
+ struct lttng_trigger *trigger;
+ struct lttng_evaluation *evaluation;
+};
+
+struct lttng_notification_comm {
+ /* Size of the payload following this field. */
+ uint32_t length;
+ /* Trigger and evaluation objects follow. */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_notification *lttng_notification_create(
+ struct lttng_trigger *trigger,
+ struct lttng_evaluation *evaluation);
+
+int lttng_notification_serialize(const struct lttng_notification *notification,
+ struct lttng_payload *payload);
+
+ssize_t lttng_notification_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_notification **notification);
+
+#endif /* LTTNG_NOTIFICATION_INTERNAL_H */
+++ /dev/null
-#ifndef LTTNG_REF_INTERNAL_H
-#define LTTNG_REF_INTERNAL_H
-
-/*
- * LTTng - Non thread-safe reference counting
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-
-typedef void (*lttng_release_func)(void *);
-
-struct lttng_ref {
- unsigned long count;
- lttng_release_func release;
-};
-
-static inline
-void lttng_ref_init(struct lttng_ref *ref, lttng_release_func release)
-{
- LTTNG_ASSERT(ref);
- ref->count = 1;
- ref->release = release;
-}
-
-static inline
-void lttng_ref_get(struct lttng_ref *ref)
-{
- LTTNG_ASSERT(ref);
- ref->count++;
- /* Overflow check. */
- LTTNG_ASSERT(ref->count);
-}
-
-static inline
-void lttng_ref_put(struct lttng_ref *ref)
-{
- LTTNG_ASSERT(ref);
- /* Underflow check. */
- LTTNG_ASSERT(ref->count);
- if (caa_unlikely((--ref->count) == 0)) {
- ref->release(ref);
- }
-}
-
-#endif /* LTTNG_REF_INTERNAL_H */
--- /dev/null
+#ifndef LTTNG_REF_INTERNAL_H
+#define LTTNG_REF_INTERNAL_H
+
+/*
+ * LTTng - Non thread-safe reference counting
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+
+typedef void (*lttng_release_func)(void *);
+
+struct lttng_ref {
+ unsigned long count;
+ lttng_release_func release;
+};
+
+static inline
+void lttng_ref_init(struct lttng_ref *ref, lttng_release_func release)
+{
+ LTTNG_ASSERT(ref);
+ ref->count = 1;
+ ref->release = release;
+}
+
+static inline
+void lttng_ref_get(struct lttng_ref *ref)
+{
+ LTTNG_ASSERT(ref);
+ ref->count++;
+ /* Overflow check. */
+ LTTNG_ASSERT(ref->count);
+}
+
+static inline
+void lttng_ref_put(struct lttng_ref *ref)
+{
+ LTTNG_ASSERT(ref);
+ /* Underflow check. */
+ LTTNG_ASSERT(ref->count);
+ if (caa_unlikely((--ref->count) == 0)) {
+ ref->release(ref);
+ }
+}
+
+#endif /* LTTNG_REF_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_ROTATE_INTERNAL_ABI_H
-#define LTTNG_ROTATE_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <lttng/constant.h>
-#include <lttng/rotation.h>
-#include <common/macros.h>
-
-/*
- * Object returned by the rotate session API.
- * This is opaque to the public library.
- */
-struct lttng_rotation_handle {
- char session_name[LTTNG_NAME_MAX];
- /*
- * ID of the rotate command.
- * This matches the session->rotate_count, so the handle is valid until
- * the next rotate command. After that, the rotation_get_state command
- * returns the "expired" state.
- */
- uint64_t rotation_id;
- /*
- * Where the rotated (readable) trace has been stored when the
- * rotation is completed.
- */
- struct lttng_trace_archive_location *archive_location;
-};
-
-struct lttng_rotation_schedule {
- enum lttng_rotation_schedule_type type;
-};
-
-struct lttng_rotation_schedule_size_threshold {
- struct lttng_rotation_schedule parent;
- struct {
- bool set;
- uint64_t bytes;
- } size;
-};
-
-struct lttng_rotation_schedule_periodic {
- struct lttng_rotation_schedule parent;
- struct {
- bool set;
- uint64_t us;
- } period;
-};
-
-struct lttng_rotation_schedules {
- /*
- * Only one rotation schedule per type is supported for now.
- * Schedules are owned by this object.
- */
- unsigned int count;
- struct lttng_rotation_schedule *schedules[2];
-};
-
-/*
- * Internal objects between lttng-ctl and the session daemon, the values
- * are then copied to the user's lttng_rotation_handle object.
- */
-
-/* For the LTTNG_ROTATE_SESSION command. */
-struct lttng_rotate_session_return {
- uint64_t rotation_id;
-} LTTNG_PACKED;
-
-/* For the LTTNG_ROTATION_GET_INFO command. */
-struct lttng_rotation_get_info_return {
- /* Represents values defined in enum lttng_rotation_state. */
- int32_t status;
- /*
- * Represents values defined in enum lttng_trace_archive_location_type.
- */
- int8_t location_type;
- union {
- struct {
- char absolute_path[LTTNG_PATH_MAX];
- } LTTNG_PACKED local;
- struct {
- char host[LTTNG_HOST_NAME_MAX];
- /*
- * Represents values defined in
- * enum lttng_trace_archive_location_relay_protocol_type.
- */
- int8_t protocol;
- struct {
- uint16_t control;
- uint16_t data;
- } LTTNG_PACKED ports;
- char relative_path[LTTNG_PATH_MAX];
- } LTTNG_PACKED relay;
- } location;
-} LTTNG_PACKED;
-
-/* For the LTTNG_SESSION_LIST_SCHEDULES command. */
-struct lttng_session_list_schedules_return {
- struct {
- uint8_t set;
- uint64_t value;
- } LTTNG_PACKED periodic;
- struct {
- uint8_t set;
- uint64_t value;
- } LTTNG_PACKED size;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_ROTATE_INTERNAL_ABI_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_ROTATE_INTERNAL_ABI_H
+#define LTTNG_ROTATE_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <lttng/constant.h>
+#include <lttng/rotation.h>
+#include <common/macros.hpp>
+
+/*
+ * Object returned by the rotate session API.
+ * This is opaque to the public library.
+ */
+struct lttng_rotation_handle {
+ char session_name[LTTNG_NAME_MAX];
+ /*
+ * ID of the rotate command.
+ * This matches the session->rotate_count, so the handle is valid until
+ * the next rotate command. After that, the rotation_get_state command
+ * returns the "expired" state.
+ */
+ uint64_t rotation_id;
+ /*
+ * Where the rotated (readable) trace has been stored when the
+ * rotation is completed.
+ */
+ struct lttng_trace_archive_location *archive_location;
+};
+
+struct lttng_rotation_schedule {
+ enum lttng_rotation_schedule_type type;
+};
+
+struct lttng_rotation_schedule_size_threshold {
+ struct lttng_rotation_schedule parent;
+ struct {
+ bool set;
+ uint64_t bytes;
+ } size;
+};
+
+struct lttng_rotation_schedule_periodic {
+ struct lttng_rotation_schedule parent;
+ struct {
+ bool set;
+ uint64_t us;
+ } period;
+};
+
+struct lttng_rotation_schedules {
+ /*
+ * Only one rotation schedule per type is supported for now.
+ * Schedules are owned by this object.
+ */
+ unsigned int count;
+ struct lttng_rotation_schedule *schedules[2];
+};
+
+/*
+ * Internal objects between lttng-ctl and the session daemon, the values
+ * are then copied to the user's lttng_rotation_handle object.
+ */
+
+/* For the LTTNG_ROTATE_SESSION command. */
+struct lttng_rotate_session_return {
+ uint64_t rotation_id;
+} LTTNG_PACKED;
+
+/* For the LTTNG_ROTATION_GET_INFO command. */
+struct lttng_rotation_get_info_return {
+ /* Represents values defined in enum lttng_rotation_state. */
+ int32_t status;
+ /*
+ * Represents values defined in enum lttng_trace_archive_location_type.
+ */
+ int8_t location_type;
+ union {
+ struct {
+ char absolute_path[LTTNG_PATH_MAX];
+ } LTTNG_PACKED local;
+ struct {
+ char host[LTTNG_HOST_NAME_MAX];
+ /*
+ * Represents values defined in
+ * enum lttng_trace_archive_location_relay_protocol_type.
+ */
+ int8_t protocol;
+ struct {
+ uint16_t control;
+ uint16_t data;
+ } LTTNG_PACKED ports;
+ char relative_path[LTTNG_PATH_MAX];
+ } LTTNG_PACKED relay;
+ } location;
+} LTTNG_PACKED;
+
+/* For the LTTNG_SESSION_LIST_SCHEDULES command. */
+struct lttng_session_list_schedules_return {
+ struct {
+ uint8_t set;
+ uint64_t value;
+ } LTTNG_PACKED periodic;
+ struct {
+ uint8_t set;
+ uint64_t value;
+ } LTTNG_PACKED size;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_ROTATE_INTERNAL_ABI_H */
+++ /dev/null
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SAVE_INTERNAL_ABI_H
-#define LTTNG_SAVE_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-/*
- * Object used by the save_session API. This is opaque to the public library.
- */
-struct lttng_save_session_attr {
- /* Name of the session to save, empty string means all. */
- char session_name[LTTNG_NAME_MAX];
- /* Destination of the session configuration. See lttng(1) for URL format. */
- char configuration_url[PATH_MAX];
- /* Overwrite the session configuration file if it exists. */
- uint8_t overwrite;
- /* Omit the sessions' name(s). */
- uint8_t omit_name;
- /* Omit the sessions' output(s). */
- uint8_t omit_output;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_SAVE_INTERNAL_ABI_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SAVE_INTERNAL_ABI_H
+#define LTTNG_SAVE_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+/*
+ * Object used by the save_session API. This is opaque to the public library.
+ */
+struct lttng_save_session_attr {
+ /* Name of the session to save, empty string means all. */
+ char session_name[LTTNG_NAME_MAX];
+ /* Destination of the session configuration. See lttng(1) for URL format. */
+ char configuration_url[PATH_MAX];
+ /* Overwrite the session configuration file if it exists. */
+ uint8_t overwrite;
+ /* Omit the sessions' name(s). */
+ uint8_t omit_name;
+ /* Omit the sessions' output(s). */
+ uint8_t omit_output;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_SAVE_INTERNAL_ABI_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
-#define LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
-
-#include <lttng/session-descriptor.h>
-#include <lttng/lttng-error.h>
-#include <common/uri.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <stdbool.h>
-
-/* Note that these enums are used as part of the lttnctl protocol. */
-enum lttng_session_descriptor_type {
- LTTNG_SESSION_DESCRIPTOR_TYPE_UNKNOWN = -1,
- /*
- * The output type determines whether this is a no-output, local,
- * or networked tracing session.
- */
- LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR = 1,
- LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT = 2,
- LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE = 3,
-};
-
-enum lttng_session_descriptor_output_type {
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE = 0,
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL = 1,
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK = 2,
-};
-
-ssize_t lttng_session_descriptor_create_from_buffer(
- const struct lttng_buffer_view *view,
- struct lttng_session_descriptor **descriptor);
-
-int lttng_session_descriptor_serialize(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_dynamic_buffer *buffer);
-
-enum lttng_session_descriptor_type
-lttng_session_descriptor_get_type(
- const struct lttng_session_descriptor *descriptor);
-
-enum lttng_session_descriptor_output_type
-lttng_session_descriptor_get_output_type(
- const struct lttng_session_descriptor *descriptor);
-
-void lttng_session_descriptor_get_local_output_uri(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_uri *local_uri);
-
-void lttng_session_descriptor_get_network_output_uris(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_uri *control,
- struct lttng_uri *data);
-
-unsigned long long
-lttng_session_descriptor_live_get_timer_interval(
- const struct lttng_session_descriptor *descriptor);
-
-int lttng_session_descriptor_set_session_name(
- struct lttng_session_descriptor *descriptor,
- const char *name);
-
-bool lttng_session_descriptor_is_output_destination_initialized(
- const struct lttng_session_descriptor *descriptor);
-
-bool lttng_session_descriptor_has_output_directory(
- const struct lttng_session_descriptor *descriptor);
-
-enum lttng_error_code lttng_session_descriptor_set_default_output(
- struct lttng_session_descriptor *descriptor,
- time_t *session_creation_time,
- const char *absolute_home_path);
-
-int lttng_session_descriptor_assign(
- struct lttng_session_descriptor *dst_descriptor,
- const struct lttng_session_descriptor *src_descriptor);
-
-#endif /* LTTNG_SESSION_DESCRIPTOR_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
+#define LTTNG_SESSION_DESCRIPTOR_INTERNAL_H
+
+#include <lttng/session-descriptor.h>
+#include <lttng/lttng-error.h>
+#include <common/uri.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <stdbool.h>
+
+/* Note that these enums are used as part of the lttnctl protocol. */
+enum lttng_session_descriptor_type {
+ LTTNG_SESSION_DESCRIPTOR_TYPE_UNKNOWN = -1,
+ /*
+ * The output type determines whether this is a no-output, local,
+ * or networked tracing session.
+ */
+ LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR = 1,
+ LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT = 2,
+ LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE = 3,
+};
+
+enum lttng_session_descriptor_output_type {
+ LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE = 0,
+ LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL = 1,
+ LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK = 2,
+};
+
+ssize_t lttng_session_descriptor_create_from_buffer(
+ const struct lttng_buffer_view *view,
+ struct lttng_session_descriptor **descriptor);
+
+int lttng_session_descriptor_serialize(
+ const struct lttng_session_descriptor *descriptor,
+ struct lttng_dynamic_buffer *buffer);
+
+enum lttng_session_descriptor_type
+lttng_session_descriptor_get_type(
+ const struct lttng_session_descriptor *descriptor);
+
+enum lttng_session_descriptor_output_type
+lttng_session_descriptor_get_output_type(
+ const struct lttng_session_descriptor *descriptor);
+
+void lttng_session_descriptor_get_local_output_uri(
+ const struct lttng_session_descriptor *descriptor,
+ struct lttng_uri *local_uri);
+
+void lttng_session_descriptor_get_network_output_uris(
+ const struct lttng_session_descriptor *descriptor,
+ struct lttng_uri *control,
+ struct lttng_uri *data);
+
+unsigned long long
+lttng_session_descriptor_live_get_timer_interval(
+ const struct lttng_session_descriptor *descriptor);
+
+int lttng_session_descriptor_set_session_name(
+ struct lttng_session_descriptor *descriptor,
+ const char *name);
+
+bool lttng_session_descriptor_is_output_destination_initialized(
+ const struct lttng_session_descriptor *descriptor);
+
+bool lttng_session_descriptor_has_output_directory(
+ const struct lttng_session_descriptor *descriptor);
+
+enum lttng_error_code lttng_session_descriptor_set_default_output(
+ struct lttng_session_descriptor *descriptor,
+ time_t *session_creation_time,
+ const char *absolute_home_path);
+
+int lttng_session_descriptor_assign(
+ struct lttng_session_descriptor *dst_descriptor,
+ const struct lttng_session_descriptor *src_descriptor);
+
+#endif /* LTTNG_SESSION_DESCRIPTOR_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSION_INTERNAL_H
-#define LTTNG_SESSION_INTERNAL_H
-
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-struct lttng_session_extended {
- struct {
- uint64_t value;
- uint8_t is_set;
- } LTTNG_PACKED creation_time;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSION_INTERNAL_H
+#define LTTNG_SESSION_INTERNAL_H
+
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+struct lttng_session_extended {
+ struct {
+ uint64_t value;
+ uint8_t is_set;
+ } LTTNG_PACKED creation_time;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_SESSION_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SNAPSHOT_INTERNAL_ABI_H
-#define LTTNG_SNAPSHOT_INTERNAL_ABI_H
-
-#include <limits.h>
-#include <stdint.h>
-#include <lttng/constant.h>
-#include <common/macros.h>
-
-/*
- * Object used for the snapshot API. This is opaque to the public library.
- */
-struct lttng_snapshot_output {
- /*
- * ID of the snapshot output. This is only used when they are listed. It is
- * assigned by the session daemon so when adding an output, this value will
- * not be used.
- */
- uint32_t id;
- /*
- * Maximum size in bytes of the snapshot meaning the total size of all
- * stream combined. A value of 0 is unlimited.
- */
- uint64_t max_size;
- /* Name of the output so it can be recognized easily when listing them. */
- char name[LTTNG_NAME_MAX];
- /* Destination of the output. See lttng(1) for URL format. */
- char ctrl_url[PATH_MAX];
- /* Destination of the output. See lttng(1) for URL format. */
- char data_url[PATH_MAX];
-} LTTNG_PACKED;
-
-/*
- * Snapshot output list object opaque to the user.
- */
-struct lttng_snapshot_output_list {
- /*
- * The position in the output array. This is changed by a get_next call.
- */
- int index;
-
- /*
- * Number of element in the array.
- */
- size_t count;
-
- /*
- * Contains snapshot output object.
- */
- struct lttng_snapshot_output *array;
-};
-
-#endif /* LTTNG_SNAPSHOT_INTERNAL_ABI_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SNAPSHOT_INTERNAL_ABI_H
+#define LTTNG_SNAPSHOT_INTERNAL_ABI_H
+
+#include <limits.h>
+#include <stdint.h>
+#include <lttng/constant.h>
+#include <common/macros.hpp>
+
+/*
+ * Object used for the snapshot API. This is opaque to the public library.
+ */
+struct lttng_snapshot_output {
+ /*
+ * ID of the snapshot output. This is only used when they are listed. It is
+ * assigned by the session daemon so when adding an output, this value will
+ * not be used.
+ */
+ uint32_t id;
+ /*
+ * Maximum size in bytes of the snapshot meaning the total size of all
+ * stream combined. A value of 0 is unlimited.
+ */
+ uint64_t max_size;
+ /* Name of the output so it can be recognized easily when listing them. */
+ char name[LTTNG_NAME_MAX];
+ /* Destination of the output. See lttng(1) for URL format. */
+ char ctrl_url[PATH_MAX];
+ /* Destination of the output. See lttng(1) for URL format. */
+ char data_url[PATH_MAX];
+} LTTNG_PACKED;
+
+/*
+ * Snapshot output list object opaque to the user.
+ */
+struct lttng_snapshot_output_list {
+ /*
+ * The position in the output array. This is changed by a get_next call.
+ */
+ int index;
+
+ /*
+ * Number of element in the array.
+ */
+ size_t count;
+
+ /*
+ * Contains snapshot output object.
+ */
+ struct lttng_snapshot_output *array;
+};
+
+#endif /* LTTNG_SNAPSHOT_INTERNAL_ABI_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRIGGER_INTERNAL_H
-#define LTTNG_TRIGGER_INTERNAL_H
-
-#include <common/credentials.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/lttng.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <urcu/ref.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct mi_writer;
-struct mi_lttng_error_query_callbacks;
-
-struct lttng_trigger {
- /* Reference counting is only exposed to internal users. */
- struct urcu_ref ref;
-
- struct lttng_condition *condition;
- struct lttng_action *action;
- char *name;
- /* For now only the uid portion of the credentials is used. */
- struct lttng_credentials creds;
- /*
- * Internal use only.
- * The unique token passed to the tracer to identify an event-rule
- * notification.
- */
- LTTNG_OPTIONAL(uint64_t) tracer_token;
-
- /*
- * Is the trigger registered?
- *
- * This is necessary since a reference holder might be interested in the
- * overall state of the trigger from the point of view of its owner.
- *
- * The main user is the action executor since we want to prevent the
- * execution of actions related to a trigger that is unregistered.
- *
- * Not considered for `is_equal`.
- */
- bool registered;
-
- /*
- * A "hidden" trigger is a trigger that is not externally listed.
- * It is used to hide triggers that are used internally by the session
- * daemon so that they can't be listed nor unregistered by external
- * clients.
- *
- * This is a property that can only be set internally by the session
- * daemon. As such, it is not serialized nor set by a
- * "create_from_buffer" constructor.
- *
- * The hidden property is preserved by copies.
- *
- * Note that notifications originating from an "hidden" trigger will not
- * be sent to clients that are not within the session daemon's process.
- */
- bool is_hidden;
-
- /*
- * The lock is used to protect against concurrent trigger execution and
- * trigger removal.
- */
- pthread_mutex_t lock;
-};
-
-struct lttng_triggers {
- struct lttng_dynamic_pointer_array array;
-};
-
-struct lttng_trigger_comm {
- /*
- * Credentials, only the uid portion is used for now.
- * Used as an override when desired by the root user.
- */
- uint64_t uid;
- /*
- * Length of the variable length payload (name, condition, and
- * an action).
- */
- uint32_t length;
- /* Includes '\0' terminator. */
- uint32_t name_length;
- /* A null-terminated name, a condition, and an action follow. */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_triggers_comm {
- uint32_t count;
- uint32_t length;
- /* Count * lttng_trigger_comm structure */
- char payload[];
-};
-
-ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view,
- struct lttng_trigger **trigger);
-
-int lttng_trigger_serialize(const struct lttng_trigger *trigger,
- struct lttng_payload *payload);
-
-bool lttng_trigger_validate(const struct lttng_trigger *trigger);
-
-int lttng_trigger_assign_name(
- struct lttng_trigger *dst, const struct lttng_trigger *src);
-
-void lttng_trigger_set_tracer_token(
- struct lttng_trigger *trigger, uint64_t token);
-
-uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger *trigger);
-
-int lttng_trigger_generate_name(struct lttng_trigger *trigger,
- uint64_t unique_id);
-
-bool lttng_trigger_is_equal(
- const struct lttng_trigger *a, const struct lttng_trigger *b);
-
-bool lttng_trigger_is_hidden(const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_hidden(struct lttng_trigger *trigger);
-
-void lttng_trigger_get(struct lttng_trigger *trigger);
-
-void lttng_trigger_put(struct lttng_trigger *trigger);
-
-/*
- * Serialize a trigger to a mi_writer.
- * Return LTTNG_OK in success, other enum lttng_error_code on error.
- */
-enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks);
-
-/*
- * Allocate a new set of triggers.
- * The returned object must be freed via lttng_triggers_destroy.
- */
-struct lttng_triggers *lttng_triggers_create(void);
-
-/*
- * Return the a pointer to a mutable element at index "index" of an
- * lttng_triggers set.
- *
- * This differs from the public `lttng_triggers_get_at_index` in that
- * the returned pointer to a mutable trigger.
- *
- * The ownership of the trigger set element is NOT transfered.
- * The returned object can NOT be freed via lttng_trigger_destroy.
- */
-struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(
- const struct lttng_triggers *triggers, unsigned int index);
-
-/*
- * Add a trigger to the triggers set.
- *
- * A reference to the added trigger is acquired on behalf of the trigger set
- * on success.
- */
-int lttng_triggers_add(
- struct lttng_triggers *triggers, struct lttng_trigger *trigger);
-
-/*
- * Remove all triggers marked as hidden from the provided trigger set.
- */
-int lttng_triggers_remove_hidden_triggers(struct lttng_triggers *triggers);
-
-/*
- * Serialize a trigger set to an lttng_payload object.
- * Return LTTNG_OK on success, negative lttng error code on error.
- */
-int lttng_triggers_serialize(const struct lttng_triggers *triggers,
- struct lttng_payload *payload);
-
-ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *view,
- struct lttng_triggers **triggers);
-
-/*
- * Serialize a trigger set to a mi_writer.
- * Return LTTNG_OK in success, other enum lttng_error_code on error.
- */
-enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks);
-
-const struct lttng_credentials *lttng_trigger_get_credentials(
- const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
- const struct lttng_credentials *creds);
-
-/*
- * Return the type of any underlying domain restriction. If no particular
- * requirement is present, returns LTTNG_DOMAIN_NONE.
- */
-enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction(
- const struct lttng_trigger *trigger);
-
-/*
- * Generate any bytecode related to the trigger.
- * On success LTTNG_OK. On error, returns lttng_error code.
- */
-enum lttng_error_code lttng_trigger_generate_bytecode(
- struct lttng_trigger *trigger,
- const struct lttng_credentials *creds);
-
-/*
- * Note that the trigger object is not locked by "copy" as it is const and
- * used with a number of 'const' triggers. If the trigger could be shared at
- * the moment of the copy, it is the caller's responsability to lock it for
- * the duration of the copy.
- */
-struct lttng_trigger *lttng_trigger_copy(const struct lttng_trigger *trigger);
-
-/*
- * A given trigger needs a tracer notifier if
- * it has an event-rule condition,
- * AND
- * it has one or more sessiond-execution action.
- */
-bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger);
-
-void lttng_trigger_set_as_registered(struct lttng_trigger *trigger);
-
-void lttng_trigger_set_as_unregistered(struct lttng_trigger *trigger);
-
-/*
- * The trigger must be locked before calling lttng_trigger_is_registered.
- *
- * The lock is necessary since a trigger can be unregistered at any time.
- *
- * Manipulations requiring that the trigger be registered must always acquire
- * the trigger lock for the duration of the manipulation using
- * `lttng_trigger_lock` and `lttng_trigger_unlock`.
- */
-bool lttng_trigger_is_registered(struct lttng_trigger *trigger);
-
-void lttng_trigger_lock(struct lttng_trigger *trigger);
-
-void lttng_trigger_unlock(struct lttng_trigger *trigger);
-
-enum lttng_trigger_status lttng_trigger_add_error_results(
- const struct lttng_trigger *trigger,
- struct lttng_error_query_results *results);
-
-enum lttng_trigger_status lttng_trigger_condition_add_error_results(
- const struct lttng_trigger *trigger,
- struct lttng_error_query_results *results);
-
-enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
- struct lttng_trigger *trigger,
- struct lttng_error_query_results *results);
-
-/*
- * Set the trigger name.
- *
- * A name is optional.
- * A name will be assigned on trigger registration if no name is set.
- *
- * The name is copied.
- *
- * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
- * if invalid parameters are passed.
- */
-enum lttng_trigger_status lttng_trigger_set_name(
- struct lttng_trigger *trigger, const char *name);
-
-#endif /* LTTNG_TRIGGER_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRIGGER_INTERNAL_H
+#define LTTNG_TRIGGER_INTERNAL_H
+
+#include <common/credentials.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/lttng.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <urcu/ref.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+
+struct lttng_trigger {
+ /* Reference counting is only exposed to internal users. */
+ struct urcu_ref ref;
+
+ struct lttng_condition *condition;
+ struct lttng_action *action;
+ char *name;
+ /* For now only the uid portion of the credentials is used. */
+ struct lttng_credentials creds;
+ /*
+ * Internal use only.
+ * The unique token passed to the tracer to identify an event-rule
+ * notification.
+ */
+ LTTNG_OPTIONAL(uint64_t) tracer_token;
+
+ /*
+ * Is the trigger registered?
+ *
+ * This is necessary since a reference holder might be interested in the
+ * overall state of the trigger from the point of view of its owner.
+ *
+ * The main user is the action executor since we want to prevent the
+ * execution of actions related to a trigger that is unregistered.
+ *
+ * Not considered for `is_equal`.
+ */
+ bool registered;
+
+ /*
+ * A "hidden" trigger is a trigger that is not externally listed.
+ * It is used to hide triggers that are used internally by the session
+ * daemon so that they can't be listed nor unregistered by external
+ * clients.
+ *
+ * This is a property that can only be set internally by the session
+ * daemon. As such, it is not serialized nor set by a
+ * "create_from_buffer" constructor.
+ *
+ * The hidden property is preserved by copies.
+ *
+ * Note that notifications originating from an "hidden" trigger will not
+ * be sent to clients that are not within the session daemon's process.
+ */
+ bool is_hidden;
+
+ /*
+ * The lock is used to protect against concurrent trigger execution and
+ * trigger removal.
+ */
+ pthread_mutex_t lock;
+};
+
+struct lttng_triggers {
+ struct lttng_dynamic_pointer_array array;
+};
+
+struct lttng_trigger_comm {
+ /*
+ * Credentials, only the uid portion is used for now.
+ * Used as an override when desired by the root user.
+ */
+ uint64_t uid;
+ /*
+ * Length of the variable length payload (name, condition, and
+ * an action).
+ */
+ uint32_t length;
+ /* Includes '\0' terminator. */
+ uint32_t name_length;
+ /* A null-terminated name, a condition, and an action follow. */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_triggers_comm {
+ uint32_t count;
+ uint32_t length;
+ /* Count * lttng_trigger_comm structure */
+ char payload[];
+};
+
+ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_trigger **trigger);
+
+int lttng_trigger_serialize(const struct lttng_trigger *trigger,
+ struct lttng_payload *payload);
+
+bool lttng_trigger_validate(const struct lttng_trigger *trigger);
+
+int lttng_trigger_assign_name(
+ struct lttng_trigger *dst, const struct lttng_trigger *src);
+
+void lttng_trigger_set_tracer_token(
+ struct lttng_trigger *trigger, uint64_t token);
+
+uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger *trigger);
+
+int lttng_trigger_generate_name(struct lttng_trigger *trigger,
+ uint64_t unique_id);
+
+bool lttng_trigger_is_equal(
+ const struct lttng_trigger *a, const struct lttng_trigger *b);
+
+bool lttng_trigger_is_hidden(const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_hidden(struct lttng_trigger *trigger);
+
+void lttng_trigger_get(struct lttng_trigger *trigger);
+
+void lttng_trigger_put(struct lttng_trigger *trigger);
+
+/*
+ * Serialize a trigger to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
+/*
+ * Allocate a new set of triggers.
+ * The returned object must be freed via lttng_triggers_destroy.
+ */
+struct lttng_triggers *lttng_triggers_create(void);
+
+/*
+ * Return the a pointer to a mutable element at index "index" of an
+ * lttng_triggers set.
+ *
+ * This differs from the public `lttng_triggers_get_at_index` in that
+ * the returned pointer to a mutable trigger.
+ *
+ * The ownership of the trigger set element is NOT transfered.
+ * The returned object can NOT be freed via lttng_trigger_destroy.
+ */
+struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(
+ const struct lttng_triggers *triggers, unsigned int index);
+
+/*
+ * Add a trigger to the triggers set.
+ *
+ * A reference to the added trigger is acquired on behalf of the trigger set
+ * on success.
+ */
+int lttng_triggers_add(
+ struct lttng_triggers *triggers, struct lttng_trigger *trigger);
+
+/*
+ * Remove all triggers marked as hidden from the provided trigger set.
+ */
+int lttng_triggers_remove_hidden_triggers(struct lttng_triggers *triggers);
+
+/*
+ * Serialize a trigger set to an lttng_payload object.
+ * Return LTTNG_OK on success, negative lttng error code on error.
+ */
+int lttng_triggers_serialize(const struct lttng_triggers *triggers,
+ struct lttng_payload *payload);
+
+ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_triggers **triggers);
+
+/*
+ * Serialize a trigger set to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
+const struct lttng_credentials *lttng_trigger_get_credentials(
+ const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds);
+
+/*
+ * Return the type of any underlying domain restriction. If no particular
+ * requirement is present, returns LTTNG_DOMAIN_NONE.
+ */
+enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction(
+ const struct lttng_trigger *trigger);
+
+/*
+ * Generate any bytecode related to the trigger.
+ * On success LTTNG_OK. On error, returns lttng_error code.
+ */
+enum lttng_error_code lttng_trigger_generate_bytecode(
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds);
+
+/*
+ * Note that the trigger object is not locked by "copy" as it is const and
+ * used with a number of 'const' triggers. If the trigger could be shared at
+ * the moment of the copy, it is the caller's responsability to lock it for
+ * the duration of the copy.
+ */
+struct lttng_trigger *lttng_trigger_copy(const struct lttng_trigger *trigger);
+
+/*
+ * A given trigger needs a tracer notifier if
+ * it has an event-rule condition,
+ * AND
+ * it has one or more sessiond-execution action.
+ */
+bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger);
+
+void lttng_trigger_set_as_registered(struct lttng_trigger *trigger);
+
+void lttng_trigger_set_as_unregistered(struct lttng_trigger *trigger);
+
+/*
+ * The trigger must be locked before calling lttng_trigger_is_registered.
+ *
+ * The lock is necessary since a trigger can be unregistered at any time.
+ *
+ * Manipulations requiring that the trigger be registered must always acquire
+ * the trigger lock for the duration of the manipulation using
+ * `lttng_trigger_lock` and `lttng_trigger_unlock`.
+ */
+bool lttng_trigger_is_registered(struct lttng_trigger *trigger);
+
+void lttng_trigger_lock(struct lttng_trigger *trigger);
+
+void lttng_trigger_unlock(struct lttng_trigger *trigger);
+
+enum lttng_trigger_status lttng_trigger_add_error_results(
+ const struct lttng_trigger *trigger,
+ struct lttng_error_query_results *results);
+
+enum lttng_trigger_status lttng_trigger_condition_add_error_results(
+ const struct lttng_trigger *trigger,
+ struct lttng_error_query_results *results);
+
+enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
+ struct lttng_trigger *trigger,
+ struct lttng_error_query_results *results);
+
+/*
+ * Set the trigger name.
+ *
+ * A name is optional.
+ * A name will be assigned on trigger registration if no name is set.
+ *
+ * The name is copied.
+ *
+ * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
+ * if invalid parameters are passed.
+ */
+enum lttng_trigger_status lttng_trigger_set_name(
+ struct lttng_trigger *trigger, const char *name);
+
+#endif /* LTTNG_TRIGGER_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
-#define LTTNG_USERSPACE_PROBE_INTERNAL_H
-
-#include <lttng/userspace-probe.h>
-#include <common/macros.h>
-#include <common/fd-handle.h>
-#include <stdbool.h>
-
-struct lttng_payload;
-struct lttng_payload_view;
-struct lttng_dynamic_buffer;
-struct mi_writer;
-
-typedef bool (*userspace_probe_location_equal_cb)(
- const struct lttng_userspace_probe_location *a,
- const struct lttng_userspace_probe_location *b);
-typedef unsigned long (*userspace_probe_location_hash_cb)(
- const struct lttng_userspace_probe_location *location);
-typedef enum lttng_error_code (*userspace_probe_location_mi)(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer);
-
-/*
- * No elf-specific comm structure is defined since no elf-specific payload is
- * currently needed.
- */
-struct lttng_userspace_probe_location_lookup_method_comm {
- /* enum lttng_userspace_probe_location_lookup_method_type */
- int8_t type;
- /* type-specific payload */
- char payload[];
-};
-
-/* Common ancestor of all userspace probe location lookup methods. */
-struct lttng_userspace_probe_location_lookup_method {
- enum lttng_userspace_probe_location_lookup_method_type type;
-};
-
-struct lttng_userspace_probe_location_lookup_method_elf {
- struct lttng_userspace_probe_location_lookup_method parent;
-};
-
-struct lttng_userspace_probe_location_lookup_method_sdt {
- struct lttng_userspace_probe_location_lookup_method parent;
-};
-
-struct lttng_userspace_probe_location_comm {
- /* enum lttng_userspace_probe_location_type */
- int8_t type;
- /*
- * Payload is composed of, in that order,
- * - type-specific payload
- * - struct lttng_userspace_probe_location_lookup_method_comm
- */
- char payload[];
-};
-
-struct lttng_userspace_probe_location_function_comm {
- /* Both lengths include the trailing \0. */
- uint32_t function_name_len;
- uint32_t binary_path_len;
- /*
- * Payload is composed of, in that order,
- * - function name (with trailing \0),
- * - absolute binary path (with trailing \0)
- */
- char payload[];
-} LTTNG_PACKED;
-
-struct lttng_userspace_probe_location_tracepoint_comm {
- /* The three lengths include the trailing \0. */
- uint32_t probe_name_len;
- uint32_t provider_name_len;
- uint32_t binary_path_len;
- /*
- * Payload is composed of, in that order,
- * - probe name (with trailing \0),
- * - provider name (with trailing \0),
- * - absolute binary path (with trailing \0)
- */
- char payload[];
-} LTTNG_PACKED;
-
-/* Common ancestor of all userspace probe locations. */
-struct lttng_userspace_probe_location {
- enum lttng_userspace_probe_location_type type;
- struct lttng_userspace_probe_location_lookup_method *lookup_method;
- userspace_probe_location_equal_cb equal;
- userspace_probe_location_hash_cb hash;
- userspace_probe_location_hash_cb mi;
-};
-
-struct lttng_userspace_probe_location_function {
- struct lttng_userspace_probe_location parent;
- char *function_name;
- char *binary_path;
- /*
- * binary_fd is a file descriptor to the executable file. It's open
- * early on to keep the backing inode valid over the course of the
- * intrumentation and use. It prevents deletion and reuse races.
- */
- struct fd_handle *binary_fd_handle;
- enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
-};
-
-struct lttng_userspace_probe_location_tracepoint {
- struct lttng_userspace_probe_location parent;
- char *probe_name;
- char *provider_name;
- char *binary_path;
- /*
- * binary_fd is a file descriptor to the executable file. It's open
- * early on to keep the backing inode valid over the course of the
- * intrumentation and use. It prevents deletion and reuse races.
- */
- struct fd_handle *binary_fd_handle;
-};
-
-int lttng_userspace_probe_location_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload);
-
-int lttng_userspace_probe_location_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **probe_location);
-
-/*
- * Returns a version of the location that is serialized to a contiguous region
- * of memory. Pass NULL to buffer to only get the storage requirement of the
- * flattened userspace probe location.
- */
-int lttng_userspace_probe_location_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer);
-
-struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
- const struct lttng_userspace_probe_location *location);
-
-bool lttng_userspace_probe_location_lookup_method_is_equal(
- const struct lttng_userspace_probe_location_lookup_method *a,
- const struct lttng_userspace_probe_location_lookup_method *b);
-
-bool lttng_userspace_probe_location_is_equal(
- const struct lttng_userspace_probe_location *a,
- const struct lttng_userspace_probe_location *b);
-
-unsigned long lttng_userspace_probe_location_hash(
- const struct lttng_userspace_probe_location *location);
-
-enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer);
-
-#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
+#define LTTNG_USERSPACE_PROBE_INTERNAL_H
+
+#include <lttng/userspace-probe.h>
+#include <common/macros.hpp>
+#include <common/fd-handle.hpp>
+#include <stdbool.h>
+
+struct lttng_payload;
+struct lttng_payload_view;
+struct lttng_dynamic_buffer;
+struct mi_writer;
+
+typedef bool (*userspace_probe_location_equal_cb)(
+ const struct lttng_userspace_probe_location *a,
+ const struct lttng_userspace_probe_location *b);
+typedef unsigned long (*userspace_probe_location_hash_cb)(
+ const struct lttng_userspace_probe_location *location);
+typedef enum lttng_error_code (*userspace_probe_location_mi)(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer);
+
+/*
+ * No elf-specific comm structure is defined since no elf-specific payload is
+ * currently needed.
+ */
+struct lttng_userspace_probe_location_lookup_method_comm {
+ /* enum lttng_userspace_probe_location_lookup_method_type */
+ int8_t type;
+ /* type-specific payload */
+ char payload[];
+};
+
+/* Common ancestor of all userspace probe location lookup methods. */
+struct lttng_userspace_probe_location_lookup_method {
+ enum lttng_userspace_probe_location_lookup_method_type type;
+};
+
+struct lttng_userspace_probe_location_lookup_method_elf {
+ struct lttng_userspace_probe_location_lookup_method parent;
+};
+
+struct lttng_userspace_probe_location_lookup_method_sdt {
+ struct lttng_userspace_probe_location_lookup_method parent;
+};
+
+struct lttng_userspace_probe_location_comm {
+ /* enum lttng_userspace_probe_location_type */
+ int8_t type;
+ /*
+ * Payload is composed of, in that order,
+ * - type-specific payload
+ * - struct lttng_userspace_probe_location_lookup_method_comm
+ */
+ char payload[];
+};
+
+struct lttng_userspace_probe_location_function_comm {
+ /* Both lengths include the trailing \0. */
+ uint32_t function_name_len;
+ uint32_t binary_path_len;
+ /*
+ * Payload is composed of, in that order,
+ * - function name (with trailing \0),
+ * - absolute binary path (with trailing \0)
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+struct lttng_userspace_probe_location_tracepoint_comm {
+ /* The three lengths include the trailing \0. */
+ uint32_t probe_name_len;
+ uint32_t provider_name_len;
+ uint32_t binary_path_len;
+ /*
+ * Payload is composed of, in that order,
+ * - probe name (with trailing \0),
+ * - provider name (with trailing \0),
+ * - absolute binary path (with trailing \0)
+ */
+ char payload[];
+} LTTNG_PACKED;
+
+/* Common ancestor of all userspace probe locations. */
+struct lttng_userspace_probe_location {
+ enum lttng_userspace_probe_location_type type;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method;
+ userspace_probe_location_equal_cb equal;
+ userspace_probe_location_hash_cb hash;
+ userspace_probe_location_hash_cb mi;
+};
+
+struct lttng_userspace_probe_location_function {
+ struct lttng_userspace_probe_location parent;
+ char *function_name;
+ char *binary_path;
+ /*
+ * binary_fd is a file descriptor to the executable file. It's open
+ * early on to keep the backing inode valid over the course of the
+ * intrumentation and use. It prevents deletion and reuse races.
+ */
+ struct fd_handle *binary_fd_handle;
+ enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
+};
+
+struct lttng_userspace_probe_location_tracepoint {
+ struct lttng_userspace_probe_location parent;
+ char *probe_name;
+ char *provider_name;
+ char *binary_path;
+ /*
+ * binary_fd is a file descriptor to the executable file. It's open
+ * early on to keep the backing inode valid over the course of the
+ * intrumentation and use. It prevents deletion and reuse races.
+ */
+ struct fd_handle *binary_fd_handle;
+};
+
+int lttng_userspace_probe_location_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct lttng_payload *payload);
+
+int lttng_userspace_probe_location_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_userspace_probe_location **probe_location);
+
+/*
+ * Returns a version of the location that is serialized to a contiguous region
+ * of memory. Pass NULL to buffer to only get the storage requirement of the
+ * flattened userspace probe location.
+ */
+int lttng_userspace_probe_location_flatten(
+ const struct lttng_userspace_probe_location *location,
+ struct lttng_dynamic_buffer *buffer);
+
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
+ const struct lttng_userspace_probe_location *location);
+
+bool lttng_userspace_probe_location_lookup_method_is_equal(
+ const struct lttng_userspace_probe_location_lookup_method *a,
+ const struct lttng_userspace_probe_location_lookup_method *b);
+
+bool lttng_userspace_probe_location_is_equal(
+ const struct lttng_userspace_probe_location *a,
+ const struct lttng_userspace_probe_location *b);
+
+unsigned long lttng_userspace_probe_location_hash(
+ const struct lttng_userspace_probe_location *location);
+
+enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer);
+
+#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2013-2014 Raphaël Beamonte <raphael.beamonte@gmail.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef VERSION_H
-#define VERSION_H
-
-#include <version.i>
-
-#endif /* VERSION_H */
--- /dev/null
+/*
+ * Copyright (C) 2013-2014 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#include <version.i>
+
+#endif /* VERSION_H */
lttng_consumerd_SOURCES = \
lttng-consumerd.cpp \
- lttng-consumerd.h \
+ lttng-consumerd.hpp \
health-consumerd.cpp \
- health-consumerd.h
+ health-consumerd.hpp
lttng_consumerd_LDADD = \
$(top_builddir)/src/common/libconsumer.la \
#include <ulimit.h>
#include <inttypes.h>
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-
-#include "lttng-consumerd.h"
-#include "health-consumerd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include "lttng-consumerd.hpp"
+#include "health-consumerd.hpp"
/* Global health check unix path */
static char health_unix_sock_path[PATH_MAX];
+++ /dev/null
-#ifndef HEALTH_CONSUMERD_H
-#define HEALTH_CONSUMERD_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#include <lttng/health-internal.h>
-
-enum health_type_consumerd {
- HEALTH_CONSUMERD_TYPE_CHANNEL = 0,
- HEALTH_CONSUMERD_TYPE_METADATA = 1,
- HEALTH_CONSUMERD_TYPE_DATA = 2,
- HEALTH_CONSUMERD_TYPE_SESSIOND = 3,
- HEALTH_CONSUMERD_TYPE_METADATA_TIMER = 4,
-
- NR_HEALTH_CONSUMERD_TYPES,
-};
-
-/* Consumerd health monitoring */
-extern struct health_app *health_consumerd;
-
-void *thread_manage_health_consumerd(void *data);
-
-extern int health_quit_pipe[2];
-
-#endif /* HEALTH_CONSUMERD_H */
--- /dev/null
+#ifndef HEALTH_CONSUMERD_H
+#define HEALTH_CONSUMERD_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#include <lttng/health-internal.hpp>
+
+enum health_type_consumerd {
+ HEALTH_CONSUMERD_TYPE_CHANNEL = 0,
+ HEALTH_CONSUMERD_TYPE_METADATA = 1,
+ HEALTH_CONSUMERD_TYPE_DATA = 2,
+ HEALTH_CONSUMERD_TYPE_SESSIOND = 3,
+ HEALTH_CONSUMERD_TYPE_METADATA_TIMER = 4,
+
+ NR_HEALTH_CONSUMERD_TYPES,
+};
+
+/* Consumerd health monitoring */
+extern struct health_app *health_consumerd;
+
+void *thread_manage_health_consumerd(void *data);
+
+extern int health_quit_pipe[2];
+
+#endif /* HEALTH_CONSUMERD_H */
#include <urcu/compiler.h>
#include <ulimit.h>
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/compat/getenv.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-
-#include "lttng-consumerd.h"
-#include "health-consumerd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include "lttng-consumerd.hpp"
+#include "health-consumerd.hpp"
/* threads (channel handling, poll, metadata, sessiond) */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CONSUMERD_H
-#define _LTTNG_CONSUMERD_H
-
-
-#define NR_LTTNG_CONSUMER_READY 1
-extern int lttng_consumer_ready;
-
-extern const char *tracing_group_name;
-
-/*
- * This function is dlsym-ed from a test, so needs to be exported. Making it
- * have a C linkage name makes it easier, as it avoids having to look up a
- * mangled name.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_consumer_type lttng_consumer_get_type();
-
-#endif /* _LTTNG_CONSUMERD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CONSUMERD_H
+#define _LTTNG_CONSUMERD_H
+
+
+#define NR_LTTNG_CONSUMER_READY 1
+extern int lttng_consumer_ready;
+
+extern const char *tracing_group_name;
+
+/*
+ * This function is dlsym-ed from a test, so needs to be exported. Making it
+ * have a C linkage name makes it easier, as it avoids having to look up a
+ * mangled name.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_consumer_type lttng_consumer_get_type();
+
+#endif /* _LTTNG_CONSUMERD_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMERD_TESTPOINT_H
-#define CONSUMERD_TESTPOINT_H
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(consumerd_data_thread_poll);
-
-#endif /* CONSUMERD_TESTPOINT_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMERD_TESTPOINT_H
+#define CONSUMERD_TESTPOINT_H
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(consumerd_data_thread_poll);
+
+#endif /* CONSUMERD_TESTPOINT_H */
#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
#include <inttypes.h>
#include <stdbool.h>
-#include <version.h>
+#include <version.hpp>
#include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/spawn-viewer.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/spawn-viewer.hpp>
+#include <common/utils.hpp>
#define COPY_BUFLEN 4096
#define RB_CRASH_DUMP_ABI_LEN 32
bin_PROGRAMS = lttng-relayd
-lttng_relayd_SOURCES = main.cpp lttng-relayd.h utils.h utils.cpp cmd.h \
- index.cpp index.h live.cpp live.h ctf-trace.cpp ctf-trace.h \
- cmd-2-1.cpp cmd-2-1.h \
- cmd-2-2.cpp cmd-2-2.h \
- cmd-2-4.cpp cmd-2-4.h \
- cmd-2-11.cpp cmd-2-11.h \
- health-relayd.cpp health-relayd.h \
- lttng-viewer-abi.h testpoint.h \
- viewer-stream.h viewer-stream.cpp \
- session.cpp session.h \
- stream.cpp stream.h \
- connection.cpp connection.h \
- viewer-session.cpp viewer-session.h \
- tracefile-array.cpp tracefile-array.h \
- tcp_keep_alive.cpp tcp_keep_alive.h \
- sessiond-trace-chunks.cpp sessiond-trace-chunks.h \
- backward-compatibility-group-by.cpp backward-compatibility-group-by.h
+lttng_relayd_SOURCES = main.cpp lttng-relayd.hpp utils.hpp utils.cpp cmd.hpp \
+ index.cpp index.hpp live.cpp live.hpp ctf-trace.cpp ctf-trace.hpp \
+ cmd-2-1.cpp cmd-2-1.hpp \
+ cmd-2-2.cpp cmd-2-2.hpp \
+ cmd-2-4.cpp cmd-2-4.hpp \
+ cmd-2-11.cpp cmd-2-11.hpp \
+ health-relayd.cpp health-relayd.hpp \
+ lttng-viewer-abi.hpp testpoint.hpp \
+ viewer-stream.hpp viewer-stream.cpp \
+ session.cpp session.hpp \
+ stream.cpp stream.hpp \
+ connection.cpp connection.hpp \
+ viewer-session.cpp viewer-session.hpp \
+ tracefile-array.cpp tracefile-array.hpp \
+ tcp_keep_alive.cpp tcp_keep_alive.hpp \
+ sessiond-trace-chunks.cpp sessiond-trace-chunks.hpp \
+ backward-compatibility-group-by.cpp backward-compatibility-group-by.hpp
# link on liblttngctl for check if relayd is already alive.
lttng_relayd_LDADD = $(URCU_LIBS) \
*
*/
-#include "common/time.h"
+#include "common/time.hpp"
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
-#include "backward-compatibility-group-by.h"
+#include "backward-compatibility-group-by.hpp"
#define DATETIME_REGEX \
".*-[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]-[0-2][0-9][0-5][0-9][0-5][0-9]$"
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef BACKWARD_COMPATIBILITY_GROUP_BY_H
-#define BACKWARD_COMPATIBILITY_GROUP_BY_H
-
-#include <time.h>
-
-char *backward_compat_group_by_session(const char *path,
- const char *local_session_name,
- time_t session_creation_time);
-
-#endif /* BACKWARD_COMPATIBILITY_GROUP_BY_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef BACKWARD_COMPATIBILITY_GROUP_BY_H
+#define BACKWARD_COMPATIBILITY_GROUP_BY_H
+
+#include <time.h>
+
+char *backward_compat_group_by_session(const char *path,
+ const char *local_session_name,
+ time_t session_creation_time);
+
+#endif /* BACKWARD_COMPATIBILITY_GROUP_BY_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/compat/string.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/compat/string.hpp>
#include <lttng/constant.h>
-#include "cmd-2-1.h"
-#include "utils.h"
+#include "cmd-2-1.hpp"
+#include "utils.hpp"
/*
* cmd_recv_stream_2_1 allocates path_name and channel_name.
+++ /dev/null
-#ifndef RELAYD_CMD_2_1_H
-#define RELAYD_CMD_2_1_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload,
- char **path_name, char **channel_name);
-
-#endif /* RELAYD_CMD_2_1_H */
--- /dev/null
+#ifndef RELAYD_CMD_2_1_H
+#define RELAYD_CMD_2_1_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload,
+ char **path_name, char **channel_name);
+
+#endif /* RELAYD_CMD_2_1_H */
#define _LGPL_SOURCE
#include <inttypes.h>
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
#include <lttng/constant.h>
-#include "cmd-2-11.h"
-#include "utils.h"
+#include "cmd-2-11.hpp"
+#include "utils.hpp"
int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
char *session_name, char *hostname, char *base_path,
+++ /dev/null
-/*
- * Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef RELAYD_CMD_2_11_H
-#define RELAYD_CMD_2_11_H
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-#include <common/uuid.h>
-
-int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
- char *session_name, char *hostname, char *base_path,
- uint32_t *live_timer, bool *snapshot,
- uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
- bool *has_current_chunk, uint64_t *current_chunk_id,
- time_t *creation_time,
- bool *session_name_contains_creation_time);
-
-int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
- char **ret_path_name, char **ret_channel_name,
- uint64_t *tracefile_size, uint64_t *tracefile_count,
- uint64_t *trace_archive_id);
-
-#endif /* RELAYD_CMD_2_11_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef RELAYD_CMD_2_11_H
+#define RELAYD_CMD_2_11_H
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+#include <common/uuid.hpp>
+
+int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
+ char *session_name, char *hostname, char *base_path,
+ uint32_t *live_timer, bool *snapshot,
+ uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
+ bool *has_current_chunk, uint64_t *current_chunk_id,
+ time_t *creation_time,
+ bool *session_name_contains_creation_time);
+
+int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
+ char **ret_path_name, char **ret_channel_name,
+ uint64_t *tracefile_size, uint64_t *tracefile_count,
+ uint64_t *trace_archive_id);
+
+#endif /* RELAYD_CMD_2_11_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
#include <lttng/constant.h>
-#include "cmd-2-2.h"
-#include "cmd-2-1.h"
-#include "utils.h"
+#include "cmd-2-2.hpp"
+#include "cmd-2-1.hpp"
+#include "utils.hpp"
/*
* cmd_recv_stream_2_2 allocates path_name and channel_name.
+++ /dev/null
-#ifndef RELAYD_CMD_2_2_H
-#define RELAYD_CMD_2_2_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_recv_stream_2_2(const struct lttng_buffer_view *payload,
- char **path_name, char **channel_name,
- uint64_t *tracefile_size, uint64_t *tracefile_count);
-
-#endif /* RELAYD_CMD_2_2_H */
--- /dev/null
+#ifndef RELAYD_CMD_2_2_H
+#define RELAYD_CMD_2_2_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_recv_stream_2_2(const struct lttng_buffer_view *payload,
+ char **path_name, char **channel_name,
+ uint64_t *tracefile_size, uint64_t *tracefile_count);
+
+#endif /* RELAYD_CMD_2_2_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/sessiond-comm/relayd.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/relayd.hpp>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
#include <lttng/constant.h>
-#include "cmd-2-4.h"
-#include "lttng-relayd.h"
+#include "cmd-2-4.hpp"
+#include "lttng-relayd.hpp"
int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
char *session_name, char *hostname,
+++ /dev/null
-#ifndef RELAYD_CMD_2_4_H
-#define RELAYD_CMD_2_4_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "lttng-relayd.h"
-#include <common/buffer-view.h>
-
-int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
- char *session_name, char *hostname,
- uint32_t *live_timer, bool *snapshot);
-
-#endif /* RELAYD_CMD_2_4_H */
--- /dev/null
+#ifndef RELAYD_CMD_2_4_H
+#define RELAYD_CMD_2_4_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "lttng-relayd.hpp"
+#include <common/buffer-view.hpp>
+
+int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
+ char *session_name, char *hostname,
+ uint32_t *live_timer, bool *snapshot);
+
+#endif /* RELAYD_CMD_2_4_H */
+++ /dev/null
-#ifndef RELAYD_CMD_H
-#define RELAYD_CMD_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include "cmd-2-1.h"
-#include "cmd-2-2.h"
-#include "cmd-2-4.h"
-#include "cmd-2-11.h"
-
-#endif /* RELAYD_CMD_H */
--- /dev/null
+#ifndef RELAYD_CMD_H
+#define RELAYD_CMD_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include "cmd-2-1.hpp"
+#include "cmd-2-2.hpp"
+#include "cmd-2-4.hpp"
+#include "cmd-2-11.hpp"
+
+#endif /* RELAYD_CMD_H */
*/
#define _LGPL_SOURCE
-#include <common/common.h>
+#include <common/common.hpp>
#include <urcu/rculist.h>
-#include "connection.h"
-#include "stream.h"
-#include "viewer-session.h"
+#include "connection.hpp"
+#include "stream.hpp"
+#include "viewer-session.hpp"
bool connection_get(struct relay_connection *conn)
{
+++ /dev/null
-#ifndef _CONNECTION_H
-#define _CONNECTION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/dynamic-buffer.h>
-
-#include "session.h"
-
-enum connection_type {
- RELAY_CONNECTION_UNKNOWN = 0,
- RELAY_DATA = 1,
- RELAY_CONTROL = 2,
- RELAY_VIEWER_COMMAND = 3,
- RELAY_VIEWER_NOTIFICATION = 4,
-};
-
-enum data_connection_state {
- DATA_CONNECTION_STATE_RECEIVE_HEADER = 0,
- DATA_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
-};
-
-enum ctrl_connection_state {
- CTRL_CONNECTION_STATE_RECEIVE_HEADER = 0,
- CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
-};
-
-struct data_connection_state_receive_header {
- uint64_t received, left_to_receive;
- char header_reception_buffer[sizeof(struct lttcomm_relayd_data_hdr)];
-};
-
-struct data_connection_state_receive_payload {
- uint64_t received, left_to_receive;
- struct lttcomm_relayd_data_hdr header;
- bool rotate_index;
-};
-
-struct ctrl_connection_state_receive_header {
- uint64_t received, left_to_receive;
-};
-
-struct ctrl_connection_state_receive_payload {
- uint64_t received, left_to_receive;
- struct lttcomm_relayd_hdr header;
-};
-
-/*
- * Internal structure to map a socket with the corresponding session.
- * A hashtable indexed on the socket FD is used for the lookups.
- *
- * Connections are assumed to be accessed from a single thread. Live
- * connections between the relay and a live client are only accessed
- * from the live worker thread.
- *
- * The connections between the consumerd/sessiond and the relayd are only
- * handled by the "main" worker thread (as in, the worker thread in main.c).
- *
- * This is why there are no back references to connections from the
- * sessions and session list.
- */
-struct relay_connection {
- struct lttcomm_sock *sock;
- struct cds_wfcq_node qnode;
-
- enum connection_type type;
- /*
- * session is only ever set for RELAY_CONTROL connection type.
- */
- struct relay_session *session;
- /*
- * viewer_session is only ever set for RELAY_VIEWER_COMMAND
- * connection type.
- */
- struct relay_viewer_session *viewer_session;
-
- /*
- * Protocol version to use for this connection. Only valid for
- * RELAY_CONTROL connection type.
- */
- uint32_t major;
- uint32_t minor;
-
- struct urcu_ref ref;
-
- bool version_check_done;
-
- /*
- * Node member of connection within global socket hash table.
- */
- struct lttng_ht_node_ulong sock_n;
- bool in_socket_ht;
- struct lttng_ht *socket_ht; /* HACK: Contained within this hash table. */
- struct rcu_head rcu_node; /* For call_rcu teardown. */
-
- union {
- struct {
- enum data_connection_state state_id;
- union {
- struct data_connection_state_receive_header receive_header;
- struct data_connection_state_receive_payload receive_payload;
- } state;
- } data;
- struct {
- enum ctrl_connection_state state_id;
- union {
- struct ctrl_connection_state_receive_header receive_header;
- struct ctrl_connection_state_receive_payload receive_payload;
- } state;
- struct lttng_dynamic_buffer reception_buffer;
- } ctrl;
- } protocol;
-};
-
-struct relay_connection *connection_create(struct lttcomm_sock *sock,
- enum connection_type type);
-struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht,
- int sock);
-int connection_reset_protocol_state(struct relay_connection *connection);
-bool connection_get(struct relay_connection *connection);
-void connection_put(struct relay_connection *connection);
-void connection_ht_add(struct lttng_ht *relay_connections_ht,
- struct relay_connection *conn);
-int connection_set_session(struct relay_connection *conn,
- struct relay_session *session);
-
-#endif /* _CONNECTION_H */
--- /dev/null
+#ifndef _CONNECTION_H
+#define _CONNECTION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/dynamic-buffer.hpp>
+
+#include "session.hpp"
+
+enum connection_type {
+ RELAY_CONNECTION_UNKNOWN = 0,
+ RELAY_DATA = 1,
+ RELAY_CONTROL = 2,
+ RELAY_VIEWER_COMMAND = 3,
+ RELAY_VIEWER_NOTIFICATION = 4,
+};
+
+enum data_connection_state {
+ DATA_CONNECTION_STATE_RECEIVE_HEADER = 0,
+ DATA_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
+};
+
+enum ctrl_connection_state {
+ CTRL_CONNECTION_STATE_RECEIVE_HEADER = 0,
+ CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD = 1,
+};
+
+struct data_connection_state_receive_header {
+ uint64_t received, left_to_receive;
+ char header_reception_buffer[sizeof(struct lttcomm_relayd_data_hdr)];
+};
+
+struct data_connection_state_receive_payload {
+ uint64_t received, left_to_receive;
+ struct lttcomm_relayd_data_hdr header;
+ bool rotate_index;
+};
+
+struct ctrl_connection_state_receive_header {
+ uint64_t received, left_to_receive;
+};
+
+struct ctrl_connection_state_receive_payload {
+ uint64_t received, left_to_receive;
+ struct lttcomm_relayd_hdr header;
+};
+
+/*
+ * Internal structure to map a socket with the corresponding session.
+ * A hashtable indexed on the socket FD is used for the lookups.
+ *
+ * Connections are assumed to be accessed from a single thread. Live
+ * connections between the relay and a live client are only accessed
+ * from the live worker thread.
+ *
+ * The connections between the consumerd/sessiond and the relayd are only
+ * handled by the "main" worker thread (as in, the worker thread in main.c).
+ *
+ * This is why there are no back references to connections from the
+ * sessions and session list.
+ */
+struct relay_connection {
+ struct lttcomm_sock *sock;
+ struct cds_wfcq_node qnode;
+
+ enum connection_type type;
+ /*
+ * session is only ever set for RELAY_CONTROL connection type.
+ */
+ struct relay_session *session;
+ /*
+ * viewer_session is only ever set for RELAY_VIEWER_COMMAND
+ * connection type.
+ */
+ struct relay_viewer_session *viewer_session;
+
+ /*
+ * Protocol version to use for this connection. Only valid for
+ * RELAY_CONTROL connection type.
+ */
+ uint32_t major;
+ uint32_t minor;
+
+ struct urcu_ref ref;
+
+ bool version_check_done;
+
+ /*
+ * Node member of connection within global socket hash table.
+ */
+ struct lttng_ht_node_ulong sock_n;
+ bool in_socket_ht;
+ struct lttng_ht *socket_ht; /* HACK: Contained within this hash table. */
+ struct rcu_head rcu_node; /* For call_rcu teardown. */
+
+ union {
+ struct {
+ enum data_connection_state state_id;
+ union {
+ struct data_connection_state_receive_header receive_header;
+ struct data_connection_state_receive_payload receive_payload;
+ } state;
+ } data;
+ struct {
+ enum ctrl_connection_state state_id;
+ union {
+ struct ctrl_connection_state_receive_header receive_header;
+ struct ctrl_connection_state_receive_payload receive_payload;
+ } state;
+ struct lttng_dynamic_buffer reception_buffer;
+ } ctrl;
+ } protocol;
+};
+
+struct relay_connection *connection_create(struct lttcomm_sock *sock,
+ enum connection_type type);
+struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht,
+ int sock);
+int connection_reset_protocol_state(struct relay_connection *connection);
+bool connection_get(struct relay_connection *connection);
+void connection_put(struct relay_connection *connection);
+void connection_ht_add(struct lttng_ht *relay_connections_ht,
+ struct relay_connection *conn);
+int connection_set_session(struct relay_connection *conn,
+ struct relay_session *session);
+
+#endif /* _CONNECTION_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
#include <urcu/rculist.h>
-#include "ctf-trace.h"
-#include "lttng-relayd.h"
-#include "stream.h"
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
static uint64_t last_relay_ctf_trace_id;
static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
+++ /dev/null
-#ifndef _CTF_TRACE_H
-#define _CTF_TRACE_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <inttypes.h>
-#include <urcu/ref.h>
-
-#include <common/hashtable/hashtable.h>
-
-#include "session.h"
-#include "stream.h"
-#include "viewer-stream.h"
-
-struct ctf_trace {
- struct urcu_ref ref; /* Every stream has a ref on the trace. */
- struct relay_session *session; /* Back ref to trace session */
-
- /* Trace sub-folder relative to the session output path. */
- char *path;
-
- /*
- * The ctf_trace lock nests inside the session lock.
- */
- pthread_mutex_t lock;
- uint64_t id;
- struct relay_viewer_stream *viewer_metadata_stream; /* RCU protected */
-
- /*
- * Relay streams associated with this ctf trace.
- * Updates are protected by the stream_list lock.
- * Traversals are protected by RCU.
- */
- struct cds_list_head stream_list;
- pthread_mutex_t stream_list_lock;
-
- /*
- * Node within session trace hash table. Node is indexed by
- * stream path name.
- */
- struct lttng_ht_node_str node;
- struct rcu_head rcu_node; /* For call_rcu teardown. */
-
- /*
- * True if the metadata stream of this trace was sent the viewer in the
- * past.
- */
- bool metadata_stream_sent_to_viewer;
-};
-
-struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
- const char *subpath);
-bool ctf_trace_get(struct ctf_trace *trace);
-void ctf_trace_put(struct ctf_trace *trace);
-
-int ctf_trace_close(struct ctf_trace *trace);
-
-struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trace *trace);
-
-#endif /* _CTF_TRACE_H */
--- /dev/null
+#ifndef _CTF_TRACE_H
+#define _CTF_TRACE_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <inttypes.h>
+#include <urcu/ref.h>
+
+#include <common/hashtable/hashtable.hpp>
+
+#include "session.hpp"
+#include "stream.hpp"
+#include "viewer-stream.hpp"
+
+struct ctf_trace {
+ struct urcu_ref ref; /* Every stream has a ref on the trace. */
+ struct relay_session *session; /* Back ref to trace session */
+
+ /* Trace sub-folder relative to the session output path. */
+ char *path;
+
+ /*
+ * The ctf_trace lock nests inside the session lock.
+ */
+ pthread_mutex_t lock;
+ uint64_t id;
+ struct relay_viewer_stream *viewer_metadata_stream; /* RCU protected */
+
+ /*
+ * Relay streams associated with this ctf trace.
+ * Updates are protected by the stream_list lock.
+ * Traversals are protected by RCU.
+ */
+ struct cds_list_head stream_list;
+ pthread_mutex_t stream_list_lock;
+
+ /*
+ * Node within session trace hash table. Node is indexed by
+ * stream path name.
+ */
+ struct lttng_ht_node_str node;
+ struct rcu_head rcu_node; /* For call_rcu teardown. */
+
+ /*
+ * True if the metadata stream of this trace was sent the viewer in the
+ * past.
+ */
+ bool metadata_stream_sent_to_viewer;
+};
+
+struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
+ const char *subpath);
+bool ctf_trace_get(struct ctf_trace *trace);
+void ctf_trace_put(struct ctf_trace *trace);
+
+int ctf_trace_close(struct ctf_trace *trace);
+
+struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trace *trace);
+
+#endif /* _CTF_TRACE_H */
#include <urcu/compiler.h>
#include <inttypes.h>
-#include <common/defaults.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/compat/poll.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-#include <common/compat/getenv.h>
-#include <common/fd-tracker/utils.h>
-
-#include "lttng-relayd.h"
-#include "health-relayd.h"
+#include <common/defaults.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/compat/poll.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/fd-tracker/utils.hpp>
+
+#include "lttng-relayd.hpp"
+#include "health-relayd.hpp"
/* Global health check unix path */
static
+++ /dev/null
-#ifndef HEALTH_RELAYD_H
-#define HEALTH_RELAYD_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <lttng/health-internal.h>
-
-#define LTTNG_RELAYD_HEALTH_ENV "LTTNG_RELAYD_HEALTH"
-
-enum health_type_relayd {
- HEALTH_RELAYD_TYPE_DISPATCHER = 0,
- HEALTH_RELAYD_TYPE_WORKER = 1,
- HEALTH_RELAYD_TYPE_LISTENER = 2,
- HEALTH_RELAYD_TYPE_LIVE_DISPATCHER = 3,
- HEALTH_RELAYD_TYPE_LIVE_WORKER = 4,
- HEALTH_RELAYD_TYPE_LIVE_LISTENER = 5,
-
- NR_HEALTH_RELAYD_TYPES,
-};
-
-extern struct health_app *health_relayd;
-
-extern int health_quit_pipe[2];
-
-void *thread_manage_health_relayd(void *data);
-
-#endif /* HEALTH_RELAYD_H */
--- /dev/null
+#ifndef HEALTH_RELAYD_H
+#define HEALTH_RELAYD_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <lttng/health-internal.hpp>
+
+#define LTTNG_RELAYD_HEALTH_ENV "LTTNG_RELAYD_HEALTH"
+
+enum health_type_relayd {
+ HEALTH_RELAYD_TYPE_DISPATCHER = 0,
+ HEALTH_RELAYD_TYPE_WORKER = 1,
+ HEALTH_RELAYD_TYPE_LISTENER = 2,
+ HEALTH_RELAYD_TYPE_LIVE_DISPATCHER = 3,
+ HEALTH_RELAYD_TYPE_LIVE_WORKER = 4,
+ HEALTH_RELAYD_TYPE_LIVE_LISTENER = 5,
+
+ NR_HEALTH_RELAYD_TYPES,
+};
+
+extern struct health_app *health_relayd;
+
+extern int health_quit_pipe[2];
+
+void *thread_manage_health_relayd(void *data);
+
+#endif /* HEALTH_RELAYD_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/compat/endian.h>
-
-#include "lttng-relayd.h"
-#include "stream.h"
-#include "index.h"
-#include "connection.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/compat/endian.hpp>
+
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
+#include "index.hpp"
+#include "connection.hpp"
/*
* Allocate a new relay index object. Pass the stream in which it is
+++ /dev/null
-#ifndef _RELAY_INDEX_H
-#define _RELAY_INDEX_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <inttypes.h>
-#include <pthread.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/index/index.h>
-
-struct relay_stream;
-struct relay_connection;
-struct lttcomm_relayd_index;
-
-struct relay_index {
- /*
- * index lock nests inside stream lock.
- */
- struct urcu_ref ref; /* Reference from getters. */
- struct relay_stream *stream; /* Back ref to stream */
-
- pthread_mutex_t lock;
- /*
- * index file on which to write the index data. May differ from
- * stream->index_file due to tracefile rotation.
- */
- struct lttng_index_file *index_file;
-
- /* Index packet data. This is the data that is written on disk. */
- struct ctf_packet_index index_data;
- /* Data + padding size of this packet, filled by the data thread. */
- uint64_t total_size;
-
- bool has_index_data;
- bool flushed;
- bool in_hash_table;
-
- /*
- * Node within indexes_ht that corresponds to this struct
- * relay_index. Indexed by net_seq_num, which is unique for this
- * index across the stream.
- */
- struct lttng_ht_node_u64 index_n;
- struct rcu_head rcu_node; /* For call_rcu teardown. */
-};
-
-struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
- uint64_t net_seq_num);
-void relay_index_put(struct relay_index *index);
-int relay_index_set_file(struct relay_index *index,
- struct lttng_index_file *index_file,
- uint64_t data_offset);
-int relay_index_set_data(struct relay_index *index,
- const struct ctf_packet_index *data);
-int relay_index_try_flush(struct relay_index *index);
-
-void relay_index_close_all(struct relay_stream *stream);
-void relay_index_close_partial_fd(struct relay_stream *stream);
-uint64_t relay_index_find_last(struct relay_stream *stream);
-int relay_index_switch_all_files(struct relay_stream *stream);
-int relay_index_set_control_data(struct relay_index *index,
- const struct lttcomm_relayd_index *data,
- unsigned int minor_version);
-
-#endif /* _RELAY_INDEX_H */
--- /dev/null
+#ifndef _RELAY_INDEX_H
+#define _RELAY_INDEX_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <inttypes.h>
+#include <pthread.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/index/index.hpp>
+
+struct relay_stream;
+struct relay_connection;
+struct lttcomm_relayd_index;
+
+struct relay_index {
+ /*
+ * index lock nests inside stream lock.
+ */
+ struct urcu_ref ref; /* Reference from getters. */
+ struct relay_stream *stream; /* Back ref to stream */
+
+ pthread_mutex_t lock;
+ /*
+ * index file on which to write the index data. May differ from
+ * stream->index_file due to tracefile rotation.
+ */
+ struct lttng_index_file *index_file;
+
+ /* Index packet data. This is the data that is written on disk. */
+ struct ctf_packet_index index_data;
+ /* Data + padding size of this packet, filled by the data thread. */
+ uint64_t total_size;
+
+ bool has_index_data;
+ bool flushed;
+ bool in_hash_table;
+
+ /*
+ * Node within indexes_ht that corresponds to this struct
+ * relay_index. Indexed by net_seq_num, which is unique for this
+ * index across the stream.
+ */
+ struct lttng_ht_node_u64 index_n;
+ struct rcu_head rcu_node; /* For call_rcu teardown. */
+};
+
+struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
+ uint64_t net_seq_num);
+void relay_index_put(struct relay_index *index);
+int relay_index_set_file(struct relay_index *index,
+ struct lttng_index_file *index_file,
+ uint64_t data_offset);
+int relay_index_set_data(struct relay_index *index,
+ const struct ctf_packet_index *data);
+int relay_index_try_flush(struct relay_index *index);
+
+void relay_index_close_all(struct relay_stream *stream);
+void relay_index_close_partial_fd(struct relay_stream *stream);
+uint64_t relay_index_find_last(struct relay_stream *stream);
+int relay_index_switch_all_files(struct relay_stream *stream);
+int relay_index_set_control_data(struct relay_index *index,
+ const struct lttcomm_relayd_index *data,
+ unsigned int minor_version);
+
+#endif /* _RELAY_INDEX_H */
#include <urcu/uatomic.h>
#include <string>
-#include <common/common.h>
-#include <common/compat/endian.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/defaults.h>
-#include <common/fd-tracker/utils.h>
-#include <common/fs-handle.h>
-#include <common/futex.h>
-#include <common/index/index.h>
-#include <common/sessiond-comm/inet.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/defaults.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/fs-handle.hpp>
+#include <common/futex.hpp>
+#include <common/index/index.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
#include <lttng/lttng.h>
-#include "cmd.h"
-#include "connection.h"
-#include "ctf-trace.h"
-#include "health-relayd.h"
-#include "live.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "stream.h"
-#include "testpoint.h"
-#include "utils.h"
-#include "viewer-session.h"
-#include "viewer-stream.h"
+#include "cmd.hpp"
+#include "connection.hpp"
+#include "ctf-trace.hpp"
+#include "health-relayd.hpp"
+#include "live.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "stream.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "viewer-session.hpp"
+#include "viewer-stream.hpp"
#define SESSION_BUF_DEFAULT_COUNT 16
+++ /dev/null
-#ifndef LTTNG_RELAYD_LIVE_H
-#define LTTNG_RELAYD_LIVE_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/uri.h>
-
-#include "lttng-relayd.h"
-
-int relayd_live_create(struct lttng_uri *live_uri);
-int relayd_live_stop(void);
-int relayd_live_join(void);
-
-#endif /* LTTNG_RELAYD_LIVE_H */
--- /dev/null
+#ifndef LTTNG_RELAYD_LIVE_H
+#define LTTNG_RELAYD_LIVE_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/uri.hpp>
+
+#include "lttng-relayd.hpp"
+
+int relayd_live_create(struct lttng_uri *live_uri);
+int relayd_live_stop(void);
+int relayd_live_join(void);
+
+#endif /* LTTNG_RELAYD_LIVE_H */
+++ /dev/null
-#ifndef LTTNG_RELAYD_H
-#define LTTNG_RELAYD_H
-
-/*
- * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/fd-tracker/fd-tracker.h>
-
-struct sessiond_trace_chunk_registry;
-
-/*
- * Queue used to enqueue relay requests
- */
-struct relay_conn_queue {
- struct cds_wfcq_head head;
- struct cds_wfcq_tail tail;
- int32_t futex;
-};
-
-enum relay_group_output_by {
- RELAYD_GROUP_OUTPUT_BY_UNKNOWN,
- RELAYD_GROUP_OUTPUT_BY_HOST,
- RELAYD_GROUP_OUTPUT_BY_SESSION,
-};
-
-/*
- * Contains stream indexed by ID. This is important since many commands lookup
- * streams only by ID thus also keeping them in this hash table makes the
- * search O(1).
- */
-extern struct lttng_ht *sessions_ht;
-extern struct lttng_ht *relay_streams_ht;
-extern struct lttng_ht *viewer_streams_ht;
-extern struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
-
-extern char *opt_output_path;
-extern const char *tracing_group_name;
-extern const char * const config_section_name;
-extern enum relay_group_output_by opt_group_output_by;
-
-extern int thread_quit_pipe[2];
-
-extern struct fd_tracker *the_fd_tracker;
-
-void lttng_relay_notify_ready(void);
-int lttng_relay_stop_threads(void);
-
-#endif /* LTTNG_RELAYD_H */
--- /dev/null
+#ifndef LTTNG_RELAYD_H
+#define LTTNG_RELAYD_H
+
+/*
+ * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+
+struct sessiond_trace_chunk_registry;
+
+/*
+ * Queue used to enqueue relay requests
+ */
+struct relay_conn_queue {
+ struct cds_wfcq_head head;
+ struct cds_wfcq_tail tail;
+ int32_t futex;
+};
+
+enum relay_group_output_by {
+ RELAYD_GROUP_OUTPUT_BY_UNKNOWN,
+ RELAYD_GROUP_OUTPUT_BY_HOST,
+ RELAYD_GROUP_OUTPUT_BY_SESSION,
+};
+
+/*
+ * Contains stream indexed by ID. This is important since many commands lookup
+ * streams only by ID thus also keeping them in this hash table makes the
+ * search O(1).
+ */
+extern struct lttng_ht *sessions_ht;
+extern struct lttng_ht *relay_streams_ht;
+extern struct lttng_ht *viewer_streams_ht;
+extern struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
+
+extern char *opt_output_path;
+extern const char *tracing_group_name;
+extern const char * const config_section_name;
+extern enum relay_group_output_by opt_group_output_by;
+
+extern int thread_quit_pipe[2];
+
+extern struct fd_tracker *the_fd_tracker;
+
+void lttng_relay_notify_ready(void);
+int lttng_relay_stop_threads(void);
+
+#endif /* LTTNG_RELAYD_H */
+++ /dev/null
-#ifndef LTTNG_VIEWER_ABI_H
-#define LTTNG_VIEWER_ABI_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#include <limits.h>
-#include <common/macros.h>
-
-#define LTTNG_VIEWER_PATH_MAX 4096
-#define LTTNG_VIEWER_NAME_MAX 255
-#define LTTNG_VIEWER_HOST_NAME_MAX 64
-
-/* Flags in reply to get_next_index and get_packet. */
-enum {
- /* New metadata is required to read this packet. */
- LTTNG_VIEWER_FLAG_NEW_METADATA = (1 << 0),
- /* New stream got added to the trace. */
- LTTNG_VIEWER_FLAG_NEW_STREAM = (1 << 1),
-};
-
-enum lttng_viewer_command {
- LTTNG_VIEWER_CONNECT = 1,
- LTTNG_VIEWER_LIST_SESSIONS = 2,
- LTTNG_VIEWER_ATTACH_SESSION = 3,
- LTTNG_VIEWER_GET_NEXT_INDEX = 4,
- LTTNG_VIEWER_GET_PACKET = 5,
- LTTNG_VIEWER_GET_METADATA = 6,
- LTTNG_VIEWER_GET_NEW_STREAMS = 7,
- LTTNG_VIEWER_CREATE_SESSION = 8,
- LTTNG_VIEWER_DETACH_SESSION = 9,
-};
-
-enum lttng_viewer_attach_return_code {
- LTTNG_VIEWER_ATTACH_OK = 1, /* The attach command succeeded. */
- LTTNG_VIEWER_ATTACH_ALREADY = 2, /* A viewer is already attached. */
- LTTNG_VIEWER_ATTACH_UNK = 3, /* The session ID is unknown. */
- LTTNG_VIEWER_ATTACH_NOT_LIVE = 4, /* The session is not live. */
- LTTNG_VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */
- LTTNG_VIEWER_ATTACH_NO_SESSION = 6, /* No viewer session created. */
-};
-
-enum lttng_viewer_next_index_return_code {
- LTTNG_VIEWER_INDEX_OK = 1, /* Index is available. */
- LTTNG_VIEWER_INDEX_RETRY = 2, /* Index not yet available. */
- LTTNG_VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */
- LTTNG_VIEWER_INDEX_ERR = 4, /* Unknow error. */
- LTTNG_VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */
- LTTNG_VIEWER_INDEX_EOF = 6, /* End of index file. */
-};
-
-enum lttng_viewer_get_packet_return_code {
- LTTNG_VIEWER_GET_PACKET_OK = 1,
- LTTNG_VIEWER_GET_PACKET_RETRY = 2,
- LTTNG_VIEWER_GET_PACKET_ERR = 3,
- LTTNG_VIEWER_GET_PACKET_EOF = 4,
-};
-
-enum lttng_viewer_get_metadata_return_code {
- LTTNG_VIEWER_METADATA_OK = 1,
- LTTNG_VIEWER_NO_NEW_METADATA = 2,
- LTTNG_VIEWER_METADATA_ERR = 3,
-};
-
-enum lttng_viewer_connection_type {
- LTTNG_VIEWER_CLIENT_COMMAND = 1,
- LTTNG_VIEWER_CLIENT_NOTIFICATION = 2,
-};
-
-enum lttng_viewer_seek {
- /* Receive the trace packets from the beginning. */
- LTTNG_VIEWER_SEEK_BEGINNING = 1,
- /* Receive the trace packets from now. */
- LTTNG_VIEWER_SEEK_LAST = 2,
-};
-
-enum lttng_viewer_new_streams_return_code {
- LTTNG_VIEWER_NEW_STREAMS_OK = 1, /* If new streams are being sent. */
- LTTNG_VIEWER_NEW_STREAMS_NO_NEW = 2, /* If no new streams are available. */
- LTTNG_VIEWER_NEW_STREAMS_ERR = 3, /* Error. */
- LTTNG_VIEWER_NEW_STREAMS_HUP = 4, /* Session closed. */
-};
-
-enum lttng_viewer_create_session_return_code {
- LTTNG_VIEWER_CREATE_SESSION_OK = 1,
- LTTNG_VIEWER_CREATE_SESSION_ERR = 2,
-};
-
-enum lttng_viewer_detach_session_return_code {
- LTTNG_VIEWER_DETACH_SESSION_OK = 1,
- LTTNG_VIEWER_DETACH_SESSION_UNK = 2,
- LTTNG_VIEWER_DETACH_SESSION_ERR = 3,
-};
-
-struct lttng_viewer_session {
- uint64_t id;
- uint32_t live_timer;
- uint32_t clients;
- uint32_t streams;
- char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
- char session_name[LTTNG_VIEWER_NAME_MAX];
-} LTTNG_PACKED;
-
-struct lttng_viewer_stream {
- uint64_t id;
- uint64_t ctf_trace_id;
- uint32_t metadata_flag;
- char path_name[LTTNG_VIEWER_PATH_MAX];
- char channel_name[LTTNG_VIEWER_NAME_MAX];
-} LTTNG_PACKED;
-
-struct lttng_viewer_cmd {
- uint64_t data_size; /* data size following this header */
- uint32_t cmd; /* enum lttcomm_relayd_command */
- uint32_t cmd_version; /* command version */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_CONNECT payload.
- */
-struct lttng_viewer_connect {
- /* session ID assigned by the relay for command connections */
- uint64_t viewer_session_id;
- uint32_t major;
- uint32_t minor;
- uint32_t type; /* enum lttng_viewer_connection_type */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_LIST_SESSIONS payload.
- */
-struct lttng_viewer_list_sessions {
- uint32_t sessions_count;
- char session_list[]; /* struct lttng_viewer_session */
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_ATTACH_SESSION payload.
- */
-struct lttng_viewer_attach_session_request {
- uint64_t session_id;
- uint64_t offset; /* unused for now */
- uint32_t seek; /* enum lttng_viewer_seek */
-} LTTNG_PACKED;
-
-struct lttng_viewer_attach_session_response {
- /* enum lttng_viewer_attach_return_code */
- uint32_t status;
- uint32_t streams_count;
- /* struct lttng_viewer_stream */
- char stream_list[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_NEXT_INDEX payload.
- */
-struct lttng_viewer_get_next_index {
- uint64_t stream_id;
-} __attribute__ ((__packed__));
-
-struct lttng_viewer_index {
- uint64_t offset;
- uint64_t packet_size;
- uint64_t content_size;
- uint64_t timestamp_begin;
- uint64_t timestamp_end;
- uint64_t events_discarded;
- uint64_t stream_id;
- uint32_t status; /* enum lttng_viewer_next_index_return_code */
- uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
-} __attribute__ ((__packed__));
-
-/*
- * LTTNG_VIEWER_GET_PACKET payload.
- */
-struct lttng_viewer_get_packet {
- uint64_t stream_id;
- uint64_t offset;
- uint32_t len;
-} LTTNG_PACKED;
-
-struct lttng_viewer_trace_packet {
- uint32_t status; /* enum lttng_viewer_get_packet_return_code */
- uint32_t len;
- uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
- char data[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_METADATA payload.
- */
-struct lttng_viewer_get_metadata {
- uint64_t stream_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_metadata_packet {
- uint64_t len;
- uint32_t status; /* enum lttng_viewer_get_metadata_return_code */
- char data[];
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_GET_NEW_STREAMS payload.
- */
-struct lttng_viewer_new_streams_request {
- uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_new_streams_response {
- /* enum lttng_viewer_new_streams_return_code */
- uint32_t status;
- uint32_t streams_count;
- /* struct lttng_viewer_stream */
- char stream_list[];
-} LTTNG_PACKED;
-
-struct lttng_viewer_create_session_response {
- /* enum lttng_viewer_create_session_return_code */
- uint32_t status;
-} LTTNG_PACKED;
-
-/*
- * LTTNG_VIEWER_DETACH_SESSION payload.
- */
-struct lttng_viewer_detach_session_request {
- uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttng_viewer_detach_session_response {
- /* enum lttng_viewer_detach_session_return_code */
- uint32_t status;
-} LTTNG_PACKED;
-
-#endif /* LTTNG_VIEWER_ABI_H */
--- /dev/null
+#ifndef LTTNG_VIEWER_ABI_H
+#define LTTNG_VIEWER_ABI_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#include <limits.h>
+#include <common/macros.hpp>
+
+#define LTTNG_VIEWER_PATH_MAX 4096
+#define LTTNG_VIEWER_NAME_MAX 255
+#define LTTNG_VIEWER_HOST_NAME_MAX 64
+
+/* Flags in reply to get_next_index and get_packet. */
+enum {
+ /* New metadata is required to read this packet. */
+ LTTNG_VIEWER_FLAG_NEW_METADATA = (1 << 0),
+ /* New stream got added to the trace. */
+ LTTNG_VIEWER_FLAG_NEW_STREAM = (1 << 1),
+};
+
+enum lttng_viewer_command {
+ LTTNG_VIEWER_CONNECT = 1,
+ LTTNG_VIEWER_LIST_SESSIONS = 2,
+ LTTNG_VIEWER_ATTACH_SESSION = 3,
+ LTTNG_VIEWER_GET_NEXT_INDEX = 4,
+ LTTNG_VIEWER_GET_PACKET = 5,
+ LTTNG_VIEWER_GET_METADATA = 6,
+ LTTNG_VIEWER_GET_NEW_STREAMS = 7,
+ LTTNG_VIEWER_CREATE_SESSION = 8,
+ LTTNG_VIEWER_DETACH_SESSION = 9,
+};
+
+enum lttng_viewer_attach_return_code {
+ LTTNG_VIEWER_ATTACH_OK = 1, /* The attach command succeeded. */
+ LTTNG_VIEWER_ATTACH_ALREADY = 2, /* A viewer is already attached. */
+ LTTNG_VIEWER_ATTACH_UNK = 3, /* The session ID is unknown. */
+ LTTNG_VIEWER_ATTACH_NOT_LIVE = 4, /* The session is not live. */
+ LTTNG_VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */
+ LTTNG_VIEWER_ATTACH_NO_SESSION = 6, /* No viewer session created. */
+};
+
+enum lttng_viewer_next_index_return_code {
+ LTTNG_VIEWER_INDEX_OK = 1, /* Index is available. */
+ LTTNG_VIEWER_INDEX_RETRY = 2, /* Index not yet available. */
+ LTTNG_VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */
+ LTTNG_VIEWER_INDEX_ERR = 4, /* Unknow error. */
+ LTTNG_VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */
+ LTTNG_VIEWER_INDEX_EOF = 6, /* End of index file. */
+};
+
+enum lttng_viewer_get_packet_return_code {
+ LTTNG_VIEWER_GET_PACKET_OK = 1,
+ LTTNG_VIEWER_GET_PACKET_RETRY = 2,
+ LTTNG_VIEWER_GET_PACKET_ERR = 3,
+ LTTNG_VIEWER_GET_PACKET_EOF = 4,
+};
+
+enum lttng_viewer_get_metadata_return_code {
+ LTTNG_VIEWER_METADATA_OK = 1,
+ LTTNG_VIEWER_NO_NEW_METADATA = 2,
+ LTTNG_VIEWER_METADATA_ERR = 3,
+};
+
+enum lttng_viewer_connection_type {
+ LTTNG_VIEWER_CLIENT_COMMAND = 1,
+ LTTNG_VIEWER_CLIENT_NOTIFICATION = 2,
+};
+
+enum lttng_viewer_seek {
+ /* Receive the trace packets from the beginning. */
+ LTTNG_VIEWER_SEEK_BEGINNING = 1,
+ /* Receive the trace packets from now. */
+ LTTNG_VIEWER_SEEK_LAST = 2,
+};
+
+enum lttng_viewer_new_streams_return_code {
+ LTTNG_VIEWER_NEW_STREAMS_OK = 1, /* If new streams are being sent. */
+ LTTNG_VIEWER_NEW_STREAMS_NO_NEW = 2, /* If no new streams are available. */
+ LTTNG_VIEWER_NEW_STREAMS_ERR = 3, /* Error. */
+ LTTNG_VIEWER_NEW_STREAMS_HUP = 4, /* Session closed. */
+};
+
+enum lttng_viewer_create_session_return_code {
+ LTTNG_VIEWER_CREATE_SESSION_OK = 1,
+ LTTNG_VIEWER_CREATE_SESSION_ERR = 2,
+};
+
+enum lttng_viewer_detach_session_return_code {
+ LTTNG_VIEWER_DETACH_SESSION_OK = 1,
+ LTTNG_VIEWER_DETACH_SESSION_UNK = 2,
+ LTTNG_VIEWER_DETACH_SESSION_ERR = 3,
+};
+
+struct lttng_viewer_session {
+ uint64_t id;
+ uint32_t live_timer;
+ uint32_t clients;
+ uint32_t streams;
+ char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
+ char session_name[LTTNG_VIEWER_NAME_MAX];
+} LTTNG_PACKED;
+
+struct lttng_viewer_stream {
+ uint64_t id;
+ uint64_t ctf_trace_id;
+ uint32_t metadata_flag;
+ char path_name[LTTNG_VIEWER_PATH_MAX];
+ char channel_name[LTTNG_VIEWER_NAME_MAX];
+} LTTNG_PACKED;
+
+struct lttng_viewer_cmd {
+ uint64_t data_size; /* data size following this header */
+ uint32_t cmd; /* enum lttcomm_relayd_command */
+ uint32_t cmd_version; /* command version */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_CONNECT payload.
+ */
+struct lttng_viewer_connect {
+ /* session ID assigned by the relay for command connections */
+ uint64_t viewer_session_id;
+ uint32_t major;
+ uint32_t minor;
+ uint32_t type; /* enum lttng_viewer_connection_type */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_LIST_SESSIONS payload.
+ */
+struct lttng_viewer_list_sessions {
+ uint32_t sessions_count;
+ char session_list[]; /* struct lttng_viewer_session */
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_ATTACH_SESSION payload.
+ */
+struct lttng_viewer_attach_session_request {
+ uint64_t session_id;
+ uint64_t offset; /* unused for now */
+ uint32_t seek; /* enum lttng_viewer_seek */
+} LTTNG_PACKED;
+
+struct lttng_viewer_attach_session_response {
+ /* enum lttng_viewer_attach_return_code */
+ uint32_t status;
+ uint32_t streams_count;
+ /* struct lttng_viewer_stream */
+ char stream_list[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_NEXT_INDEX payload.
+ */
+struct lttng_viewer_get_next_index {
+ uint64_t stream_id;
+} __attribute__ ((__packed__));
+
+struct lttng_viewer_index {
+ uint64_t offset;
+ uint64_t packet_size;
+ uint64_t content_size;
+ uint64_t timestamp_begin;
+ uint64_t timestamp_end;
+ uint64_t events_discarded;
+ uint64_t stream_id;
+ uint32_t status; /* enum lttng_viewer_next_index_return_code */
+ uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
+} __attribute__ ((__packed__));
+
+/*
+ * LTTNG_VIEWER_GET_PACKET payload.
+ */
+struct lttng_viewer_get_packet {
+ uint64_t stream_id;
+ uint64_t offset;
+ uint32_t len;
+} LTTNG_PACKED;
+
+struct lttng_viewer_trace_packet {
+ uint32_t status; /* enum lttng_viewer_get_packet_return_code */
+ uint32_t len;
+ uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
+ char data[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_METADATA payload.
+ */
+struct lttng_viewer_get_metadata {
+ uint64_t stream_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_metadata_packet {
+ uint64_t len;
+ uint32_t status; /* enum lttng_viewer_get_metadata_return_code */
+ char data[];
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_GET_NEW_STREAMS payload.
+ */
+struct lttng_viewer_new_streams_request {
+ uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_new_streams_response {
+ /* enum lttng_viewer_new_streams_return_code */
+ uint32_t status;
+ uint32_t streams_count;
+ /* struct lttng_viewer_stream */
+ char stream_list[];
+} LTTNG_PACKED;
+
+struct lttng_viewer_create_session_response {
+ /* enum lttng_viewer_create_session_return_code */
+ uint32_t status;
+} LTTNG_PACKED;
+
+/*
+ * LTTNG_VIEWER_DETACH_SESSION payload.
+ */
+struct lttng_viewer_detach_session_request {
+ uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttng_viewer_detach_session_response {
+ /* enum lttng_viewer_detach_session_return_code */
+ uint32_t status;
+} LTTNG_PACKED;
+
+#endif /* LTTNG_VIEWER_ABI_H */
#include <algorithm>
#include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/compat/endian.h>
-#include <common/compat/getenv.h>
-#include <common/defaults.h>
-#include <common/daemonize.h>
-#include <common/futex.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/inet.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/align.h>
-#include <common/ini-config/ini-config.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/string-utils/format.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/fd-tracker/utils.h>
-
-#include "backward-compatibility-group-by.h"
-#include "cmd.h"
-#include "connection.h"
-#include "ctf-trace.h"
-#include "health-relayd.h"
-#include "index.h"
-#include "live.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "sessiond-trace-chunks.h"
-#include "stream.h"
-#include "tcp_keep_alive.h"
-#include "testpoint.h"
-#include "tracefile-array.h"
-#include "utils.h"
-#include "version.h"
-#include "viewer-stream.h"
+#include <common/common.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/defaults.hpp>
+#include <common/daemonize.hpp>
+#include <common/futex.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/align.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fd-tracker/utils.hpp>
+
+#include "backward-compatibility-group-by.hpp"
+#include "cmd.hpp"
+#include "connection.hpp"
+#include "ctf-trace.hpp"
+#include "health-relayd.hpp"
+#include "index.hpp"
+#include "live.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "sessiond-trace-chunks.hpp"
+#include "stream.hpp"
+#include "tcp_keep_alive.hpp"
+#include "testpoint.hpp"
+#include "tracefile-array.hpp"
+#include "utils.hpp"
+#include "version.hpp"
+#include "viewer-stream.hpp"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
*/
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/compat/path.h>
-#include <common/fd-tracker/utils.h>
-#include <common/time.h>
-#include <common/utils.h>
-#include <common/uuid.h>
+#include <common/common.hpp>
+#include <common/compat/path.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/time.hpp>
+#include <common/utils.hpp>
+#include <common/uuid.hpp>
#include <urcu/rculist.h>
#include <sys/stat.h>
-#include "ctf-trace.h"
-#include "lttng-relayd.h"
-#include "session.h"
-#include "sessiond-trace-chunks.h"
-#include "stream.h"
-#include <common/defaults.h>
-#include "utils.h"
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "sessiond-trace-chunks.hpp"
+#include "stream.hpp"
+#include <common/defaults.hpp>
+#include "utils.hpp"
/* Global session id used in the session creation. */
static uint64_t last_relay_session_id;
+++ /dev/null
-#ifndef _SESSION_H
-#define _SESSION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-#include <lttng/constant.h>
-#include <common/hashtable/hashtable.h>
-#include <common/uuid.h>
-#include <common/trace-chunk.h>
-#include <common/optional.h>
-
-/*
- * Represents a session for the relay point of view
- */
-struct relay_session {
- /*
- * This session id is generated by the relay daemon to guarantee
- * its uniqueness even when serving multiple session daemons.
- * It is used to match a set of streams to their session.
- */
- uint64_t id;
- /*
- * ID of the session in the session daemon's domain.
- * This information is only provided by 2.11+ peers.
- */
- LTTNG_OPTIONAL(uint64_t) id_sessiond;
- /*
- * Only provided by 2.11+ peers. However, the UUID is set to 'nil' in
- * the other cases.
- */
- lttng_uuid sessiond_uuid;
- /*
- * Contains the creation time on the session daemon's end for 2.11+
- * peers. Otherwise, this contains the session creation time on the
- * relay daemon's end.
- */
- LTTNG_OPTIONAL(time_t) creation_time;
- /* Must _not_ be empty for 2.4+ peers. */
- char session_name[LTTNG_NAME_MAX];
- char hostname[LTTNG_HOST_NAME_MAX];
- char base_path[LTTNG_PATH_MAX];
- /*
- * Session output path relative to relayd's output path.
- * Will be empty when interacting with peers < 2.11 since their
- * streams' path are expressed relative to the relay daemon's
- * output path.
- */
- char output_path[LTTNG_PATH_MAX];
- uint32_t live_timer;
-
- /* Session in snapshot mode. */
- bool snapshot;
-
- /*
- * Session has no back reference to its connection because it
- * has a life-time that can be longer than the consumer connection's
- * life-time; a reference can still be held by the viewer
- * connection through the viewer streams.
- */
-
- struct urcu_ref ref;
-
- mutable pthread_mutex_t lock;
-
- /* major/minor version used for this session. */
- uint32_t major;
- uint32_t minor;
-
- bool viewer_attached;
- /* Tell if the session connection has been closed on the streaming side. */
- bool connection_closed;
-
- /*
- * Tell if the session is currently living in a exiting relayd and
- * should be cleaned forcefully without waiting for pending data or
- * pending ctrl data.
- */
- bool aborted;
-
- bool session_name_contains_creation_time;
- /* Whether session has performed an explicit rotation. */
- bool has_rotated;
-
- /* Contains ctf_trace object of that session indexed by path name. */
- struct lttng_ht *ctf_traces_ht;
-
- /*
- * This contains streams that are received on that connection.
- * It's used to store them until we get the streams sent
- * command. When this is received, we remove those streams from
- * the list and publish them.
- *
- * Updates are protected by the recv_list_lock.
- * Traversals are protected by RCU.
- * recv_list_lock also protects stream_count.
- */
- struct cds_list_head recv_list; /* RCU list. */
- uint32_t stream_count;
- pthread_mutex_t recv_list_lock;
-
- /*
- * Flag checked and exchanged with uatomic_cmpxchg to tell the
- * viewer-side if new streams got added since the last check.
- */
- unsigned long new_streams;
-
- /*
- * Node in the global session hash table.
- */
- struct lttng_ht_node_u64 session_n;
- /*
- * Member of the session list in struct relay_viewer_session.
- * Updates are protected by the relay_viewer_session
- * session_list_lock. Traversals are protected by RCU.
- */
- struct cds_list_head viewer_session_node;
- struct lttng_trace_chunk *current_trace_chunk;
- struct lttng_trace_chunk *pending_closure_trace_chunk;
- /*
- * Prevent live viewers from taking of copy of the chunk
- * while new chunk has a temporary directory name.
- */
- bool ongoing_rotation;
- struct lttng_directory_handle *output_directory;
- struct rcu_head rcu_node; /* For call_rcu teardown. */
-};
-
-struct relay_session *session_create(const char *session_name,
- const char *hostname, const char *base_path,
- uint32_t live_timer,
- bool snapshot,
- const lttng_uuid sessiond_uuid,
- const uint64_t *id_sessiond,
- const uint64_t *current_chunk_id,
- const time_t *creation_time,
- uint32_t major,
- uint32_t minor,
- bool session_name_contains_creation_timestamp);
-struct relay_session *session_get_by_id(uint64_t id);
-bool session_get(struct relay_session *session);
-void session_put(struct relay_session *session);
-
-int session_close(struct relay_session *session);
-int session_abort(struct relay_session *session);
-
-bool session_has_ongoing_rotation(const struct relay_session *session);
-
-void print_sessions(void);
-
-#endif /* _SESSION_H */
--- /dev/null
+#ifndef _SESSION_H
+#define _SESSION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+#include <lttng/constant.h>
+#include <common/hashtable/hashtable.hpp>
+#include <common/uuid.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/optional.hpp>
+
+/*
+ * Represents a session for the relay point of view
+ */
+struct relay_session {
+ /*
+ * This session id is generated by the relay daemon to guarantee
+ * its uniqueness even when serving multiple session daemons.
+ * It is used to match a set of streams to their session.
+ */
+ uint64_t id;
+ /*
+ * ID of the session in the session daemon's domain.
+ * This information is only provided by 2.11+ peers.
+ */
+ LTTNG_OPTIONAL(uint64_t) id_sessiond;
+ /*
+ * Only provided by 2.11+ peers. However, the UUID is set to 'nil' in
+ * the other cases.
+ */
+ lttng_uuid sessiond_uuid;
+ /*
+ * Contains the creation time on the session daemon's end for 2.11+
+ * peers. Otherwise, this contains the session creation time on the
+ * relay daemon's end.
+ */
+ LTTNG_OPTIONAL(time_t) creation_time;
+ /* Must _not_ be empty for 2.4+ peers. */
+ char session_name[LTTNG_NAME_MAX];
+ char hostname[LTTNG_HOST_NAME_MAX];
+ char base_path[LTTNG_PATH_MAX];
+ /*
+ * Session output path relative to relayd's output path.
+ * Will be empty when interacting with peers < 2.11 since their
+ * streams' path are expressed relative to the relay daemon's
+ * output path.
+ */
+ char output_path[LTTNG_PATH_MAX];
+ uint32_t live_timer;
+
+ /* Session in snapshot mode. */
+ bool snapshot;
+
+ /*
+ * Session has no back reference to its connection because it
+ * has a life-time that can be longer than the consumer connection's
+ * life-time; a reference can still be held by the viewer
+ * connection through the viewer streams.
+ */
+
+ struct urcu_ref ref;
+
+ mutable pthread_mutex_t lock;
+
+ /* major/minor version used for this session. */
+ uint32_t major;
+ uint32_t minor;
+
+ bool viewer_attached;
+ /* Tell if the session connection has been closed on the streaming side. */
+ bool connection_closed;
+
+ /*
+ * Tell if the session is currently living in a exiting relayd and
+ * should be cleaned forcefully without waiting for pending data or
+ * pending ctrl data.
+ */
+ bool aborted;
+
+ bool session_name_contains_creation_time;
+ /* Whether session has performed an explicit rotation. */
+ bool has_rotated;
+
+ /* Contains ctf_trace object of that session indexed by path name. */
+ struct lttng_ht *ctf_traces_ht;
+
+ /*
+ * This contains streams that are received on that connection.
+ * It's used to store them until we get the streams sent
+ * command. When this is received, we remove those streams from
+ * the list and publish them.
+ *
+ * Updates are protected by the recv_list_lock.
+ * Traversals are protected by RCU.
+ * recv_list_lock also protects stream_count.
+ */
+ struct cds_list_head recv_list; /* RCU list. */
+ uint32_t stream_count;
+ pthread_mutex_t recv_list_lock;
+
+ /*
+ * Flag checked and exchanged with uatomic_cmpxchg to tell the
+ * viewer-side if new streams got added since the last check.
+ */
+ unsigned long new_streams;
+
+ /*
+ * Node in the global session hash table.
+ */
+ struct lttng_ht_node_u64 session_n;
+ /*
+ * Member of the session list in struct relay_viewer_session.
+ * Updates are protected by the relay_viewer_session
+ * session_list_lock. Traversals are protected by RCU.
+ */
+ struct cds_list_head viewer_session_node;
+ struct lttng_trace_chunk *current_trace_chunk;
+ struct lttng_trace_chunk *pending_closure_trace_chunk;
+ /*
+ * Prevent live viewers from taking of copy of the chunk
+ * while new chunk has a temporary directory name.
+ */
+ bool ongoing_rotation;
+ struct lttng_directory_handle *output_directory;
+ struct rcu_head rcu_node; /* For call_rcu teardown. */
+};
+
+struct relay_session *session_create(const char *session_name,
+ const char *hostname, const char *base_path,
+ uint32_t live_timer,
+ bool snapshot,
+ const lttng_uuid sessiond_uuid,
+ const uint64_t *id_sessiond,
+ const uint64_t *current_chunk_id,
+ const time_t *creation_time,
+ uint32_t major,
+ uint32_t minor,
+ bool session_name_contains_creation_timestamp);
+struct relay_session *session_get_by_id(uint64_t id);
+bool session_get(struct relay_session *session);
+void session_put(struct relay_session *session);
+
+int session_close(struct relay_session *session);
+int session_abort(struct relay_session *session);
+
+bool session_has_ongoing_rotation(const struct relay_session *session);
+
+void print_sessions(void);
+
+#endif /* _SESSION_H */
*
*/
-#include "sessiond-trace-chunks.h"
+#include "sessiond-trace-chunks.hpp"
#include <urcu.h>
#include <urcu/rculfhash.h>
#include <urcu/ref.h>
-#include <common/macros.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/trace-chunk-registry.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/string-utils/format.h>
+#include <common/macros.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/string-utils/format.hpp>
#include <stdio.h>
#include <inttypes.h>
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TRACE_CHUNK_REGISTRY_H
-#define SESSIOND_TRACE_CHUNK_REGISTRY_H
-
-#include <common/uuid.h>
-#include <common/trace-chunk.h>
-#include <stdint.h>
-
-/*
- * A session trace chunk registry allows the relay daemon to share trace chunks
- * used by different "relay sessions" when they were created for the same
- * user-visible session daemon session. Tracing multiple domains (e.g. ust and
- * kernel) results in per-domain relay sessions being created.
- *
- * Sharing trace chunks, and their output directory more specifically, is
- * essential to properly implement session rotations. The sharing of output
- * directory handles allows directory renames to be performed once and without
- * races that would stem from from multiple renames.
- */
-struct sessiond_trace_chunk_registry;
-
-struct sessiond_trace_chunk_registry *
-sessiond_trace_chunk_registry_create(void);
-
-void sessiond_trace_chunk_registry_destroy(
- struct sessiond_trace_chunk_registry *sessiond_registry);
-
-int sessiond_trace_chunk_registry_session_created(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid);
-
-int sessiond_trace_chunk_registry_session_destroyed(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid);
-
-struct lttng_trace_chunk *sessiond_trace_chunk_registry_publish_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid, uint64_t session_id,
- struct lttng_trace_chunk *chunk);
-
-struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_anonymous_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid,
- uint64_t session_id);
-
-struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid,
- uint64_t session_id, uint64_t chunk_id);
-
-int sessiond_trace_chunk_registry_chunk_exists(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid sessiond_uuid,
- uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
-
-#endif /* SESSIOND_TRACE_CHUNK_REGISTRY_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TRACE_CHUNK_REGISTRY_H
+#define SESSIOND_TRACE_CHUNK_REGISTRY_H
+
+#include <common/uuid.hpp>
+#include <common/trace-chunk.hpp>
+#include <stdint.h>
+
+/*
+ * A session trace chunk registry allows the relay daemon to share trace chunks
+ * used by different "relay sessions" when they were created for the same
+ * user-visible session daemon session. Tracing multiple domains (e.g. ust and
+ * kernel) results in per-domain relay sessions being created.
+ *
+ * Sharing trace chunks, and their output directory more specifically, is
+ * essential to properly implement session rotations. The sharing of output
+ * directory handles allows directory renames to be performed once and without
+ * races that would stem from from multiple renames.
+ */
+struct sessiond_trace_chunk_registry;
+
+struct sessiond_trace_chunk_registry *
+sessiond_trace_chunk_registry_create(void);
+
+void sessiond_trace_chunk_registry_destroy(
+ struct sessiond_trace_chunk_registry *sessiond_registry);
+
+int sessiond_trace_chunk_registry_session_created(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid);
+
+int sessiond_trace_chunk_registry_session_destroyed(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid);
+
+struct lttng_trace_chunk *sessiond_trace_chunk_registry_publish_chunk(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid, uint64_t session_id,
+ struct lttng_trace_chunk *chunk);
+
+struct lttng_trace_chunk *
+sessiond_trace_chunk_registry_get_anonymous_chunk(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid,
+ uint64_t session_id);
+
+struct lttng_trace_chunk *
+sessiond_trace_chunk_registry_get_chunk(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid,
+ uint64_t session_id, uint64_t chunk_id);
+
+int sessiond_trace_chunk_registry_chunk_exists(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid sessiond_uuid,
+ uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
+
+#endif /* SESSIOND_TRACE_CHUNK_REGISTRY_H */
#define _LGPL_SOURCE
#include <algorithm>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/fs-handle.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/fs-handle.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/utils.hpp>
#include <sys/stat.h>
#include <urcu/rculist.h>
-#include "lttng-relayd.h"
-#include "index.h"
-#include "stream.h"
-#include "viewer-stream.h"
+#include "lttng-relayd.hpp"
+#include "index.hpp"
+#include "stream.hpp"
+#include "viewer-stream.hpp"
#include <sys/types.h>
#include <fcntl.h>
+++ /dev/null
-#ifndef _STREAM_H
-#define _STREAM_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/trace-chunk.h>
-#include <common/optional.h>
-#include <common/buffer-view.h>
-
-#include "session.h"
-#include "tracefile-array.h"
-
-struct lttcomm_relayd_index;
-
-struct relay_stream_rotation {
- /*
- * Indicates if the stream's data and index have been rotated. A
- * rotation is considered completed when both rotations have occurred.
- */
- bool data_rotated;
- bool index_rotated;
- /*
- * Packet sequence number of the first packet of the new trace chunk to
- * which the stream is rotating.
- */
- uint64_t packet_seq_num;
- /*
- * Monotonically increasing previous network sequence number of first
- * data packet of the new trace chunk to which the stream is rotating.
- */
- uint64_t prev_data_net_seq;
- struct lttng_trace_chunk *next_trace_chunk;
-};
-
-/*
- * Represents a stream in the relay
- */
-struct relay_stream {
- uint64_t stream_handle;
-
- struct urcu_ref ref;
- /* Back reference to trace. Protected by refcount on trace object. */
- struct ctf_trace *trace;
-
- /*
- * To protect from concurrent read/update. The viewer stream
- * lock nests inside the stream lock. The stream lock nests
- * inside the ctf_trace lock.
- */
- pthread_mutex_t lock;
- /* previous data sequence number written to disk. */
- uint64_t prev_data_seq;
- /* previous index sequence number written to disk. */
- uint64_t prev_index_seq;
- /* seq num to encounter before closing. */
- uint64_t last_net_seq_num;
-
- struct fs_handle *file;
- /* index file on which to write the index data. */
- struct lttng_index_file *index_file;
-
- char *path_name;
- char *channel_name;
-
- /* On-disk circular buffer of tracefiles. */
- uint64_t tracefile_size;
- uint64_t tracefile_size_current;
- /* Max number of trace files for this stream. */
- uint64_t tracefile_count;
- /*
- * Index of the currently active file for this stream's on-disk
- * ring buffer.
- */
- uint64_t tracefile_current_index;
- /*
- * Indicates that the on-disk buffer has wrapped around. Stream
- * files shall be unlinked before being opened after this has occurred.
- */
- bool tracefile_wrapped_around;
-
- /*
- * Position in the tracefile where we have the full index also on disk.
- */
- uint64_t pos_after_last_complete_data_index;
-
- /*
- * Counts the number of received indexes. The "tag" associated
- * with an index is taken before incrementing this seqcount.
- * Therefore, the sequence tag associated with the last index
- * received is always index_received_seqcount - 1.
- */
- uint64_t index_received_seqcount;
-
- /*
- * Packet sequence number of the last received packet index.
- * Only populated when interacting with CTF_INDEX 1.1+.
- */
- LTTNG_OPTIONAL(uint64_t) received_packet_seq_num;
-
- /*
- * Tracefile array is an index of the stream trace files,
- * indexed by position. It allows keeping track of the oldest
- * available indexes when overwriting trace files in tracefile
- * rotation.
- */
- struct tracefile_array *tfa;
-
- bool closed; /* Stream is closed. */
- bool close_requested; /* Close command has been received. */
-
- /*
- * Counts number of indexes in indexes_ht. Redundant info.
- * Protected by stream lock.
- */
- int indexes_in_flight;
- struct lttng_ht *indexes_ht;
-
- /*
- * If the stream is inactive, this field is updated with the
- * live beacon timestamp end, when it is active, this
- * field == -1ULL.
- */
- uint64_t beacon_ts_end;
-
- /* CTF stream ID, -1ULL when unset (first packet not received yet). */
- uint64_t ctf_stream_id;
-
- /* Indicate if the stream was initialized for a data pending command. */
- bool data_pending_check_done;
-
- /* Is this stream a metadata stream ? */
- bool is_metadata;
- /* Amount of metadata received (bytes). */
- uint64_t metadata_received;
-
- /*
- * Member of the stream list in struct ctf_trace.
- * Updates are protected by the stream_list_lock.
- * Traversals are protected by RCU.
- */
- struct cds_list_head stream_node;
- /*
- * Temporary list belonging to the connection until all streams
- * are received for that connection.
- * Member of the stream recv list in the connection.
- * Updates are protected by the stream_recv_list_lock.
- * Traversals are protected by RCU.
- */
- bool in_recv_list;
- struct cds_list_head recv_node;
- /* Protected by session lock. */
- bool published;
- /* Notified viewer that no new metadata is available. */
- bool no_new_metadata_notified;
- /*
- * Node of stream within global stream hash table.
- */
- struct lttng_ht_node_u64 node;
- bool in_stream_ht; /* is stream in stream hash table. */
- struct rcu_head rcu_node; /* For call_rcu teardown. */
- /*
- * The trace chunk to which the file currently being produced (if any)
- * belongs.
- *
- * Note that a relay stream can have no output trace chunk. For
- * instance, after a session stop followed by a session clear,
- * streams will not have an output trace chunk until the session
- * is resumed.
- */
- struct lttng_trace_chunk *trace_chunk;
- LTTNG_OPTIONAL(struct relay_stream_rotation) ongoing_rotation;
- uint64_t completed_rotation_count;
-};
-
-struct relay_stream *stream_create(struct ctf_trace *trace,
- uint64_t stream_handle, char *path_name,
- char *channel_name, uint64_t tracefile_size,
- uint64_t tracefile_count);
-
-struct relay_stream *stream_get_by_id(uint64_t stream_id);
-bool stream_get(struct relay_stream *stream);
-void stream_put(struct relay_stream *stream);
-int stream_rotate_output_files(struct relay_session *session,
- struct relay_stream *stream);
-int stream_set_pending_rotation(struct relay_stream *stream,
- struct lttng_trace_chunk *next_trace_chunk,
- uint64_t rotation_sequence_number);
-void try_stream_close(struct relay_stream *stream);
-void stream_publish(struct relay_stream *stream);
-int stream_init_packet(struct relay_stream *stream, size_t packet_size,
- bool *file_rotated);
-int stream_write(struct relay_stream *stream,
- const struct lttng_buffer_view *packet, size_t padding_len);
-/* Called after the reception of a complete data packet. */
-int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
- bool rotate_index, bool *flushed, uint64_t total_size);
-int stream_complete_packet(struct relay_stream *stream,
- size_t packet_total_size, uint64_t sequence_number,
- bool index_flushed);
-/* Index info is in host endianness. */
-int stream_add_index(struct relay_stream *stream,
- const struct lttcomm_relayd_index *index_info);
-int stream_reset_file(struct relay_stream *stream);
-
-void print_relay_streams(void);
-
-#endif /* _STREAM_H */
--- /dev/null
+#ifndef _STREAM_H
+#define _STREAM_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/optional.hpp>
+#include <common/buffer-view.hpp>
+
+#include "session.hpp"
+#include "tracefile-array.hpp"
+
+struct lttcomm_relayd_index;
+
+struct relay_stream_rotation {
+ /*
+ * Indicates if the stream's data and index have been rotated. A
+ * rotation is considered completed when both rotations have occurred.
+ */
+ bool data_rotated;
+ bool index_rotated;
+ /*
+ * Packet sequence number of the first packet of the new trace chunk to
+ * which the stream is rotating.
+ */
+ uint64_t packet_seq_num;
+ /*
+ * Monotonically increasing previous network sequence number of first
+ * data packet of the new trace chunk to which the stream is rotating.
+ */
+ uint64_t prev_data_net_seq;
+ struct lttng_trace_chunk *next_trace_chunk;
+};
+
+/*
+ * Represents a stream in the relay
+ */
+struct relay_stream {
+ uint64_t stream_handle;
+
+ struct urcu_ref ref;
+ /* Back reference to trace. Protected by refcount on trace object. */
+ struct ctf_trace *trace;
+
+ /*
+ * To protect from concurrent read/update. The viewer stream
+ * lock nests inside the stream lock. The stream lock nests
+ * inside the ctf_trace lock.
+ */
+ pthread_mutex_t lock;
+ /* previous data sequence number written to disk. */
+ uint64_t prev_data_seq;
+ /* previous index sequence number written to disk. */
+ uint64_t prev_index_seq;
+ /* seq num to encounter before closing. */
+ uint64_t last_net_seq_num;
+
+ struct fs_handle *file;
+ /* index file on which to write the index data. */
+ struct lttng_index_file *index_file;
+
+ char *path_name;
+ char *channel_name;
+
+ /* On-disk circular buffer of tracefiles. */
+ uint64_t tracefile_size;
+ uint64_t tracefile_size_current;
+ /* Max number of trace files for this stream. */
+ uint64_t tracefile_count;
+ /*
+ * Index of the currently active file for this stream's on-disk
+ * ring buffer.
+ */
+ uint64_t tracefile_current_index;
+ /*
+ * Indicates that the on-disk buffer has wrapped around. Stream
+ * files shall be unlinked before being opened after this has occurred.
+ */
+ bool tracefile_wrapped_around;
+
+ /*
+ * Position in the tracefile where we have the full index also on disk.
+ */
+ uint64_t pos_after_last_complete_data_index;
+
+ /*
+ * Counts the number of received indexes. The "tag" associated
+ * with an index is taken before incrementing this seqcount.
+ * Therefore, the sequence tag associated with the last index
+ * received is always index_received_seqcount - 1.
+ */
+ uint64_t index_received_seqcount;
+
+ /*
+ * Packet sequence number of the last received packet index.
+ * Only populated when interacting with CTF_INDEX 1.1+.
+ */
+ LTTNG_OPTIONAL(uint64_t) received_packet_seq_num;
+
+ /*
+ * Tracefile array is an index of the stream trace files,
+ * indexed by position. It allows keeping track of the oldest
+ * available indexes when overwriting trace files in tracefile
+ * rotation.
+ */
+ struct tracefile_array *tfa;
+
+ bool closed; /* Stream is closed. */
+ bool close_requested; /* Close command has been received. */
+
+ /*
+ * Counts number of indexes in indexes_ht. Redundant info.
+ * Protected by stream lock.
+ */
+ int indexes_in_flight;
+ struct lttng_ht *indexes_ht;
+
+ /*
+ * If the stream is inactive, this field is updated with the
+ * live beacon timestamp end, when it is active, this
+ * field == -1ULL.
+ */
+ uint64_t beacon_ts_end;
+
+ /* CTF stream ID, -1ULL when unset (first packet not received yet). */
+ uint64_t ctf_stream_id;
+
+ /* Indicate if the stream was initialized for a data pending command. */
+ bool data_pending_check_done;
+
+ /* Is this stream a metadata stream ? */
+ bool is_metadata;
+ /* Amount of metadata received (bytes). */
+ uint64_t metadata_received;
+
+ /*
+ * Member of the stream list in struct ctf_trace.
+ * Updates are protected by the stream_list_lock.
+ * Traversals are protected by RCU.
+ */
+ struct cds_list_head stream_node;
+ /*
+ * Temporary list belonging to the connection until all streams
+ * are received for that connection.
+ * Member of the stream recv list in the connection.
+ * Updates are protected by the stream_recv_list_lock.
+ * Traversals are protected by RCU.
+ */
+ bool in_recv_list;
+ struct cds_list_head recv_node;
+ /* Protected by session lock. */
+ bool published;
+ /* Notified viewer that no new metadata is available. */
+ bool no_new_metadata_notified;
+ /*
+ * Node of stream within global stream hash table.
+ */
+ struct lttng_ht_node_u64 node;
+ bool in_stream_ht; /* is stream in stream hash table. */
+ struct rcu_head rcu_node; /* For call_rcu teardown. */
+ /*
+ * The trace chunk to which the file currently being produced (if any)
+ * belongs.
+ *
+ * Note that a relay stream can have no output trace chunk. For
+ * instance, after a session stop followed by a session clear,
+ * streams will not have an output trace chunk until the session
+ * is resumed.
+ */
+ struct lttng_trace_chunk *trace_chunk;
+ LTTNG_OPTIONAL(struct relay_stream_rotation) ongoing_rotation;
+ uint64_t completed_rotation_count;
+};
+
+struct relay_stream *stream_create(struct ctf_trace *trace,
+ uint64_t stream_handle, char *path_name,
+ char *channel_name, uint64_t tracefile_size,
+ uint64_t tracefile_count);
+
+struct relay_stream *stream_get_by_id(uint64_t stream_id);
+bool stream_get(struct relay_stream *stream);
+void stream_put(struct relay_stream *stream);
+int stream_rotate_output_files(struct relay_session *session,
+ struct relay_stream *stream);
+int stream_set_pending_rotation(struct relay_stream *stream,
+ struct lttng_trace_chunk *next_trace_chunk,
+ uint64_t rotation_sequence_number);
+void try_stream_close(struct relay_stream *stream);
+void stream_publish(struct relay_stream *stream);
+int stream_init_packet(struct relay_stream *stream, size_t packet_size,
+ bool *file_rotated);
+int stream_write(struct relay_stream *stream,
+ const struct lttng_buffer_view *packet, size_t padding_len);
+/* Called after the reception of a complete data packet. */
+int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
+ bool rotate_index, bool *flushed, uint64_t total_size);
+int stream_complete_packet(struct relay_stream *stream,
+ size_t packet_total_size, uint64_t sequence_number,
+ bool index_flushed);
+/* Index info is in host endianness. */
+int stream_add_index(struct relay_stream *stream,
+ const struct lttcomm_relayd_index *index_info);
+int stream_reset_file(struct relay_stream *stream);
+
+void print_relay_streams(void);
+
+#endif /* _STREAM_H */
#include <sys/socket.h>
#include <limits.h>
-#include <common/compat/getenv.h>
-#include <common/time.h>
-#include <common/defaults.h>
-#include <common/ini-config/ini-config.h>
+#include <common/compat/getenv.hpp>
+#include <common/time.hpp>
+#include <common/defaults.hpp>
+#include <common/ini-config/ini-config.hpp>
-#include "tcp_keep_alive.h"
+#include "tcp_keep_alive.hpp"
#define SOLARIS_IDLE_TIME_MIN_S 10
#define SOLARIS_IDLE_TIME_MAX_S 864000 /* 10 days */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef RELAYD_TCP_KEEP_ALIVE_H
-#define RELAYD_TCP_KEEP_ALIVE_H
-
-#include <common/macros.h>
-
-int socket_apply_keep_alive_config(int socket_fd);
-
-#endif /* RELAYD_TCP_KEEP_ALIVE_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef RELAYD_TCP_KEEP_ALIVE_H
+#define RELAYD_TCP_KEEP_ALIVE_H
+
+#include <common/macros.hpp>
+
+int socket_apply_keep_alive_config(int socket_fd);
+
+#endif /* RELAYD_TCP_KEEP_ALIVE_H */
+++ /dev/null
-#ifndef RELAYD_TESTPOINT_H
-#define RELAYD_TESTPOINT_H
-
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(relayd_thread_dispatcher);
-TESTPOINT_DECL(relayd_thread_worker);
-TESTPOINT_DECL(relayd_thread_listener);
-TESTPOINT_DECL(relayd_thread_live_dispatcher);
-TESTPOINT_DECL(relayd_thread_live_worker);
-TESTPOINT_DECL(relayd_thread_live_listener);
-
-#endif /* SESSIOND_TESTPOINT_H */
--- /dev/null
+#ifndef RELAYD_TESTPOINT_H
+#define RELAYD_TESTPOINT_H
+
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(relayd_thread_dispatcher);
+TESTPOINT_DECL(relayd_thread_worker);
+TESTPOINT_DECL(relayd_thread_listener);
+TESTPOINT_DECL(relayd_thread_live_dispatcher);
+TESTPOINT_DECL(relayd_thread_live_worker);
+TESTPOINT_DECL(relayd_thread_live_listener);
+
+#endif /* SESSIOND_TESTPOINT_H */
*/
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
-#include "tracefile-array.h"
+#include "tracefile-array.hpp"
struct tracefile_array *tracefile_array_create(size_t count)
{
+++ /dev/null
-#ifndef _TRACEFILE_ARRAY_H
-#define _TRACEFILE_ARRAY_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdbool.h>
-
-struct tracefile {
- /* Per-tracefile head/tail seq. */
- uint64_t seq_head; /* Newest seqcount. Inclusive. */
- uint64_t seq_tail; /* Oldest seqcount. Inclusive. */
-};
-
-enum tracefile_rotate_type {
- TRACEFILE_ROTATE_READ,
- TRACEFILE_ROTATE_WRITE,
-};
-
-/*
- * Represents an array of trace files in a stream.
- * head is the most recent file/trace packet.
- * tail is the oldest file/trace packet.
- *
- * There are two heads: a "read" head and a "write" head. The "write" head is
- * the position of the newest data file. The "read" head position is only moved
- * forward when the index is received.
- *
- * The viewer uses the "read" head position as upper bound, which
- * ensures it never attempts to open a non-existing index file.
- */
-struct tracefile_array {
- struct tracefile *tf;
- size_t count;
-
- /* Current head/tail files. */
- uint64_t file_head_read;
- uint64_t file_head_write;
- uint64_t file_tail;
-
- /* Overall head/tail seq for the entire array. Inclusive. */
- uint64_t seq_head;
- uint64_t seq_tail;
-};
-
-struct tracefile_array *tracefile_array_create(size_t count);
-void tracefile_array_destroy(struct tracefile_array *tfa);
-
-void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type);
-void tracefile_array_commit_seq(struct tracefile_array *tfa,
- uint64_t new_seq_head);
-void tracefile_array_reset(struct tracefile_array *tfa);
-
-uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);
-/* May return -1ULL in the case where we have not received any indexes yet. */
-uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);
-
-uint64_t tracefile_array_get_file_index_tail(struct tracefile_array *tfa);
-/* May return -1ULL in the case where we have not received any indexes yet. */
-uint64_t tracefile_array_get_seq_tail(struct tracefile_array *tfa);
-
-bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
- uint64_t file_index, uint64_t seq);
-
-#endif /* _STREAM_H */
--- /dev/null
+#ifndef _TRACEFILE_ARRAY_H
+#define _TRACEFILE_ARRAY_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdbool.h>
+
+struct tracefile {
+ /* Per-tracefile head/tail seq. */
+ uint64_t seq_head; /* Newest seqcount. Inclusive. */
+ uint64_t seq_tail; /* Oldest seqcount. Inclusive. */
+};
+
+enum tracefile_rotate_type {
+ TRACEFILE_ROTATE_READ,
+ TRACEFILE_ROTATE_WRITE,
+};
+
+/*
+ * Represents an array of trace files in a stream.
+ * head is the most recent file/trace packet.
+ * tail is the oldest file/trace packet.
+ *
+ * There are two heads: a "read" head and a "write" head. The "write" head is
+ * the position of the newest data file. The "read" head position is only moved
+ * forward when the index is received.
+ *
+ * The viewer uses the "read" head position as upper bound, which
+ * ensures it never attempts to open a non-existing index file.
+ */
+struct tracefile_array {
+ struct tracefile *tf;
+ size_t count;
+
+ /* Current head/tail files. */
+ uint64_t file_head_read;
+ uint64_t file_head_write;
+ uint64_t file_tail;
+
+ /* Overall head/tail seq for the entire array. Inclusive. */
+ uint64_t seq_head;
+ uint64_t seq_tail;
+};
+
+struct tracefile_array *tracefile_array_create(size_t count);
+void tracefile_array_destroy(struct tracefile_array *tfa);
+
+void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type);
+void tracefile_array_commit_seq(struct tracefile_array *tfa,
+ uint64_t new_seq_head);
+void tracefile_array_reset(struct tracefile_array *tfa);
+
+uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);
+/* May return -1ULL in the case where we have not received any indexes yet. */
+uint64_t tracefile_array_get_seq_head(struct tracefile_array *tfa);
+
+uint64_t tracefile_array_get_file_index_tail(struct tracefile_array *tfa);
+/* May return -1ULL in the case where we have not received any indexes yet. */
+uint64_t tracefile_array_get_seq_tail(struct tracefile_array *tfa);
+
+bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
+ uint64_t file_index, uint64_t seq);
+
+#endif /* _STREAM_H */
#include <stdlib.h>
#include <string.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
-#include "lttng-relayd.h"
-#include "utils.h"
+#include "lttng-relayd.hpp"
+#include "utils.hpp"
static char *create_output_path_auto(const char *path_name)
{
+++ /dev/null
-#ifndef RELAYD_UTILS_H
-#define RELAYD_UTILS_H
-
-/*
- * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-char *create_output_path(const char *path_name);
-
-#endif /* RELAYD_UTILS_H */
--- /dev/null
+#ifndef RELAYD_UTILS_H
+#define RELAYD_UTILS_H
+
+/*
+ * Copyright (C) 2012 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+char *create_output_path(const char *path_name);
+
+#endif /* RELAYD_UTILS_H */
*/
#define _LGPL_SOURCE
-#include <common/common.h>
+#include <common/common.hpp>
#include <urcu/rculist.h>
-#include "lttng-relayd.h"
-#include "ctf-trace.h"
-#include "session.h"
-#include "viewer-session.h"
-#include "viewer-stream.h"
-#include "stream.h"
+#include "lttng-relayd.hpp"
+#include "ctf-trace.hpp"
+#include "session.hpp"
+#include "viewer-session.hpp"
+#include "viewer-stream.hpp"
+#include "stream.hpp"
struct relay_viewer_session *viewer_session_create(void)
{
+++ /dev/null
-#ifndef _VIEWER_SESSION_H
-#define _VIEWER_SESSION_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/trace-chunk.h>
-
-#include "session.h"
-#include "lttng-viewer-abi.h"
-
-struct relay_viewer_session {
- /*
- * Session list. Updates are protected by the session_list_lock.
- * Traversals are protected by RCU.
- * This list limits the design to having the sessions in at most
- * one viewer session.
- */
- struct cds_list_head session_list; /* RCU list. */
- pthread_mutex_t session_list_lock; /* Protects list updates. */
- /*
- * The viewer session's current trace chunk is initially set, when
- * a viewer attaches to the viewer session, to a copy the corresponding
- * relay_session's current trace chunk.
- *
- * A live session always attempts to "catch-up" to the newest available
- * trace chunk. This means that when a viewer reaches the end of a
- * trace chunk, the viewer session may not transition to the "next" one:
- * it jumps to the most recent trace chunk available (the one being
- * produced by the relay_session). Hence, if the producer performs
- * multiple rotations before a viewer completes the consumption of a
- * trace chunk, it will skip over those "intermediary" trace chunks.
- *
- * A viewer session updates its current trace chunk when:
- * 1) new viewer streams are created,
- * 2) a new index is requested,
- * 3) metadata is requested.
- *
- * Hence, as a general principle, the viewer session will reference the
- * most recent trace chunk available _even if its streams do not point to
- * it_. It indicates which trace chunk viewer streams should transition
- * to when the end of their current trace chunk is reached.
- *
- * Note that a viewer session's trace chunk points to the session's
- * output directory. The sub-directories in which the various stream files
- * are created are considered as being a part of their name.
- */
- struct lttng_trace_chunk *current_trace_chunk;
-};
-
-struct relay_viewer_session *viewer_session_create(void);
-void viewer_session_destroy(struct relay_viewer_session *vsession);
-void viewer_session_close(struct relay_viewer_session *vsession);
-
-enum lttng_viewer_attach_return_code viewer_session_attach(
- struct relay_viewer_session *vsession,
- struct relay_session *session);
-int viewer_session_is_attached(struct relay_viewer_session *vsession,
- struct relay_session *session);
-void viewer_session_close_one_session(struct relay_viewer_session *vsession,
- struct relay_session *session);
-int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
- struct lttng_trace_chunk *relay_session_trace_chunk);
-
-#endif /* _VIEWER_SESSION_H */
--- /dev/null
+#ifndef _VIEWER_SESSION_H
+#define _VIEWER_SESSION_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/trace-chunk.hpp>
+
+#include "session.hpp"
+#include "lttng-viewer-abi.hpp"
+
+struct relay_viewer_session {
+ /*
+ * Session list. Updates are protected by the session_list_lock.
+ * Traversals are protected by RCU.
+ * This list limits the design to having the sessions in at most
+ * one viewer session.
+ */
+ struct cds_list_head session_list; /* RCU list. */
+ pthread_mutex_t session_list_lock; /* Protects list updates. */
+ /*
+ * The viewer session's current trace chunk is initially set, when
+ * a viewer attaches to the viewer session, to a copy the corresponding
+ * relay_session's current trace chunk.
+ *
+ * A live session always attempts to "catch-up" to the newest available
+ * trace chunk. This means that when a viewer reaches the end of a
+ * trace chunk, the viewer session may not transition to the "next" one:
+ * it jumps to the most recent trace chunk available (the one being
+ * produced by the relay_session). Hence, if the producer performs
+ * multiple rotations before a viewer completes the consumption of a
+ * trace chunk, it will skip over those "intermediary" trace chunks.
+ *
+ * A viewer session updates its current trace chunk when:
+ * 1) new viewer streams are created,
+ * 2) a new index is requested,
+ * 3) metadata is requested.
+ *
+ * Hence, as a general principle, the viewer session will reference the
+ * most recent trace chunk available _even if its streams do not point to
+ * it_. It indicates which trace chunk viewer streams should transition
+ * to when the end of their current trace chunk is reached.
+ *
+ * Note that a viewer session's trace chunk points to the session's
+ * output directory. The sub-directories in which the various stream files
+ * are created are considered as being a part of their name.
+ */
+ struct lttng_trace_chunk *current_trace_chunk;
+};
+
+struct relay_viewer_session *viewer_session_create(void);
+void viewer_session_destroy(struct relay_viewer_session *vsession);
+void viewer_session_close(struct relay_viewer_session *vsession);
+
+enum lttng_viewer_attach_return_code viewer_session_attach(
+ struct relay_viewer_session *vsession,
+ struct relay_session *session);
+int viewer_session_is_attached(struct relay_viewer_session *vsession,
+ struct relay_session *session);
+void viewer_session_close_one_session(struct relay_viewer_session *vsession,
+ struct relay_session *session);
+int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
+ struct lttng_trace_chunk *relay_session_trace_chunk);
+
+#endif /* _VIEWER_SESSION_H */
*/
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/index/index.h>
-#include <common/compat/string.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/index/index.hpp>
+#include <common/compat/string.hpp>
+#include <common/utils.hpp>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <algorithm>
-#include "lttng-relayd.h"
-#include "viewer-stream.h"
+#include "lttng-relayd.hpp"
+#include "viewer-stream.hpp"
static void viewer_stream_release_composite_objects(struct relay_viewer_stream *vstream)
{
+++ /dev/null
-#ifndef _VIEWER_STREAM_H
-#define _VIEWER_STREAM_H
-
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <limits.h>
-#include <inttypes.h>
-#include <pthread.h>
-
-#include <common/hashtable/hashtable.h>
-
-#include "ctf-trace.h"
-#include "lttng-viewer-abi.h"
-#include "stream.h"
-
-struct relay_stream;
-
-/*
- * The viewer stream's lifetime is the intersection of their viewer connection's
- * lifetime and the duration during which at least:
- * a) their input source is still active
- * b) they still have data left to send to the client.
- *
- * This means that both the sessiond/consumerd connection or the viewer
- * connection may tear down (and unpublish) a relay_viewer_stream.
- *
- * Viewer stream updates are protected by their associated stream's lock.
- */
-struct relay_viewer_stream {
- struct urcu_ref ref;
-
- /* Back ref to stream. */
- struct relay_stream *stream;
-
- struct {
- struct fs_handle *handle;
- struct lttng_trace_chunk *trace_chunk;
- } stream_file;
- /* index file from which to read the index data. */
- struct lttng_index_file *index_file;
- /*
- * Last seen rotation count in stream.
- *
- * Sampled on every change to the viewer stream trace chunk,
- * this allows the live server to determine if it saw the latest
- * rotation that occurred on the receiving end.
- */
- uint64_t last_seen_rotation_count;
-
- char *path_name;
- char *channel_name;
-
- uint64_t current_tracefile_id;
-
- /*
- * Counts the number of sent indexes. The "tag" associated
- * with an index to send is the current index_received_seqcount,
- * because we increment index_received_seqcount after sending
- * each index. This index_received_seqcount counter can also be
- * updated when catching up with the producer.
- */
- uint64_t index_sent_seqcount;
-
- /* Indicates if this stream has been sent to a viewer client. */
- bool sent_flag;
- /* For metadata stream, how much metadata has been sent. */
- uint64_t metadata_sent;
-
- struct lttng_ht_node_u64 stream_n;
- struct rcu_head rcu_node;
-};
-
-struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
- struct lttng_trace_chunk *viewer_trace_chunk,
- enum lttng_viewer_seek seek_t);
-
-struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
-bool viewer_stream_get(struct relay_viewer_stream *vstream);
-void viewer_stream_put(struct relay_viewer_stream *vstream);
-int viewer_stream_rotate(struct relay_viewer_stream *vstream);
-bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
- uint64_t seq);
-void print_viewer_streams(void);
-void viewer_stream_close_files(struct relay_viewer_stream *vstream);
-void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
-
-#endif /* _VIEWER_STREAM_H */
--- /dev/null
+#ifndef _VIEWER_STREAM_H
+#define _VIEWER_STREAM_H
+
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <limits.h>
+#include <inttypes.h>
+#include <pthread.h>
+
+#include <common/hashtable/hashtable.hpp>
+
+#include "ctf-trace.hpp"
+#include "lttng-viewer-abi.hpp"
+#include "stream.hpp"
+
+struct relay_stream;
+
+/*
+ * The viewer stream's lifetime is the intersection of their viewer connection's
+ * lifetime and the duration during which at least:
+ * a) their input source is still active
+ * b) they still have data left to send to the client.
+ *
+ * This means that both the sessiond/consumerd connection or the viewer
+ * connection may tear down (and unpublish) a relay_viewer_stream.
+ *
+ * Viewer stream updates are protected by their associated stream's lock.
+ */
+struct relay_viewer_stream {
+ struct urcu_ref ref;
+
+ /* Back ref to stream. */
+ struct relay_stream *stream;
+
+ struct {
+ struct fs_handle *handle;
+ struct lttng_trace_chunk *trace_chunk;
+ } stream_file;
+ /* index file from which to read the index data. */
+ struct lttng_index_file *index_file;
+ /*
+ * Last seen rotation count in stream.
+ *
+ * Sampled on every change to the viewer stream trace chunk,
+ * this allows the live server to determine if it saw the latest
+ * rotation that occurred on the receiving end.
+ */
+ uint64_t last_seen_rotation_count;
+
+ char *path_name;
+ char *channel_name;
+
+ uint64_t current_tracefile_id;
+
+ /*
+ * Counts the number of sent indexes. The "tag" associated
+ * with an index to send is the current index_received_seqcount,
+ * because we increment index_received_seqcount after sending
+ * each index. This index_received_seqcount counter can also be
+ * updated when catching up with the producer.
+ */
+ uint64_t index_sent_seqcount;
+
+ /* Indicates if this stream has been sent to a viewer client. */
+ bool sent_flag;
+ /* For metadata stream, how much metadata has been sent. */
+ uint64_t metadata_sent;
+
+ struct lttng_ht_node_u64 stream_n;
+ struct rcu_head rcu_node;
+};
+
+struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
+ struct lttng_trace_chunk *viewer_trace_chunk,
+ enum lttng_viewer_seek seek_t);
+
+struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
+bool viewer_stream_get(struct relay_viewer_stream *vstream);
+void viewer_stream_put(struct relay_viewer_stream *vstream);
+int viewer_stream_rotate(struct relay_viewer_stream *vstream);
+bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
+ uint64_t seq);
+void print_viewer_streams(void);
+void viewer_stream_close_files(struct relay_viewer_stream *vstream);
+void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
+
+#endif /* _VIEWER_STREAM_H */
noinst_LTLIBRARIES = liblttng-sessiond-common.la
-liblttng_sessiond_common_la_SOURCES = utils.cpp utils.h \
- trace-kernel.cpp trace-kernel.h \
- kernel.cpp kernel.h \
- ust-app.h ust-sigbus.h trace-ust.h notify-apps.h \
- lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
- ust-ctl-internal.h ust-abi-internal.h ust-error-internal.h \
- ust-registry.h \
- condition-internal.cpp condition-internal.h \
- context.cpp context.h \
- channel.cpp channel.h \
- event.cpp event.h \
- consumer.cpp consumer.h \
- session.cpp session.h \
- modprobe.cpp modprobe.h kern-modules.h \
- fd-limit.cpp fd-limit.h \
- kernel-consumer.cpp kernel-consumer.h \
- consumer.h \
- health-sessiond.h \
- cmd.cpp cmd.h \
- buffer-registry.cpp buffer-registry.h \
- testpoint.h \
- snapshot.cpp snapshot.h \
- agent.cpp agent.h \
- save.h save.cpp \
- lttng-syscall.h lttng-syscall.cpp \
- notification-thread.h notification-thread.cpp \
- notification-thread-internal.h \
- notification-thread-commands.h notification-thread-commands.cpp \
- notification-thread-events.h notification-thread-events.cpp \
- sessiond-config.h sessiond-config.cpp \
- rotate.h rotate.cpp \
- rotation-thread.h rotation-thread.cpp \
- timer.cpp timer.h \
+liblttng_sessiond_common_la_SOURCES = utils.cpp utils.hpp \
+ trace-kernel.cpp trace-kernel.hpp \
+ kernel.cpp kernel.hpp \
+ ust-app.hpp ust-sigbus.hpp trace-ust.hpp notify-apps.hpp \
+ lttng-ust-ctl.hpp lttng-ust-abi.hpp lttng-ust-error.hpp \
+ ust-ctl-internal.hpp ust-abi-internal.hpp ust-error-internal.hpp \
+ ust-registry.hpp \
+ condition-internal.cpp condition-internal.hpp \
+ context.cpp context.hpp \
+ channel.cpp channel.hpp \
+ event.cpp event.hpp \
+ consumer.cpp consumer.hpp \
+ session.cpp session.hpp \
+ modprobe.cpp modprobe.hpp kern-modules.hpp \
+ fd-limit.cpp fd-limit.hpp \
+ kernel-consumer.cpp kernel-consumer.hpp \
+ consumer.hpp \
+ health-sessiond.hpp \
+ cmd.cpp cmd.hpp \
+ buffer-registry.cpp buffer-registry.hpp \
+ testpoint.hpp \
+ snapshot.cpp snapshot.hpp \
+ agent.cpp agent.hpp \
+ save.hpp save.cpp \
+ lttng-syscall.hpp lttng-syscall.cpp \
+ notification-thread.hpp notification-thread.cpp \
+ notification-thread-internal.hpp \
+ notification-thread-commands.hpp notification-thread-commands.cpp \
+ notification-thread-events.hpp notification-thread-events.cpp \
+ sessiond-config.hpp sessiond-config.cpp \
+ rotate.hpp rotate.cpp \
+ rotation-thread.hpp rotation-thread.cpp \
+ timer.cpp timer.hpp \
globals.cpp \
thread-utils.cpp \
process-utils.cpp \
- thread.cpp thread.h \
+ thread.cpp thread.hpp \
health.cpp \
- client.cpp client.h \
- dispatch.cpp dispatch.h \
- register.cpp register.h \
- manage-apps.cpp manage-apps.h \
- manage-kernel.cpp manage-kernel.h \
- manage-consumer.cpp manage-consumer.h \
- clear.cpp clear.h \
- tracker.cpp tracker.h \
- event-notifier-error-accounting.cpp event-notifier-error-accounting.h \
- action-executor.cpp action-executor.h\
+ client.cpp client.hpp \
+ dispatch.cpp dispatch.hpp \
+ register.cpp register.hpp \
+ manage-apps.cpp manage-apps.hpp \
+ manage-kernel.cpp manage-kernel.hpp \
+ manage-consumer.cpp manage-consumer.hpp \
+ clear.cpp clear.hpp \
+ tracker.cpp tracker.hpp \
+ event-notifier-error-accounting.cpp event-notifier-error-accounting.hpp \
+ action-executor.cpp action-executor.hpp\
trigger-error-query.cpp
if HAVE_LIBLTTNG_UST_CTL
liblttng_sessiond_common_la_SOURCES += trace-ust.cpp ust-registry.cpp ust-app.cpp \
- ust-consumer.cpp ust-consumer.h notify-apps.cpp \
- ust-metadata.cpp ust-clock.h agent-thread.cpp agent-thread.h \
- ust-field-utils.h ust-field-utils.cpp \
+ ust-consumer.cpp ust-consumer.hpp notify-apps.cpp \
+ ust-metadata.cpp ust-clock.hpp agent-thread.cpp agent-thread.hpp \
+ ust-field-utils.hpp ust-field-utils.cpp \
ust-sigbus.cpp
endif
bin_PROGRAMS = lttng-sessiond
-lttng_sessiond_SOURCES = lttng-sessiond.h main.cpp
+lttng_sessiond_SOURCES = lttng-sessiond.hpp main.cpp
lttng_sessiond_LDFLAGS = -rdynamic
*
*/
-#include "action-executor.h"
-#include "cmd.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-internal.h"
-#include "session.h"
-#include "thread.h"
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
+#include "action-executor.hpp"
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-internal.hpp"
+#include "session.hpp"
+#include "thread.hpp"
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
#include <lttng/action/list.h>
-#include <lttng/action/notify-internal.h>
+#include <lttng/action/notify-internal.hpp>
#include <lttng/action/notify.h>
#include <lttng/action/rotate-session.h>
#include <lttng/action/snapshot-session.h>
#include <lttng/action/start-session.h>
#include <lttng/action/stop-session.h>
#include <lttng/condition/evaluation.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/lttng-error.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ACTION_EXECUTOR_H
-#define ACTION_EXECUTOR_H
-
-struct action_executor;
-struct notification_thread_handle;
-struct lttng_evaluation;
-struct lttng_trigger;
-struct notification_client_list;
-struct lttng_credentials;
-
-enum action_executor_status {
- ACTION_EXECUTOR_STATUS_OK,
- ACTION_EXECUTOR_STATUS_OVERFLOW,
- ACTION_EXECUTOR_STATUS_ERROR,
- ACTION_EXECUTOR_STATUS_INVALID,
-};
-
-struct action_executor *action_executor_create(
- struct notification_thread_handle *handle);
-
-void action_executor_destroy(struct action_executor *executor);
-
-/*
- * Enqueue a job on an action executor's work queue to perform the actions
- * associated with a trigger.
- *
- * A reference to `trigger` is acquired.
- * A reference to `list` is acquired.
- *
- * This function assumes the ownership of the `evaluation` both on success and
- * failure: the caller should no longer access it once the function returns.
- */
-enum action_executor_status action_executor_enqueue_trigger(
- struct action_executor *executor,
- struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation,
- const struct lttng_credentials *object_creds,
- struct notification_client_list *list);
-
-#endif /* ACTION_EXECUTOR_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ACTION_EXECUTOR_H
+#define ACTION_EXECUTOR_H
+
+struct action_executor;
+struct notification_thread_handle;
+struct lttng_evaluation;
+struct lttng_trigger;
+struct notification_client_list;
+struct lttng_credentials;
+
+enum action_executor_status {
+ ACTION_EXECUTOR_STATUS_OK,
+ ACTION_EXECUTOR_STATUS_OVERFLOW,
+ ACTION_EXECUTOR_STATUS_ERROR,
+ ACTION_EXECUTOR_STATUS_INVALID,
+};
+
+struct action_executor *action_executor_create(
+ struct notification_thread_handle *handle);
+
+void action_executor_destroy(struct action_executor *executor);
+
+/*
+ * Enqueue a job on an action executor's work queue to perform the actions
+ * associated with a trigger.
+ *
+ * A reference to `trigger` is acquired.
+ * A reference to `list` is acquired.
+ *
+ * This function assumes the ownership of the `evaluation` both on success and
+ * failure: the caller should no longer access it once the function returns.
+ */
+enum action_executor_status action_executor_enqueue_trigger(
+ struct action_executor *executor,
+ struct lttng_trigger *trigger,
+ struct lttng_evaluation *evaluation,
+ const struct lttng_credentials *object_creds,
+ struct notification_client_list *list);
+
+#endif /* ACTION_EXECUTOR_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
-
-#include <common/compat/endian.h>
-
-#include "fd-limit.h"
-#include "agent-thread.h"
-#include "agent.h"
-#include "lttng-sessiond.h"
-#include "session.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/common.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+
+#include <common/compat/endian.hpp>
+
+#include "fd-limit.hpp"
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "lttng-sessiond.hpp"
+#include "session.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <stdbool.h>
-
-#ifndef LTTNG_SESSIOND_AGENT_THREAD_H
-#define LTTNG_SESSIOND_AGENT_THREAD_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-bool launch_agent_management_thread(void);
-bool agent_tracing_is_enabled(void);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-bool launch_agent_management_thread(void)
-{
- return true;
-}
-
-static inline
-bool agent_tracing_is_enabled(void)
-{
- return false;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_SESSIOND_AGENT_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <stdbool.h>
+
+#ifndef LTTNG_SESSIOND_AGENT_THREAD_H
+#define LTTNG_SESSIOND_AGENT_THREAD_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+bool launch_agent_management_thread(void);
+bool agent_tracing_is_enabled(void);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+bool launch_agent_management_thread(void)
+{
+ return true;
+}
+
+static inline
+bool agent_tracing_is_enabled(void)
+{
+ return false;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_SESSIOND_AGENT_THREAD_H */
#include <urcu/rculist.h>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/jul-logging.h>
#include <lttng/event-rule/log4j-logging.h>
#include <lttng/event-rule/python-logging.h>
#include <lttng/condition/condition.h>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/domain-internal.h>
-#include <lttng/log-level-rule-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/log-level-rule-internal.hpp>
-#include <common/common.h>
-#include <common/sessiond-comm/agent.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/agent.hpp>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
-#include "agent.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "common/error.h"
+#include "agent.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "common/error.hpp"
typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
const struct lttng_event_rule *rule, const char **pattern);
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_AGENT_H
-#define LTTNG_SESSIOND_AGENT_H
-
-#include <inttypes.h>
-
-#include <common/hashtable/hashtable.h>
-#include <lttng/lttng.h>
-
-/* Agent protocol version that is verified during the agent registration. */
-#define AGENT_MAJOR_VERSION 2
-#define AGENT_MINOR_VERSION 0
-
-/*
- * Hash table that contains the agent app created upon registration indexed by
- * socket. Global to the session daemon.
- */
-extern struct lttng_ht *the_agent_apps_ht_by_sock;
-
-/*
- * Hash table that contains the trigger agents by domain */
-extern struct lttng_ht *the_trigger_agents_ht_by_domain;
-
-struct agent_ht_key {
- const char *name;
- int loglevel_value;
- enum lttng_loglevel_type loglevel_type;
- const char *filter_expression;
-};
-
-/*
- * Registration message payload from an agent application. The PID is used to
- * find back the corresponding UST app object so both socket can be linked.
- */
-struct agent_register_msg {
- /* This maps to a lttng_domain_type. */
- uint32_t domain;
- uint32_t pid;
- uint32_t major_version;
- uint32_t minor_version;
-};
-
-/*
- * Agent application object created after a successful registration. This
- * object is linked to its associated UST app by their PID through hash table
- * lookups.
- */
-struct agent_app {
- /*
- * PID sent during registration of an agent application.
- */
- pid_t pid;
-
- /* Domain of the application. */
- enum lttng_domain_type domain;
-
- /*
- * AGENT TCP socket that was created upon registration.
- */
- struct lttcomm_sock *sock;
-
- /* Initialized with the AGENT sock value. */
- struct lttng_ht_node_ulong node;
-};
-
-/*
- * Agent event representation.
- * Accesses to this structure are protected by the session list lock.
- */
-struct agent_event {
- /* Name of the event. */
- char name[LTTNG_SYMBOL_NAME_LEN];
- int loglevel_value;
- enum lttng_loglevel_type loglevel_type;
-
- /*
- * Tells if the event is enabled or not on the agent. While this can be
- * implicitly tested as a boolean, it is in fact a reference count and
- * the AGENT_EVENT_IS_ENABLED macro should be used to prevent accidental
- * comparisons to non-zero literals (e.g. '1').
- *
- * Multiple triggers and events can map to the same agent event as it
- * is merely a "filter" in front of a user space tracer enabler.
- *
- * This count is updated to ensure an event is only disabled when all
- * matching enablers are disabled.
- */
- unsigned int enabled_count;
-
- /* Hash table node of the agent domain object. */
- struct lttng_ht_node_str node;
-
- /* Filter associated with the event. NULL if none. */
- struct lttng_bytecode *filter;
- char *filter_expression;
- struct lttng_event_exclusion *exclusion;
-};
-
-#define AGENT_EVENT_IS_ENABLED(agent_event) (!!agent_event->enabled_count)
-
-/*
- * Agent object containing events enabled/disabled for a given domain in a
- * scope. The scope is typically a session, but can also be "global" in the
- * context of event notifiers: see event_notifiers_find_agent().
- */
-struct agent {
- /*
- * This indicates if that domain is being used meaning if at least one
- * event has been at some point in time added to it. This is used so when
- * listing domains for a session, we can tell or not if the agent is
- * actually enabled.
- */
- unsigned int being_used:1;
-
- /* What domain this agent is. */
- enum lttng_domain_type domain;
-
- /* Contains event indexed by name. */
- struct lttng_ht *events;
-
- /* Application context list (struct agent_app_ctx). */
- struct cds_list_head app_ctx_list;
-
- /* Node used for the hash table indexed by domain type. */
- struct lttng_ht_node_u64 node;
-};
-
-/* Allocate agent apps hash table */
-int agent_app_ht_alloc(void);
-/* Clean-up agent apps hash table */
-void agent_app_ht_clean(void);
-
-/* Initialize an already allocated agent domain. */
-int agent_init(struct agent *agt);
-struct agent *agent_create(enum lttng_domain_type domain);
-void agent_destroy(struct agent *agt);
-void agent_add(struct agent *agt, struct lttng_ht *ht);
-
-/* Agent event API. */
-struct agent_event *agent_create_event(const char *name,
- enum lttng_loglevel_type loglevel_type, int loglevel_value,
- struct lttng_bytecode *filter,
- char *filter_expression);
-void agent_add_event(struct agent_event *event, struct agent *agt);
-
-struct agent_event *agent_find_event(const char *name,
- enum lttng_loglevel_type loglevel_type,
- int loglevel_value,
- const char *filter_expression,
- struct agent *agt);
-void agent_find_events_by_name(const char *name, struct agent *agt,
- struct lttng_ht_iter* iter);
-void agent_event_next_duplicate(const char *name,
- struct agent *agt, struct lttng_ht_iter* iter);
-void agent_delete_event(struct agent_event *event, struct agent *agt);
-void agent_destroy_event(struct agent_event *event);
-
-/* Agent context API.*/
-int agent_enable_context(const struct lttng_event_context *ctx,
- enum lttng_domain_type domain);
-int agent_add_context(const struct lttng_event_context *ctx,
- struct agent *agt);
-
-/* Agent app API. */
-struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
- struct lttcomm_sock *sock);
-void agent_add_app(struct agent_app *app);
-void agent_delete_app(struct agent_app *app);
-struct agent_app *agent_find_app_by_sock(int sock);
-void agent_destroy_app(struct agent_app *app);
-void agent_destroy_app_by_sock(int sock);
-int agent_send_registration_done(struct agent_app *app);
-
-/* Agent action API */
-int agent_enable_event(struct agent_event *event,
- enum lttng_domain_type domain);
-int agent_disable_event(struct agent_event *event,
- enum lttng_domain_type domain);
-void agent_update(const struct agent *agt, const struct agent_app *app);
-int agent_list_events(struct lttng_event **events,
- enum lttng_domain_type domain);
-
-struct agent_event *agent_find_event_by_trigger(
- const struct lttng_trigger *trigger, struct agent *agt);
-
-/* Global event notifier per-domain agents. */
-struct agent *agent_find_by_event_notifier_domain(
- enum lttng_domain_type domain_type);
-void agent_by_event_notifier_domain_ht_destroy(void);
-int agent_by_event_notifier_domain_ht_create(void);
-
-#endif /* LTTNG_SESSIOND_AGENT_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_AGENT_H
+#define LTTNG_SESSIOND_AGENT_H
+
+#include <inttypes.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/lttng.h>
+
+/* Agent protocol version that is verified during the agent registration. */
+#define AGENT_MAJOR_VERSION 2
+#define AGENT_MINOR_VERSION 0
+
+/*
+ * Hash table that contains the agent app created upon registration indexed by
+ * socket. Global to the session daemon.
+ */
+extern struct lttng_ht *the_agent_apps_ht_by_sock;
+
+/*
+ * Hash table that contains the trigger agents by domain */
+extern struct lttng_ht *the_trigger_agents_ht_by_domain;
+
+struct agent_ht_key {
+ const char *name;
+ int loglevel_value;
+ enum lttng_loglevel_type loglevel_type;
+ const char *filter_expression;
+};
+
+/*
+ * Registration message payload from an agent application. The PID is used to
+ * find back the corresponding UST app object so both socket can be linked.
+ */
+struct agent_register_msg {
+ /* This maps to a lttng_domain_type. */
+ uint32_t domain;
+ uint32_t pid;
+ uint32_t major_version;
+ uint32_t minor_version;
+};
+
+/*
+ * Agent application object created after a successful registration. This
+ * object is linked to its associated UST app by their PID through hash table
+ * lookups.
+ */
+struct agent_app {
+ /*
+ * PID sent during registration of an agent application.
+ */
+ pid_t pid;
+
+ /* Domain of the application. */
+ enum lttng_domain_type domain;
+
+ /*
+ * AGENT TCP socket that was created upon registration.
+ */
+ struct lttcomm_sock *sock;
+
+ /* Initialized with the AGENT sock value. */
+ struct lttng_ht_node_ulong node;
+};
+
+/*
+ * Agent event representation.
+ * Accesses to this structure are protected by the session list lock.
+ */
+struct agent_event {
+ /* Name of the event. */
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ int loglevel_value;
+ enum lttng_loglevel_type loglevel_type;
+
+ /*
+ * Tells if the event is enabled or not on the agent. While this can be
+ * implicitly tested as a boolean, it is in fact a reference count and
+ * the AGENT_EVENT_IS_ENABLED macro should be used to prevent accidental
+ * comparisons to non-zero literals (e.g. '1').
+ *
+ * Multiple triggers and events can map to the same agent event as it
+ * is merely a "filter" in front of a user space tracer enabler.
+ *
+ * This count is updated to ensure an event is only disabled when all
+ * matching enablers are disabled.
+ */
+ unsigned int enabled_count;
+
+ /* Hash table node of the agent domain object. */
+ struct lttng_ht_node_str node;
+
+ /* Filter associated with the event. NULL if none. */
+ struct lttng_bytecode *filter;
+ char *filter_expression;
+ struct lttng_event_exclusion *exclusion;
+};
+
+#define AGENT_EVENT_IS_ENABLED(agent_event) (!!agent_event->enabled_count)
+
+/*
+ * Agent object containing events enabled/disabled for a given domain in a
+ * scope. The scope is typically a session, but can also be "global" in the
+ * context of event notifiers: see event_notifiers_find_agent().
+ */
+struct agent {
+ /*
+ * This indicates if that domain is being used meaning if at least one
+ * event has been at some point in time added to it. This is used so when
+ * listing domains for a session, we can tell or not if the agent is
+ * actually enabled.
+ */
+ unsigned int being_used:1;
+
+ /* What domain this agent is. */
+ enum lttng_domain_type domain;
+
+ /* Contains event indexed by name. */
+ struct lttng_ht *events;
+
+ /* Application context list (struct agent_app_ctx). */
+ struct cds_list_head app_ctx_list;
+
+ /* Node used for the hash table indexed by domain type. */
+ struct lttng_ht_node_u64 node;
+};
+
+/* Allocate agent apps hash table */
+int agent_app_ht_alloc(void);
+/* Clean-up agent apps hash table */
+void agent_app_ht_clean(void);
+
+/* Initialize an already allocated agent domain. */
+int agent_init(struct agent *agt);
+struct agent *agent_create(enum lttng_domain_type domain);
+void agent_destroy(struct agent *agt);
+void agent_add(struct agent *agt, struct lttng_ht *ht);
+
+/* Agent event API. */
+struct agent_event *agent_create_event(const char *name,
+ enum lttng_loglevel_type loglevel_type, int loglevel_value,
+ struct lttng_bytecode *filter,
+ char *filter_expression);
+void agent_add_event(struct agent_event *event, struct agent *agt);
+
+struct agent_event *agent_find_event(const char *name,
+ enum lttng_loglevel_type loglevel_type,
+ int loglevel_value,
+ const char *filter_expression,
+ struct agent *agt);
+void agent_find_events_by_name(const char *name, struct agent *agt,
+ struct lttng_ht_iter* iter);
+void agent_event_next_duplicate(const char *name,
+ struct agent *agt, struct lttng_ht_iter* iter);
+void agent_delete_event(struct agent_event *event, struct agent *agt);
+void agent_destroy_event(struct agent_event *event);
+
+/* Agent context API.*/
+int agent_enable_context(const struct lttng_event_context *ctx,
+ enum lttng_domain_type domain);
+int agent_add_context(const struct lttng_event_context *ctx,
+ struct agent *agt);
+
+/* Agent app API. */
+struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
+ struct lttcomm_sock *sock);
+void agent_add_app(struct agent_app *app);
+void agent_delete_app(struct agent_app *app);
+struct agent_app *agent_find_app_by_sock(int sock);
+void agent_destroy_app(struct agent_app *app);
+void agent_destroy_app_by_sock(int sock);
+int agent_send_registration_done(struct agent_app *app);
+
+/* Agent action API */
+int agent_enable_event(struct agent_event *event,
+ enum lttng_domain_type domain);
+int agent_disable_event(struct agent_event *event,
+ enum lttng_domain_type domain);
+void agent_update(const struct agent *agt, const struct agent_app *app);
+int agent_list_events(struct lttng_event **events,
+ enum lttng_domain_type domain);
+
+struct agent_event *agent_find_event_by_trigger(
+ const struct lttng_trigger *trigger, struct agent *agt);
+
+/* Global event notifier per-domain agents. */
+struct agent *agent_find_by_event_notifier_domain(
+ enum lttng_domain_type domain_type);
+void agent_by_event_notifier_domain_ht_destroy(void);
+int agent_by_event_notifier_domain_ht_create(void);
+
+#endif /* LTTNG_SESSIOND_AGENT_H */
#define _LGPL_SOURCE
#include <inttypes.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
-
-#include "buffer-registry.h"
-#include "fd-limit.h"
-#include "ust-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
+
+#include "buffer-registry.hpp"
+#include "fd-limit.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
/*
* Set in main.c during initialization process of the daemon. This contains
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_BUFFER_REGISTRY_H
-#define LTTNG_BUFFER_REGISTRY_H
-
-#include <stdint.h>
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-#include <common/hashtable/hashtable.h>
-
-#include "consumer.h"
-#include "lttng-ust-ctl.h"
-#include "ust-registry.h"
-
-struct buffer_reg_stream {
- struct cds_list_head lnode;
- union {
- /* Original object data that MUST be copied over. */
- struct lttng_ust_abi_object_data *ust;
- } obj;
-};
-
-struct buffer_reg_channel {
- /* This key is the same as a tracing channel key. */
- uint32_t key;
- /* Key of the channel on the consumer side. */
- uint64_t consumer_key;
- /* Stream registry object of this channel registry. */
- struct cds_list_head streams;
- /* Total number of stream in the list. */
- uint64_t stream_count;
- /* Used to ensure mutual exclusion to the stream's list. */
- pthread_mutex_t stream_list_lock;
- /* Node for hash table usage. */
- struct lttng_ht_node_u64 node;
- /* Size of subbuffers in this channel. */
- size_t subbuf_size;
- /* Number of subbuffers per stream. */
- size_t num_subbuf;
- union {
- /* Original object data that MUST be copied over. */
- struct lttng_ust_abi_object_data *ust;
- } obj;
-};
-
-struct buffer_reg_session {
- /* Registry per domain. */
- union {
- struct ust_registry_session *ust;
- } reg;
-
- /* Contains buffer registry channel indexed by tracing channel key. */
- struct lttng_ht *channels;
-};
-
-/*
- * Registry object for per UID buffers.
- */
-struct buffer_reg_uid {
- /*
- * Keys to match this object in a hash table. The following three variables
- * identify a unique per UID buffer registry.
- */
- uint64_t session_id; /* Unique tracing session id. */
- int bits_per_long; /* ABI */
- uid_t uid; /* Owner. */
-
- enum lttng_domain_type domain;
- struct buffer_reg_session *registry;
-
- /* Indexed by session id. */
- struct lttng_ht_node_u64 node;
- /* Node of a linked list used to teardown object at a destroy session. */
- struct cds_list_head lnode;
-
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
-};
-
-/*
- * Registry object for per PID buffers.
- */
-struct buffer_reg_pid {
- uint64_t session_id;
-
- struct buffer_reg_session *registry;
-
- /* Indexed by session id. */
- struct lttng_ht_node_u64 node;
-
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
-};
-
-/* Buffer registry per UID. */
-void buffer_reg_init_uid_registry(void);
-int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
- enum lttng_domain_type domain, struct buffer_reg_uid **regp,
- const char *root_shm_path, const char *shm_path);
-void buffer_reg_uid_add(struct buffer_reg_uid *reg);
-struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
- uint32_t bits_per_long, uid_t uid);
-void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
-void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
- struct consumer_output *consumer);
-
-/* Buffer registry per PID. */
-void buffer_reg_init_pid_registry(void);
-int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
- const char *root_shm_path, const char *shm_path);
-void buffer_reg_pid_add(struct buffer_reg_pid *reg);
-struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
-void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
-void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
-
-/* Channel */
-int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
-void buffer_reg_channel_add(struct buffer_reg_session *session,
- struct buffer_reg_channel *channel);
-struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
- struct buffer_reg_uid *reg);
-void buffer_reg_channel_remove(struct buffer_reg_session *session,
- struct buffer_reg_channel *regp);
-void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
- enum lttng_domain_type domain);
-
-/* Stream */
-int buffer_reg_stream_create(struct buffer_reg_stream **regp);
-void buffer_reg_stream_add(struct buffer_reg_stream *stream,
- struct buffer_reg_channel *channel);
-void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
- enum lttng_domain_type domain);
-
-/* Global registry. */
-void buffer_reg_destroy_registries(void);
-
-int buffer_reg_uid_consumer_channel_key(
- struct cds_list_head *buffer_reg_uid_list,
- uint64_t chan_key, uint64_t *consumer_chan_key);
-
-#endif /* LTTNG_BUFFER_REGISTRY_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_BUFFER_REGISTRY_H
+#define LTTNG_BUFFER_REGISTRY_H
+
+#include <stdint.h>
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+#include <common/hashtable/hashtable.hpp>
+
+#include "consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "ust-registry.hpp"
+
+struct buffer_reg_stream {
+ struct cds_list_head lnode;
+ union {
+ /* Original object data that MUST be copied over. */
+ struct lttng_ust_abi_object_data *ust;
+ } obj;
+};
+
+struct buffer_reg_channel {
+ /* This key is the same as a tracing channel key. */
+ uint32_t key;
+ /* Key of the channel on the consumer side. */
+ uint64_t consumer_key;
+ /* Stream registry object of this channel registry. */
+ struct cds_list_head streams;
+ /* Total number of stream in the list. */
+ uint64_t stream_count;
+ /* Used to ensure mutual exclusion to the stream's list. */
+ pthread_mutex_t stream_list_lock;
+ /* Node for hash table usage. */
+ struct lttng_ht_node_u64 node;
+ /* Size of subbuffers in this channel. */
+ size_t subbuf_size;
+ /* Number of subbuffers per stream. */
+ size_t num_subbuf;
+ union {
+ /* Original object data that MUST be copied over. */
+ struct lttng_ust_abi_object_data *ust;
+ } obj;
+};
+
+struct buffer_reg_session {
+ /* Registry per domain. */
+ union {
+ struct ust_registry_session *ust;
+ } reg;
+
+ /* Contains buffer registry channel indexed by tracing channel key. */
+ struct lttng_ht *channels;
+};
+
+/*
+ * Registry object for per UID buffers.
+ */
+struct buffer_reg_uid {
+ /*
+ * Keys to match this object in a hash table. The following three variables
+ * identify a unique per UID buffer registry.
+ */
+ uint64_t session_id; /* Unique tracing session id. */
+ int bits_per_long; /* ABI */
+ uid_t uid; /* Owner. */
+
+ enum lttng_domain_type domain;
+ struct buffer_reg_session *registry;
+
+ /* Indexed by session id. */
+ struct lttng_ht_node_u64 node;
+ /* Node of a linked list used to teardown object at a destroy session. */
+ struct cds_list_head lnode;
+
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+};
+
+/*
+ * Registry object for per PID buffers.
+ */
+struct buffer_reg_pid {
+ uint64_t session_id;
+
+ struct buffer_reg_session *registry;
+
+ /* Indexed by session id. */
+ struct lttng_ht_node_u64 node;
+
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+};
+
+/* Buffer registry per UID. */
+void buffer_reg_init_uid_registry(void);
+int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
+ enum lttng_domain_type domain, struct buffer_reg_uid **regp,
+ const char *root_shm_path, const char *shm_path);
+void buffer_reg_uid_add(struct buffer_reg_uid *reg);
+struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
+ uint32_t bits_per_long, uid_t uid);
+void buffer_reg_uid_remove(struct buffer_reg_uid *regp);
+void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
+ struct consumer_output *consumer);
+
+/* Buffer registry per PID. */
+void buffer_reg_init_pid_registry(void);
+int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
+ const char *root_shm_path, const char *shm_path);
+void buffer_reg_pid_add(struct buffer_reg_pid *reg);
+struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id);
+void buffer_reg_pid_remove(struct buffer_reg_pid *regp);
+void buffer_reg_pid_destroy(struct buffer_reg_pid *regp);
+
+/* Channel */
+int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp);
+void buffer_reg_channel_add(struct buffer_reg_session *session,
+ struct buffer_reg_channel *channel);
+struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
+ struct buffer_reg_uid *reg);
+void buffer_reg_channel_remove(struct buffer_reg_session *session,
+ struct buffer_reg_channel *regp);
+void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
+ enum lttng_domain_type domain);
+
+/* Stream */
+int buffer_reg_stream_create(struct buffer_reg_stream **regp);
+void buffer_reg_stream_add(struct buffer_reg_stream *stream,
+ struct buffer_reg_channel *channel);
+void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
+ enum lttng_domain_type domain);
+
+/* Global registry. */
+void buffer_reg_destroy_registries(void);
+
+int buffer_reg_uid_consumer_channel_key(
+ struct cds_list_head *buffer_reg_uid_list,
+ uint64_t chan_key, uint64_t *consumer_chan_key);
+
+#endif /* LTTNG_BUFFER_REGISTRY_H */
#include <string.h>
#include <unistd.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "channel.h"
-#include "lttng-sessiond.h"
-#include "kernel.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "channel.hpp"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
+#include "ust-app.hpp"
+#include "agent.hpp"
/*
* Return allocated channel attributes.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_CHANNEL_H
-#define _LTT_CHANNEL_H
-
-#include <lttng/lttng.h>
-
-#include "trace-kernel.h"
-#include "trace-ust.h"
-
-int channel_kernel_disable(struct ltt_kernel_session *ksession,
- char *channel_name);
-enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
- struct ltt_kernel_channel *kchan);
-enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
- struct lttng_channel *chan,
- int kernel_pipe);
-
-struct lttng_channel *channel_new_default_attr(int domain,
- enum lttng_buffer_type type);
-void channel_attr_destroy(struct lttng_channel *channel);
-
-enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
- struct lttng_channel *attr, enum lttng_buffer_type type);
-enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan);
-int channel_ust_disable(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan);
-
-struct lttng_channel *trace_ust_channel_to_lttng_channel(
- const struct ltt_ust_channel *uchan);
-
-#endif /* _LTT_CHANNEL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_CHANNEL_H
+#define _LTT_CHANNEL_H
+
+#include <lttng/lttng.h>
+
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+
+int channel_kernel_disable(struct ltt_kernel_session *ksession,
+ char *channel_name);
+enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
+ struct ltt_kernel_channel *kchan);
+enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
+ struct lttng_channel *chan,
+ int kernel_pipe);
+
+struct lttng_channel *channel_new_default_attr(int domain,
+ enum lttng_buffer_type type);
+void channel_attr_destroy(struct lttng_channel *channel);
+
+enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
+ struct lttng_channel *attr, enum lttng_buffer_type type);
+enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
+int channel_ust_disable(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
+
+struct lttng_channel *trace_ust_channel_to_lttng_channel(
+ const struct ltt_ust_channel *uchan);
+
+#endif /* _LTT_CHANNEL_H */
#include <string.h>
#include <unistd.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/utils.h>
-
-#include "clear.h"
-#include "session.h"
-#include "ust-app.h"
-#include "kernel.h"
-#include "cmd.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+
+#include "clear.hpp"
+#include "session.hpp"
+#include "ust-app.hpp"
+#include "kernel.hpp"
+#include "cmd.hpp"
struct cmd_clear_session_reply_context {
int reply_sock_fd;
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CLEAR_H
-#define CLEAR_H
-
-#include "session.h"
-
-int cmd_clear_session(struct ltt_session *session, int *sock_fd);
-
-#endif /* CLEAT_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CLEAR_H
+#define CLEAR_H
+
+#include "session.hpp"
+
+int cmd_clear_session(struct ltt_session *session, int *sock_fd);
+
+#endif /* CLEAT_H */
*
*/
-#include "common/buffer-view.h"
-#include "common/compat/socket.h"
-#include "common/dynamic-array.h"
-#include "common/dynamic-buffer.h"
-#include "common/fd-handle.h"
-#include "common/payload-view.h"
-#include "common/payload.h"
-#include "common/sessiond-comm/sessiond-comm.h"
+#include "common/buffer-view.hpp"
+#include "common/compat/socket.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/dynamic-buffer.hpp"
+#include "common/fd-handle.hpp"
+#include "common/payload-view.hpp"
+#include "common/payload.hpp"
+#include "common/sessiond-comm/sessiond-comm.hpp"
#include "lttng/lttng-error.h"
#include "lttng/tracker.h"
-#include <common/compat/getenv.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/utils.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <common/compat/getenv.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/utils.hpp>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
#include <pthread.h>
#include <signal.h>
#include <stddef.h>
#include <sys/stat.h>
#include <unistd.h>
-#include "agent-thread.h"
-#include "clear.h"
-#include "client.h"
-#include "cmd.h"
-#include "health-sessiond.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "manage-consumer.h"
-#include "save.h"
-#include "testpoint.h"
-#include "utils.h"
+#include "agent-thread.hpp"
+#include "clear.hpp"
+#include "client.hpp"
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "manage-consumer.hpp"
+#include "save.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
static bool is_root;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CLIENT_SESSIOND_H
-#define CLIENT_SESSIOND_H
-
-#include "thread.h"
-
-struct lttng_thread *launch_client_thread(void);
-
-#endif /* CLIENT_SESSIOND_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CLIENT_SESSIOND_H
+#define CLIENT_SESSIOND_H
+
+#include "thread.hpp"
+
+struct lttng_thread *launch_client_thread(void);
+
+#endif /* CLIENT_SESSIOND_H */
#include <urcu/list.h>
#include <urcu/uatomic.h>
-#include <common/buffer-view.h>
-#include <common/common.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-buffer.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/relayd/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/string-utils/string-utils.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
-
+#include <common/buffer-view.hpp>
+#include <common/common.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
+#include <lttng/action/action-internal.hpp>
#include <lttng/action/action.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/channel-internal.h>
+#include <lttng/channel-internal.hpp>
#include <lttng/channel.h>
+#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/condition.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/location-internal.h>
-#include <lttng/rotate-internal.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
-
-#include "agent-thread.h"
-#include "agent.h"
-#include "buffer-registry.h"
-#include "channel.h"
-#include "cmd.h"
-#include "consumer.h"
-#include "event-notifier-error-accounting.h"
-#include "event.h"
-#include "health-sessiond.h"
-#include "kernel-consumer.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "lttng-syscall.h"
-#include "notification-thread-commands.h"
-#include "notification-thread.h"
-#include "rotate.h"
-#include "rotation-thread.h"
-#include "session.h"
-#include "timer.h"
-#include "tracker.h"
-#include "utils.h"
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/condition/event-rule-matches.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/location-internal.hpp>
+#include <lttng/lttng-error.h>
+#include <lttng/rotate-internal.hpp>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/tracker.h>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
+
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "event.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "tracker.hpp"
+#include "utils.hpp"
/* Sleep for 100ms between each check for the shm path's deletion. */
#define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CMD_H
-#define CMD_H
-
-#include "context.h"
-#include "lttng-sessiond.h"
-#include "lttng/tracker.h"
-#include "session.h"
-#include <common/tracker.h>
-
-struct notification_thread_handle;
-struct lttng_dynamic_buffer;
-
-/*
- * A callback (and associated user data) that should be run after a command
- * has been executed. No locks should be taken while executing this handler.
- *
- * The command's reply should not be sent until the handler has run and
- * completed successfully. On failure, the handler's return code should
- * be the only reply sent to the client.
- */
-typedef enum lttng_error_code (*completion_handler_function)(void *);
-struct cmd_completion_handler {
- completion_handler_function run;
- void *data;
-};
-
-/*
- * Init the command subsystem. Must be called before using any of the functions
- * above. This is called in the main() of the session daemon.
- */
-void cmd_init(void);
-
-/* Session commands */
-enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock,
- struct lttng_session_descriptor **return_descriptor);
-int cmd_destroy_session(struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle,
- int *sock_fd);
-
-/* Channel commands */
-int cmd_disable_channel(struct ltt_session *session,
- enum lttng_domain_type domain, char *channel_name);
-int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe);
-
-/* Process attribute tracker commands */
-enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy *policy);
-enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy);
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- struct lttng_process_attr_values **values);
-
-/* Event commands */
-int cmd_disable_event(struct command_ctx *cmd_ctx,
- struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion);
-int cmd_add_context(struct command_ctx *cmd_ctx,
- const struct lttng_event_context *event_context,
- int kwpipe);
-int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain,
- char *channel_name, struct lttng_event *event,
- struct lttng_bytecode *bytecode);
-int cmd_enable_event(struct command_ctx *cmd_ctx,
- struct lttng_event *event,
- char *filter_expression,
- struct lttng_event_exclusion *exclusion,
- struct lttng_bytecode *bytecode,
- int wpipe);
-
-/* Trace session action commands */
-int cmd_start_trace(struct ltt_session *session);
-int cmd_stop_trace(struct ltt_session *session);
-
-/* Consumer commands */
-int cmd_register_consumer(struct ltt_session *session,
- enum lttng_domain_type domain,
- const char *sock_path, struct consumer_data *cdata);
-int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
- struct lttng_uri *uris);
-int cmd_setup_relayd(struct ltt_session *session);
-
-/* Listing commands */
-ssize_t cmd_list_domains(struct ltt_session *session,
- struct lttng_domain **domains);
-enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
- struct ltt_session *session,
- char *channel_name,
- struct lttng_payload *payload);
-enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
- struct ltt_session *session,
- struct lttng_payload *payload);
-void cmd_list_lttng_sessions(struct lttng_session *sessions,
- size_t session_count, uid_t uid, gid_t gid);
-enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
- struct lttng_payload *reply);
-enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
- struct lttng_payload *reply_payload);
-ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
- struct lttng_snapshot_output **outputs);
-enum lttng_error_code cmd_list_syscalls(
- struct lttng_payload *reply_payload);
-
-int cmd_data_pending(struct ltt_session *session);
-
-/* Snapshot */
-int cmd_snapshot_add_output(struct ltt_session *session,
- const struct lttng_snapshot_output *output, uint32_t *id);
-int cmd_snapshot_del_output(struct ltt_session *session,
- const struct lttng_snapshot_output *output);
-int cmd_snapshot_record(struct ltt_session *session,
- const struct lttng_snapshot_output *output, int wait);
-
-int cmd_set_session_shm_path(struct ltt_session *session,
- const char *shm_path);
-int cmd_regenerate_metadata(struct ltt_session *session);
-int cmd_regenerate_statedump(struct ltt_session *session);
-
-enum lttng_error_code cmd_register_trigger(
- const struct lttng_credentials *cmd_creds,
- struct lttng_trigger *trigger,
- bool is_anonymous_trigger,
- struct notification_thread_handle *notification_thread_handle,
- struct lttng_trigger **return_trigger);
-enum lttng_error_code cmd_unregister_trigger(
- const struct lttng_credentials *cmd_creds,
- const struct lttng_trigger *trigger,
- struct notification_thread_handle *notification_thread_handle);
-
-enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
- struct notification_thread_handle *notification_thread_handle,
- struct lttng_triggers **return_triggers);
-enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
- const struct lttng_error_query *query,
- struct lttng_error_query_results **_results,
- struct notification_thread_handle *notification_thread);
-
-int cmd_rotate_session(struct ltt_session *session,
- struct lttng_rotate_session_return *rotate_return,
- bool quiet_rotation,
- enum lttng_trace_chunk_command_type command);
-int cmd_rotate_get_info(struct ltt_session *session,
- struct lttng_rotation_get_info_return *info_return,
- uint64_t rotate_id);
-int cmd_rotation_set_schedule(struct ltt_session *session,
- bool activate, enum lttng_rotation_schedule_type schedule_type,
- uint64_t value,
- struct notification_thread_handle *notification_thread_handle);
-
-const struct cmd_completion_handler *cmd_pop_completion_handler(void);
-int start_kernel_session(struct ltt_kernel_session *ksess);
-int stop_kernel_session(struct ltt_kernel_session *ksess);
-
-#endif /* CMD_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CMD_H
+#define CMD_H
+
+#include "context.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng/tracker.h"
+#include "session.hpp"
+#include <common/tracker.hpp>
+
+struct notification_thread_handle;
+struct lttng_dynamic_buffer;
+
+/*
+ * A callback (and associated user data) that should be run after a command
+ * has been executed. No locks should be taken while executing this handler.
+ *
+ * The command's reply should not be sent until the handler has run and
+ * completed successfully. On failure, the handler's return code should
+ * be the only reply sent to the client.
+ */
+typedef enum lttng_error_code (*completion_handler_function)(void *);
+struct cmd_completion_handler {
+ completion_handler_function run;
+ void *data;
+};
+
+/*
+ * Init the command subsystem. Must be called before using any of the functions
+ * above. This is called in the main() of the session daemon.
+ */
+void cmd_init(void);
+
+/* Session commands */
+enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock,
+ struct lttng_session_descriptor **return_descriptor);
+int cmd_destroy_session(struct ltt_session *session,
+ struct notification_thread_handle *notification_thread_handle,
+ int *sock_fd);
+
+/* Channel commands */
+int cmd_disable_channel(struct ltt_session *session,
+ enum lttng_domain_type domain, char *channel_name);
+int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe);
+
+/* Process attribute tracker commands */
+enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy *policy);
+enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy);
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
+ struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ struct lttng_process_attr_values **values);
+
+/* Event commands */
+int cmd_disable_event(struct command_ctx *cmd_ctx,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion);
+int cmd_add_context(struct command_ctx *cmd_ctx,
+ const struct lttng_event_context *event_context,
+ int kwpipe);
+int cmd_set_filter(struct ltt_session *session, enum lttng_domain_type domain,
+ char *channel_name, struct lttng_event *event,
+ struct lttng_bytecode *bytecode);
+int cmd_enable_event(struct command_ctx *cmd_ctx,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_event_exclusion *exclusion,
+ struct lttng_bytecode *bytecode,
+ int wpipe);
+
+/* Trace session action commands */
+int cmd_start_trace(struct ltt_session *session);
+int cmd_stop_trace(struct ltt_session *session);
+
+/* Consumer commands */
+int cmd_register_consumer(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ const char *sock_path, struct consumer_data *cdata);
+int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
+ struct lttng_uri *uris);
+int cmd_setup_relayd(struct ltt_session *session);
+
+/* Listing commands */
+ssize_t cmd_list_domains(struct ltt_session *session,
+ struct lttng_domain **domains);
+enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
+ struct ltt_session *session,
+ char *channel_name,
+ struct lttng_payload *payload);
+enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
+ struct ltt_session *session,
+ struct lttng_payload *payload);
+void cmd_list_lttng_sessions(struct lttng_session *sessions,
+ size_t session_count, uid_t uid, gid_t gid);
+enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
+ struct lttng_payload *reply);
+enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
+ struct lttng_payload *reply_payload);
+ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
+ struct lttng_snapshot_output **outputs);
+enum lttng_error_code cmd_list_syscalls(
+ struct lttng_payload *reply_payload);
+
+int cmd_data_pending(struct ltt_session *session);
+
+/* Snapshot */
+int cmd_snapshot_add_output(struct ltt_session *session,
+ const struct lttng_snapshot_output *output, uint32_t *id);
+int cmd_snapshot_del_output(struct ltt_session *session,
+ const struct lttng_snapshot_output *output);
+int cmd_snapshot_record(struct ltt_session *session,
+ const struct lttng_snapshot_output *output, int wait);
+
+int cmd_set_session_shm_path(struct ltt_session *session,
+ const char *shm_path);
+int cmd_regenerate_metadata(struct ltt_session *session);
+int cmd_regenerate_statedump(struct ltt_session *session);
+
+enum lttng_error_code cmd_register_trigger(
+ const struct lttng_credentials *cmd_creds,
+ struct lttng_trigger *trigger,
+ bool is_anonymous_trigger,
+ struct notification_thread_handle *notification_thread_handle,
+ struct lttng_trigger **return_trigger);
+enum lttng_error_code cmd_unregister_trigger(
+ const struct lttng_credentials *cmd_creds,
+ const struct lttng_trigger *trigger,
+ struct notification_thread_handle *notification_thread_handle);
+
+enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
+ struct notification_thread_handle *notification_thread_handle,
+ struct lttng_triggers **return_triggers);
+enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
+ const struct lttng_error_query *query,
+ struct lttng_error_query_results **_results,
+ struct notification_thread_handle *notification_thread);
+
+int cmd_rotate_session(struct ltt_session *session,
+ struct lttng_rotate_session_return *rotate_return,
+ bool quiet_rotation,
+ enum lttng_trace_chunk_command_type command);
+int cmd_rotate_get_info(struct ltt_session *session,
+ struct lttng_rotation_get_info_return *info_return,
+ uint64_t rotate_id);
+int cmd_rotation_set_schedule(struct ltt_session *session,
+ bool activate, enum lttng_rotation_schedule_type schedule_type,
+ uint64_t value,
+ struct notification_thread_handle *notification_thread_handle);
+
+const struct cmd_completion_handler *cmd_pop_completion_handler(void);
+int start_kernel_session(struct ltt_kernel_session *ksess);
+int stop_kernel_session(struct ltt_kernel_session *ksess);
+
+#endif /* CMD_H */
*
*/
-#include <common/hashtable/utils.h>
-#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.hpp>
+#include <common/hashtable/hashtable.hpp>
#include <lttng/condition/condition.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include "condition-internal.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include "condition-internal.hpp"
static
unsigned long lttng_condition_buffer_usage_hash(
+++ /dev/null
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_CONDITION_INTERNAL_H
-#define LTTNG_SESSIOND_CONDITION_INTERNAL_H
-
-#include <lttng/condition/condition.h>
-
-/*
- * The lttng_condition hashing code is kept in this file (rather than
- * condition.c) since it makes use of GPLv2 code (hashtable utils), which we
- * don't want to link in liblttng-ctl.
- */
-unsigned long lttng_condition_hash(const struct lttng_condition *condition);
-
-struct lttng_condition *lttng_condition_copy(
- const struct lttng_condition *condition);
-
-#endif /* LTTNG_SESSIOND_CONDITION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_CONDITION_INTERNAL_H
+#define LTTNG_SESSIOND_CONDITION_INTERNAL_H
+
+#include <lttng/condition/condition.h>
+
+/*
+ * The lttng_condition hashing code is kept in this file (rather than
+ * condition.c) since it makes use of GPLv2 code (hashtable utils), which we
+ * don't want to link in liblttng-ctl.
+ */
+unsigned long lttng_condition_hash(const struct lttng_condition *condition);
+
+struct lttng_condition *lttng_condition_copy(
+ const struct lttng_condition *condition);
+
+#endif /* LTTNG_SESSIOND_CONDITION_INTERNAL_H */
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/uri.h>
-#include <common/relayd/relayd.h>
-#include <common/string-utils/format.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "lttng-sessiond.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/uri.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/string-utils/format.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "lttng-sessiond.hpp"
/*
* Return allocated full pathname of the session using the consumer trace path
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _CONSUMER_H
-#define _CONSUMER_H
-
-#include <common/consumer/consumer.h>
-#include <common/hashtable/hashtable.h>
-#include <lttng/lttng.h>
-#include <urcu/ref.h>
-#include <algorithm>
-
-#include "snapshot.h"
-
-struct snapshot;
-struct snapshot_output;
-struct ltt_session;
-
-/*
- * Needed until we use C++14, where std::max is constexpr.
- *
- * Use a static_assert so we remember to remove it when we upgrade to a newer
- * C++.
- */
-static_assert(__cplusplus == 201103L, "");
-template <typename T>
-constexpr T max_constexpr(T l, T r)
-{
- return l > r ? l : r;
-}
-
-enum consumer_dst_type {
- CONSUMER_DST_LOCAL,
- CONSUMER_DST_NET,
-};
-
-enum consumer_trace_chunk_exists_status {
- CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_LOCAL,
- CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_REMOTE,
- CONSUMER_TRACE_CHUNK_EXISTS_STATUS_UNKNOWN_CHUNK,
-};
-
-struct consumer_socket {
- /*
- * File descriptor. This is just a reference to the consumer data meaning
- * that every access must be locked and checked for a possible invalid
- * value.
- */
- int *fd_ptr;
-
- /*
- * To use this socket (send/recv), this lock MUST be acquired.
- */
- pthread_mutex_t *lock;
-
- /*
- * Indicates if the socket was registered by a third part
- * (REGISTER_CONSUMER) or is the spawn consumer of the session daemon.
- * During the destroy phase of a consumer output, we close the socket if
- * this flag is set to 1 since we don't need the fd anymore.
- */
- unsigned int registered;
-
- /* Flag if network sockets were sent to the consumer. */
- unsigned int control_sock_sent;
- unsigned int data_sock_sent;
-
- struct lttng_ht_node_ulong node;
-
- enum lttng_consumer_type type;
-};
-
-struct consumer_data {
- consumer_data (lttng_consumer_type type_)
- : type(type_)
- {}
-
- enum lttng_consumer_type type;
-
- /* Mutex to control consumerd pid assignation */
- pthread_mutex_t pid_mutex = PTHREAD_MUTEX_INITIALIZER;
- pid_t pid = 0;
-
- int err_sock = -1;
- /* These two sockets uses the cmd_unix_sock_path. */
- int cmd_sock = -1;
- /*
- * Write-end of the channel monitoring pipe to be passed to the
- * consumer.
- */
- int channel_monitor_pipe = -1;
- /*
- * The metadata socket object is handled differently and only created
- * locally in this object thus it's the only reference available in the
- * session daemon. For that reason, a variable for the fd is required and
- * the metadata socket fd points to it.
- */
- int metadata_fd = 0;
- struct consumer_socket metadata_sock {};
-
- /* consumer error and command Unix socket path */
- const char *err_unix_sock_path = nullptr;
- const char *cmd_unix_sock_path = nullptr;
-
- /*
- * This lock has two purposes. It protects any change to the consumer
- * socket and make sure only one thread uses this object for read/write
- * operations.
- */
- pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-};
-
-/*
- * Network URIs
- */
-struct consumer_net {
- /*
- * Indicate if URI type is set. Those flags should only be set when the
- * created URI is done AND valid.
- */
- int control_isset;
- int data_isset;
-
- /*
- * The following two URIs MUST have the same destination address for
- * network streaming to work. Network hop are not yet supported.
- */
-
- /* Control path for network streaming. */
- struct lttng_uri control;
-
- /* Data path for network streaming. */
- struct lttng_uri data;
-
- /* <hostname>/<session-name> */
- char base_dir[PATH_MAX];
-};
-
-/*
- * Consumer output object describing where and how to send data.
- */
-struct consumer_output {
- struct urcu_ref ref; /* Refcount */
-
- /* If the consumer is enabled meaning that should be used */
- unsigned int enabled;
- enum consumer_dst_type type;
-
- /*
- * The net_seq_index is the index of the network stream on the consumer
- * side. It tells the consumer which streams goes to which relayd with this
- * index. The relayd sockets are index with it on the consumer side.
- */
- uint64_t net_seq_index;
- /* Store the relay protocol in use if the session is remote. */
- uint32_t relay_major_version;
- uint32_t relay_minor_version;
-
- /* True if relayd supports the clear feature. */
- bool relay_allows_clear;
-
- /*
- * Subdirectory path name used for both local and network
- * consumer ("kernel", "ust", or empty).
- */
- char domain_subdir[
- max_constexpr(sizeof(DEFAULT_KERNEL_TRACE_DIR),
- sizeof(DEFAULT_UST_TRACE_DIR))];
-
- /*
- * Hashtable of consumer_socket index by the file descriptor value. For
- * multiarch consumer support, we can have more than one consumer (ex:
- * 32 and 64 bit).
- */
- struct lttng_ht *socks;
-
- /* Tell if this output is used for snapshot. */
- unsigned int snapshot:1;
-
- union {
- char session_root_path[LTTNG_PATH_MAX];
- struct consumer_net net;
- } dst;
-
- /*
- * Sub-directory below the session_root_path where the next chunk of
- * trace will be stored (\0 before the first session rotation).
- */
- char chunk_path[LTTNG_PATH_MAX];
-};
-
-struct consumer_socket *consumer_find_socket(int key,
- const struct consumer_output *consumer);
-struct consumer_socket *consumer_find_socket_by_bitness(int bits,
- const struct consumer_output *consumer);
-struct consumer_socket *consumer_allocate_socket(int *fd);
-void consumer_add_socket(struct consumer_socket *sock,
- struct consumer_output *consumer);
-void consumer_del_socket(struct consumer_socket *sock,
- struct consumer_output *consumer);
-void consumer_destroy_socket(struct consumer_socket *sock);
-int consumer_copy_sockets(struct consumer_output *dst,
- struct consumer_output *src);
-void consumer_destroy_output_sockets(struct consumer_output *obj);
-int consumer_socket_send(struct consumer_socket *socket, const void *msg,
- size_t len);
-int consumer_socket_recv(struct consumer_socket *socket, void *msg,
- size_t len);
-
-struct consumer_output *consumer_create_output(enum consumer_dst_type type);
-struct consumer_output *consumer_copy_output(struct consumer_output *obj);
-void consumer_output_get(struct consumer_output *obj);
-void consumer_output_put(struct consumer_output *obj);
-int consumer_set_network_uri(const struct ltt_session *session,
- struct consumer_output *obj,
- struct lttng_uri *uri);
-int consumer_send_fds(struct consumer_socket *sock, const int *fds,
- size_t nb_fd);
-int consumer_send_msg(struct consumer_socket *sock,
- const struct lttcomm_consumer_msg *msg);
-int consumer_send_stream(struct consumer_socket *sock,
- struct consumer_output *dst, struct lttcomm_consumer_msg *msg,
- const int *fds, size_t nb_fd);
-int consumer_send_channel(struct consumer_socket *sock,
- struct lttcomm_consumer_msg *msg);
-int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
- struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
- enum lttng_stream_type type, uint64_t session_id,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- const uint64_t *current_chunk_id, time_t session_creation_time,
- bool session_name_contains_creation_time);
-int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
- int pipe);
-int consumer_send_destroy_relayd(struct consumer_socket *sock,
- struct consumer_output *consumer);
-int consumer_recv_status_reply(struct consumer_socket *sock);
-int consumer_recv_status_channel(struct consumer_socket *sock,
- uint64_t *key, unsigned int *stream_count);
-void consumer_output_send_destroy_relayd(struct consumer_output *consumer);
-int consumer_create_socket(struct consumer_data *data,
- struct consumer_output *output);
-
-void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t subbuf_size,
- uint64_t num_subbuf,
- int overwrite,
- unsigned int switch_timer_interval,
- unsigned int read_timer_interval,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- unsigned int monitor_timer_interval,
- int output,
- int type,
- uint64_t session_id,
- const char *pathname,
- const char *name,
- uint64_t relayd_id,
- uint64_t key,
- unsigned char *uuid,
- uint32_t chan_id,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- uint64_t session_id_per_pid,
- unsigned int monitor,
- uint32_t ust_app_uid,
- int64_t blocking_timeout,
- const char *root_shm_path,
- const char *shm_path,
- struct lttng_trace_chunk *trace_chunk,
- const struct lttng_credentials *buffer_credentials);
-void consumer_init_add_stream_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t channel_key,
- uint64_t stream_key,
- int32_t cpu);
-void consumer_init_streams_sent_comm_msg(struct lttcomm_consumer_msg *msg,
- enum lttng_consumer_command cmd,
- uint64_t channel_key, uint64_t net_seq_idx);
-void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t channel_key,
- uint64_t session_id,
- const char *pathname,
- uint64_t relayd_id,
- const char *name,
- unsigned int nb_init_streams,
- enum lttng_event_output output,
- int type,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- unsigned int monitor,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- unsigned int monitor_timer_interval,
- struct lttng_trace_chunk *trace_chunk);
-int consumer_is_data_pending(uint64_t session_id,
- struct consumer_output *consumer);
-int consumer_close_metadata(struct consumer_socket *socket,
- uint64_t metadata_key);
-int consumer_setup_metadata(struct consumer_socket *socket,
- uint64_t metadata_key);
-int consumer_push_metadata(struct consumer_socket *socket,
- uint64_t metadata_key, char *metadata_str, size_t len,
- size_t target_offset, uint64_t version);
-int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
-int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key);
-int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
- struct consumer_output *consumer, uint64_t *discarded);
-int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
- struct consumer_output *consumer, uint64_t *lost);
-
-/* Snapshot command. */
-enum lttng_error_code consumer_snapshot_channel(struct consumer_socket *socket,
- uint64_t key, const struct consumer_output *output, int metadata,
- const char *channel_path, uint64_t nb_packets_per_stream);
-
-/* Rotation commands. */
-int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
- struct consumer_output *output, bool is_metadata_channel);
-int consumer_init(struct consumer_socket *socket,
- const lttng_uuid sessiond_uuid);
-
-int consumer_create_trace_chunk(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- const char *domain_subdir);
-int consumer_close_trace_chunk(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- char *closed_trace_chunk_path);
-int consumer_trace_chunk_exists(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- enum consumer_trace_chunk_exists_status *result);
-int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key);
-
-char *setup_channel_trace_path(struct consumer_output *consumer,
- const char *session_path, size_t *consumer_path_offset);
-
-/* Clear command */
-int consumer_clear_channel(struct consumer_socket *socket, uint64_t key);
-
-#endif /* _CONSUMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _CONSUMER_H
+#define _CONSUMER_H
+
+#include <common/consumer/consumer.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/lttng.h>
+#include <urcu/ref.h>
+#include <algorithm>
+
+#include "snapshot.hpp"
+
+struct snapshot;
+struct snapshot_output;
+struct ltt_session;
+
+/*
+ * Needed until we use C++14, where std::max is constexpr.
+ *
+ * Use a static_assert so we remember to remove it when we upgrade to a newer
+ * C++.
+ */
+static_assert(__cplusplus == 201103L, "");
+template <typename T>
+constexpr T max_constexpr(T l, T r)
+{
+ return l > r ? l : r;
+}
+
+enum consumer_dst_type {
+ CONSUMER_DST_LOCAL,
+ CONSUMER_DST_NET,
+};
+
+enum consumer_trace_chunk_exists_status {
+ CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_LOCAL,
+ CONSUMER_TRACE_CHUNK_EXISTS_STATUS_EXISTS_REMOTE,
+ CONSUMER_TRACE_CHUNK_EXISTS_STATUS_UNKNOWN_CHUNK,
+};
+
+struct consumer_socket {
+ /*
+ * File descriptor. This is just a reference to the consumer data meaning
+ * that every access must be locked and checked for a possible invalid
+ * value.
+ */
+ int *fd_ptr;
+
+ /*
+ * To use this socket (send/recv), this lock MUST be acquired.
+ */
+ pthread_mutex_t *lock;
+
+ /*
+ * Indicates if the socket was registered by a third part
+ * (REGISTER_CONSUMER) or is the spawn consumer of the session daemon.
+ * During the destroy phase of a consumer output, we close the socket if
+ * this flag is set to 1 since we don't need the fd anymore.
+ */
+ unsigned int registered;
+
+ /* Flag if network sockets were sent to the consumer. */
+ unsigned int control_sock_sent;
+ unsigned int data_sock_sent;
+
+ struct lttng_ht_node_ulong node;
+
+ enum lttng_consumer_type type;
+};
+
+struct consumer_data {
+ consumer_data (lttng_consumer_type type_)
+ : type(type_)
+ {}
+
+ enum lttng_consumer_type type;
+
+ /* Mutex to control consumerd pid assignation */
+ pthread_mutex_t pid_mutex = PTHREAD_MUTEX_INITIALIZER;
+ pid_t pid = 0;
+
+ int err_sock = -1;
+ /* These two sockets uses the cmd_unix_sock_path. */
+ int cmd_sock = -1;
+ /*
+ * Write-end of the channel monitoring pipe to be passed to the
+ * consumer.
+ */
+ int channel_monitor_pipe = -1;
+ /*
+ * The metadata socket object is handled differently and only created
+ * locally in this object thus it's the only reference available in the
+ * session daemon. For that reason, a variable for the fd is required and
+ * the metadata socket fd points to it.
+ */
+ int metadata_fd = 0;
+ struct consumer_socket metadata_sock {};
+
+ /* consumer error and command Unix socket path */
+ const char *err_unix_sock_path = nullptr;
+ const char *cmd_unix_sock_path = nullptr;
+
+ /*
+ * This lock has two purposes. It protects any change to the consumer
+ * socket and make sure only one thread uses this object for read/write
+ * operations.
+ */
+ pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+};
+
+/*
+ * Network URIs
+ */
+struct consumer_net {
+ /*
+ * Indicate if URI type is set. Those flags should only be set when the
+ * created URI is done AND valid.
+ */
+ int control_isset;
+ int data_isset;
+
+ /*
+ * The following two URIs MUST have the same destination address for
+ * network streaming to work. Network hop are not yet supported.
+ */
+
+ /* Control path for network streaming. */
+ struct lttng_uri control;
+
+ /* Data path for network streaming. */
+ struct lttng_uri data;
+
+ /* <hostname>/<session-name> */
+ char base_dir[PATH_MAX];
+};
+
+/*
+ * Consumer output object describing where and how to send data.
+ */
+struct consumer_output {
+ struct urcu_ref ref; /* Refcount */
+
+ /* If the consumer is enabled meaning that should be used */
+ unsigned int enabled;
+ enum consumer_dst_type type;
+
+ /*
+ * The net_seq_index is the index of the network stream on the consumer
+ * side. It tells the consumer which streams goes to which relayd with this
+ * index. The relayd sockets are index with it on the consumer side.
+ */
+ uint64_t net_seq_index;
+ /* Store the relay protocol in use if the session is remote. */
+ uint32_t relay_major_version;
+ uint32_t relay_minor_version;
+
+ /* True if relayd supports the clear feature. */
+ bool relay_allows_clear;
+
+ /*
+ * Subdirectory path name used for both local and network
+ * consumer ("kernel", "ust", or empty).
+ */
+ char domain_subdir[
+ max_constexpr(sizeof(DEFAULT_KERNEL_TRACE_DIR),
+ sizeof(DEFAULT_UST_TRACE_DIR))];
+
+ /*
+ * Hashtable of consumer_socket index by the file descriptor value. For
+ * multiarch consumer support, we can have more than one consumer (ex:
+ * 32 and 64 bit).
+ */
+ struct lttng_ht *socks;
+
+ /* Tell if this output is used for snapshot. */
+ unsigned int snapshot:1;
+
+ union {
+ char session_root_path[LTTNG_PATH_MAX];
+ struct consumer_net net;
+ } dst;
+
+ /*
+ * Sub-directory below the session_root_path where the next chunk of
+ * trace will be stored (\0 before the first session rotation).
+ */
+ char chunk_path[LTTNG_PATH_MAX];
+};
+
+struct consumer_socket *consumer_find_socket(int key,
+ const struct consumer_output *consumer);
+struct consumer_socket *consumer_find_socket_by_bitness(int bits,
+ const struct consumer_output *consumer);
+struct consumer_socket *consumer_allocate_socket(int *fd);
+void consumer_add_socket(struct consumer_socket *sock,
+ struct consumer_output *consumer);
+void consumer_del_socket(struct consumer_socket *sock,
+ struct consumer_output *consumer);
+void consumer_destroy_socket(struct consumer_socket *sock);
+int consumer_copy_sockets(struct consumer_output *dst,
+ struct consumer_output *src);
+void consumer_destroy_output_sockets(struct consumer_output *obj);
+int consumer_socket_send(struct consumer_socket *socket, const void *msg,
+ size_t len);
+int consumer_socket_recv(struct consumer_socket *socket, void *msg,
+ size_t len);
+
+struct consumer_output *consumer_create_output(enum consumer_dst_type type);
+struct consumer_output *consumer_copy_output(struct consumer_output *obj);
+void consumer_output_get(struct consumer_output *obj);
+void consumer_output_put(struct consumer_output *obj);
+int consumer_set_network_uri(const struct ltt_session *session,
+ struct consumer_output *obj,
+ struct lttng_uri *uri);
+int consumer_send_fds(struct consumer_socket *sock, const int *fds,
+ size_t nb_fd);
+int consumer_send_msg(struct consumer_socket *sock,
+ const struct lttcomm_consumer_msg *msg);
+int consumer_send_stream(struct consumer_socket *sock,
+ struct consumer_output *dst, struct lttcomm_consumer_msg *msg,
+ const int *fds, size_t nb_fd);
+int consumer_send_channel(struct consumer_socket *sock,
+ struct lttcomm_consumer_msg *msg);
+int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
+ struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
+ enum lttng_stream_type type, uint64_t session_id,
+ const char *session_name, const char *hostname,
+ const char *base_path, int session_live_timer,
+ const uint64_t *current_chunk_id, time_t session_creation_time,
+ bool session_name_contains_creation_time);
+int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
+ int pipe);
+int consumer_send_destroy_relayd(struct consumer_socket *sock,
+ struct consumer_output *consumer);
+int consumer_recv_status_reply(struct consumer_socket *sock);
+int consumer_recv_status_channel(struct consumer_socket *sock,
+ uint64_t *key, unsigned int *stream_count);
+void consumer_output_send_destroy_relayd(struct consumer_output *consumer);
+int consumer_create_socket(struct consumer_data *data,
+ struct consumer_output *output);
+
+void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
+ uint64_t subbuf_size,
+ uint64_t num_subbuf,
+ int overwrite,
+ unsigned int switch_timer_interval,
+ unsigned int read_timer_interval,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ unsigned int monitor_timer_interval,
+ int output,
+ int type,
+ uint64_t session_id,
+ const char *pathname,
+ const char *name,
+ uint64_t relayd_id,
+ uint64_t key,
+ unsigned char *uuid,
+ uint32_t chan_id,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ uint64_t session_id_per_pid,
+ unsigned int monitor,
+ uint32_t ust_app_uid,
+ int64_t blocking_timeout,
+ const char *root_shm_path,
+ const char *shm_path,
+ struct lttng_trace_chunk *trace_chunk,
+ const struct lttng_credentials *buffer_credentials);
+void consumer_init_add_stream_comm_msg(struct lttcomm_consumer_msg *msg,
+ uint64_t channel_key,
+ uint64_t stream_key,
+ int32_t cpu);
+void consumer_init_streams_sent_comm_msg(struct lttcomm_consumer_msg *msg,
+ enum lttng_consumer_command cmd,
+ uint64_t channel_key, uint64_t net_seq_idx);
+void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg,
+ uint64_t channel_key,
+ uint64_t session_id,
+ const char *pathname,
+ uint64_t relayd_id,
+ const char *name,
+ unsigned int nb_init_streams,
+ enum lttng_event_output output,
+ int type,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ unsigned int monitor,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ unsigned int monitor_timer_interval,
+ struct lttng_trace_chunk *trace_chunk);
+int consumer_is_data_pending(uint64_t session_id,
+ struct consumer_output *consumer);
+int consumer_close_metadata(struct consumer_socket *socket,
+ uint64_t metadata_key);
+int consumer_setup_metadata(struct consumer_socket *socket,
+ uint64_t metadata_key);
+int consumer_push_metadata(struct consumer_socket *socket,
+ uint64_t metadata_key, char *metadata_str, size_t len,
+ size_t target_offset, uint64_t version);
+int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
+int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key);
+int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
+ struct consumer_output *consumer, uint64_t *discarded);
+int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
+ struct consumer_output *consumer, uint64_t *lost);
+
+/* Snapshot command. */
+enum lttng_error_code consumer_snapshot_channel(struct consumer_socket *socket,
+ uint64_t key, const struct consumer_output *output, int metadata,
+ const char *channel_path, uint64_t nb_packets_per_stream);
+
+/* Rotation commands. */
+int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
+ struct consumer_output *output, bool is_metadata_channel);
+int consumer_init(struct consumer_socket *socket,
+ const lttng_uuid sessiond_uuid);
+
+int consumer_create_trace_chunk(struct consumer_socket *socket,
+ uint64_t relayd_id, uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ const char *domain_subdir);
+int consumer_close_trace_chunk(struct consumer_socket *socket,
+ uint64_t relayd_id, uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ char *closed_trace_chunk_path);
+int consumer_trace_chunk_exists(struct consumer_socket *socket,
+ uint64_t relayd_id, uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ enum consumer_trace_chunk_exists_status *result);
+int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key);
+
+char *setup_channel_trace_path(struct consumer_output *consumer,
+ const char *session_path, size_t *consumer_path_offset);
+
+/* Clear command */
+int consumer_clear_channel(struct consumer_socket *socket, uint64_t key);
+
+#endif /* _CONSUMER_H */
#include <unistd.h>
#include <urcu/list.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "context.h"
-#include "kernel.h"
-#include "ust-app.h"
-#include "trace-ust.h"
-#include "agent.h"
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "context.hpp"
+#include "kernel.hpp"
+#include "ust-app.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
/*
* Add kernel context to all channel.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_CONTEXT_H
-#define _LTT_CONTEXT_H
-
-#include <lttng/lttng.h>
-
-#include "trace-kernel.h"
-#include "trace-ust.h"
-#include "lttng-ust-ctl.h"
-
-int context_kernel_add(struct ltt_kernel_session *ksession,
- const struct lttng_event_context *ctx,
- const char *channel_name);
-int context_ust_add(struct ltt_ust_session *usess,
- enum lttng_domain_type domain,
- const struct lttng_event_context *ctx,
- const char *channel_name);
-
-#endif /* _LTT_CONTEXT_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_CONTEXT_H
+#define _LTT_CONTEXT_H
+
+#include <lttng/lttng.h>
+
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+#include "lttng-ust-ctl.hpp"
+
+int context_kernel_add(struct ltt_kernel_session *ksession,
+ const struct lttng_event_context *ctx,
+ const char *channel_name);
+int context_ust_add(struct ltt_ust_session *usess,
+ enum lttng_domain_type domain,
+ const struct lttng_event_context *ctx,
+ const char *channel_name);
+
+#endif /* _LTT_CONTEXT_H */
#include <stddef.h>
#include <stdlib.h>
#include <urcu.h>
-#include <common/futex.h>
-#include <common/macros.h>
-
-#include "dispatch.h"
-#include "ust-app.h"
-#include "testpoint.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "thread.h"
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+
+#include "dispatch.hpp"
+#include "ust-app.hpp"
+#include "testpoint.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "thread.hpp"
struct thread_notifiers {
struct ust_cmd_queue *ust_cmd_queue;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_UST_DISPATCH_THREAD_H
-#define SESSIOND_UST_DISPATCH_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
- int apps_cmd_pipe_write_fd,
- int apps_cmd_notify_write_fd);
-
-#endif /* SESSIOND_UST_DISPATCH_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_UST_DISPATCH_THREAD_H
+#define SESSIOND_UST_DISPATCH_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
+ int apps_cmd_pipe_write_fd,
+ int apps_cmd_notify_write_fd);
+
+#endif /* SESSIOND_UST_DISPATCH_THREAD_H */
#include <urcu/compiler.h>
#include <pthread.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/index-allocator.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/shm.h>
-#include <lttng/trigger/trigger-internal.h>
-
-#include "event-notifier-error-accounting.h"
-#include "lttng-ust-error.h"
-#include "ust-app.h"
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/index-allocator.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/shm.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+
+#include "event-notifier-error-accounting.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
#define ERROR_COUNTER_INDEX_HT_INITIAL_SIZE 16
+++ /dev/null
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
-#define _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
-
-#include <stdint.h>
-
-#include <lttng/trigger/trigger.h>
-
-#include "ust-app.h"
-
-enum event_notifier_error_accounting_status {
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD,
- EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED,
-};
-
-/*
- * Initialize the event notifier error accounting system.
- * `buffer_size_kernel` and `buffer_size_ust` represent the number of buckets
- * to be allocated for each domain.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
- uint64_t buffer_size_ust);
-
-/*
- * Register the kernel event notifier group.
- * This allocates the counter object on the kernel side.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_kernel(
- int kernel_event_notifier_group_fd);
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-/*
- * Register a UST application.
- *
- * This reuses (or creates) the counter object of the app UID.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_app(struct ust_app *app);
-
-/*
- * Unregister a UST application.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_unregister_app(struct ust_app *app);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_app(
- struct ust_app *app __attribute__((unused)))
-{
- return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
-}
-
-static inline
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_unregister_app(
- struct ust_app *app __attribute__((unused)))
-{
- return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-/*
- * Allocates, reserves and returns the error counter index for that trigger.
- */
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_event_notifier(
- const struct lttng_trigger *trigger,
- uint64_t *error_counter_index);
-
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_get_count(
- const struct lttng_trigger *trigger,
- uint64_t *count);
-
-void event_notifier_error_accounting_unregister_event_notifier(
- const struct lttng_trigger *trigger);
-
-void event_notifier_error_accounting_fini(void);
-
-#endif /* _EVENT_NOTIFIER_ERROR_ACCOUNTING_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
+#define _EVENT_NOTIFIER_ERROR_ACCOUNTING_H
+
+#include <stdint.h>
+
+#include <lttng/trigger/trigger.h>
+
+#include "ust-app.hpp"
+
+enum event_notifier_error_accounting_status {
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD,
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED,
+};
+
+/*
+ * Initialize the event notifier error accounting system.
+ * `buffer_size_kernel` and `buffer_size_ust` represent the number of buckets
+ * to be allocated for each domain.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
+ uint64_t buffer_size_ust);
+
+/*
+ * Register the kernel event notifier group.
+ * This allocates the counter object on the kernel side.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_kernel(
+ int kernel_event_notifier_group_fd);
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+/*
+ * Register a UST application.
+ *
+ * This reuses (or creates) the counter object of the app UID.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_app(struct ust_app *app);
+
+/*
+ * Unregister a UST application.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_unregister_app(struct ust_app *app);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_app(
+ struct ust_app *app __attribute__((unused)))
+{
+ return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+}
+
+static inline
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_unregister_app(
+ struct ust_app *app __attribute__((unused)))
+{
+ return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+/*
+ * Allocates, reserves and returns the error counter index for that trigger.
+ */
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_register_event_notifier(
+ const struct lttng_trigger *trigger,
+ uint64_t *error_counter_index);
+
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_get_count(
+ const struct lttng_trigger *trigger,
+ uint64_t *count);
+
+void event_notifier_error_accounting_unregister_event_notifier(
+ const struct lttng_trigger *trigger);
+
+void event_notifier_error_accounting_fini(void);
+
+#endif /* _EVENT_NOTIFIER_ERROR_ACCOUNTING_H */
#include <urcu/list.h>
#include <string.h>
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
#include <lttng/lttng.h>
#include <lttng/condition/condition.h>
#include <lttng/condition/event-rule-matches.h>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <common/bytecode/bytecode.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/filter.h>
-#include <common/context.h>
-
-#include "channel.h"
-#include "event.h"
-#include "kernel.h"
-#include "lttng-sessiond.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "ust-app.h"
-#include "trace-kernel.h"
-#include "trace-ust.h"
-#include "agent.h"
-#include "utils.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <common/bytecode/bytecode.hpp>
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/filter.hpp>
+#include <common/context.hpp>
+
+#include "channel.hpp"
+#include "event.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
+#include "trace-kernel.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
+#include "utils.hpp"
/*
* Add unique UST event based on the event name, filter bytecode and loglevel.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_EVENT_H
-#define _LTT_EVENT_H
-
-#include "trace-kernel.h"
-
-struct agent;
-
-int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
- const char *event_name, enum lttng_event_type event_type);
-
-int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
- struct lttng_event *event, char *filter_expression,
- struct lttng_bytecode *filter);
-
-int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- bool internal_event);
-int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, const char *event_name);
-
-int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan);
-
-int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt,
- struct lttng_event *event, struct lttng_bytecode *filter,
- char *filter_expression);
-int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt,
- struct lttng_event *event, struct lttng_bytecode *filter,
- char *filter_expression);
-
-int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
- const char *event_name);
-int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt);
-
-int trigger_agent_enable(
- const struct lttng_trigger *trigger, struct agent *agt);
-int trigger_agent_disable(
- const struct lttng_trigger *trigger, struct agent *agt);
-
-const char *event_get_default_agent_ust_name(enum lttng_domain_type domain);
-
-#endif /* _LTT_EVENT_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_EVENT_H
+#define _LTT_EVENT_H
+
+#include "trace-kernel.hpp"
+
+struct agent;
+
+int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
+ const char *event_name, enum lttng_event_type event_type);
+
+int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
+ struct lttng_event *event, char *filter_expression,
+ struct lttng_bytecode *filter);
+
+int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ bool internal_event);
+int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, const char *event_name);
+
+int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
+
+int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt,
+ struct lttng_event *event, struct lttng_bytecode *filter,
+ char *filter_expression);
+int event_agent_enable_all(struct ltt_ust_session *usess, struct agent *agt,
+ struct lttng_event *event, struct lttng_bytecode *filter,
+ char *filter_expression);
+
+int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
+ const char *event_name);
+int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt);
+
+int trigger_agent_enable(
+ const struct lttng_trigger *trigger, struct agent *agt);
+int trigger_agent_disable(
+ const struct lttng_trigger *trigger, struct agent *agt);
+
+const char *event_get_default_agent_ust_name(enum lttng_domain_type domain);
+
+#endif /* _LTT_EVENT_H */
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
-#include "fd-limit.h"
-#include <common/error.h>
-#include <common/compat/errno.h>
+#include "fd-limit.hpp"
+#include <common/error.hpp>
+#include <common/compat/errno.hpp>
/* total count of fd. */
static long fd_count;
+++ /dev/null
-#ifndef _LTTNG_FD_LIMIT_H
-#define _LTTNG_FD_LIMIT_H
-
-/*
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-enum lttng_fd_type {
- LTTNG_FD_APPS,
- LTTNG_FD_NR_TYPES,
-};
-
-int lttng_fd_get(enum lttng_fd_type type, unsigned int nr);
-void lttng_fd_put(enum lttng_fd_type type, unsigned int nr);
-void lttng_fd_init(void);
-
-#endif /* _LTTNG_FD_LIMIT_H */
--- /dev/null
+#ifndef _LTTNG_FD_LIMIT_H
+#define _LTTNG_FD_LIMIT_H
+
+/*
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+enum lttng_fd_type {
+ LTTNG_FD_APPS,
+ LTTNG_FD_NR_TYPES,
+};
+
+int lttng_fd_get(enum lttng_fd_type type, unsigned int nr);
+void lttng_fd_put(enum lttng_fd_type type, unsigned int nr);
+void lttng_fd_init(void);
+
+#endif /* _LTTNG_FD_LIMIT_H */
*
*/
-#include "lttng-sessiond.h"
-#include <common/uuid.h>
+#include "lttng-sessiond.hpp"
+#include <common/uuid.hpp>
lttng_uuid the_sessiond_uuid;
+++ /dev/null
-#ifndef HEALTH_SESSIOND_H
-#define HEALTH_SESSIOND_H
-
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <lttng/health-internal.h>
-#include <stdbool.h>
-
-enum health_type_sessiond {
- HEALTH_SESSIOND_TYPE_CMD = 0,
- HEALTH_SESSIOND_TYPE_APP_MANAGE = 1,
- HEALTH_SESSIOND_TYPE_APP_REG = 2,
- HEALTH_SESSIOND_TYPE_KERNEL = 3,
- HEALTH_SESSIOND_TYPE_CONSUMER = 4,
- HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY = 6,
- HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH = 7,
- HEALTH_SESSIOND_TYPE_NOTIFICATION = 8,
- HEALTH_SESSIOND_TYPE_ROTATION = 9,
- HEALTH_SESSIOND_TYPE_TIMER = 10,
- HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR = 11,
-
- NR_HEALTH_SESSIOND_TYPES,
-};
-
-/* Application health monitoring */
-extern struct health_app *the_health_sessiond;
-
-bool launch_health_management_thread(void);
-
-#endif /* HEALTH_SESSIOND_H */
--- /dev/null
+#ifndef HEALTH_SESSIOND_H
+#define HEALTH_SESSIOND_H
+
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <lttng/health-internal.hpp>
+#include <stdbool.h>
+
+enum health_type_sessiond {
+ HEALTH_SESSIOND_TYPE_CMD = 0,
+ HEALTH_SESSIOND_TYPE_APP_MANAGE = 1,
+ HEALTH_SESSIOND_TYPE_APP_REG = 2,
+ HEALTH_SESSIOND_TYPE_KERNEL = 3,
+ HEALTH_SESSIOND_TYPE_CONSUMER = 4,
+ HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY = 6,
+ HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH = 7,
+ HEALTH_SESSIOND_TYPE_NOTIFICATION = 8,
+ HEALTH_SESSIOND_TYPE_ROTATION = 9,
+ HEALTH_SESSIOND_TYPE_TIMER = 10,
+ HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR = 11,
+
+ NR_HEALTH_SESSIOND_TYPES,
+};
+
+/* Application health monitoring */
+extern struct health_app *the_health_sessiond;
+
+bool launch_health_management_thread(void);
+
+#endif /* HEALTH_SESSIOND_H */
*
*/
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/pipe.h>
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/pipe.hpp>
#include <inttypes.h>
#include <sys/stat.h>
-#include "utils.h"
-#include "thread.h"
+#include "utils.hpp"
+#include "thread.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _KERN_MODULES_H
-#define _KERN_MODULES_H
-
-/*
- * Compatible lttng-modules version.
- */
-#define KERN_MODULES_PRE_MAJOR 1
-#define KERN_MODULES_PRE_MINOR 9
-
-#define KERN_MODULES_MAJOR 2
-#define KERN_MODULES_MINOR 0
-
-enum kernel_module_property_load_policy {
- KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED = 0,
- KERNEL_MODULE_PROPERTY_LOAD_POLICY_OPTIONAL = 1,
-};
-
-struct kern_modules_param {
- char *name;
- enum kernel_module_property_load_policy load_policy;
- bool loaded;
-};
-
-#endif /* _KERN_MODULES_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _KERN_MODULES_H
+#define _KERN_MODULES_H
+
+/*
+ * Compatible lttng-modules version.
+ */
+#define KERN_MODULES_PRE_MAJOR 1
+#define KERN_MODULES_PRE_MINOR 9
+
+#define KERN_MODULES_MAJOR 2
+#define KERN_MODULES_MINOR 0
+
+enum kernel_module_property_load_policy {
+ KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED = 0,
+ KERNEL_MODULE_PROPERTY_LOAD_POLICY_OPTIONAL = 1,
+};
+
+struct kern_modules_param {
+ char *name;
+ enum kernel_module_property_load_policy load_policy;
+ bool loaded;
+};
+
+#endif /* _KERN_MODULES_H */
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/string.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "kernel-consumer.h"
-#include "notification-thread-commands.h"
-#include "session.h"
-#include "lttng-sessiond.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/string.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "notification-thread-commands.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
static char *create_channel_path(struct consumer_output *consumer,
size_t *consumer_path_offset)
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <sys/types.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "trace-kernel.h"
-
-int kernel_consumer_send_channel_streams(struct consumer_socket *sock,
- struct ltt_kernel_channel *channel, struct ltt_kernel_session *session,
- unsigned int monitor);
-
-int kernel_consumer_send_session(struct consumer_socket *sock,
- struct ltt_kernel_session *session);
-
-int kernel_consumer_add_metadata(struct consumer_socket *sock,
- struct ltt_kernel_session *session, unsigned int monitor);
-
-int kernel_consumer_destroy_channel(struct consumer_socket *socket,
- struct ltt_kernel_channel *channel);
-
-int kernel_consumer_destroy_metadata(struct consumer_socket *socket,
- struct ltt_kernel_metadata *metadata);
-
-int kernel_consumer_streams_sent(struct consumer_socket *sock,
- struct ltt_kernel_session *session, uint64_t channel_key);
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <sys/types.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "trace-kernel.hpp"
+
+int kernel_consumer_send_channel_streams(struct consumer_socket *sock,
+ struct ltt_kernel_channel *channel, struct ltt_kernel_session *session,
+ unsigned int monitor);
+
+int kernel_consumer_send_session(struct consumer_socket *sock,
+ struct ltt_kernel_session *session);
+
+int kernel_consumer_add_metadata(struct consumer_socket *sock,
+ struct ltt_kernel_session *session, unsigned int monitor);
+
+int kernel_consumer_destroy_channel(struct consumer_socket *socket,
+ struct ltt_kernel_channel *channel);
+
+int kernel_consumer_destroy_metadata(struct consumer_socket *socket,
+ struct ltt_kernel_metadata *metadata);
+
+int kernel_consumer_streams_sent(struct consumer_socket *sock,
+ struct ltt_kernel_session *session, uint64_t channel_key);
#include <inttypes.h>
#include <sys/types.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
-#include <common/trace-chunk.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/kernel-ctl/kernel-ioctl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/kernel-ctl/kernel-ioctl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/utils.hpp>
#include <lttng/event.h>
#include <lttng/lttng-error.h>
#include <lttng/tracker.h>
#include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-
-#include "event-notifier-error-accounting.h"
-#include "lttng-sessiond.h"
-#include "lttng-syscall.h"
-#include "condition-internal.h"
-#include "consumer.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
-#include "kern-modules.h"
-#include "sessiond-config.h"
-#include "utils.h"
-#include "rotate.h"
-#include "modprobe.h"
-#include "tracker.h"
-#include "notification-thread-commands.h"
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+
+#include "event-notifier-error-accounting.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "condition-internal.hpp"
+#include "consumer.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
+#include "kern-modules.hpp"
+#include "sessiond-config.hpp"
+#include "utils.hpp"
+#include "rotate.hpp"
+#include "modprobe.hpp"
+#include "tracker.hpp"
+#include "notification-thread-commands.hpp"
/*
* Key used to reference a channel between the sessiond and the consumer. This
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_KERNEL_CTL_H
-#define _LTT_KERNEL_CTL_H
-
-#include "lttng/lttng-error.h"
-#include "lttng/tracker.h"
-#include "session.h"
-#include "snapshot.h"
-#include "trace-kernel.h"
-
-/*
- * Default size for the event list when kernel_list_events is called. This size
- * value is based on the initial LTTng 2.0 version set of tracepoints.
- *
- * This is NOT an upper bound because if the real event list size is bigger,
- * dynamic reallocation is performed.
- */
-#define KERNEL_EVENT_INIT_LIST_SIZE 64
-
-int kernel_add_channel_context(struct ltt_kernel_channel *chan,
- struct ltt_kernel_context *ctx);
-int kernel_create_session(struct ltt_session *session);
-int kernel_create_channel(struct ltt_kernel_session *session,
- struct lttng_channel *chan);
-int kernel_create_event(struct lttng_event *ev, struct ltt_kernel_channel *channel,
- char *filter_expression, struct lttng_bytecode *filter);
-int kernel_disable_channel(struct ltt_kernel_channel *chan);
-int kernel_disable_event(struct ltt_kernel_event *event);
-int kernel_enable_event(struct ltt_kernel_event *event);
-int kernel_enable_channel(struct ltt_kernel_channel *chan);
-enum lttng_error_code kernel_process_attr_tracker_set_tracking_policy(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy);
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_add_value(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-const struct process_attr_tracker *kernel_get_process_attr_tracker(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr);
-int kernel_open_metadata(struct ltt_kernel_session *session);
-int kernel_open_metadata_stream(struct ltt_kernel_session *session);
-int kernel_open_channel_stream(struct ltt_kernel_channel *channel);
-int kernel_flush_buffer(struct ltt_kernel_channel *channel);
-int kernel_metadata_flush_buffer(int fd);
-int kernel_start_session(struct ltt_kernel_session *session);
-int kernel_stop_session(struct ltt_kernel_session *session);
-ssize_t kernel_list_events(struct lttng_event **event_list);
-void kernel_wait_quiescent(void);
-int kernel_validate_version(struct lttng_kernel_abi_tracer_version *kernel_tracer_version,
- struct lttng_kernel_abi_tracer_abi_version *kernel_tracer_abi_version);
-void kernel_destroy_session(struct ltt_kernel_session *ksess);
-void kernel_free_session(struct ltt_kernel_session *ksess);
-void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
-enum lttng_error_code kernel_snapshot_record(
- struct ltt_kernel_session *ksess,
- const struct consumer_output *output,
- uint64_t nb_packets_per_stream);
-int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits);
-enum lttng_error_code kernel_rotate_session(struct ltt_session *session);
-enum lttng_error_code kernel_clear_session(struct ltt_session *session);
-
-int init_kernel_workarounds(void);
-int kernel_supports_ring_buffer_snapshot_sample_positions(void);
-int kernel_supports_ring_buffer_packet_sequence_number(void);
-int kernel_supports_event_notifiers(void);
-int init_kernel_tracer(void);
-void cleanup_kernel_tracer(void);
-bool kernel_tracer_is_initialized(void);
-
-enum lttng_error_code kernel_create_channel_subdirectories(
- const struct ltt_kernel_session *ksess);
-
-enum lttng_error_code kernel_create_event_notifier_group_notification_fd(
- int *event_notifier_group_notification_fd);
-enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(
- int event_notifier_group_notification_fd);
-
-enum lttng_error_code kernel_register_event_notifier(
- struct lttng_trigger *trigger,
- const struct lttng_credentials *cmd_creds);
-enum lttng_error_code kernel_unregister_event_notifier(
- const struct lttng_trigger *trigger);
-
-int kernel_get_notification_fd(void);
-
-#endif /* _LTT_KERNEL_CTL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_KERNEL_CTL_H
+#define _LTT_KERNEL_CTL_H
+
+#include "lttng/lttng-error.h"
+#include "lttng/tracker.h"
+#include "session.hpp"
+#include "snapshot.hpp"
+#include "trace-kernel.hpp"
+
+/*
+ * Default size for the event list when kernel_list_events is called. This size
+ * value is based on the initial LTTng 2.0 version set of tracepoints.
+ *
+ * This is NOT an upper bound because if the real event list size is bigger,
+ * dynamic reallocation is performed.
+ */
+#define KERNEL_EVENT_INIT_LIST_SIZE 64
+
+int kernel_add_channel_context(struct ltt_kernel_channel *chan,
+ struct ltt_kernel_context *ctx);
+int kernel_create_session(struct ltt_session *session);
+int kernel_create_channel(struct ltt_kernel_session *session,
+ struct lttng_channel *chan);
+int kernel_create_event(struct lttng_event *ev, struct ltt_kernel_channel *channel,
+ char *filter_expression, struct lttng_bytecode *filter);
+int kernel_disable_channel(struct ltt_kernel_channel *chan);
+int kernel_disable_event(struct ltt_kernel_event *event);
+int kernel_enable_event(struct ltt_kernel_event *event);
+int kernel_enable_channel(struct ltt_kernel_channel *chan);
+enum lttng_error_code kernel_process_attr_tracker_set_tracking_policy(
+ struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy);
+enum lttng_error_code kernel_process_attr_tracker_inclusion_set_add_value(
+ struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+enum lttng_error_code kernel_process_attr_tracker_inclusion_set_remove_value(
+ struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+const struct process_attr_tracker *kernel_get_process_attr_tracker(
+ struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr);
+int kernel_open_metadata(struct ltt_kernel_session *session);
+int kernel_open_metadata_stream(struct ltt_kernel_session *session);
+int kernel_open_channel_stream(struct ltt_kernel_channel *channel);
+int kernel_flush_buffer(struct ltt_kernel_channel *channel);
+int kernel_metadata_flush_buffer(int fd);
+int kernel_start_session(struct ltt_kernel_session *session);
+int kernel_stop_session(struct ltt_kernel_session *session);
+ssize_t kernel_list_events(struct lttng_event **event_list);
+void kernel_wait_quiescent(void);
+int kernel_validate_version(struct lttng_kernel_abi_tracer_version *kernel_tracer_version,
+ struct lttng_kernel_abi_tracer_abi_version *kernel_tracer_abi_version);
+void kernel_destroy_session(struct ltt_kernel_session *ksess);
+void kernel_free_session(struct ltt_kernel_session *ksess);
+void kernel_destroy_channel(struct ltt_kernel_channel *kchan);
+enum lttng_error_code kernel_snapshot_record(
+ struct ltt_kernel_session *ksess,
+ const struct consumer_output *output,
+ uint64_t nb_packets_per_stream);
+int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits);
+enum lttng_error_code kernel_rotate_session(struct ltt_session *session);
+enum lttng_error_code kernel_clear_session(struct ltt_session *session);
+
+int init_kernel_workarounds(void);
+int kernel_supports_ring_buffer_snapshot_sample_positions(void);
+int kernel_supports_ring_buffer_packet_sequence_number(void);
+int kernel_supports_event_notifiers(void);
+int init_kernel_tracer(void);
+void cleanup_kernel_tracer(void);
+bool kernel_tracer_is_initialized(void);
+
+enum lttng_error_code kernel_create_channel_subdirectories(
+ const struct ltt_kernel_session *ksess);
+
+enum lttng_error_code kernel_create_event_notifier_group_notification_fd(
+ int *event_notifier_group_notification_fd);
+enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(
+ int event_notifier_group_notification_fd);
+
+enum lttng_error_code kernel_register_event_notifier(
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *cmd_creds);
+enum lttng_error_code kernel_unregister_event_notifier(
+ const struct lttng_trigger *trigger);
+
+int kernel_get_notification_fd(void);
+
+#endif /* _LTT_KERNEL_CTL_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2013 Raphaël Beamonte <raphael.beamonte@gmail.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SESSIOND_H
-#define _LTT_SESSIOND_H
-
-#include <urcu.h>
-#include <urcu/wfcqueue.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/payload.h>
-#include <common/compat/poll.h>
-#include <common/compat/socket.h>
-#include <common/uuid.h>
-
-#include "session.h"
-#include "ust-app.h"
-#include "notification-thread.h"
-#include "sessiond-config.h"
-
-/*
- * Consumer daemon state which is changed when spawning it, killing it or in
- * case of a fatal error.
- */
-enum consumerd_state {
- CONSUMER_STARTED = 1,
- CONSUMER_STOPPED = 2,
- CONSUMER_ERROR = 3,
-};
-
-/* Unique identifier of a session daemon instance. */
-extern lttng_uuid the_sessiond_uuid;
-
-/*
- * This consumer daemon state is used to validate if a client command will be
- * able to reach the consumer. If not, the client is informed. For instance,
- * doing a "lttng start" when the consumer state is set to ERROR will return an
- * error to the client.
- *
- * The following example shows a possible race condition of this scheme:
- *
- * consumer thread error happens
- * client cmd arrives
- * client cmd checks state -> still OK
- * consumer thread exit, sets error
- * client cmd try to talk to consumer
- * ...
- *
- * However, since the consumer is a different daemon, we have no way of making
- * sure the command will reach it safely even with this state flag. This is why
- * we consider that up to the state validation during command processing, the
- * command is safe. After that, we can not guarantee the correctness of the
- * client request vis-a-vis the consumer.
- */
-extern enum consumerd_state the_ust_consumerd_state;
-extern enum consumerd_state the_kernel_consumerd_state;
-
-/* Set in main.c at boot time of the daemon */
-extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
-extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
-
-/* Notification thread handle. */
-extern struct notification_thread_handle *the_notification_thread_handle;
-
-/*
- * This contains extra data needed for processing a command received by the
- * session daemon from the lttng client.
- */
-struct command_ctx {
- unsigned int lttng_msg_size;
- struct ltt_session *session;
- /* Input message */
- struct lttcomm_session_msg lsm;
- /* Reply content, starts with an lttcomm_lttng_msg header. */
- struct lttng_payload reply_payload;
- lttng_sock_cred creds;
-};
-
-struct ust_command {
- int sock;
- struct ust_register_msg reg_msg;
- struct cds_wfcq_node node;
-};
-
-/*
- * Queue used to enqueue UST registration request (ust_command) and synchronized
- * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
- */
-struct ust_cmd_queue {
- int32_t futex;
- struct cds_wfcq_head head;
- struct cds_wfcq_tail tail;
-};
-
-/*
- * This is the wait queue containing wait nodes during the application
- * registration process.
- */
-struct ust_reg_wait_queue {
- unsigned long count;
- struct cds_list_head head;
-};
-
-/*
- * Use by the dispatch registration to queue UST command socket to wait for the
- * notify socket.
- */
-struct ust_reg_wait_node {
- struct ust_app *app;
- struct cds_list_head head;
-};
-
-extern int the_kernel_poll_pipe[2];
-
-/*
- * Populated when the daemon starts with the current page size of the system.
- * Set in main() with the current page size.
- */
-extern long the_page_size;
-
-/* Application health monitoring */
-extern struct health_app *the_health_sessiond;
-
-extern struct sessiond_config the_config;
-
-extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
-
-/* Parent PID for --sig-parent option */
-extern pid_t the_ppid;
-/* Internal parent PID use with daemonize. */
-extern pid_t the_child_ppid;
-
-/* Consumer daemon specific control data. */
-extern struct consumer_data the_ustconsumer32_data;
-extern struct consumer_data the_ustconsumer64_data;
-extern struct consumer_data the_kconsumer_data;
-
-int sessiond_init_thread_quit_pipe(void);
-int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
-int sessiond_wait_for_quit_pipe(int timeout_ms);
-int sessiond_notify_quit_pipe(void);
-void sessiond_close_quit_pipe(void);
-
-int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
-void sessiond_signal_parents(void);
-
-void sessiond_set_client_thread_state(bool running);
-void sessiond_wait_client_thread_stopped(void);
-
-void *thread_manage_consumer(void *data);
-
-#endif /* _LTT_SESSIOND_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2013 Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SESSIOND_H
+#define _LTT_SESSIOND_H
+
+#include <urcu.h>
+#include <urcu/wfcqueue.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/payload.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/uuid.hpp>
+
+#include "session.hpp"
+#include "ust-app.hpp"
+#include "notification-thread.hpp"
+#include "sessiond-config.hpp"
+
+/*
+ * Consumer daemon state which is changed when spawning it, killing it or in
+ * case of a fatal error.
+ */
+enum consumerd_state {
+ CONSUMER_STARTED = 1,
+ CONSUMER_STOPPED = 2,
+ CONSUMER_ERROR = 3,
+};
+
+/* Unique identifier of a session daemon instance. */
+extern lttng_uuid the_sessiond_uuid;
+
+/*
+ * This consumer daemon state is used to validate if a client command will be
+ * able to reach the consumer. If not, the client is informed. For instance,
+ * doing a "lttng start" when the consumer state is set to ERROR will return an
+ * error to the client.
+ *
+ * The following example shows a possible race condition of this scheme:
+ *
+ * consumer thread error happens
+ * client cmd arrives
+ * client cmd checks state -> still OK
+ * consumer thread exit, sets error
+ * client cmd try to talk to consumer
+ * ...
+ *
+ * However, since the consumer is a different daemon, we have no way of making
+ * sure the command will reach it safely even with this state flag. This is why
+ * we consider that up to the state validation during command processing, the
+ * command is safe. After that, we can not guarantee the correctness of the
+ * client request vis-a-vis the consumer.
+ */
+extern enum consumerd_state the_ust_consumerd_state;
+extern enum consumerd_state the_kernel_consumerd_state;
+
+/* Set in main.c at boot time of the daemon */
+extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
+extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
+
+/* Notification thread handle. */
+extern struct notification_thread_handle *the_notification_thread_handle;
+
+/*
+ * This contains extra data needed for processing a command received by the
+ * session daemon from the lttng client.
+ */
+struct command_ctx {
+ unsigned int lttng_msg_size;
+ struct ltt_session *session;
+ /* Input message */
+ struct lttcomm_session_msg lsm;
+ /* Reply content, starts with an lttcomm_lttng_msg header. */
+ struct lttng_payload reply_payload;
+ lttng_sock_cred creds;
+};
+
+struct ust_command {
+ int sock;
+ struct ust_register_msg reg_msg;
+ struct cds_wfcq_node node;
+};
+
+/*
+ * Queue used to enqueue UST registration request (ust_command) and synchronized
+ * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
+ */
+struct ust_cmd_queue {
+ int32_t futex;
+ struct cds_wfcq_head head;
+ struct cds_wfcq_tail tail;
+};
+
+/*
+ * This is the wait queue containing wait nodes during the application
+ * registration process.
+ */
+struct ust_reg_wait_queue {
+ unsigned long count;
+ struct cds_list_head head;
+};
+
+/*
+ * Use by the dispatch registration to queue UST command socket to wait for the
+ * notify socket.
+ */
+struct ust_reg_wait_node {
+ struct ust_app *app;
+ struct cds_list_head head;
+};
+
+extern int the_kernel_poll_pipe[2];
+
+/*
+ * Populated when the daemon starts with the current page size of the system.
+ * Set in main() with the current page size.
+ */
+extern long the_page_size;
+
+/* Application health monitoring */
+extern struct health_app *the_health_sessiond;
+
+extern struct sessiond_config the_config;
+
+extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
+
+/* Parent PID for --sig-parent option */
+extern pid_t the_ppid;
+/* Internal parent PID use with daemonize. */
+extern pid_t the_child_ppid;
+
+/* Consumer daemon specific control data. */
+extern struct consumer_data the_ustconsumer32_data;
+extern struct consumer_data the_ustconsumer64_data;
+extern struct consumer_data the_kconsumer_data;
+
+int sessiond_init_thread_quit_pipe(void);
+int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+int sessiond_wait_for_quit_pipe(int timeout_ms);
+int sessiond_notify_quit_pipe(void);
+void sessiond_close_quit_pipe(void);
+
+int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
+void sessiond_signal_parents(void);
+
+void sessiond_set_client_thread_state(bool running);
+void sessiond_wait_client_thread_stopped(void);
+
+void *thread_manage_consumer(void *data);
+
+#endif /* _LTT_SESSIOND_H */
#define _LGPL_SOURCE
#include <stdbool.h>
-#include <common/common.h>
-#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/common.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
-#include "lttng-sessiond.h"
-#include "kernel.h"
-#include "lttng-syscall.h"
-#include "utils.h"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-syscall.hpp"
+#include "utils.hpp"
/* Global syscall table. */
struct syscall *syscall_table;
+++ /dev/null
-/*
- * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SYSCALL_H
-#define LTTNG_SYSCALL_H
-
-#include <common/hashtable/hashtable.h>
-#include <lttng/event.h>
-
-#include "trace-kernel.h"
-
-/*
- * Default size of the kernel system call array. With this size, we usually
- * reallocate twice considering a 32 bit compat layer also.
- */
-#define SYSCALL_TABLE_INIT_SIZE 256
-
-/* Maximum length of a syscall name. */
-#define SYSCALL_NAME_LEN 255
-
-/*
- * Represent a kernel syscall and used when we are populating the internal
- * list.
- */
-struct syscall {
- uint32_t index;
- uint32_t bitness;
- char name[SYSCALL_NAME_LEN];
- /* Used by the list syscalls command. */
- struct lttng_ht_node_str node;
-};
-
-/*
- * Allocated once when listing all syscalls at boot time. This is an array
- * indexed by the syscall index provided in the listing.
- */
-extern struct syscall *syscall_table;
-
-/* Use to list kernel system calls. */
-int syscall_init_table(int tracer_fd);
-ssize_t syscall_table_list(struct lttng_event **events);
-
-#endif /* LTTNG_SYSCALL_H */
--- /dev/null
+/*
+ * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SYSCALL_H
+#define LTTNG_SYSCALL_H
+
+#include <common/hashtable/hashtable.hpp>
+#include <lttng/event.h>
+
+#include "trace-kernel.hpp"
+
+/*
+ * Default size of the kernel system call array. With this size, we usually
+ * reallocate twice considering a 32 bit compat layer also.
+ */
+#define SYSCALL_TABLE_INIT_SIZE 256
+
+/* Maximum length of a syscall name. */
+#define SYSCALL_NAME_LEN 255
+
+/*
+ * Represent a kernel syscall and used when we are populating the internal
+ * list.
+ */
+struct syscall {
+ uint32_t index;
+ uint32_t bitness;
+ char name[SYSCALL_NAME_LEN];
+ /* Used by the list syscalls command. */
+ struct lttng_ht_node_str node;
+};
+
+/*
+ * Allocated once when listing all syscalls at boot time. This is an array
+ * indexed by the syscall index provided in the listing.
+ */
+extern struct syscall *syscall_table;
+
+/* Use to list kernel system calls. */
+int syscall_init_table(int tracer_fd);
+ssize_t syscall_table_list(struct lttng_event **events);
+
+#endif /* LTTNG_SYSCALL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_ABI_H
-#define LTTNG_UST_ABI_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-abi.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-abi-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_ABI_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_ABI_H
+#define LTTNG_UST_ABI_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-abi.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-abi-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_ABI_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_CTL_H
-#define LTTNG_UST_CTL_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-ctl.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-ctl-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_CTL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_CTL_H
+#define LTTNG_UST_CTL_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-ctl.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-ctl-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_CTL_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_ERROR_H
-#define LTTNG_UST_ERROR_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-#include <lttng/ust-error.h>
-#else /* HAVE_LIBLTTNG_UST_CTL */
-/* Use local copy of the LTTng-UST header. */
-#include "ust-error-internal.h"
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_ERROR_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_ERROR_H
+#define LTTNG_UST_ERROR_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-error.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-error-internal.hpp"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_ERROR_H */
#include <unistd.h>
#include <ctype.h>
-#include <common/common.h>
-#include <common/compat/socket.h>
-#include <common/compat/getenv.h>
-#include <common/defaults.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/futex.h>
-#include <common/relayd/relayd.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/daemonize.h>
-#include <common/config/session-config.h>
-#include <common/ini-config/ini-config.h>
-#include <common/dynamic-buffer.h>
-#include <lttng/event-internal.h>
-
-#include "lttng-sessiond.h"
-#include "buffer-registry.h"
-#include "channel.h"
-#include "cmd.h"
-#include "consumer.h"
-#include "context.h"
-#include "event.h"
-#include "event-notifier-error-accounting.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "ust-consumer.h"
-#include "utils.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "testpoint.h"
-#include "notify-apps.h"
-#include "agent-thread.h"
-#include "save.h"
-#include "notification-thread.h"
-#include "notification-thread-commands.h"
-#include "rotation-thread.h"
-#include "agent.h"
-#include "sessiond-config.h"
-#include "timer.h"
-#include "thread.h"
-#include "client.h"
-#include "dispatch.h"
-#include "register.h"
-#include "manage-apps.h"
-#include "manage-kernel.h"
-#include "modprobe.h"
-#include "ust-sigbus.h"
+#include <common/common.hpp>
+#include <common/compat/socket.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/defaults.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/futex.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/daemonize.hpp>
+#include <common/config/session-config.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <lttng/event-internal.hpp>
+#include "lttng-sessiond.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "context.hpp"
+#include "event.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "ust-consumer.hpp"
+#include "utils.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "testpoint.hpp"
+#include "notify-apps.hpp"
+#include "agent-thread.hpp"
+#include "save.hpp"
+#include "notification-thread.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotation-thread.hpp"
+#include "agent.hpp"
+#include "sessiond-config.hpp"
+#include "timer.hpp"
+#include "thread.hpp"
+#include "client.hpp"
+#include "dispatch.hpp"
+#include "register.hpp"
+#include "manage-apps.hpp"
+#include "manage-kernel.hpp"
+#include "modprobe.hpp"
+#include "ust-sigbus.hpp"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
*
*/
-#include "manage-apps.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
+#include "manage-apps.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
-#define SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_application_management_thread(int apps_cmd_pipe_read_fd);
-
-#endif /* SESSIOND_APPLICATION_MANAGEMENT_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
+#define SESSIOND_APPLICATION_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_application_management_thread(int apps_cmd_pipe_read_fd);
+
+#endif /* SESSIOND_APPLICATION_MANAGEMENT_THREAD_H */
#include <signal.h>
-#include <common/pipe.h>
-#include <common/utils.h>
-
-#include "manage-consumer.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
-#include "ust-consumer.h"
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
+#include "manage-consumer.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
+#include "ust-consumer.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
-#define SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_consumer_management_thread(struct consumer_data *consumer_data);
-
-#endif /* SESSIOND_CONSUMER_MANAGEMENT_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
+#define SESSIOND_CONSUMER_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_consumer_management_thread(struct consumer_data *consumer_data);
+
+#endif /* SESSIOND_CONSUMER_MANAGEMENT_THREAD_H */
*
*/
-#include <common/pipe.h>
-#include <common/utils.h>
-
-#include "manage-kernel.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "utils.h"
-#include "thread.h"
-#include "kernel.h"
-#include "kernel-consumer.h"
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
+#include "manage-kernel.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
+#include "kernel.hpp"
+#include "kernel-consumer.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_KERNEL_MANAGEMENT_THREAD_H
-#define SESSIOND_KERNEL_MANAGEMENT_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd);
-
-#endif /* SESSIOND_KERNEL_MANAGEMENT_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_KERNEL_MANAGEMENT_THREAD_H
+#define SESSIOND_KERNEL_MANAGEMENT_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd);
+
+#endif /* SESSIOND_KERNEL_MANAGEMENT_THREAD_H */
#include <stdlib.h>
#include <sys/wait.h>
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
-#include "modprobe.h"
-#include "kern-modules.h"
-#include "lttng-sessiond.h"
+#include "modprobe.hpp"
+#include "kern-modules.hpp"
+#include "lttng-sessiond.hpp"
/* LTTng kernel tracer mandatory core modules list */
struct kern_modules_param kern_modules_control_core[] = {
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _MODPROBE_H
-#define _MODPROBE_H
-
-void modprobe_remove_lttng_all(void);
-void modprobe_remove_lttng_control(void);
-void modprobe_remove_lttng_data(void);
-int modprobe_lttng_control(void);
-int modprobe_lttng_data(void);
-
-#endif /* _MODPROBE_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _MODPROBE_H
+#define _MODPROBE_H
+
+void modprobe_remove_lttng_all(void);
+void modprobe_remove_lttng_control(void);
+void modprobe_remove_lttng_data(void);
+int modprobe_lttng_control(void);
+int modprobe_lttng_data(void);
+
+#endif /* _MODPROBE_H */
#include <lttng/trigger/trigger.h>
#include <lttng/lttng-error.h>
-#include "notification-thread.h"
-#include "notification-thread-commands.h"
-#include <common/error.h>
+#include "notification-thread.hpp"
+#include "notification-thread-commands.hpp"
+#include <common/error.hpp>
#include <unistd.h>
#include <stdint.h>
#include <inttypes.h>
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_COMMANDS_H
-#define NOTIFICATION_THREAD_COMMANDS_H
-
-#include <lttng/domain.h>
-#include <lttng/lttng-error.h>
-#include <urcu/rculfhash.h>
-#include "notification-thread.h"
-#include "notification-thread-internal.h"
-#include "notification-thread-events.h"
-#include <common/waiter.h>
-#include <stdbool.h>
-
-struct notification_thread_data;
-struct lttng_trigger;
-
-enum notification_thread_command_type {
- NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
- NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
- NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
- NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
- NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
- NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
- NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
- NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
- NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
- NOTIFICATION_COMMAND_TYPE_QUIT,
- NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
- NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
-};
-
-struct notification_thread_command {
- struct cds_list_head cmd_list_node;
-
- enum notification_thread_command_type type;
- union {
- /* Register trigger. */
- struct {
- struct lttng_trigger *trigger;
- bool is_trigger_anonymous;
- } register_trigger;
- /* Unregister trigger. */
- struct {
- const struct lttng_trigger *trigger;
- } unregister_trigger;
- /* Add channel. */
- struct {
- struct {
- const char *name;
- uid_t uid;
- gid_t gid;
- } session;
- struct {
- const char *name;
- enum lttng_domain_type domain;
- uint64_t key;
- uint64_t capacity;
- } channel;
- } add_channel;
- /* Remove channel. */
- struct {
- uint64_t key;
- enum lttng_domain_type domain;
- } remove_channel;
- struct {
- const char *session_name;
- uid_t uid;
- gid_t gid;
- uint64_t trace_archive_chunk_id;
- /* Weak reference. */
- struct lttng_trace_archive_location *location;
- } session_rotation;
- /* Add/Remove tracer event source fd. */
- struct {
- int tracer_event_source_fd;
- enum lttng_domain_type domain;
- } tracer_event_source;
- /* List triggers. */
- struct {
- /* Credentials of the requesting user. */
- uid_t uid;
- } list_triggers;
- /* Client communication update. */
- struct {
- notification_client_id id;
- enum client_transmission_status status;
- } client_communication_update;
-
- struct {
- const struct lttng_trigger *trigger;
- } get_trigger;
-
- } parameters;
-
- union {
- struct {
- struct lttng_triggers *triggers;
- } list_triggers;
- struct {
- struct lttng_trigger *trigger;
- } get_trigger;
- } reply;
- /* lttng_waiter on which to wait for command reply (optional). */
- struct lttng_waiter reply_waiter;
- enum lttng_error_code reply_code;
- bool is_async;
-};
-
-enum lttng_error_code notification_thread_command_register_trigger(
- struct notification_thread_handle *handle,
- struct lttng_trigger *trigger,
- bool is_anonymous_trigger);
-
-enum lttng_error_code notification_thread_command_unregister_trigger(
- struct notification_thread_handle *handle,
- const struct lttng_trigger *trigger);
-
-enum lttng_error_code notification_thread_command_add_channel(
- struct notification_thread_handle *handle,
- char *session_name, uid_t session_uid, gid_t session_gid,
- char *channel_name, uint64_t key,
- enum lttng_domain_type domain, uint64_t capacity);
-
-enum lttng_error_code notification_thread_command_remove_channel(
- struct notification_thread_handle *handle,
- uint64_t key, enum lttng_domain_type domain);
-
-enum lttng_error_code notification_thread_command_session_rotation_ongoing(
- struct notification_thread_handle *handle,
- const char *session_name, uid_t session_uid, gid_t session_gid,
- uint64_t trace_archive_chunk_id);
-
-/* Ownership of location is transferred. */
-enum lttng_error_code notification_thread_command_session_rotation_completed(
- struct notification_thread_handle *handle,
- const char *session_name, uid_t session_uid, gid_t session_gid,
- uint64_t trace_archive_chunk_id,
- struct lttng_trace_archive_location *location);
-
-/*
- * Return the set of triggers visible to a given client.
- *
- * The trigger objects contained in the set are the actual trigger instances
- * used by the notification subsystem (i.e. not a copy). Given that the command
- * is only used to serialize the triggers, this is fine: the properties that
- * are serialized are immutable over the lifetime of the triggers.
- *
- * Moreover, the lifetime of the trigger instances is protected through
- * reference counting (references are held by the trigger set).
- *
- * The caller has the exclusive ownership of the returned trigger set.
- */
-enum lttng_error_code notification_thread_command_list_triggers(
- struct notification_thread_handle *handle,
- uid_t client_uid,
- struct lttng_triggers **triggers);
-
-/*
- * The ownership of trigger_event_application_pipe is _not_ transferred to
- * the notification thread.
- */
-enum lttng_error_code notification_thread_command_add_tracer_event_source(
- struct notification_thread_handle *handle,
- int tracer_event_source_fd,
- enum lttng_domain_type domain);
-
-enum lttng_error_code notification_thread_command_remove_tracer_event_source(
- struct notification_thread_handle *handle,
- int tracer_event_source_fd);
-
-void notification_thread_command_quit(
- struct notification_thread_handle *handle);
-
-enum lttng_error_code notification_thread_command_get_trigger(
- struct notification_thread_handle *handle,
- const struct lttng_trigger *trigger,
- struct lttng_trigger **real_trigger);
-
-#endif /* NOTIFICATION_THREAD_COMMANDS_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_COMMANDS_H
+#define NOTIFICATION_THREAD_COMMANDS_H
+
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
+#include <urcu/rculfhash.h>
+#include "notification-thread.hpp"
+#include "notification-thread-internal.hpp"
+#include "notification-thread-events.hpp"
+#include <common/waiter.hpp>
+#include <stdbool.h>
+
+struct notification_thread_data;
+struct lttng_trigger;
+
+enum notification_thread_command_type {
+ NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
+ NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
+ NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
+ NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
+ NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
+ NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
+ NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
+ NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
+ NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
+ NOTIFICATION_COMMAND_TYPE_QUIT,
+ NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
+ NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
+};
+
+struct notification_thread_command {
+ struct cds_list_head cmd_list_node;
+
+ enum notification_thread_command_type type;
+ union {
+ /* Register trigger. */
+ struct {
+ struct lttng_trigger *trigger;
+ bool is_trigger_anonymous;
+ } register_trigger;
+ /* Unregister trigger. */
+ struct {
+ const struct lttng_trigger *trigger;
+ } unregister_trigger;
+ /* Add channel. */
+ struct {
+ struct {
+ const char *name;
+ uid_t uid;
+ gid_t gid;
+ } session;
+ struct {
+ const char *name;
+ enum lttng_domain_type domain;
+ uint64_t key;
+ uint64_t capacity;
+ } channel;
+ } add_channel;
+ /* Remove channel. */
+ struct {
+ uint64_t key;
+ enum lttng_domain_type domain;
+ } remove_channel;
+ struct {
+ const char *session_name;
+ uid_t uid;
+ gid_t gid;
+ uint64_t trace_archive_chunk_id;
+ /* Weak reference. */
+ struct lttng_trace_archive_location *location;
+ } session_rotation;
+ /* Add/Remove tracer event source fd. */
+ struct {
+ int tracer_event_source_fd;
+ enum lttng_domain_type domain;
+ } tracer_event_source;
+ /* List triggers. */
+ struct {
+ /* Credentials of the requesting user. */
+ uid_t uid;
+ } list_triggers;
+ /* Client communication update. */
+ struct {
+ notification_client_id id;
+ enum client_transmission_status status;
+ } client_communication_update;
+
+ struct {
+ const struct lttng_trigger *trigger;
+ } get_trigger;
+
+ } parameters;
+
+ union {
+ struct {
+ struct lttng_triggers *triggers;
+ } list_triggers;
+ struct {
+ struct lttng_trigger *trigger;
+ } get_trigger;
+ } reply;
+ /* lttng_waiter on which to wait for command reply (optional). */
+ struct lttng_waiter reply_waiter;
+ enum lttng_error_code reply_code;
+ bool is_async;
+};
+
+enum lttng_error_code notification_thread_command_register_trigger(
+ struct notification_thread_handle *handle,
+ struct lttng_trigger *trigger,
+ bool is_anonymous_trigger);
+
+enum lttng_error_code notification_thread_command_unregister_trigger(
+ struct notification_thread_handle *handle,
+ const struct lttng_trigger *trigger);
+
+enum lttng_error_code notification_thread_command_add_channel(
+ struct notification_thread_handle *handle,
+ char *session_name, uid_t session_uid, gid_t session_gid,
+ char *channel_name, uint64_t key,
+ enum lttng_domain_type domain, uint64_t capacity);
+
+enum lttng_error_code notification_thread_command_remove_channel(
+ struct notification_thread_handle *handle,
+ uint64_t key, enum lttng_domain_type domain);
+
+enum lttng_error_code notification_thread_command_session_rotation_ongoing(
+ struct notification_thread_handle *handle,
+ const char *session_name, uid_t session_uid, gid_t session_gid,
+ uint64_t trace_archive_chunk_id);
+
+/* Ownership of location is transferred. */
+enum lttng_error_code notification_thread_command_session_rotation_completed(
+ struct notification_thread_handle *handle,
+ const char *session_name, uid_t session_uid, gid_t session_gid,
+ uint64_t trace_archive_chunk_id,
+ struct lttng_trace_archive_location *location);
+
+/*
+ * Return the set of triggers visible to a given client.
+ *
+ * The trigger objects contained in the set are the actual trigger instances
+ * used by the notification subsystem (i.e. not a copy). Given that the command
+ * is only used to serialize the triggers, this is fine: the properties that
+ * are serialized are immutable over the lifetime of the triggers.
+ *
+ * Moreover, the lifetime of the trigger instances is protected through
+ * reference counting (references are held by the trigger set).
+ *
+ * The caller has the exclusive ownership of the returned trigger set.
+ */
+enum lttng_error_code notification_thread_command_list_triggers(
+ struct notification_thread_handle *handle,
+ uid_t client_uid,
+ struct lttng_triggers **triggers);
+
+/*
+ * The ownership of trigger_event_application_pipe is _not_ transferred to
+ * the notification thread.
+ */
+enum lttng_error_code notification_thread_command_add_tracer_event_source(
+ struct notification_thread_handle *handle,
+ int tracer_event_source_fd,
+ enum lttng_domain_type domain);
+
+enum lttng_error_code notification_thread_command_remove_tracer_event_source(
+ struct notification_thread_handle *handle,
+ int tracer_event_source_fd);
+
+void notification_thread_command_quit(
+ struct notification_thread_handle *handle);
+
+enum lttng_error_code notification_thread_command_get_trigger(
+ struct notification_thread_handle *handle,
+ const struct lttng_trigger *trigger,
+ struct lttng_trigger **real_trigger);
+
+#endif /* NOTIFICATION_THREAD_COMMANDS_H */
*/
#include "lttng/action/action.h"
-#include "lttng/trigger/trigger-internal.h"
+#include "lttng/trigger/trigger-internal.hpp"
#define _LGPL_SOURCE
#include <urcu.h>
#include <urcu/rculfhash.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/futex.h>
-#include <common/unix.h>
-#include <common/dynamic-buffer.h>
-#include <common/hashtable/utils.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/futex.hpp>
+#include <common/unix.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
#include <lttng/condition/condition.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/domain-internal.h>
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <lttng/domain-internal.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/domain-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/domain-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <time.h>
#include <unistd.h>
#include <inttypes.h>
#include <fcntl.h>
-#include "condition-internal.h"
-#include "event-notifier-error-accounting.h"
-#include "notification-thread.h"
-#include "notification-thread-events.h"
-#include "notification-thread-commands.h"
-#include "lttng-sessiond.h"
-#include "kernel.h"
+#include "condition-internal.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "notification-thread.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread-commands.hpp"
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
#define CLIENT_POLL_MASK_IN (LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP)
#define CLIENT_POLL_MASK_IN_OUT (CLIENT_POLL_MASK_IN | LPOLLOUT)
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_EVENTS_H
-#define NOTIFICATION_THREAD_EVENTS_H
-
-#include <lttng/domain.h>
-#include "notification-thread.h"
-
-/**
- * Event handling function shall only return an error if
- * the thread should be stopped.
- */
-int handle_notification_thread_command(
- struct notification_thread_handle *handle,
- struct notification_thread_state *state);
-
-int handle_notification_thread_client_connect(
- struct notification_thread_state *state);
-
-int handle_notification_thread_client_disconnect(
- int client_fd,
- struct notification_thread_state *state);
-
-int handle_notification_thread_client_disconnect_all(
- struct notification_thread_state *state);
-
-int handle_notification_thread_trigger_unregister_all(
- struct notification_thread_state *state);
-
-int handle_notification_thread_tracer_event_source_died(
- struct notification_thread_state *state,
- int tracer_event_source_fd);
-
-int handle_notification_thread_client_in(
- struct notification_thread_state *state,
- int socket);
-
-int handle_notification_thread_client_out(
- struct notification_thread_state *state,
- int socket);
-
-int handle_notification_thread_channel_sample(
- struct notification_thread_state *state, int pipe,
- enum lttng_domain_type domain);
-
-int handle_notification_thread_event_notification(
- struct notification_thread_state *state, int pipe,
- enum lttng_domain_type domain);
-
-#endif /* NOTIFICATION_THREAD_EVENTS_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_EVENTS_H
+#define NOTIFICATION_THREAD_EVENTS_H
+
+#include <lttng/domain.h>
+#include "notification-thread.hpp"
+
+/**
+ * Event handling function shall only return an error if
+ * the thread should be stopped.
+ */
+int handle_notification_thread_command(
+ struct notification_thread_handle *handle,
+ struct notification_thread_state *state);
+
+int handle_notification_thread_client_connect(
+ struct notification_thread_state *state);
+
+int handle_notification_thread_client_disconnect(
+ int client_fd,
+ struct notification_thread_state *state);
+
+int handle_notification_thread_client_disconnect_all(
+ struct notification_thread_state *state);
+
+int handle_notification_thread_trigger_unregister_all(
+ struct notification_thread_state *state);
+
+int handle_notification_thread_tracer_event_source_died(
+ struct notification_thread_state *state,
+ int tracer_event_source_fd);
+
+int handle_notification_thread_client_in(
+ struct notification_thread_state *state,
+ int socket);
+
+int handle_notification_thread_client_out(
+ struct notification_thread_state *state,
+ int socket);
+
+int handle_notification_thread_channel_sample(
+ struct notification_thread_state *state, int pipe,
+ enum lttng_domain_type domain);
+
+int handle_notification_thread_event_notification(
+ struct notification_thread_state *state, int pipe,
+ enum lttng_domain_type domain);
+
+#endif /* NOTIFICATION_THREAD_EVENTS_H */
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_INTERNAL_H
-#define NOTIFICATION_THREAD_INTERNAL_H
-
-#include <common/compat/socket.h>
-#include <common/credentials.h>
-#include <common/payload.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/ref-internal.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <urcu/rculfhash.h>
-#include <urcu/ref.h>
-#include <urcu/call-rcu.h>
-#include "notification-thread.h"
-
-struct lttng_evaluation;
-struct notification_thread_handle;
-
-struct channel_key {
- uint64_t key;
- enum lttng_domain_type domain;
-};
-
-struct session_info {
- struct lttng_ref ref;
- char *name;
- uid_t uid;
- gid_t gid;
- /*
- * Hashtable containing back-refs (weak) to all channels in this session.
- * The hashtable's key is a hash of (struct channel_key) and
- * the value is of type (struct channel_info *).
- */
- struct cds_lfht *channel_infos_ht;
- struct lttng_session_trigger_list *trigger_list;
- /* Node in the notification thread state's sessions_ht. */
- struct cds_lfht_node sessions_ht_node;
- /*
- * Weak reference to the thread state's sessions_ht. Used for removal on
- * destruction.
- */
- struct cds_lfht *sessions_ht;
- uint64_t consumed_data_size;
- struct {
- /* Whether a rotation is ongoing for this session. */
- bool ongoing;
- /* Identifier of the currently ongoing rotation. */
- uint64_t id;
- } rotation;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-struct channel_info {
- struct channel_key key;
- char *name;
- uint64_t capacity;
- /*
- * A channel info holds a reference (lttng_ref) on session_info.
- * session_info, in return, holds a weak reference to the channel.
- */
- struct session_info *session_info;
- /* Node in the notification thread state's channels_ht. */
- struct cds_lfht_node channels_ht_node;
- /* Node in the session_info's channels_ht. */
- struct cds_lfht_node session_info_channels_ht_node;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-/*
- * Facilities to carry the different notifications type in the action
- * processing code path.
- */
-struct lttng_event_notifier_notification {
- uint64_t tracer_token;
- enum lttng_domain_type type;
- size_t capture_buf_size;
- char *capture_buffer;
-};
-
-struct notification_client_list_element {
- struct notification_client *client;
- struct cds_list_head node;
-};
-
-/*
- * Thread safety of notification_client and notification_client_list.
- *
- * The notification thread (main thread) and the action executor
- * interact through client lists. Hence, when the action executor
- * thread looks-up the list of clients subscribed to a given
- * condition, it will acquire a reference to the list and lock it
- * while attempting to communicate with the various clients.
- *
- * It is not necessary to reference-count clients as they are guaranteed
- * to be 'alive' if they are present in a list and that list is locked. Indeed,
- * removing references to the client from those subscription lists is part of
- * the work performed on destruction of a client.
- *
- * No provision for other access scenarios are taken into account;
- * this is the bare minimum to make these accesses safe and the
- * notification thread's state is _not_ "thread-safe" in any general
- * sense.
- */
-struct notification_client_list {
- pthread_mutex_t lock;
- struct urcu_ref ref;
- struct lttng_condition *condition;
- /* List of triggers that have an identical condition than `condition`. */
- struct cds_list_head triggers_list;
- struct cds_list_head clients_list;
- /* Weak reference to container. */
- struct cds_lfht *notification_trigger_clients_ht;
- struct cds_lfht_node notification_trigger_clients_ht_node;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-struct notification_client {
- /*
- * Nests within the notification_client_list lock.
- *
- * Protects the outbound communication and the active flag which
- * is used by both the notification and action executor threads.
- *
- * The remaining fields of the object can be used without any
- * synchronization as they are either immutable (id, creds, version) or
- * only accessed by the notification thread.
- */
- pthread_mutex_t lock;
- notification_client_id id;
- int socket;
- /* Client protocol version. */
- uint8_t major, minor;
- uid_t uid;
- gid_t gid;
- bool is_sessiond;
- /*
- * Indicates if the credentials and versions of the client have been
- * checked.
- */
- bool validated;
- /*
- * Conditions to which the client's notification channel is subscribed.
- * List of struct lttng_condition_list_node. The condition member is
- * owned by the client.
- */
- struct cds_list_head condition_list;
- struct cds_lfht_node client_socket_ht_node;
- struct cds_lfht_node client_id_ht_node;
- struct {
- /*
- * If a client's communication is inactive, it means that a
- * fatal error has occurred (could be either a protocol error or
- * the socket API returned a fatal error). No further
- * communication should be attempted; the client is queued for
- * clean-up.
- */
- bool active;
- struct {
- /*
- * During the reception of a message, the reception
- * buffers' "size" is set to contain the current
- * message's complete payload.
- */
- struct lttng_payload payload;
- /* Bytes left to receive for the current message. */
- size_t bytes_to_receive;
- /* FDs left to receive for the current message. */
- int fds_to_receive;
- /* Type of the message being received. */
- enum lttng_notification_channel_message_type msg_type;
- /*
- * Indicates whether or not credentials are expected
- * from the client.
- */
- bool expect_creds;
- /*
- * Indicates whether or not credentials were received
- * from the client.
- */
- bool creds_received;
- /* Only used during credentials reception. */
- lttng_sock_cred creds;
- } inbound;
- struct {
- /*
- * Indicates whether or not a notification addressed to
- * this client was dropped because a command reply was
- * already buffered.
- *
- * A notification is dropped whenever the buffer is not
- * empty.
- */
- bool dropped_notification;
- /*
- * Indicates whether or not a command reply is already
- * buffered. In this case, it means that the client is
- * not consuming command replies before emitting a new
- * one. This could be caused by a protocol error or a
- * misbehaving/malicious client.
- */
- bool queued_command_reply;
- struct lttng_payload payload;
- } outbound;
- } communication;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-enum client_transmission_status {
- CLIENT_TRANSMISSION_STATUS_COMPLETE,
- CLIENT_TRANSMISSION_STATUS_QUEUED,
- /* Communication failure. */
- CLIENT_TRANSMISSION_STATUS_FAIL,
- /* Fatal error. */
- CLIENT_TRANSMISSION_STATUS_ERROR,
-};
-
-bool notification_client_list_get(struct notification_client_list *list);
-
-void notification_client_list_put(struct notification_client_list *list);
-
-/* Only returns a non-zero value if a fatal error occurred. */
-typedef int (*report_client_transmission_result_cb)(
- struct notification_client *client,
- enum client_transmission_status status,
- void *user_data);
-
-int notification_client_list_send_evaluation(
- struct notification_client_list *list,
- const struct lttng_trigger *trigger,
- const struct lttng_evaluation *evaluation,
- const struct lttng_credentials *source_object_creds,
- report_client_transmission_result_cb client_report,
- void *user_data);
-
-int notification_thread_client_communication_update(
- struct notification_thread_handle *handle,
- notification_client_id id,
- enum client_transmission_status transmission_status);
-
-/*
- * Takes ownership of the payload if present.
- */
-struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
- uint64_t tracer_token,
- enum lttng_domain_type domain,
- char *payload,
- size_t payload_size);
-
-void lttng_event_notifier_notification_destroy(
- struct lttng_event_notifier_notification *event_notifier_notification);
-
-#endif /* NOTIFICATION_THREAD_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_INTERNAL_H
+#define NOTIFICATION_THREAD_INTERNAL_H
+
+#include <common/compat/socket.hpp>
+#include <common/credentials.hpp>
+#include <common/payload.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/ref-internal.hpp>
+#include <stdbool.h>
+#include <unistd.h>
+#include <urcu/rculfhash.h>
+#include <urcu/ref.h>
+#include <urcu/call-rcu.h>
+#include "notification-thread.hpp"
+
+struct lttng_evaluation;
+struct notification_thread_handle;
+
+struct channel_key {
+ uint64_t key;
+ enum lttng_domain_type domain;
+};
+
+struct session_info {
+ struct lttng_ref ref;
+ char *name;
+ uid_t uid;
+ gid_t gid;
+ /*
+ * Hashtable containing back-refs (weak) to all channels in this session.
+ * The hashtable's key is a hash of (struct channel_key) and
+ * the value is of type (struct channel_info *).
+ */
+ struct cds_lfht *channel_infos_ht;
+ struct lttng_session_trigger_list *trigger_list;
+ /* Node in the notification thread state's sessions_ht. */
+ struct cds_lfht_node sessions_ht_node;
+ /*
+ * Weak reference to the thread state's sessions_ht. Used for removal on
+ * destruction.
+ */
+ struct cds_lfht *sessions_ht;
+ uint64_t consumed_data_size;
+ struct {
+ /* Whether a rotation is ongoing for this session. */
+ bool ongoing;
+ /* Identifier of the currently ongoing rotation. */
+ uint64_t id;
+ } rotation;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+struct channel_info {
+ struct channel_key key;
+ char *name;
+ uint64_t capacity;
+ /*
+ * A channel info holds a reference (lttng_ref) on session_info.
+ * session_info, in return, holds a weak reference to the channel.
+ */
+ struct session_info *session_info;
+ /* Node in the notification thread state's channels_ht. */
+ struct cds_lfht_node channels_ht_node;
+ /* Node in the session_info's channels_ht. */
+ struct cds_lfht_node session_info_channels_ht_node;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+/*
+ * Facilities to carry the different notifications type in the action
+ * processing code path.
+ */
+struct lttng_event_notifier_notification {
+ uint64_t tracer_token;
+ enum lttng_domain_type type;
+ size_t capture_buf_size;
+ char *capture_buffer;
+};
+
+struct notification_client_list_element {
+ struct notification_client *client;
+ struct cds_list_head node;
+};
+
+/*
+ * Thread safety of notification_client and notification_client_list.
+ *
+ * The notification thread (main thread) and the action executor
+ * interact through client lists. Hence, when the action executor
+ * thread looks-up the list of clients subscribed to a given
+ * condition, it will acquire a reference to the list and lock it
+ * while attempting to communicate with the various clients.
+ *
+ * It is not necessary to reference-count clients as they are guaranteed
+ * to be 'alive' if they are present in a list and that list is locked. Indeed,
+ * removing references to the client from those subscription lists is part of
+ * the work performed on destruction of a client.
+ *
+ * No provision for other access scenarios are taken into account;
+ * this is the bare minimum to make these accesses safe and the
+ * notification thread's state is _not_ "thread-safe" in any general
+ * sense.
+ */
+struct notification_client_list {
+ pthread_mutex_t lock;
+ struct urcu_ref ref;
+ struct lttng_condition *condition;
+ /* List of triggers that have an identical condition than `condition`. */
+ struct cds_list_head triggers_list;
+ struct cds_list_head clients_list;
+ /* Weak reference to container. */
+ struct cds_lfht *notification_trigger_clients_ht;
+ struct cds_lfht_node notification_trigger_clients_ht_node;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+struct notification_client {
+ /*
+ * Nests within the notification_client_list lock.
+ *
+ * Protects the outbound communication and the active flag which
+ * is used by both the notification and action executor threads.
+ *
+ * The remaining fields of the object can be used without any
+ * synchronization as they are either immutable (id, creds, version) or
+ * only accessed by the notification thread.
+ */
+ pthread_mutex_t lock;
+ notification_client_id id;
+ int socket;
+ /* Client protocol version. */
+ uint8_t major, minor;
+ uid_t uid;
+ gid_t gid;
+ bool is_sessiond;
+ /*
+ * Indicates if the credentials and versions of the client have been
+ * checked.
+ */
+ bool validated;
+ /*
+ * Conditions to which the client's notification channel is subscribed.
+ * List of struct lttng_condition_list_node. The condition member is
+ * owned by the client.
+ */
+ struct cds_list_head condition_list;
+ struct cds_lfht_node client_socket_ht_node;
+ struct cds_lfht_node client_id_ht_node;
+ struct {
+ /*
+ * If a client's communication is inactive, it means that a
+ * fatal error has occurred (could be either a protocol error or
+ * the socket API returned a fatal error). No further
+ * communication should be attempted; the client is queued for
+ * clean-up.
+ */
+ bool active;
+ struct {
+ /*
+ * During the reception of a message, the reception
+ * buffers' "size" is set to contain the current
+ * message's complete payload.
+ */
+ struct lttng_payload payload;
+ /* Bytes left to receive for the current message. */
+ size_t bytes_to_receive;
+ /* FDs left to receive for the current message. */
+ int fds_to_receive;
+ /* Type of the message being received. */
+ enum lttng_notification_channel_message_type msg_type;
+ /*
+ * Indicates whether or not credentials are expected
+ * from the client.
+ */
+ bool expect_creds;
+ /*
+ * Indicates whether or not credentials were received
+ * from the client.
+ */
+ bool creds_received;
+ /* Only used during credentials reception. */
+ lttng_sock_cred creds;
+ } inbound;
+ struct {
+ /*
+ * Indicates whether or not a notification addressed to
+ * this client was dropped because a command reply was
+ * already buffered.
+ *
+ * A notification is dropped whenever the buffer is not
+ * empty.
+ */
+ bool dropped_notification;
+ /*
+ * Indicates whether or not a command reply is already
+ * buffered. In this case, it means that the client is
+ * not consuming command replies before emitting a new
+ * one. This could be caused by a protocol error or a
+ * misbehaving/malicious client.
+ */
+ bool queued_command_reply;
+ struct lttng_payload payload;
+ } outbound;
+ } communication;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+enum client_transmission_status {
+ CLIENT_TRANSMISSION_STATUS_COMPLETE,
+ CLIENT_TRANSMISSION_STATUS_QUEUED,
+ /* Communication failure. */
+ CLIENT_TRANSMISSION_STATUS_FAIL,
+ /* Fatal error. */
+ CLIENT_TRANSMISSION_STATUS_ERROR,
+};
+
+bool notification_client_list_get(struct notification_client_list *list);
+
+void notification_client_list_put(struct notification_client_list *list);
+
+/* Only returns a non-zero value if a fatal error occurred. */
+typedef int (*report_client_transmission_result_cb)(
+ struct notification_client *client,
+ enum client_transmission_status status,
+ void *user_data);
+
+int notification_client_list_send_evaluation(
+ struct notification_client_list *list,
+ const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
+ const struct lttng_credentials *source_object_creds,
+ report_client_transmission_result_cb client_report,
+ void *user_data);
+
+int notification_thread_client_communication_update(
+ struct notification_thread_handle *handle,
+ notification_client_id id,
+ enum client_transmission_status transmission_status);
+
+/*
+ * Takes ownership of the payload if present.
+ */
+struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
+ uint64_t tracer_token,
+ enum lttng_domain_type domain,
+ char *payload,
+ size_t payload_size);
+
+void lttng_event_notifier_notification_destroy(
+ struct lttng_event_notifier_notification *event_notifier_notification);
+
+#endif /* NOTIFICATION_THREAD_INTERNAL_H */
#define _LGPL_SOURCE
#include <lttng/trigger/trigger.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/align.h>
-#include <common/time.h>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
#include <sys/stat.h>
#include <time.h>
#include <signal.h>
-#include "notification-thread.h"
-#include "notification-thread-events.h"
-#include "notification-thread-commands.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "thread.h"
-#include "testpoint.h"
+#include "notification-thread.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread-commands.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "thread.hpp"
+#include "testpoint.hpp"
-#include "kernel.h"
-#include <common/kernel-ctl/kernel-ctl.h>
+#include "kernel.hpp"
+#include <common/kernel-ctl/kernel-ctl.hpp>
#include <urcu.h>
#include <urcu/list.h>
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef NOTIFICATION_THREAD_H
-#define NOTIFICATION_THREAD_H
-
-#include "action-executor.h"
-#include "thread.h"
-#include <common/compat/poll.h>
-#include <common/hashtable/hashtable.h>
-#include <common/pipe.h>
-#include <lttng/trigger/trigger.h>
-#include <lttng/domain.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <urcu.h>
-#include <urcu/list.h>
-#include <urcu/rculfhash.h>
-
-typedef uint64_t notification_client_id;
-
-/*
- * The notification thread holds no ownership of the tracer event source pipe
- * file descriptor. The tracer management logic must remove the event source
- * from the notification thread (see external commands) before releasing
- * this file descriptor.
- */
-struct notification_event_tracer_event_source_element {
- int fd;
- /*
- * A tracer event source can be removed from the notification thread's
- * poll set before the end of its lifetime (for instance, when an error
- * or hang-up is detected on its file descriptor). This is done to
- * allow the notification thread to ignore follow-up events on this
- * file descriptors.
- *
- * Under such circumstances, the notification thread still expects
- * the normal clean-up to occur through the 'REMOVE_TRACER_EVENT_SOURCE'
- * command.
- */
- bool is_fd_in_poll_set;
- enum lttng_domain_type domain;
- struct cds_list_head node;
-};
-
-struct notification_trigger_tokens_ht_element {
- uint64_t token;
- /* Weak reference to the trigger. */
- struct lttng_trigger *trigger;
- struct cds_lfht_node node;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-struct notification_thread_handle {
- /*
- * Queue of struct notification command.
- * event_pipe must be WRITE(2) to signal that a new command
- * has been enqueued.
- */
- struct {
- struct lttng_pipe *event_pipe;
- struct cds_list_head list;
- pthread_mutex_t lock;
- } cmd_queue;
- /*
- * Read side of pipes used to receive channel status info collected
- * by the various consumer daemons.
- */
- struct {
- int ust32_consumer;
- int ust64_consumer;
- int kernel_consumer;
- } channel_monitoring_pipes;
- /* Used to wait for the launch of the notification thread. */
- sem_t ready;
-};
-
-/**
- * This thread maintains an internal state associating clients and triggers.
- *
- * In order to speed-up and simplify queries, hash tables providing the
- * following associations are maintained:
- *
- * - client_socket_ht: associate a client's socket (fd) to its
- * "struct notification_client".
- * This hash table owns the "struct notification_client" which must
- * thus be disposed-of on removal from the hash table.
- *
- * - client_id_ht: associate a client's id to its "struct notification_client"
- * This hash table holds a _weak_ reference to the
- * "struct notification_client".
- *
- * - channel_triggers_ht:
- * associates a channel key to a list of
- * struct lttng_trigger_list_nodes. The triggers in this list are
- * those that have conditions that apply to a particular channel.
- * A channel entry is only created when a channel is added; the
- * list of triggers applying to such a channel is built at that
- * moment.
- * This hash table owns the list, but not the triggers themselves.
- *
- * - session_triggers_ht:
- * associates a session name to a list of
- * struct lttng_trigger_list_nodes. The triggers in this list are
- * those that have conditions that apply to a particular session.
- * A session entry is only created when a session is created; the
- * list of triggers applying to this new session is built at that
- * moment. This happens at the time of creation of a session_info.
- * Likewise, the list is destroyed at the time of the session_info's
- * destruction.
- *
- * - channel_state_ht:
- * associates a pair (channel key, channel domain) to its last
- * sampled state received from the consumer daemon
- * (struct channel_state).
- * This previous sample is kept to implement edge-triggered
- * conditions as we need to detect the state transitions.
- * This hash table owns the channel state.
- *
- * - notification_trigger_clients_ht:
- * associates notification-emitting triggers to clients
- * (struct notification_client_list) subscribed to those
- * conditions.
- * The condition's hash and match functions are used directly since
- * all triggers in this hash table have the "notify" action.
- * This hash table holds no ownership.
- *
- * - channels_ht:
- * associates a channel_key to a struct channel_info. The hash table
- * holds the ownership of the struct channel_info.
- *
- * - sessions_ht:
- * associates a session_name (hash) to a struct session_info. The
- * hash table holds no ownership of the struct session_info;
- * the session_info structure is owned by the session's various
- * channels through their struct channel_info (ref-counting is used).
- *
- * - triggers_ht:
- * associates a trigger to a struct lttng_trigger_ht_element.
- * The hash table holds the ownership of the
- * lttng_trigger_ht_elements along with the triggers themselves.
- * - triggers_by_name_uid_ht:
- * associates a trigger (name, uid) tuple to
- * a struct lttng_trigger_ht_element.
- * The hash table does not hold any ownership and is used strictly
- * for lookup on registration.
- * - tracer_event_sources_list:
- * A list of tracer event source (read side fd) of type
-* struct notification_event_tracer_event_source_element.
-*
- *
- * The thread reacts to the following internal events:
- * 1) creation of a tracing channel,
- * 2) destruction of a tracing channel,
- * 3) registration of a trigger,
- * 4) unregistration of a trigger,
- * 5) reception of a channel monitor sample from the consumer daemon,
- * 6) Session rotation ongoing,
- * 7) Session rotation completed,
- * 8) registration of a tracer event source,
- * 9) unregistration of a tracer event source,
- *
- * Events specific to notification-emitting triggers:
- * 9) connection of a notification client,
- * 10) disconnection of a notification client,
- * 11) subscription of a client to a conditions' notifications,
- * 12) unsubscription of a client from a conditions' notifications,
- *
- *
- * 1) Creation of a tracing channel
- * - notification_trigger_clients_ht is traversed to identify
- * triggers which apply to this new channel,
- * - triggers identified are added to the channel_triggers_ht.
- * - add channel to channels_ht
- * - if it is the first channel of a session, a session_info is created and
- * added to the sessions_ht. A list of the triggers associated with that
- * session is built, and it is added to session_triggers_ht.
- *
- * 2) Destruction of a tracing channel
- * - remove entry from channel_triggers_ht, releasing the list wrapper and
- * elements,
- * - remove entry from the channel_state_ht.
- * - remove channel from channels_ht
- * - if it was the last known channel of a session, the session_info
- * structure is torndown, which in return destroys the list of triggers
- * applying to that session.
- *
- * 3) Registration of a trigger
- * - if the trigger's action is of type "notify",
- * - traverse the list of conditions of every client to build a list of
- * clients which have to be notified when this trigger's condition is met,
- * - add list of clients (even if it is empty) to the
- * notification_trigger_clients_ht,
- * - add trigger to channel_triggers_ht (if applicable),
- * - add trigger to session_triggers_ht (if applicable),
- * - add trigger to triggers_by_name_uid_ht
- * - add trigger to triggers_ht
- * - evaluate the trigger's condition right away to react if that condition
- * is true from the beginning.
- *
- * 4) Unregistration of a trigger
- * - if the trigger's action is of type "notify",
- * - remove the trigger from the notification_trigger_clients_ht,
- * - remove trigger from channel_triggers_ht (if applicable),
- * - remove trigger from session_triggers_ht (if applicable),
- * - remove trigger from triggers_by_name_uid_ht
- * - remove trigger from triggers_ht
- *
- * 5) Reception of a channel monitor sample from the consumer daemon
- * - evaluate the conditions associated with the triggers found in
- * the channel_triggers_ht,
- * - if a condition evaluates to "true" and the condition is of type
- * "notify", query the notification_trigger_clients_ht and send
- * a notification to the clients.
- *
- * 6) Session rotation ongoing
- *
- * 7) Session rotation completed
- *
- * 8) Registration of a tracer event source
- * - Add the tracer event source of the application to
- * tracer_event_sources_list,
- * - Add the trace event source to the pollset.
- *
- * 8) Unregistration of a tracer event source
- * - Remove the tracer event source of the application from
- * tracer_event_sources_list,
- * - Remove the trace event source from the pollset.
- *
- * 10) Connection of a client
- * - add client socket to the client_socket_ht,
- * - add client socket to the client_id_ht.
- *
- * 11) Disconnection of a client
- * - remove client socket from the client_id_ht,
- * - remove client socket from the client_socket_ht,
- * - traverse all conditions to which the client is subscribed and remove
- * the client from the notification_trigger_clients_ht.
- *
- * 12) Subscription of a client to a condition's notifications
- * - Add the condition to the client's list of subscribed conditions,
- * - Look-up notification_trigger_clients_ht and add the client to
- * list of clients.
- * - Evaluate the condition for the client that subscribed if the trigger
- * was already registered.
- *
- * 13) Unsubscription of a client to a condition's notifications
- * - Remove the condition from the client's list of subscribed conditions,
- * - Look-up notification_trigger_clients_ht and remove the client
- * from the list of clients.
- */
-struct notification_thread_state {
- int notification_channel_socket;
- struct lttng_poll_event events;
- struct cds_lfht *client_socket_ht;
- struct cds_lfht *client_id_ht;
- struct cds_lfht *channel_triggers_ht;
- struct cds_lfht *session_triggers_ht;
- struct cds_lfht *channel_state_ht;
- struct cds_lfht *notification_trigger_clients_ht;
- struct cds_lfht *channels_ht;
- struct cds_lfht *sessions_ht;
- struct cds_lfht *triggers_ht;
- struct cds_lfht *triggers_by_name_uid_ht;
- struct cds_lfht *trigger_tokens_ht;
- struct {
- uint64_t next_tracer_token;
- uint64_t name_offset;
- } trigger_id;
- /*
- * Read side of the pipes used to receive tracer events. As their name
- * implies, tracer event source activity originate from either
- * registered applications (user space tracer) or from the kernel
- * tracer.
- *
- * The list is not protected by a lock since add and remove operations
- * are currently done only by the notification thread through in
- * response to blocking commands.
- */
- struct cds_list_head tracer_event_sources_list;
- notification_client_id next_notification_client_id;
- struct action_executor *executor;
-
- /*
- * Indicates the thread to break for the poll event processing loop and
- * call _poll_wait() again.
- *
- * This is necessary because some events on one fd might trigger the
- * consumption of another fd.
- * For example, a single _poll_wait() call can return notification
- * thread commands and events from the tracer event source (event
- * notifier).
- * Picture a scenario where we receive two events:
- * the first one is a _REMOVE_TRACER_EVENT_SOURCE command, and
- * the second is an POLLIN on the tracer event source fd.
- *
- * The _REMOVE_TRACER_EVENT_SOURCE will read all the data of the
- * removed tracer event source.
- *
- * The second event is now invalid has we consumed all the data for
- * which we received the POLLIN.
- *
- * For this reason, we need to break for the event processing loop and
- * call _poll_wait() again to get a clean view of the activity on the
- * fds.
- */
- bool restart_poll;
-};
-
-/* notification_thread_data takes ownership of the channel monitor pipes. */
-struct notification_thread_handle *notification_thread_handle_create(
- struct lttng_pipe *ust32_channel_monitor_pipe,
- struct lttng_pipe *ust64_channel_monitor_pipe,
- struct lttng_pipe *kernel_channel_monitor_pipe);
-void notification_thread_handle_destroy(
- struct notification_thread_handle *handle);
-struct lttng_thread *launch_notification_thread(
- struct notification_thread_handle *handle);
-
-#endif /* NOTIFICATION_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef NOTIFICATION_THREAD_H
+#define NOTIFICATION_THREAD_H
+
+#include "action-executor.hpp"
+#include "thread.hpp"
+#include <common/compat/poll.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/pipe.hpp>
+#include <lttng/trigger/trigger.h>
+#include <lttng/domain.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <urcu.h>
+#include <urcu/list.h>
+#include <urcu/rculfhash.h>
+
+typedef uint64_t notification_client_id;
+
+/*
+ * The notification thread holds no ownership of the tracer event source pipe
+ * file descriptor. The tracer management logic must remove the event source
+ * from the notification thread (see external commands) before releasing
+ * this file descriptor.
+ */
+struct notification_event_tracer_event_source_element {
+ int fd;
+ /*
+ * A tracer event source can be removed from the notification thread's
+ * poll set before the end of its lifetime (for instance, when an error
+ * or hang-up is detected on its file descriptor). This is done to
+ * allow the notification thread to ignore follow-up events on this
+ * file descriptors.
+ *
+ * Under such circumstances, the notification thread still expects
+ * the normal clean-up to occur through the 'REMOVE_TRACER_EVENT_SOURCE'
+ * command.
+ */
+ bool is_fd_in_poll_set;
+ enum lttng_domain_type domain;
+ struct cds_list_head node;
+};
+
+struct notification_trigger_tokens_ht_element {
+ uint64_t token;
+ /* Weak reference to the trigger. */
+ struct lttng_trigger *trigger;
+ struct cds_lfht_node node;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+struct notification_thread_handle {
+ /*
+ * Queue of struct notification command.
+ * event_pipe must be WRITE(2) to signal that a new command
+ * has been enqueued.
+ */
+ struct {
+ struct lttng_pipe *event_pipe;
+ struct cds_list_head list;
+ pthread_mutex_t lock;
+ } cmd_queue;
+ /*
+ * Read side of pipes used to receive channel status info collected
+ * by the various consumer daemons.
+ */
+ struct {
+ int ust32_consumer;
+ int ust64_consumer;
+ int kernel_consumer;
+ } channel_monitoring_pipes;
+ /* Used to wait for the launch of the notification thread. */
+ sem_t ready;
+};
+
+/**
+ * This thread maintains an internal state associating clients and triggers.
+ *
+ * In order to speed-up and simplify queries, hash tables providing the
+ * following associations are maintained:
+ *
+ * - client_socket_ht: associate a client's socket (fd) to its
+ * "struct notification_client".
+ * This hash table owns the "struct notification_client" which must
+ * thus be disposed-of on removal from the hash table.
+ *
+ * - client_id_ht: associate a client's id to its "struct notification_client"
+ * This hash table holds a _weak_ reference to the
+ * "struct notification_client".
+ *
+ * - channel_triggers_ht:
+ * associates a channel key to a list of
+ * struct lttng_trigger_list_nodes. The triggers in this list are
+ * those that have conditions that apply to a particular channel.
+ * A channel entry is only created when a channel is added; the
+ * list of triggers applying to such a channel is built at that
+ * moment.
+ * This hash table owns the list, but not the triggers themselves.
+ *
+ * - session_triggers_ht:
+ * associates a session name to a list of
+ * struct lttng_trigger_list_nodes. The triggers in this list are
+ * those that have conditions that apply to a particular session.
+ * A session entry is only created when a session is created; the
+ * list of triggers applying to this new session is built at that
+ * moment. This happens at the time of creation of a session_info.
+ * Likewise, the list is destroyed at the time of the session_info's
+ * destruction.
+ *
+ * - channel_state_ht:
+ * associates a pair (channel key, channel domain) to its last
+ * sampled state received from the consumer daemon
+ * (struct channel_state).
+ * This previous sample is kept to implement edge-triggered
+ * conditions as we need to detect the state transitions.
+ * This hash table owns the channel state.
+ *
+ * - notification_trigger_clients_ht:
+ * associates notification-emitting triggers to clients
+ * (struct notification_client_list) subscribed to those
+ * conditions.
+ * The condition's hash and match functions are used directly since
+ * all triggers in this hash table have the "notify" action.
+ * This hash table holds no ownership.
+ *
+ * - channels_ht:
+ * associates a channel_key to a struct channel_info. The hash table
+ * holds the ownership of the struct channel_info.
+ *
+ * - sessions_ht:
+ * associates a session_name (hash) to a struct session_info. The
+ * hash table holds no ownership of the struct session_info;
+ * the session_info structure is owned by the session's various
+ * channels through their struct channel_info (ref-counting is used).
+ *
+ * - triggers_ht:
+ * associates a trigger to a struct lttng_trigger_ht_element.
+ * The hash table holds the ownership of the
+ * lttng_trigger_ht_elements along with the triggers themselves.
+ * - triggers_by_name_uid_ht:
+ * associates a trigger (name, uid) tuple to
+ * a struct lttng_trigger_ht_element.
+ * The hash table does not hold any ownership and is used strictly
+ * for lookup on registration.
+ * - tracer_event_sources_list:
+ * A list of tracer event source (read side fd) of type
+* struct notification_event_tracer_event_source_element.
+*
+ *
+ * The thread reacts to the following internal events:
+ * 1) creation of a tracing channel,
+ * 2) destruction of a tracing channel,
+ * 3) registration of a trigger,
+ * 4) unregistration of a trigger,
+ * 5) reception of a channel monitor sample from the consumer daemon,
+ * 6) Session rotation ongoing,
+ * 7) Session rotation completed,
+ * 8) registration of a tracer event source,
+ * 9) unregistration of a tracer event source,
+ *
+ * Events specific to notification-emitting triggers:
+ * 9) connection of a notification client,
+ * 10) disconnection of a notification client,
+ * 11) subscription of a client to a conditions' notifications,
+ * 12) unsubscription of a client from a conditions' notifications,
+ *
+ *
+ * 1) Creation of a tracing channel
+ * - notification_trigger_clients_ht is traversed to identify
+ * triggers which apply to this new channel,
+ * - triggers identified are added to the channel_triggers_ht.
+ * - add channel to channels_ht
+ * - if it is the first channel of a session, a session_info is created and
+ * added to the sessions_ht. A list of the triggers associated with that
+ * session is built, and it is added to session_triggers_ht.
+ *
+ * 2) Destruction of a tracing channel
+ * - remove entry from channel_triggers_ht, releasing the list wrapper and
+ * elements,
+ * - remove entry from the channel_state_ht.
+ * - remove channel from channels_ht
+ * - if it was the last known channel of a session, the session_info
+ * structure is torndown, which in return destroys the list of triggers
+ * applying to that session.
+ *
+ * 3) Registration of a trigger
+ * - if the trigger's action is of type "notify",
+ * - traverse the list of conditions of every client to build a list of
+ * clients which have to be notified when this trigger's condition is met,
+ * - add list of clients (even if it is empty) to the
+ * notification_trigger_clients_ht,
+ * - add trigger to channel_triggers_ht (if applicable),
+ * - add trigger to session_triggers_ht (if applicable),
+ * - add trigger to triggers_by_name_uid_ht
+ * - add trigger to triggers_ht
+ * - evaluate the trigger's condition right away to react if that condition
+ * is true from the beginning.
+ *
+ * 4) Unregistration of a trigger
+ * - if the trigger's action is of type "notify",
+ * - remove the trigger from the notification_trigger_clients_ht,
+ * - remove trigger from channel_triggers_ht (if applicable),
+ * - remove trigger from session_triggers_ht (if applicable),
+ * - remove trigger from triggers_by_name_uid_ht
+ * - remove trigger from triggers_ht
+ *
+ * 5) Reception of a channel monitor sample from the consumer daemon
+ * - evaluate the conditions associated with the triggers found in
+ * the channel_triggers_ht,
+ * - if a condition evaluates to "true" and the condition is of type
+ * "notify", query the notification_trigger_clients_ht and send
+ * a notification to the clients.
+ *
+ * 6) Session rotation ongoing
+ *
+ * 7) Session rotation completed
+ *
+ * 8) Registration of a tracer event source
+ * - Add the tracer event source of the application to
+ * tracer_event_sources_list,
+ * - Add the trace event source to the pollset.
+ *
+ * 8) Unregistration of a tracer event source
+ * - Remove the tracer event source of the application from
+ * tracer_event_sources_list,
+ * - Remove the trace event source from the pollset.
+ *
+ * 10) Connection of a client
+ * - add client socket to the client_socket_ht,
+ * - add client socket to the client_id_ht.
+ *
+ * 11) Disconnection of a client
+ * - remove client socket from the client_id_ht,
+ * - remove client socket from the client_socket_ht,
+ * - traverse all conditions to which the client is subscribed and remove
+ * the client from the notification_trigger_clients_ht.
+ *
+ * 12) Subscription of a client to a condition's notifications
+ * - Add the condition to the client's list of subscribed conditions,
+ * - Look-up notification_trigger_clients_ht and add the client to
+ * list of clients.
+ * - Evaluate the condition for the client that subscribed if the trigger
+ * was already registered.
+ *
+ * 13) Unsubscription of a client to a condition's notifications
+ * - Remove the condition from the client's list of subscribed conditions,
+ * - Look-up notification_trigger_clients_ht and remove the client
+ * from the list of clients.
+ */
+struct notification_thread_state {
+ int notification_channel_socket;
+ struct lttng_poll_event events;
+ struct cds_lfht *client_socket_ht;
+ struct cds_lfht *client_id_ht;
+ struct cds_lfht *channel_triggers_ht;
+ struct cds_lfht *session_triggers_ht;
+ struct cds_lfht *channel_state_ht;
+ struct cds_lfht *notification_trigger_clients_ht;
+ struct cds_lfht *channels_ht;
+ struct cds_lfht *sessions_ht;
+ struct cds_lfht *triggers_ht;
+ struct cds_lfht *triggers_by_name_uid_ht;
+ struct cds_lfht *trigger_tokens_ht;
+ struct {
+ uint64_t next_tracer_token;
+ uint64_t name_offset;
+ } trigger_id;
+ /*
+ * Read side of the pipes used to receive tracer events. As their name
+ * implies, tracer event source activity originate from either
+ * registered applications (user space tracer) or from the kernel
+ * tracer.
+ *
+ * The list is not protected by a lock since add and remove operations
+ * are currently done only by the notification thread through in
+ * response to blocking commands.
+ */
+ struct cds_list_head tracer_event_sources_list;
+ notification_client_id next_notification_client_id;
+ struct action_executor *executor;
+
+ /*
+ * Indicates the thread to break for the poll event processing loop and
+ * call _poll_wait() again.
+ *
+ * This is necessary because some events on one fd might trigger the
+ * consumption of another fd.
+ * For example, a single _poll_wait() call can return notification
+ * thread commands and events from the tracer event source (event
+ * notifier).
+ * Picture a scenario where we receive two events:
+ * the first one is a _REMOVE_TRACER_EVENT_SOURCE command, and
+ * the second is an POLLIN on the tracer event source fd.
+ *
+ * The _REMOVE_TRACER_EVENT_SOURCE will read all the data of the
+ * removed tracer event source.
+ *
+ * The second event is now invalid has we consumed all the data for
+ * which we received the POLLIN.
+ *
+ * For this reason, we need to break for the event processing loop and
+ * call _poll_wait() again to get a clean view of the activity on the
+ * fds.
+ */
+ bool restart_poll;
+};
+
+/* notification_thread_data takes ownership of the channel monitor pipes. */
+struct notification_thread_handle *notification_thread_handle_create(
+ struct lttng_pipe *ust32_channel_monitor_pipe,
+ struct lttng_pipe *ust64_channel_monitor_pipe,
+ struct lttng_pipe *kernel_channel_monitor_pipe);
+void notification_thread_handle_destroy(
+ struct notification_thread_handle *handle);
+struct lttng_thread *launch_notification_thread(
+ struct notification_thread_handle *handle);
+
+#endif /* NOTIFICATION_THREAD_H */
#define _LGPL_SOURCE
-#include <common/common.h>
-#include <common/utils.h>
-
-#include "fd-limit.h"
-#include "lttng-sessiond.h"
-#include "notify-apps.h"
-#include "health-sessiond.h"
-#include "testpoint.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+
+#include "fd-limit.hpp"
+#include "lttng-sessiond.hpp"
+#include "notify-apps.hpp"
+#include "health-sessiond.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef UST_THREAD_H
-#define UST_THREAD_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-bool launch_application_notification_thread(int apps_cmd_notify_pipe_read_fd);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static
-bool launch_application_notification_thread(
- int apps_cmd_notify_pipe_read_fd __attribute__((unused)))
-{
- return true;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* UST_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef UST_THREAD_H
+#define UST_THREAD_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+bool launch_application_notification_thread(int apps_cmd_notify_pipe_read_fd);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static
+bool launch_application_notification_thread(
+ int apps_cmd_notify_pipe_read_fd __attribute__((unused)))
+{
+ return true;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* UST_THREAD_H */
*/
#include <signal.h>
-#include "lttng-sessiond.h"
+#include "lttng-sessiond.hpp"
/* Notify parents that we are ready for cmd and health check */
void sessiond_signal_parents(void)
#include <stddef.h>
#include <stdlib.h>
#include <urcu.h>
-#include <common/futex.h>
-#include <common/macros.h>
-#include <common/shm.h>
-#include <common/utils.h>
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+#include <common/shm.hpp>
+#include <common/utils.hpp>
#include <sys/stat.h>
-#include "register.h"
-#include "lttng-sessiond.h"
-#include "testpoint.h"
-#include "health-sessiond.h"
-#include "fd-limit.h"
-#include "utils.h"
-#include "thread.h"
+#include "register.hpp"
+#include "lttng-sessiond.hpp"
+#include "testpoint.hpp"
+#include "health-sessiond.hpp"
+#include "fd-limit.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
struct thread_state {
struct lttng_pipe *quit_pipe;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_APPLICATION_REGISTRATION_THREAD_H
-#define SESSIOND_APPLICATION_REGISTRATION_THREAD_H
-
-#include <stdbool.h>
-#include "lttng-sessiond.h"
-
-struct lttng_thread *launch_application_registration_thread(
- struct ust_cmd_queue *cmd_queue);
-
-#endif /* SESSIOND_APPLICATION_REGISTRATION_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_APPLICATION_REGISTRATION_THREAD_H
+#define SESSIOND_APPLICATION_REGISTRATION_THREAD_H
+
+#include <stdbool.h>
+#include "lttng-sessiond.hpp"
+
+struct lttng_thread *launch_application_registration_thread(
+ struct ust_cmd_queue *cmd_queue);
+
+#endif /* SESSIOND_APPLICATION_REGISTRATION_THREAD_H */
#define _LGPL_SOURCE
#include <lttng/trigger/trigger.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/futex.h>
-#include <common/align.h>
-#include <common/time.h>
-#include <common/hashtable/utils.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/credentials.h>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/futex.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/credentials.hpp>
#include <sys/stat.h>
#include <time.h>
#include <signal.h>
#include <inttypes.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/rotate-internal.h>
-
-#include "session.h"
-#include "rotate.h"
-#include "rotation-thread.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "cmd.h"
-#include "utils.h"
-#include "notification-thread-commands.h"
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+
+#include "session.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "cmd.hpp"
+#include "utils.hpp"
+#include "notification-thread-commands.hpp"
#include <urcu.h>
#include <urcu/list.h>
+++ /dev/null
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ROTATE_H
-#define ROTATE_H
-
-#include "rotation-thread.h"
-#include <stdint.h>
-
-/*
- * Subscribe/unsubscribe the notification_channel from the rotation_thread to
- * session usage notifications to perform size-based rotations.
- */
-int subscribe_session_consumed_size_rotation(struct ltt_session *session,
- uint64_t size,
- struct notification_thread_handle *notification_thread_handle);
-int unsubscribe_session_consumed_size_rotation(struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle);
-
-#endif /* ROTATE_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ROTATE_H
+#define ROTATE_H
+
+#include "rotation-thread.hpp"
+#include <stdint.h>
+
+/*
+ * Subscribe/unsubscribe the notification_channel from the rotation_thread to
+ * session usage notifications to perform size-based rotations.
+ */
+int subscribe_session_consumed_size_rotation(struct ltt_session *session,
+ uint64_t size,
+ struct notification_thread_handle *notification_thread_handle);
+int unsubscribe_session_consumed_size_rotation(struct ltt_session *session,
+ struct notification_thread_handle *notification_thread_handle);
+
+#endif /* ROTATE_H */
#define _LGPL_SOURCE
#include <lttng/trigger/trigger.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/futex.h>
-#include <common/align.h>
-#include <common/time.h>
-#include <common/hashtable/utils.h>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/futex.hpp>
+#include <common/align.hpp>
+#include <common/time.hpp>
+#include <common/hashtable/utils.hpp>
#include <sys/stat.h>
#include <time.h>
#include <signal.h>
#include <inttypes.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/rotate-internal.h>
-#include <lttng/location-internal.h>
-#include <lttng/condition/condition-internal.h>
-
-#include "rotation-thread.h"
-#include "lttng-sessiond.h"
-#include "health-sessiond.h"
-#include "rotate.h"
-#include "cmd.h"
-#include "session.h"
-#include "timer.h"
-#include "notification-thread-commands.h"
-#include "utils.h"
-#include "thread.h"
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <lttng/location-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+
+#include "rotation-thread.hpp"
+#include "lttng-sessiond.hpp"
+#include "health-sessiond.hpp"
+#include "rotate.hpp"
+#include "cmd.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "notification-thread-commands.hpp"
+#include "utils.hpp"
+#include "thread.hpp"
#include <urcu.h>
#include <urcu/list.h>
+++ /dev/null
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef ROTATION_THREAD_H
-#define ROTATION_THREAD_H
-
-#include <urcu/list.h>
-#include <urcu.h>
-#include <urcu/rculfhash.h>
-#include <lttng/domain.h>
-#include <common/pipe.h>
-#include <common/compat/poll.h>
-#include <common/hashtable/hashtable.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include "session.h"
-#include "notification-thread.h"
-
-extern struct lttng_notification_channel *rotate_notification_channel;
-
-enum rotation_thread_job_type {
- ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
- ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
-};
-
-struct rotation_thread_timer_queue;
-struct rotation_thread_handle;
-
-struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void);
-void rotation_thread_timer_queue_destroy(
- struct rotation_thread_timer_queue *queue);
-
-struct rotation_thread_handle *rotation_thread_handle_create(
- struct rotation_thread_timer_queue *rotation_timer_queue,
- struct notification_thread_handle *notification_thread_handle);
-
-void rotation_thread_handle_destroy(
- struct rotation_thread_handle *handle);
-
-void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
- enum rotation_thread_job_type job_type,
- struct ltt_session *session);
-
-bool launch_rotation_thread(struct rotation_thread_handle *handle);
-
-#endif /* ROTATION_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef ROTATION_THREAD_H
+#define ROTATION_THREAD_H
+
+#include <urcu/list.h>
+#include <urcu.h>
+#include <urcu/rculfhash.h>
+#include <lttng/domain.h>
+#include <common/pipe.hpp>
+#include <common/compat/poll.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <pthread.h>
+#include <semaphore.h>
+#include "session.hpp"
+#include "notification-thread.hpp"
+
+extern struct lttng_notification_channel *rotate_notification_channel;
+
+enum rotation_thread_job_type {
+ ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
+ ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
+};
+
+struct rotation_thread_timer_queue;
+struct rotation_thread_handle;
+
+struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void);
+void rotation_thread_timer_queue_destroy(
+ struct rotation_thread_timer_queue *queue);
+
+struct rotation_thread_handle *rotation_thread_handle_create(
+ struct rotation_thread_timer_queue *rotation_timer_queue,
+ struct notification_thread_handle *notification_thread_handle);
+
+void rotation_thread_handle_destroy(
+ struct rotation_thread_handle *handle);
+
+void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
+ enum rotation_thread_job_type job_type,
+ struct ltt_session *session);
+
+bool launch_rotation_thread(struct rotation_thread_handle *handle);
+
+#endif /* ROTATION_THREAD_H */
#include <urcu/uatomic.h>
#include <unistd.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/config/session-config.h>
-#include <common/utils.h>
-#include <common/runas.h>
-#include <lttng/save-internal.h>
-
-#include "kernel.h"
-#include "save.h"
-#include "session.h"
-#include "lttng-syscall.h"
-#include "trace-ust.h"
-#include "agent.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/config/session-config.hpp>
+#include <common/utils.hpp>
+#include <common/runas.hpp>
+#include <lttng/save-internal.hpp>
+
+#include "kernel.hpp"
+#include "save.hpp"
+#include "session.hpp"
+#include "lttng-syscall.hpp"
+#include "trace-ust.hpp"
+#include "agent.hpp"
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
static
+++ /dev/null
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SAVE_H
-#define SAVE_H
-
-#include <lttng/save.h>
-#include <common/compat/socket.h>
-
-int cmd_save_sessions(struct lttng_save_session_attr *attr,
- lttng_sock_cred *creds);
-
-#endif /* SAVE_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SAVE_H
+#define SAVE_H
+
+#include <lttng/save.h>
+#include <common/compat/socket.hpp>
+
+int cmd_save_sessions(struct lttng_save_session_attr *attr,
+ lttng_sock_cred *creds);
+
+#endif /* SAVE_H */
#include <sys/types.h>
#include <pthread.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/trace-chunk.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/location-internal.h>
-#include "lttng-sessiond.h"
-#include "kernel.h"
-
-#include "session.h"
-#include "utils.h"
-#include "trace-ust.h"
-#include "timer.h"
-#include "cmd.h"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/location-internal.hpp>
+#include "lttng-sessiond.hpp"
+#include "kernel.hpp"
+
+#include "session.hpp"
+#include "utils.hpp"
+#include "trace-ust.hpp"
+#include "timer.hpp"
+#include "cmd.hpp"
struct ltt_session_destroy_notifier_element {
ltt_session_destroy_notifier notifier;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SESSION_H
-#define _LTT_SESSION_H
-
-#include <limits.h>
-#include <stdbool.h>
-#include <urcu/list.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/dynamic-array.h>
-#include <lttng/rotation.h>
-#include <lttng/location.h>
-#include <lttng/lttng-error.h>
-
-#include "snapshot.h"
-#include "trace-kernel.h"
-#include "consumer.h"
-
-struct ltt_ust_session;
-
-typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
- void *user_data);
-typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
- void *user_data);
-
-/*
- * Tracing session list
- *
- * Statically declared in session.c and can be accessed by using
- * session_get_list() function that returns the pointer to the list.
- */
-struct ltt_session_list {
- /*
- * This lock protects any read/write access to the list and
- * next_uuid. All public functions in session.c acquire this
- * lock and release it before returning. If none of those
- * functions are used, the lock MUST be acquired in order to
- * iterate or/and do any actions on that list.
- */
- pthread_mutex_t lock;
- /*
- * This condition variable is signaled on every removal from
- * the session list.
- */
- pthread_cond_t removal_cond;
-
- /*
- * Session unique ID generator. The session list lock MUST be
- * upon update and read of this counter.
- */
- uint64_t next_uuid;
-
- /* Linked list head */
- struct cds_list_head head;
-};
-
-/*
- * This data structure contains information needed to identify a tracing
- * session for both LTTng and UST.
- */
-struct ltt_session {
- char name[NAME_MAX];
- bool has_auto_generated_name;
- bool name_contains_creation_time;
- char hostname[LTTNG_HOST_NAME_MAX]; /* Local hostname. */
- /* Path of the last closed chunk. */
- char last_chunk_path[LTTNG_PATH_MAX];
- time_t creation_time;
- struct ltt_kernel_session *kernel_session;
- struct ltt_ust_session *ust_session;
- struct urcu_ref ref;
- /*
- * Protect any read/write on this session data structure. This lock must be
- * acquired *before* using any public functions declared below. Use
- * session_lock() and session_unlock() for that.
- */
- pthread_mutex_t lock;
- struct cds_list_head list;
- uint64_t id; /* session unique identifier */
- /* Indicates if the session has been added to the session list and ht.*/
- bool published;
- /* Indicates if a destroy command has been applied to this session. */
- bool destroyed;
- /* UID/GID of the user owning the session */
- uid_t uid;
- gid_t gid;
- /*
- * Network session handle. A value of 0 means that there is no remote
- * session established.
- */
- uint64_t net_handle;
- /*
- * This consumer is only set when the create_session_uri call is made.
- * This contains the temporary information for a consumer output. Upon
- * creation of the UST or kernel session, this consumer, if available, is
- * copied into those sessions.
- */
- struct consumer_output *consumer;
- /*
- * Indicates whether or not the user has specified an output directory
- * or if it was configured using the default configuration.
- */
- bool has_user_specified_directory;
- /* Did at least ONE start command has been triggered?. */
- unsigned int has_been_started:1;
- /*
- * Is the session active? Start trace command sets this to 1 and the stop
- * command reset it to 0.
- */
- unsigned int active:1;
-
- /* Snapshot representation in a session. */
- struct snapshot snapshot;
- /* Indicate if the session has to output the traces or not. */
- unsigned int output_traces;
- /*
- * This session is in snapshot mode. This means that channels enabled
- * will be set in overwrite mode by default and must be in mmap
- * output mode. Note that snapshots can be taken on a session that
- * is not in "snapshot_mode". This parameter only affects channel
- * creation defaults.
- */
- unsigned int snapshot_mode;
- /*
- * A session that has channels that don't use 'mmap' output can't be
- * used to capture snapshots. This is set to true whenever a
- * 'splice' kernel channel is enabled.
- */
- bool has_non_mmap_channel;
- /*
- * Timer set when the session is created for live reading.
- */
- unsigned int live_timer;
- /*
- * Path where to keep the shared memory files.
- */
- char shm_path[PATH_MAX];
- /*
- * Node in ltt_sessions_ht_by_id.
- */
- struct lttng_ht_node_u64 node;
- /*
- * Node in ltt_sessions_ht_by_name.
- */
- struct lttng_ht_node_str node_by_name;
- /*
- * Timer to check periodically if a relay and/or consumer has completed
- * the last rotation.
- */
- bool rotation_pending_check_timer_enabled;
- timer_t rotation_pending_check_timer;
- /* Timer to periodically rotate a session. */
- bool rotation_schedule_timer_enabled;
- timer_t rotation_schedule_timer;
- /* Value for periodic rotations, 0 if disabled. */
- uint64_t rotate_timer_period;
- /* Value for size-based rotations, 0 if disabled. */
- uint64_t rotate_size;
- /*
- * Keep a state if this session was rotated after the last stop command.
- * We only allow one rotation after a stop. At destroy, we also need to
- * know if a rotation occurred since the last stop to rename the current
- * chunk. After a stop followed by rotate, all subsequent clear
- * (without prior start) will succeed, but will be effect-less.
- */
- bool rotated_after_last_stop;
- /*
- * Track whether the session was cleared after last stop. All subsequent
- * clear (without prior start) will succeed, but will be effect-less. A
- * subsequent rotate (without prior start) will return an error.
- */
- bool cleared_after_last_stop;
- /*
- * True if the session has had an explicit non-quiet rotation.
- */
- bool rotated;
- /*
- * Condition and trigger for size-based rotations.
- */
- struct lttng_condition *rotate_condition;
- struct lttng_trigger *rotate_trigger;
- LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id;
- struct lttng_trace_chunk *current_trace_chunk;
- struct lttng_trace_chunk *chunk_being_archived;
- /* Current state of a rotation. */
- enum lttng_rotation_state rotation_state;
- bool quiet_rotation;
- char *last_archived_chunk_name;
- LTTNG_OPTIONAL(uint64_t) last_archived_chunk_id;
- struct lttng_dynamic_array destroy_notifiers;
- struct lttng_dynamic_array clear_notifiers;
- /* Session base path override. Set non-null. */
- char *base_path;
-};
-
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
- struct ltt_session **out_session);
-void session_lock(struct ltt_session *session);
-void session_unlock(struct ltt_session *session);
-
-/*
- * The session list lock covers more ground than its name implies. While
- * it does protect against concurent mutations of the session list, it is
- * also used as a multi-session lock when synchronizing newly-registered
- * 'user space tracer' and 'agent' applications.
- *
- * In other words, it prevents tracer configurations from changing while they
- * are being transmitted to the various applications.
- */
-void session_lock_list(void);
-int session_trylock_list(void);
-void session_unlock_list(void);
-
-void session_destroy(struct ltt_session *session);
-int session_add_destroy_notifier(struct ltt_session *session,
- ltt_session_destroy_notifier notifier, void *user_data);
-
-int session_add_clear_notifier(struct ltt_session *session,
- ltt_session_clear_notifier notifier, void *user_data);
-void session_notify_clear(struct ltt_session *session);
-
-bool session_get(struct ltt_session *session);
-void session_put(struct ltt_session *session);
-
-enum consumer_dst_type session_get_consumer_destination_type(
- const struct ltt_session *session);
-const char *session_get_net_consumer_hostname(
- const struct ltt_session *session);
-void session_get_net_consumer_ports(
- const struct ltt_session *session,
- uint16_t *control_port, uint16_t *data_port);
-struct lttng_trace_archive_location *session_get_trace_archive_location(
- const struct ltt_session *session);
-
-struct ltt_session *session_find_by_name(const char *name);
-struct ltt_session *session_find_by_id(uint64_t id);
-
-struct ltt_session_list *session_get_list(void);
-void session_list_wait_empty(void);
-
-bool session_access_ok(struct ltt_session *session, uid_t uid);
-
-int session_reset_rotation_state(struct ltt_session *session,
- enum lttng_rotation_state result);
-
-/* Create a new trace chunk object from the session's configuration. */
-struct lttng_trace_chunk *session_create_new_trace_chunk(
- const struct ltt_session *session,
- const struct consumer_output *consumer_output_override,
- const char *session_base_path_override,
- const char *chunk_name_override);
-
-/*
- * Set `new_trace_chunk` as the session's current trace chunk. A reference
- * to `new_trace_chunk` is acquired by the session. The chunk is created
- * on remote peers (consumer and relay daemons).
- *
- * A reference to the session's current trace chunk is returned through
- * `current_session_trace_chunk` on success.
- */
-int session_set_trace_chunk(struct ltt_session *session,
- struct lttng_trace_chunk *new_trace_chunk,
- struct lttng_trace_chunk **current_session_trace_chunk);
-
-/*
- * Close a chunk on the remote peers of a session. Has no effect on the
- * ltt_session itself.
- */
-int session_close_trace_chunk(struct ltt_session *session,
- struct lttng_trace_chunk *trace_chunk,
- enum lttng_trace_chunk_command_type close_command,
- char *path);
-
-/* Open a packet in all channels of a given session. */
-enum lttng_error_code session_open_packets(struct ltt_session *session);
-
-bool session_output_supports_trace_chunks(const struct ltt_session *session);
-
-/*
- * Sample the id of a session looked up via its name.
- * Here the term "sampling" hint the caller that this return the id at a given
- * point in time with no guarantee that the session for which the id was
- * sampled still exist at that point.
- *
- * Return 0 when the session is not found,
- * Return 1 when the session is found and set `id`.
- */
-bool sample_session_id_by_name(const char *name, uint64_t *id);
-
-#endif /* _LTT_SESSION_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SESSION_H
+#define _LTT_SESSION_H
+
+#include <limits.h>
+#include <stdbool.h>
+#include <urcu/list.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/dynamic-array.hpp>
+#include <lttng/rotation.h>
+#include <lttng/location.h>
+#include <lttng/lttng-error.h>
+
+#include "snapshot.hpp"
+#include "trace-kernel.hpp"
+#include "consumer.hpp"
+
+struct ltt_ust_session;
+
+typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
+ void *user_data);
+typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
+ void *user_data);
+
+/*
+ * Tracing session list
+ *
+ * Statically declared in session.c and can be accessed by using
+ * session_get_list() function that returns the pointer to the list.
+ */
+struct ltt_session_list {
+ /*
+ * This lock protects any read/write access to the list and
+ * next_uuid. All public functions in session.c acquire this
+ * lock and release it before returning. If none of those
+ * functions are used, the lock MUST be acquired in order to
+ * iterate or/and do any actions on that list.
+ */
+ pthread_mutex_t lock;
+ /*
+ * This condition variable is signaled on every removal from
+ * the session list.
+ */
+ pthread_cond_t removal_cond;
+
+ /*
+ * Session unique ID generator. The session list lock MUST be
+ * upon update and read of this counter.
+ */
+ uint64_t next_uuid;
+
+ /* Linked list head */
+ struct cds_list_head head;
+};
+
+/*
+ * This data structure contains information needed to identify a tracing
+ * session for both LTTng and UST.
+ */
+struct ltt_session {
+ char name[NAME_MAX];
+ bool has_auto_generated_name;
+ bool name_contains_creation_time;
+ char hostname[LTTNG_HOST_NAME_MAX]; /* Local hostname. */
+ /* Path of the last closed chunk. */
+ char last_chunk_path[LTTNG_PATH_MAX];
+ time_t creation_time;
+ struct ltt_kernel_session *kernel_session;
+ struct ltt_ust_session *ust_session;
+ struct urcu_ref ref;
+ /*
+ * Protect any read/write on this session data structure. This lock must be
+ * acquired *before* using any public functions declared below. Use
+ * session_lock() and session_unlock() for that.
+ */
+ pthread_mutex_t lock;
+ struct cds_list_head list;
+ uint64_t id; /* session unique identifier */
+ /* Indicates if the session has been added to the session list and ht.*/
+ bool published;
+ /* Indicates if a destroy command has been applied to this session. */
+ bool destroyed;
+ /* UID/GID of the user owning the session */
+ uid_t uid;
+ gid_t gid;
+ /*
+ * Network session handle. A value of 0 means that there is no remote
+ * session established.
+ */
+ uint64_t net_handle;
+ /*
+ * This consumer is only set when the create_session_uri call is made.
+ * This contains the temporary information for a consumer output. Upon
+ * creation of the UST or kernel session, this consumer, if available, is
+ * copied into those sessions.
+ */
+ struct consumer_output *consumer;
+ /*
+ * Indicates whether or not the user has specified an output directory
+ * or if it was configured using the default configuration.
+ */
+ bool has_user_specified_directory;
+ /* Did at least ONE start command has been triggered?. */
+ unsigned int has_been_started:1;
+ /*
+ * Is the session active? Start trace command sets this to 1 and the stop
+ * command reset it to 0.
+ */
+ unsigned int active:1;
+
+ /* Snapshot representation in a session. */
+ struct snapshot snapshot;
+ /* Indicate if the session has to output the traces or not. */
+ unsigned int output_traces;
+ /*
+ * This session is in snapshot mode. This means that channels enabled
+ * will be set in overwrite mode by default and must be in mmap
+ * output mode. Note that snapshots can be taken on a session that
+ * is not in "snapshot_mode". This parameter only affects channel
+ * creation defaults.
+ */
+ unsigned int snapshot_mode;
+ /*
+ * A session that has channels that don't use 'mmap' output can't be
+ * used to capture snapshots. This is set to true whenever a
+ * 'splice' kernel channel is enabled.
+ */
+ bool has_non_mmap_channel;
+ /*
+ * Timer set when the session is created for live reading.
+ */
+ unsigned int live_timer;
+ /*
+ * Path where to keep the shared memory files.
+ */
+ char shm_path[PATH_MAX];
+ /*
+ * Node in ltt_sessions_ht_by_id.
+ */
+ struct lttng_ht_node_u64 node;
+ /*
+ * Node in ltt_sessions_ht_by_name.
+ */
+ struct lttng_ht_node_str node_by_name;
+ /*
+ * Timer to check periodically if a relay and/or consumer has completed
+ * the last rotation.
+ */
+ bool rotation_pending_check_timer_enabled;
+ timer_t rotation_pending_check_timer;
+ /* Timer to periodically rotate a session. */
+ bool rotation_schedule_timer_enabled;
+ timer_t rotation_schedule_timer;
+ /* Value for periodic rotations, 0 if disabled. */
+ uint64_t rotate_timer_period;
+ /* Value for size-based rotations, 0 if disabled. */
+ uint64_t rotate_size;
+ /*
+ * Keep a state if this session was rotated after the last stop command.
+ * We only allow one rotation after a stop. At destroy, we also need to
+ * know if a rotation occurred since the last stop to rename the current
+ * chunk. After a stop followed by rotate, all subsequent clear
+ * (without prior start) will succeed, but will be effect-less.
+ */
+ bool rotated_after_last_stop;
+ /*
+ * Track whether the session was cleared after last stop. All subsequent
+ * clear (without prior start) will succeed, but will be effect-less. A
+ * subsequent rotate (without prior start) will return an error.
+ */
+ bool cleared_after_last_stop;
+ /*
+ * True if the session has had an explicit non-quiet rotation.
+ */
+ bool rotated;
+ /*
+ * Condition and trigger for size-based rotations.
+ */
+ struct lttng_condition *rotate_condition;
+ struct lttng_trigger *rotate_trigger;
+ LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id;
+ struct lttng_trace_chunk *current_trace_chunk;
+ struct lttng_trace_chunk *chunk_being_archived;
+ /* Current state of a rotation. */
+ enum lttng_rotation_state rotation_state;
+ bool quiet_rotation;
+ char *last_archived_chunk_name;
+ LTTNG_OPTIONAL(uint64_t) last_archived_chunk_id;
+ struct lttng_dynamic_array destroy_notifiers;
+ struct lttng_dynamic_array clear_notifiers;
+ /* Session base path override. Set non-null. */
+ char *base_path;
+};
+
+enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
+ struct ltt_session **out_session);
+void session_lock(struct ltt_session *session);
+void session_unlock(struct ltt_session *session);
+
+/*
+ * The session list lock covers more ground than its name implies. While
+ * it does protect against concurent mutations of the session list, it is
+ * also used as a multi-session lock when synchronizing newly-registered
+ * 'user space tracer' and 'agent' applications.
+ *
+ * In other words, it prevents tracer configurations from changing while they
+ * are being transmitted to the various applications.
+ */
+void session_lock_list(void);
+int session_trylock_list(void);
+void session_unlock_list(void);
+
+void session_destroy(struct ltt_session *session);
+int session_add_destroy_notifier(struct ltt_session *session,
+ ltt_session_destroy_notifier notifier, void *user_data);
+
+int session_add_clear_notifier(struct ltt_session *session,
+ ltt_session_clear_notifier notifier, void *user_data);
+void session_notify_clear(struct ltt_session *session);
+
+bool session_get(struct ltt_session *session);
+void session_put(struct ltt_session *session);
+
+enum consumer_dst_type session_get_consumer_destination_type(
+ const struct ltt_session *session);
+const char *session_get_net_consumer_hostname(
+ const struct ltt_session *session);
+void session_get_net_consumer_ports(
+ const struct ltt_session *session,
+ uint16_t *control_port, uint16_t *data_port);
+struct lttng_trace_archive_location *session_get_trace_archive_location(
+ const struct ltt_session *session);
+
+struct ltt_session *session_find_by_name(const char *name);
+struct ltt_session *session_find_by_id(uint64_t id);
+
+struct ltt_session_list *session_get_list(void);
+void session_list_wait_empty(void);
+
+bool session_access_ok(struct ltt_session *session, uid_t uid);
+
+int session_reset_rotation_state(struct ltt_session *session,
+ enum lttng_rotation_state result);
+
+/* Create a new trace chunk object from the session's configuration. */
+struct lttng_trace_chunk *session_create_new_trace_chunk(
+ const struct ltt_session *session,
+ const struct consumer_output *consumer_output_override,
+ const char *session_base_path_override,
+ const char *chunk_name_override);
+
+/*
+ * Set `new_trace_chunk` as the session's current trace chunk. A reference
+ * to `new_trace_chunk` is acquired by the session. The chunk is created
+ * on remote peers (consumer and relay daemons).
+ *
+ * A reference to the session's current trace chunk is returned through
+ * `current_session_trace_chunk` on success.
+ */
+int session_set_trace_chunk(struct ltt_session *session,
+ struct lttng_trace_chunk *new_trace_chunk,
+ struct lttng_trace_chunk **current_session_trace_chunk);
+
+/*
+ * Close a chunk on the remote peers of a session. Has no effect on the
+ * ltt_session itself.
+ */
+int session_close_trace_chunk(struct ltt_session *session,
+ struct lttng_trace_chunk *trace_chunk,
+ enum lttng_trace_chunk_command_type close_command,
+ char *path);
+
+/* Open a packet in all channels of a given session. */
+enum lttng_error_code session_open_packets(struct ltt_session *session);
+
+bool session_output_supports_trace_chunks(const struct ltt_session *session);
+
+/*
+ * Sample the id of a session looked up via its name.
+ * Here the term "sampling" hint the caller that this return the id at a given
+ * point in time with no guarantee that the session for which the id was
+ * sampled still exist at that point.
+ *
+ * Return 0 when the session is not found,
+ * Return 1 when the session is found and set `id`.
+ */
+bool sample_session_id_by_name(const char *name, uint64_t *id);
+
+#endif /* _LTT_SESSION_H */
*
*/
-#include "version.h"
-#include "sessiond-config.h"
-#include "lttng-ust-ctl.h"
-#include <common/defaults.h>
+#include "version.hpp"
+#include "sessiond-config.hpp"
+#include "lttng-ust-ctl.hpp"
+#include <common/defaults.hpp>
#include <limits.h>
#include <ctype.h>
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
static
struct sessiond_config sessiond_config_build_defaults = {
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_SESSIOND_CONFIG_H
-#define LTTNG_SESSIOND_CONFIG_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-
-struct config_string {
- char *value;
- bool should_free;
-};
-
-struct config_int_range {
- int begin, end;
-};
-
-/* Config string takes ownership of value. */
-void config_string_set(struct config_string *string, char *value);
-
-struct sessiond_config {
- int verbose;
- int verbose_consumer;
- /* Agent TCP port range for registration. Used by the agent thread. */
- struct config_int_range agent_tcp_port;
-
- int event_notifier_buffer_size_kernel;
- int event_notifier_buffer_size_userspace;
- /* Socket timeout for receiving and sending (in seconds). */
- int app_socket_timeout;
-
- bool quiet;
- bool no_kernel;
- bool background;
- bool daemonize;
- bool sig_parent;
-
- struct config_string tracing_group_name;
-
- struct config_string kmod_probes_list;
- struct config_string kmod_extra_probes_list;
-
- struct config_string rundir;
-
- /* Global application Unix socket path */
- struct config_string apps_unix_sock_path;
- /* Global client Unix socket path */
- struct config_string client_unix_sock_path;
- /* Global wait shm path for UST */
- struct config_string wait_shm_path;
- /* Global health check unix path */
- struct config_string health_unix_sock_path;
- /*
- * LTTNG_UST_CLOCK_PLUGIN environment variable to be passed to spawned
- * consumer daemons.
- */
- struct config_string lttng_ust_clock_plugin;
- struct config_string pid_file_path;
- struct config_string lock_file_path;
- struct config_string load_session_path;
- struct config_string agent_port_file_path;
-
- struct config_string consumerd32_path;
- struct config_string consumerd32_bin_path;
- struct config_string consumerd32_lib_dir;
- struct config_string consumerd32_err_unix_sock_path;
- struct config_string consumerd32_cmd_unix_sock_path;
-
- struct config_string consumerd64_path;
- struct config_string consumerd64_bin_path;
- struct config_string consumerd64_lib_dir;
- struct config_string consumerd64_err_unix_sock_path;
- struct config_string consumerd64_cmd_unix_sock_path;
-
- struct config_string kconsumerd_path;
- struct config_string kconsumerd_err_unix_sock_path;
- struct config_string kconsumerd_cmd_unix_sock_path;
-};
-
-/* Initialize the sessiond_config values to build-defaults. */
-int sessiond_config_init(struct sessiond_config *config);
-
-/* Override sessiond_config values with values specified by the environment. */
-int sessiond_config_apply_env_config(struct sessiond_config *config);
-
-void sessiond_config_fini(struct sessiond_config *config);
-
-int sessiond_config_resolve_paths(struct sessiond_config *config);
-
-void sessiond_config_log(struct sessiond_config *config);
-
-#endif /* LTTNG_SESSIOND_CONFIG_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_SESSIOND_CONFIG_H
+#define LTTNG_SESSIOND_CONFIG_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+
+struct config_string {
+ char *value;
+ bool should_free;
+};
+
+struct config_int_range {
+ int begin, end;
+};
+
+/* Config string takes ownership of value. */
+void config_string_set(struct config_string *string, char *value);
+
+struct sessiond_config {
+ int verbose;
+ int verbose_consumer;
+ /* Agent TCP port range for registration. Used by the agent thread. */
+ struct config_int_range agent_tcp_port;
+
+ int event_notifier_buffer_size_kernel;
+ int event_notifier_buffer_size_userspace;
+ /* Socket timeout for receiving and sending (in seconds). */
+ int app_socket_timeout;
+
+ bool quiet;
+ bool no_kernel;
+ bool background;
+ bool daemonize;
+ bool sig_parent;
+
+ struct config_string tracing_group_name;
+
+ struct config_string kmod_probes_list;
+ struct config_string kmod_extra_probes_list;
+
+ struct config_string rundir;
+
+ /* Global application Unix socket path */
+ struct config_string apps_unix_sock_path;
+ /* Global client Unix socket path */
+ struct config_string client_unix_sock_path;
+ /* Global wait shm path for UST */
+ struct config_string wait_shm_path;
+ /* Global health check unix path */
+ struct config_string health_unix_sock_path;
+ /*
+ * LTTNG_UST_CLOCK_PLUGIN environment variable to be passed to spawned
+ * consumer daemons.
+ */
+ struct config_string lttng_ust_clock_plugin;
+ struct config_string pid_file_path;
+ struct config_string lock_file_path;
+ struct config_string load_session_path;
+ struct config_string agent_port_file_path;
+
+ struct config_string consumerd32_path;
+ struct config_string consumerd32_bin_path;
+ struct config_string consumerd32_lib_dir;
+ struct config_string consumerd32_err_unix_sock_path;
+ struct config_string consumerd32_cmd_unix_sock_path;
+
+ struct config_string consumerd64_path;
+ struct config_string consumerd64_bin_path;
+ struct config_string consumerd64_lib_dir;
+ struct config_string consumerd64_err_unix_sock_path;
+ struct config_string consumerd64_cmd_unix_sock_path;
+
+ struct config_string kconsumerd_path;
+ struct config_string kconsumerd_err_unix_sock_path;
+ struct config_string kconsumerd_cmd_unix_sock_path;
+};
+
+/* Initialize the sessiond_config values to build-defaults. */
+int sessiond_config_init(struct sessiond_config *config);
+
+/* Override sessiond_config values with values specified by the environment. */
+int sessiond_config_apply_env_config(struct sessiond_config *config);
+
+void sessiond_config_fini(struct sessiond_config *config);
+
+int sessiond_config_resolve_paths(struct sessiond_config *config);
+
+void sessiond_config_log(struct sessiond_config *config);
+
+#endif /* LTTNG_SESSIOND_CONFIG_H */
#include <string.h>
#include <urcu/uatomic.h>
-#include <common/defaults.h>
+#include <common/defaults.hpp>
-#include "snapshot.h"
-#include "utils.h"
+#include "snapshot.hpp"
+#include "utils.hpp"
/*
* Return the atomically incremented value of next_output_id.
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SNAPSHOT_H
-#define SNAPSHOT_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <common/common.h>
-#include <common/hashtable/hashtable.h>
-#include <common/uri.h>
-
-#include "consumer.h"
-
-struct consumer_output;
-struct ltt_session;
-
-struct snapshot_output {
- uint32_t id;
- uint64_t max_size;
- /* Number of snapshot taken with that output. */
- uint64_t nb_snapshot;
- char name[NAME_MAX];
- struct consumer_output *consumer;
- int kernel_sockets_copied;
- int ust_sockets_copied;
- /*
- * Contains the string with "<date>-<time>" for when the snapshot command
- * is triggered. This is to make sure every streams will use the same time
- * for the directory output.
- */
- char datetime[16];
-
- /* Indexed by ID. */
- struct lttng_ht_node_ulong node;
-};
-
-struct snapshot {
- unsigned long next_output_id;
- size_t nb_output;
- /*
- * Number of snapshot taken for that object. This value is used with a
- * temporary output of a snapshot record.
- */
- uint64_t nb_snapshot;
- struct lttng_ht *output_ht;
-};
-
-/* Snapshot object. */
-struct snapshot *snapshot_alloc(void);
-void snapshot_destroy(struct snapshot *obj);
-int snapshot_init(struct snapshot *obj);
-void snapshot_delete_output(struct snapshot *snapshot,
- struct snapshot_output *output);
-void snapshot_add_output(struct snapshot *snapshot,
- struct snapshot_output *output);
-
-/* Snapshot output object. */
-struct snapshot_output *snapshot_output_alloc(void);
-void snapshot_output_destroy(struct snapshot_output *obj);
-int snapshot_output_init(const struct ltt_session *session,
- uint64_t max_size, const char *name,
- const char *ctrl_url, const char *data_url,
- struct consumer_output *consumer, struct snapshot_output *output,
- struct snapshot *snapshot);
-int snapshot_output_init_with_uri(const struct ltt_session *session,
- uint64_t max_size, const char *name,
- struct lttng_uri *uris, size_t nb_uri,
- struct consumer_output *consumer, struct snapshot_output *output,
- struct snapshot *snapshot);
-struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
- struct snapshot *snapshot);
-struct snapshot_output *snapshot_find_output_by_name(const char *name,
- struct snapshot *snapshot);
-
-#endif /* SNAPSHOT_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SNAPSHOT_H
+#define SNAPSHOT_H
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <common/common.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/uri.hpp>
+
+#include "consumer.hpp"
+
+struct consumer_output;
+struct ltt_session;
+
+struct snapshot_output {
+ uint32_t id;
+ uint64_t max_size;
+ /* Number of snapshot taken with that output. */
+ uint64_t nb_snapshot;
+ char name[NAME_MAX];
+ struct consumer_output *consumer;
+ int kernel_sockets_copied;
+ int ust_sockets_copied;
+ /*
+ * Contains the string with "<date>-<time>" for when the snapshot command
+ * is triggered. This is to make sure every streams will use the same time
+ * for the directory output.
+ */
+ char datetime[16];
+
+ /* Indexed by ID. */
+ struct lttng_ht_node_ulong node;
+};
+
+struct snapshot {
+ unsigned long next_output_id;
+ size_t nb_output;
+ /*
+ * Number of snapshot taken for that object. This value is used with a
+ * temporary output of a snapshot record.
+ */
+ uint64_t nb_snapshot;
+ struct lttng_ht *output_ht;
+};
+
+/* Snapshot object. */
+struct snapshot *snapshot_alloc(void);
+void snapshot_destroy(struct snapshot *obj);
+int snapshot_init(struct snapshot *obj);
+void snapshot_delete_output(struct snapshot *snapshot,
+ struct snapshot_output *output);
+void snapshot_add_output(struct snapshot *snapshot,
+ struct snapshot_output *output);
+
+/* Snapshot output object. */
+struct snapshot_output *snapshot_output_alloc(void);
+void snapshot_output_destroy(struct snapshot_output *obj);
+int snapshot_output_init(const struct ltt_session *session,
+ uint64_t max_size, const char *name,
+ const char *ctrl_url, const char *data_url,
+ struct consumer_output *consumer, struct snapshot_output *output,
+ struct snapshot *snapshot);
+int snapshot_output_init_with_uri(const struct ltt_session *session,
+ uint64_t max_size, const char *name,
+ struct lttng_uri *uris, size_t nb_uri,
+ struct consumer_output *consumer, struct snapshot_output *output,
+ struct snapshot *snapshot);
+struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
+ struct snapshot *snapshot);
+struct snapshot_output *snapshot_find_output_by_name(const char *name,
+ struct snapshot *snapshot);
+
+#endif /* SNAPSHOT_H */
+++ /dev/null
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TESTPOINT_H
-#define SESSIOND_TESTPOINT_H
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(sessiond_thread_manage_clients);
-TESTPOINT_DECL(sessiond_thread_manage_clients_before_loop);
-TESTPOINT_DECL(sessiond_thread_registration_apps);
-TESTPOINT_DECL(sessiond_thread_manage_apps);
-TESTPOINT_DECL(sessiond_thread_manage_apps_before_loop);
-TESTPOINT_DECL(sessiond_thread_manage_kernel);
-TESTPOINT_DECL(sessiond_thread_manage_kernel_before_loop);
-TESTPOINT_DECL(sessiond_thread_manage_consumer);
-TESTPOINT_DECL(sessiond_thread_app_manage_notify);
-TESTPOINT_DECL(sessiond_thread_app_reg_dispatch);
-TESTPOINT_DECL(sessiond_thread_notification);
-TESTPOINT_DECL(sessiond_handle_notifier_event_pipe);
-
-#endif /* SESSIOND_TESTPOINT_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TESTPOINT_H
+#define SESSIOND_TESTPOINT_H
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(sessiond_thread_manage_clients);
+TESTPOINT_DECL(sessiond_thread_manage_clients_before_loop);
+TESTPOINT_DECL(sessiond_thread_registration_apps);
+TESTPOINT_DECL(sessiond_thread_manage_apps);
+TESTPOINT_DECL(sessiond_thread_manage_apps_before_loop);
+TESTPOINT_DECL(sessiond_thread_manage_kernel);
+TESTPOINT_DECL(sessiond_thread_manage_kernel_before_loop);
+TESTPOINT_DECL(sessiond_thread_manage_consumer);
+TESTPOINT_DECL(sessiond_thread_app_manage_notify);
+TESTPOINT_DECL(sessiond_thread_app_reg_dispatch);
+TESTPOINT_DECL(sessiond_thread_notification);
+TESTPOINT_DECL(sessiond_handle_notifier_event_pipe);
+
+#endif /* SESSIOND_TESTPOINT_H */
*
*/
-#include "lttng-sessiond.h"
-#include "utils.h"
-#include <common/utils.h>
+#include "lttng-sessiond.hpp"
+#include "utils.hpp"
+#include <common/utils.hpp>
#include <pthread.h>
/*
*
*/
-#include "thread.h"
+#include "thread.hpp"
#include <urcu/list.h>
#include <urcu/ref.h>
#include <pthread.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/defaults.h>
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/defaults.hpp>
static struct thread_list {
struct cds_list_head head;
+++ /dev/null
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <stdbool.h>
-
-#ifndef THREAD_H
-#define THREAD_H
-
-struct lttng_thread;
-
-/* Main function of the new thread. */
-typedef void *(*lttng_thread_entry_point)(void *);
-
-/* Callback invoked to initiate the shutdown a thread. */
-typedef bool (*lttng_thread_shutdown_cb)(void *);
-
-/*
- * Callback invoked to clean-up the thread data.
- * Invoked when the thread is destroyed to ensure there is no
- * race between a use by the "thread shutdown callback" and
- * a use by the thread itself.
- */
-typedef void (*lttng_thread_cleanup_cb)(void *);
-
-/*
- * Returns a reference to the newly-created thread.
- * The shutdown and cleanup callbacks are optional.
- */
-struct lttng_thread *lttng_thread_create(const char *name,
- lttng_thread_entry_point entry,
- lttng_thread_shutdown_cb shutdown,
- lttng_thread_cleanup_cb cleanup,
- void *thread_data);
-
-bool lttng_thread_get(struct lttng_thread *thread);
-void lttng_thread_put(struct lttng_thread *thread);
-
-const char *lttng_thread_get_name(const struct lttng_thread *thread);
-
-/*
- * Explicitly shutdown a thread. This function returns once the
- * thread has returned and been joined.
- *
- * It is invalid to call this function more than once on a thread.
- *
- * Returns true on success, false on error.
- */
-bool lttng_thread_shutdown(struct lttng_thread *thread);
-
-/*
- * Shutdown all orphaned threads (threads to which no external reference
- * exist).
- *
- * Returns once all orphaned threads have been joined.
- */
-void lttng_thread_list_shutdown_orphans(void);
-
-#endif /* THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <stdbool.h>
+
+#ifndef THREAD_H
+#define THREAD_H
+
+struct lttng_thread;
+
+/* Main function of the new thread. */
+typedef void *(*lttng_thread_entry_point)(void *);
+
+/* Callback invoked to initiate the shutdown a thread. */
+typedef bool (*lttng_thread_shutdown_cb)(void *);
+
+/*
+ * Callback invoked to clean-up the thread data.
+ * Invoked when the thread is destroyed to ensure there is no
+ * race between a use by the "thread shutdown callback" and
+ * a use by the thread itself.
+ */
+typedef void (*lttng_thread_cleanup_cb)(void *);
+
+/*
+ * Returns a reference to the newly-created thread.
+ * The shutdown and cleanup callbacks are optional.
+ */
+struct lttng_thread *lttng_thread_create(const char *name,
+ lttng_thread_entry_point entry,
+ lttng_thread_shutdown_cb shutdown,
+ lttng_thread_cleanup_cb cleanup,
+ void *thread_data);
+
+bool lttng_thread_get(struct lttng_thread *thread);
+void lttng_thread_put(struct lttng_thread *thread);
+
+const char *lttng_thread_get_name(const struct lttng_thread *thread);
+
+/*
+ * Explicitly shutdown a thread. This function returns once the
+ * thread has returned and been joined.
+ *
+ * It is invalid to call this function more than once on a thread.
+ *
+ * Returns true on success, false on error.
+ */
+bool lttng_thread_shutdown(struct lttng_thread *thread);
+
+/*
+ * Shutdown all orphaned threads (threads to which no external reference
+ * exist).
+ *
+ * Returns once all orphaned threads have been joined.
+ */
+void lttng_thread_list_shutdown_orphans(void);
+
+#endif /* THREAD_H */
#include <inttypes.h>
#include <signal.h>
-#include "timer.h"
-#include "health-sessiond.h"
-#include "rotation-thread.h"
-#include "thread.h"
+#include "timer.hpp"
+#include "health-sessiond.hpp"
+#include "rotation-thread.hpp"
+#include "thread.hpp"
#define LTTNG_SESSIOND_SIG_QS SIGRTMIN + 10
#define LTTNG_SESSIOND_SIG_EXIT SIGRTMIN + 11
+++ /dev/null
-/*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SESSIOND_TIMER_H
-#define SESSIOND_TIMER_H
-
-#include <pthread.h>
-#include <stdbool.h>
-
-#include "session.h"
-
-struct timer_thread_parameters {
- struct rotation_thread_timer_queue *rotation_thread_job_queue;
-};
-
-int timer_signal_init(void);
-
-/* Start a session's rotation pending check timer (one-shot mode). */
-int timer_session_rotation_pending_check_start(struct ltt_session *session,
- unsigned int interval_us);
-/* Stop a session's rotation pending check timer. */
-int timer_session_rotation_pending_check_stop(struct ltt_session *session);
-
-/* Start a session's rotation schedule timer. */
-int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
- unsigned int interval_us);
-/* Stop a session's rotation schedule timer. */
-int timer_session_rotation_schedule_timer_stop(struct ltt_session *session);
-
-bool launch_timer_thread(
- struct timer_thread_parameters *timer_thread_parameters);
-
-#endif /* SESSIOND_TIMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SESSIOND_TIMER_H
+#define SESSIOND_TIMER_H
+
+#include <pthread.h>
+#include <stdbool.h>
+
+#include "session.hpp"
+
+struct timer_thread_parameters {
+ struct rotation_thread_timer_queue *rotation_thread_job_queue;
+};
+
+int timer_signal_init(void);
+
+/* Start a session's rotation pending check timer (one-shot mode). */
+int timer_session_rotation_pending_check_start(struct ltt_session *session,
+ unsigned int interval_us);
+/* Stop a session's rotation pending check timer. */
+int timer_session_rotation_pending_check_stop(struct ltt_session *session);
+
+/* Start a session's rotation schedule timer. */
+int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
+ unsigned int interval_us);
+/* Stop a session's rotation schedule timer. */
+int timer_session_rotation_schedule_timer_stop(struct ltt_session *session);
+
+bool launch_timer_thread(
+ struct timer_thread_parameters *timer_thread_parameters);
+
+#endif /* SESSIOND_TIMER_H */
#include <lttng/lttng-error.h>
#include <lttng/kernel-probe.h>
#include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/kernel-kprobe.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
#include <lttng/event-rule/kernel-syscall.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
#include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
#include <lttng/event-rule/kernel-uprobe.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/trace-chunk.h>
-#include <common/macros.h>
-
-#include "consumer.h"
-#include "trace-kernel.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/macros.hpp>
+
+#include "consumer.hpp"
+#include "trace-kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
/*
* Find the channel name for the given kernel session.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACE_KERNEL_H
-#define _LTT_TRACE_KERNEL_H
-
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-#include <common/lttng-kernel.h>
-#include <common/lttng-kernel-old.h>
-#include <common/defaults.h>
-
-#include "consumer.h"
-#include "tracker.h"
-
-/* Kernel event list */
-struct ltt_kernel_event_list {
- struct cds_list_head head;
-};
-
-/* Channel stream list */
-struct ltt_kernel_stream_list {
- struct cds_list_head head;
-};
-
-/* Channel list */
-struct ltt_kernel_channel_list {
- struct cds_list_head head;
-};
-
-struct ltt_kernel_context {
- struct lttng_kernel_abi_context ctx;
- struct cds_list_head list;
- /* Indicates whether or not the context is in a list. */
- bool in_list;
-};
-
-/* Kernel event */
-struct ltt_kernel_event {
- int fd;
- int enabled;
- enum lttng_event_type type;
- struct lttng_kernel_abi_event *event;
- struct cds_list_head list;
- char *filter_expression;
- struct lttng_bytecode *filter;
- struct lttng_userspace_probe_location *userspace_probe_location;
-};
-
-/* Kernel event */
-struct ltt_kernel_event_notifier_rule {
- int fd;
- uint64_t error_counter_index;
- int enabled;
- enum lttng_event_type type;
- struct lttng_trigger *trigger;
- uint64_t token;
- const struct lttng_bytecode *filter;
- struct lttng_userspace_probe_location *userspace_probe_location;
- struct cds_lfht_node ht_node;
- /* call_rcu delayed reclaim. */
- struct rcu_head rcu_node;
-};
-
-/* Kernel channel */
-struct ltt_kernel_channel {
- int fd;
- uint64_t key; /* Key to reference this channel with the consumer. */
- int enabled;
- unsigned int stream_count;
- unsigned int event_count;
- bool published_to_notification_thread;
- struct cds_list_head ctx_list;
- struct lttng_channel *channel;
- struct ltt_kernel_event_list events_list;
- struct ltt_kernel_stream_list stream_list;
- struct cds_list_head list;
- /* Session pointer which has a reference to this object. */
- struct ltt_kernel_session *session;
- bool sent_to_consumer;
-};
-
-/* Metadata */
-struct ltt_kernel_metadata {
- int fd;
- uint64_t key; /* Key to reference this channel with the consumer. */
- struct lttng_channel *conf;
-};
-
-/* Channel stream */
-struct ltt_kernel_stream {
- int fd;
- int state;
- int cpu;
- bool sent_to_consumer;
- /* Format is %s_%d respectively channel name and CPU number. */
- char name[DEFAULT_STREAM_NAME_LEN];
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- struct cds_list_head list;
-};
-
-/* Kernel session */
-struct ltt_kernel_session {
- int fd;
- int metadata_stream_fd;
- int consumer_fds_sent;
- unsigned int channel_count;
- unsigned int stream_count_global;
- struct ltt_kernel_metadata *metadata;
- struct ltt_kernel_channel_list channel_list;
- /* UID/GID of the user owning the session */
- uid_t uid;
- gid_t gid;
- struct consumer_output *consumer;
- /* Tracing session id */
- uint64_t id;
- /* Session is active or not meaning it has been started or stopped. */
- unsigned int active:1;
- /* Tell or not if the session has to output the traces. */
- unsigned int output_traces;
- unsigned int snapshot_mode;
- unsigned int has_non_default_channel;
- bool is_live_session;
- /* Current trace chunk of the ltt_session. */
- struct lttng_trace_chunk *current_trace_chunk;
- /* Tracker lists */
- struct process_attr_tracker *tracker_pid;
- struct process_attr_tracker *tracker_vpid;
- struct process_attr_tracker *tracker_uid;
- struct process_attr_tracker *tracker_vuid;
- struct process_attr_tracker *tracker_gid;
- struct process_attr_tracker *tracker_vgid;
-};
-
-/*
- * Lookup functions. NULL is returned if not found.
- */
-struct ltt_kernel_event *trace_kernel_get_event_by_name(
- char *name, struct ltt_kernel_channel *channel,
- enum lttng_event_type type);
-struct ltt_kernel_event *trace_kernel_find_event(
- char *name, struct ltt_kernel_channel *channel,
- enum lttng_event_type type,
- struct lttng_bytecode *filter);
-struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
- const char *name, struct ltt_kernel_session *session);
-
-/*
- * Create functions malloc() the data structure.
- */
-struct ltt_kernel_session *trace_kernel_create_session(void);
-struct ltt_kernel_channel *trace_kernel_create_channel(
- struct lttng_channel *chan);
-enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
- char *filter_expression, struct lttng_bytecode *filter,
- struct ltt_kernel_event **kernel_event);
-struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
-struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
- unsigned int count);
-struct ltt_kernel_context *trace_kernel_create_context(
- struct lttng_kernel_abi_context *ctx);
-/* Trigger is only non-const to acquire a reference. */
-enum lttng_error_code trace_kernel_create_event_notifier_rule(
- struct lttng_trigger *trigger,
- uint64_t token,
- uint64_t error_counter_index,
- struct ltt_kernel_event_notifier_rule **event_notifier_rule);
-struct ltt_kernel_context *trace_kernel_copy_context(
- struct ltt_kernel_context *ctx);
-enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
- const struct lttng_event_rule *rule,
- struct lttng_kernel_abi_event_notifier *kernel_event_notifier);
-
-/*
- * Destroy functions free() the data structure and remove from linked list if
- * it's applies.
- */
-void trace_kernel_destroy_session(struct ltt_kernel_session *session);
-void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
-void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
-void trace_kernel_destroy_event(struct ltt_kernel_event *event);
-void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
-void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
-void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule);
-void trace_kernel_free_session(struct ltt_kernel_session *session);
-
-#endif /* _LTT_TRACE_KERNEL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACE_KERNEL_H
+#define _LTT_TRACE_KERNEL_H
+
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+#include <common/lttng-kernel.hpp>
+#include <common/lttng-kernel-old.hpp>
+#include <common/defaults.hpp>
+
+#include "consumer.hpp"
+#include "tracker.hpp"
+
+/* Kernel event list */
+struct ltt_kernel_event_list {
+ struct cds_list_head head;
+};
+
+/* Channel stream list */
+struct ltt_kernel_stream_list {
+ struct cds_list_head head;
+};
+
+/* Channel list */
+struct ltt_kernel_channel_list {
+ struct cds_list_head head;
+};
+
+struct ltt_kernel_context {
+ struct lttng_kernel_abi_context ctx;
+ struct cds_list_head list;
+ /* Indicates whether or not the context is in a list. */
+ bool in_list;
+};
+
+/* Kernel event */
+struct ltt_kernel_event {
+ int fd;
+ int enabled;
+ enum lttng_event_type type;
+ struct lttng_kernel_abi_event *event;
+ struct cds_list_head list;
+ char *filter_expression;
+ struct lttng_bytecode *filter;
+ struct lttng_userspace_probe_location *userspace_probe_location;
+};
+
+/* Kernel event */
+struct ltt_kernel_event_notifier_rule {
+ int fd;
+ uint64_t error_counter_index;
+ int enabled;
+ enum lttng_event_type type;
+ struct lttng_trigger *trigger;
+ uint64_t token;
+ const struct lttng_bytecode *filter;
+ struct lttng_userspace_probe_location *userspace_probe_location;
+ struct cds_lfht_node ht_node;
+ /* call_rcu delayed reclaim. */
+ struct rcu_head rcu_node;
+};
+
+/* Kernel channel */
+struct ltt_kernel_channel {
+ int fd;
+ uint64_t key; /* Key to reference this channel with the consumer. */
+ int enabled;
+ unsigned int stream_count;
+ unsigned int event_count;
+ bool published_to_notification_thread;
+ struct cds_list_head ctx_list;
+ struct lttng_channel *channel;
+ struct ltt_kernel_event_list events_list;
+ struct ltt_kernel_stream_list stream_list;
+ struct cds_list_head list;
+ /* Session pointer which has a reference to this object. */
+ struct ltt_kernel_session *session;
+ bool sent_to_consumer;
+};
+
+/* Metadata */
+struct ltt_kernel_metadata {
+ int fd;
+ uint64_t key; /* Key to reference this channel with the consumer. */
+ struct lttng_channel *conf;
+};
+
+/* Channel stream */
+struct ltt_kernel_stream {
+ int fd;
+ int state;
+ int cpu;
+ bool sent_to_consumer;
+ /* Format is %s_%d respectively channel name and CPU number. */
+ char name[DEFAULT_STREAM_NAME_LEN];
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ struct cds_list_head list;
+};
+
+/* Kernel session */
+struct ltt_kernel_session {
+ int fd;
+ int metadata_stream_fd;
+ int consumer_fds_sent;
+ unsigned int channel_count;
+ unsigned int stream_count_global;
+ struct ltt_kernel_metadata *metadata;
+ struct ltt_kernel_channel_list channel_list;
+ /* UID/GID of the user owning the session */
+ uid_t uid;
+ gid_t gid;
+ struct consumer_output *consumer;
+ /* Tracing session id */
+ uint64_t id;
+ /* Session is active or not meaning it has been started or stopped. */
+ unsigned int active:1;
+ /* Tell or not if the session has to output the traces. */
+ unsigned int output_traces;
+ unsigned int snapshot_mode;
+ unsigned int has_non_default_channel;
+ bool is_live_session;
+ /* Current trace chunk of the ltt_session. */
+ struct lttng_trace_chunk *current_trace_chunk;
+ /* Tracker lists */
+ struct process_attr_tracker *tracker_pid;
+ struct process_attr_tracker *tracker_vpid;
+ struct process_attr_tracker *tracker_uid;
+ struct process_attr_tracker *tracker_vuid;
+ struct process_attr_tracker *tracker_gid;
+ struct process_attr_tracker *tracker_vgid;
+};
+
+/*
+ * Lookup functions. NULL is returned if not found.
+ */
+struct ltt_kernel_event *trace_kernel_get_event_by_name(
+ char *name, struct ltt_kernel_channel *channel,
+ enum lttng_event_type type);
+struct ltt_kernel_event *trace_kernel_find_event(
+ char *name, struct ltt_kernel_channel *channel,
+ enum lttng_event_type type,
+ struct lttng_bytecode *filter);
+struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
+ const char *name, struct ltt_kernel_session *session);
+
+/*
+ * Create functions malloc() the data structure.
+ */
+struct ltt_kernel_session *trace_kernel_create_session(void);
+struct ltt_kernel_channel *trace_kernel_create_channel(
+ struct lttng_channel *chan);
+enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
+ char *filter_expression, struct lttng_bytecode *filter,
+ struct ltt_kernel_event **kernel_event);
+struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
+struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
+ unsigned int count);
+struct ltt_kernel_context *trace_kernel_create_context(
+ struct lttng_kernel_abi_context *ctx);
+/* Trigger is only non-const to acquire a reference. */
+enum lttng_error_code trace_kernel_create_event_notifier_rule(
+ struct lttng_trigger *trigger,
+ uint64_t token,
+ uint64_t error_counter_index,
+ struct ltt_kernel_event_notifier_rule **event_notifier_rule);
+struct ltt_kernel_context *trace_kernel_copy_context(
+ struct ltt_kernel_context *ctx);
+enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
+ const struct lttng_event_rule *rule,
+ struct lttng_kernel_abi_event_notifier *kernel_event_notifier);
+
+/*
+ * Destroy functions free() the data structure and remove from linked list if
+ * it's applies.
+ */
+void trace_kernel_destroy_session(struct ltt_kernel_session *session);
+void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
+void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
+void trace_kernel_destroy_event(struct ltt_kernel_event *event);
+void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
+void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
+void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule);
+void trace_kernel_free_session(struct ltt_kernel_session *session);
+
+#endif /* _LTT_TRACE_KERNEL_H */
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
-
-#include "buffer-registry.h"
-#include "trace-ust.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
+
+#include "buffer-registry.hpp"
+#include "trace-ust.hpp"
+#include "utils.hpp"
+#include "ust-app.hpp"
+#include "agent.hpp"
/*
* Match function for the events hash table lookup.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACE_UST_H
-#define _LTT_TRACE_UST_H
-
-#include <limits.h>
-#include <urcu/list.h>
-
-#include <common/defaults.h>
-#include <common/hashtable/hashtable.h>
-#include <common/tracker.h>
-#include <lttng/lttng.h>
-
-#include "consumer.h"
-#include "lttng-ust-ctl.h"
-
-struct agent;
-
-struct ltt_ust_ht_key {
- const char *name;
- const struct lttng_bytecode *filter;
- enum lttng_ust_abi_loglevel_type loglevel_type;
- int loglevel_value;
- const struct lttng_event_exclusion *exclusion;
-};
-
-/* Context hash table nodes */
-struct ltt_ust_context {
- struct lttng_ust_context_attr ctx;
- struct lttng_ht_node_ulong node;
- struct cds_list_head list;
-};
-
-/* UST event */
-struct ltt_ust_event {
- unsigned int enabled;
- struct lttng_ust_abi_event attr;
- struct lttng_ht_node_str node;
- char *filter_expression;
- struct lttng_bytecode *filter;
- struct lttng_event_exclusion *exclusion;
- /*
- * An internal event is an event which was created by the session daemon
- * through which, for example, events emitted in Agent domains are
- * "funelled". This is used to hide internal events from external
- * clients as they should never be modified by the external world.
- */
- bool internal;
-};
-
-/* UST channel */
-struct ltt_ust_channel {
- uint64_t id; /* unique id per session. */
- unsigned int enabled;
- /*
- * A UST channel can be part of a userspace sub-domain such as JUL,
- * Log4j, Python.
- */
- enum lttng_domain_type domain;
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ust_abi_channel_attr attr;
- struct lttng_ht *ctx;
- struct cds_list_head ctx_list;
- struct lttng_ht *events;
- struct lttng_ht_node_str node;
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- uint64_t per_pid_closed_app_discarded;
- uint64_t per_pid_closed_app_lost;
- uint64_t monitor_timer_interval;
-};
-
-/* UST domain global (LTTNG_DOMAIN_UST) */
-struct ltt_ust_domain_global {
- struct lttng_ht *channels;
- struct cds_list_head registry_buffer_uid_list;
-};
-
-struct ust_id_tracker_node {
- struct lttng_ht_node_ulong node;
-};
-
-struct ust_id_tracker {
- struct lttng_ht *ht;
-};
-
-/* UST session */
-struct ltt_ust_session {
- uint64_t id; /* Unique identifier of session */
- struct ltt_ust_domain_global domain_global;
- /* Hash table of agent indexed by agent domain. */
- struct lttng_ht *agents;
- /* UID/GID of the user owning the session */
- uid_t uid;
- gid_t gid;
- /* Is the session active meaning has is been started or stopped. */
- unsigned int active:1;
- struct consumer_output *consumer;
- /* Sequence number for filters so the tracer knows the ordering. */
- uint64_t filter_seq_num;
- /* This indicates which type of buffer this session is set for. */
- enum lttng_buffer_type buffer_type;
- /* If set to 1, the buffer_type can not be changed anymore. */
- int buffer_type_changed;
- /* For per UID buffer, every buffer reg object is kept of this session */
- struct cds_list_head buffer_reg_uid_list;
- /* Next channel ID available for a newly registered channel. */
- uint64_t next_channel_id;
- /* Once this value reaches UINT32_MAX, no more id can be allocated. */
- uint64_t used_channel_id;
- /* Tell or not if the session has to output the traces. */
- unsigned int output_traces;
- unsigned int snapshot_mode;
- unsigned int has_non_default_channel;
- unsigned int live_timer_interval; /* usec */
-
- /* Metadata channel attributes. */
- struct lttng_ust_abi_channel_attr metadata_attr;
-
- /*
- * Path where to keep the shared memory files.
- */
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
-
- /* Current trace chunk of the ltt_session. */
- struct lttng_trace_chunk *current_trace_chunk;
-
- /* Trackers used for actual lookup on app registration. */
- struct ust_id_tracker vpid_tracker;
- struct ust_id_tracker vuid_tracker;
- struct ust_id_tracker vgid_tracker;
-
- /* Tracker list of keys requested by users. */
- struct process_attr_tracker *tracker_vpid;
- struct process_attr_tracker *tracker_vuid;
- struct process_attr_tracker *tracker_vgid;
-};
-
-/*
- * Validate that the id has reached the maximum allowed or not.
- *
- * Return 0 if NOT else 1.
- */
-static inline int trace_ust_is_max_id(uint64_t id)
-{
- return (id == UINT64_MAX) ? 1 : 0;
-}
-
-/*
- * Return next available channel id and increment the used counter. The
- * trace_ust_is_max_id function MUST be called before in order to validate if
- * the maximum number of IDs have been reached. If not, it is safe to call this
- * function.
- *
- * Return a unique channel ID. If max is reached, the used_channel_id counter
- * is returned.
- */
-static inline uint64_t trace_ust_get_next_chan_id(struct ltt_ust_session *s)
-{
- if (trace_ust_is_max_id(s->used_channel_id)) {
- return s->used_channel_id;
- }
-
- s->used_channel_id++;
- return s->next_channel_id++;
-}
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key);
-int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
- const void *_key);
-
-/*
- * Lookup functions. NULL is returned if not found.
- */
-struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
- char *name, struct lttng_bytecode *filter,
- enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value,
- struct lttng_event_exclusion *exclusion);
-struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
- const char *name);
-struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
- enum lttng_domain_type domain_type);
-
-/*
- * Create functions malloc() the data structure.
- */
-struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
- enum lttng_domain_type domain);
-
-enum lttng_error_code trace_ust_create_event(struct lttng_event *ev,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- bool internal_event, struct ltt_ust_event **ust_event);
-struct ltt_ust_context *trace_ust_create_context(
- const struct lttng_event_context *ctx);
-int trace_ust_match_context(const struct ltt_ust_context *uctx,
- const struct lttng_event_context *ctx);
-void trace_ust_delete_channel(struct lttng_ht *ht,
- struct ltt_ust_channel *channel);
-
-/*
- * Destroy functions free() the data structure and remove from linked list if
- * it's applies.
- */
-void trace_ust_destroy_session(struct ltt_ust_session *session);
-void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
-void trace_ust_destroy_event(struct ltt_ust_event *event);
-void trace_ust_destroy_context(struct ltt_ust_context *ctx);
-void trace_ust_free_session(struct ltt_ust_session *session);
-
-int trace_ust_id_tracker_lookup(enum lttng_process_attr process_attr,
- struct ltt_ust_session *session,
- int id);
-enum lttng_error_code trace_ust_process_attr_tracker_set_tracking_policy(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy);
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value);
-const struct process_attr_tracker *trace_ust_get_process_attr_tracker(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline int trace_ust_ht_match_event(
- struct cds_lfht_node *node __attribute__((unused)),
- const void *_key __attribute__((unused)))
-{
- return 0;
-}
-
-static inline int trace_ust_ht_match_event_by_name(
- struct cds_lfht_node *node __attribute__((unused)),
- const void *_key __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-struct ltt_ust_channel *trace_ust_find_channel_by_name(
- struct lttng_ht *ht __attribute__((unused)),
- const char *name __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-struct ltt_ust_session *trace_ust_create_session(
- unsigned int session_id __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-struct ltt_ust_channel *trace_ust_create_channel(
- struct lttng_channel *attr __attribute__((unused)),
- enum lttng_domain_type domain __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-enum lttng_error_code trace_ust_create_event(
- struct lttng_event *ev __attribute__((unused)),
- const char *filter_expression __attribute__((unused)),
- struct lttng_bytecode *filter __attribute__((unused)),
- struct lttng_event_exclusion *exclusion __attribute__((unused)),
- bool internal_event __attribute__((unused)),
- struct ltt_ust_event **ust_event __attribute__((unused)))
-{
- return LTTNG_ERR_NO_UST;
-}
-
-static inline
-void trace_ust_destroy_session(
- struct ltt_ust_session *session __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_destroy_channel(
- struct ltt_ust_channel *channel __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_destroy_event(
- struct ltt_ust_event *event __attribute__((unused)))
-{
-}
-
-static inline
-void trace_ust_free_session(
- struct ltt_ust_session *session __attribute__((unused)))
-{
-}
-
-static inline
-struct ltt_ust_context *trace_ust_create_context(
- const struct lttng_event_context *ctx __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-int trace_ust_match_context(
- const struct ltt_ust_context *uctx __attribute__((unused)),
- const struct lttng_event_context *ctx __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-struct ltt_ust_event *trace_ust_find_event(
- struct lttng_ht *ht __attribute__((unused)),
- char *name __attribute__((unused)),
- struct lttng_bytecode *filter __attribute__((unused)),
- enum lttng_ust_abi_loglevel_type loglevel_type __attribute__((unused)),
- int loglevel_value __attribute__((unused)),
- struct lttng_event_exclusion *exclusion __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-void trace_ust_delete_channel(
- struct lttng_ht *ht __attribute__((unused)),
- struct ltt_ust_channel *channel __attribute__((unused)))
-{
- return;
-}
-
-static inline
-struct agent *trace_ust_find_agent(
- struct ltt_ust_session *session __attribute__((unused)),
- enum lttng_domain_type domain_type __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline int trace_ust_id_tracker_lookup(
- enum lttng_process_attr process_attr __attribute__((unused)),
- struct ltt_ust_session *session __attribute__((unused)),
- int id __attribute__((unused)))
-{
- return 0;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_set_tracking_policy(
- struct ltt_ust_session *session __attribute__((unused)),
- enum lttng_process_attr process_attr __attribute__((unused)),
- enum lttng_tracking_policy policy __attribute__((unused)))
-{
- return LTTNG_OK;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_inclusion_set_add_value(
- struct ltt_ust_session *session __attribute__((unused)),
- enum lttng_process_attr process_attr __attribute__((unused)),
- const struct process_attr_value *value __attribute__((unused)))
-{
- return LTTNG_OK;
-}
-
-static inline enum lttng_error_code
-trace_ust_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_ust_session *session __attribute__((unused)),
- enum lttng_process_attr process_attr __attribute__((unused)),
- const struct process_attr_value *value __attribute__((unused)))
-{
- return LTTNG_OK;
-}
-
-static inline const struct process_attr_tracker *
-trace_ust_get_process_attr_tracker(
- struct ltt_ust_session *session __attribute__((unused)),
- enum lttng_process_attr process_attr __attribute__((unused)))
-{
- return NULL;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTT_TRACE_UST_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACE_UST_H
+#define _LTT_TRACE_UST_H
+
+#include <limits.h>
+#include <urcu/list.h>
+
+#include <common/defaults.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/tracker.hpp>
+#include <lttng/lttng.h>
+
+#include "consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+
+struct agent;
+
+struct ltt_ust_ht_key {
+ const char *name;
+ const struct lttng_bytecode *filter;
+ enum lttng_ust_abi_loglevel_type loglevel_type;
+ int loglevel_value;
+ const struct lttng_event_exclusion *exclusion;
+};
+
+/* Context hash table nodes */
+struct ltt_ust_context {
+ struct lttng_ust_context_attr ctx;
+ struct lttng_ht_node_ulong node;
+ struct cds_list_head list;
+};
+
+/* UST event */
+struct ltt_ust_event {
+ unsigned int enabled;
+ struct lttng_ust_abi_event attr;
+ struct lttng_ht_node_str node;
+ char *filter_expression;
+ struct lttng_bytecode *filter;
+ struct lttng_event_exclusion *exclusion;
+ /*
+ * An internal event is an event which was created by the session daemon
+ * through which, for example, events emitted in Agent domains are
+ * "funelled". This is used to hide internal events from external
+ * clients as they should never be modified by the external world.
+ */
+ bool internal;
+};
+
+/* UST channel */
+struct ltt_ust_channel {
+ uint64_t id; /* unique id per session. */
+ unsigned int enabled;
+ /*
+ * A UST channel can be part of a userspace sub-domain such as JUL,
+ * Log4j, Python.
+ */
+ enum lttng_domain_type domain;
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ust_abi_channel_attr attr;
+ struct lttng_ht *ctx;
+ struct cds_list_head ctx_list;
+ struct lttng_ht *events;
+ struct lttng_ht_node_str node;
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ uint64_t per_pid_closed_app_discarded;
+ uint64_t per_pid_closed_app_lost;
+ uint64_t monitor_timer_interval;
+};
+
+/* UST domain global (LTTNG_DOMAIN_UST) */
+struct ltt_ust_domain_global {
+ struct lttng_ht *channels;
+ struct cds_list_head registry_buffer_uid_list;
+};
+
+struct ust_id_tracker_node {
+ struct lttng_ht_node_ulong node;
+};
+
+struct ust_id_tracker {
+ struct lttng_ht *ht;
+};
+
+/* UST session */
+struct ltt_ust_session {
+ uint64_t id; /* Unique identifier of session */
+ struct ltt_ust_domain_global domain_global;
+ /* Hash table of agent indexed by agent domain. */
+ struct lttng_ht *agents;
+ /* UID/GID of the user owning the session */
+ uid_t uid;
+ gid_t gid;
+ /* Is the session active meaning has is been started or stopped. */
+ unsigned int active:1;
+ struct consumer_output *consumer;
+ /* Sequence number for filters so the tracer knows the ordering. */
+ uint64_t filter_seq_num;
+ /* This indicates which type of buffer this session is set for. */
+ enum lttng_buffer_type buffer_type;
+ /* If set to 1, the buffer_type can not be changed anymore. */
+ int buffer_type_changed;
+ /* For per UID buffer, every buffer reg object is kept of this session */
+ struct cds_list_head buffer_reg_uid_list;
+ /* Next channel ID available for a newly registered channel. */
+ uint64_t next_channel_id;
+ /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+ uint64_t used_channel_id;
+ /* Tell or not if the session has to output the traces. */
+ unsigned int output_traces;
+ unsigned int snapshot_mode;
+ unsigned int has_non_default_channel;
+ unsigned int live_timer_interval; /* usec */
+
+ /* Metadata channel attributes. */
+ struct lttng_ust_abi_channel_attr metadata_attr;
+
+ /*
+ * Path where to keep the shared memory files.
+ */
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+
+ /* Current trace chunk of the ltt_session. */
+ struct lttng_trace_chunk *current_trace_chunk;
+
+ /* Trackers used for actual lookup on app registration. */
+ struct ust_id_tracker vpid_tracker;
+ struct ust_id_tracker vuid_tracker;
+ struct ust_id_tracker vgid_tracker;
+
+ /* Tracker list of keys requested by users. */
+ struct process_attr_tracker *tracker_vpid;
+ struct process_attr_tracker *tracker_vuid;
+ struct process_attr_tracker *tracker_vgid;
+};
+
+/*
+ * Validate that the id has reached the maximum allowed or not.
+ *
+ * Return 0 if NOT else 1.
+ */
+static inline int trace_ust_is_max_id(uint64_t id)
+{
+ return (id == UINT64_MAX) ? 1 : 0;
+}
+
+/*
+ * Return next available channel id and increment the used counter. The
+ * trace_ust_is_max_id function MUST be called before in order to validate if
+ * the maximum number of IDs have been reached. If not, it is safe to call this
+ * function.
+ *
+ * Return a unique channel ID. If max is reached, the used_channel_id counter
+ * is returned.
+ */
+static inline uint64_t trace_ust_get_next_chan_id(struct ltt_ust_session *s)
+{
+ if (trace_ust_is_max_id(s->used_channel_id)) {
+ return s->used_channel_id;
+ }
+
+ s->used_channel_id++;
+ return s->next_channel_id++;
+}
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key);
+int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
+ const void *_key);
+
+/*
+ * Lookup functions. NULL is returned if not found.
+ */
+struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
+ char *name, struct lttng_bytecode *filter,
+ enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value,
+ struct lttng_event_exclusion *exclusion);
+struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
+ const char *name);
+struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
+ enum lttng_domain_type domain_type);
+
+/*
+ * Create functions malloc() the data structure.
+ */
+struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
+ enum lttng_domain_type domain);
+
+enum lttng_error_code trace_ust_create_event(struct lttng_event *ev,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ bool internal_event, struct ltt_ust_event **ust_event);
+struct ltt_ust_context *trace_ust_create_context(
+ const struct lttng_event_context *ctx);
+int trace_ust_match_context(const struct ltt_ust_context *uctx,
+ const struct lttng_event_context *ctx);
+void trace_ust_delete_channel(struct lttng_ht *ht,
+ struct ltt_ust_channel *channel);
+
+/*
+ * Destroy functions free() the data structure and remove from linked list if
+ * it's applies.
+ */
+void trace_ust_destroy_session(struct ltt_ust_session *session);
+void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
+void trace_ust_destroy_event(struct ltt_ust_event *event);
+void trace_ust_destroy_context(struct ltt_ust_context *ctx);
+void trace_ust_free_session(struct ltt_ust_session *session);
+
+int trace_ust_id_tracker_lookup(enum lttng_process_attr process_attr,
+ struct ltt_ust_session *session,
+ int id);
+enum lttng_error_code trace_ust_process_attr_tracker_set_tracking_policy(
+ struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy);
+enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value(
+ struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value(
+ struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value);
+const struct process_attr_tracker *trace_ust_get_process_attr_tracker(
+ struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline int trace_ust_ht_match_event(
+ struct cds_lfht_node *node __attribute__((unused)),
+ const void *_key __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline int trace_ust_ht_match_event_by_name(
+ struct cds_lfht_node *node __attribute__((unused)),
+ const void *_key __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+struct ltt_ust_channel *trace_ust_find_channel_by_name(
+ struct lttng_ht *ht __attribute__((unused)),
+ const char *name __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+struct ltt_ust_session *trace_ust_create_session(
+ unsigned int session_id __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+struct ltt_ust_channel *trace_ust_create_channel(
+ struct lttng_channel *attr __attribute__((unused)),
+ enum lttng_domain_type domain __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+enum lttng_error_code trace_ust_create_event(
+ struct lttng_event *ev __attribute__((unused)),
+ const char *filter_expression __attribute__((unused)),
+ struct lttng_bytecode *filter __attribute__((unused)),
+ struct lttng_event_exclusion *exclusion __attribute__((unused)),
+ bool internal_event __attribute__((unused)),
+ struct ltt_ust_event **ust_event __attribute__((unused)))
+{
+ return LTTNG_ERR_NO_UST;
+}
+
+static inline
+void trace_ust_destroy_session(
+ struct ltt_ust_session *session __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_destroy_channel(
+ struct ltt_ust_channel *channel __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_destroy_event(
+ struct ltt_ust_event *event __attribute__((unused)))
+{
+}
+
+static inline
+void trace_ust_free_session(
+ struct ltt_ust_session *session __attribute__((unused)))
+{
+}
+
+static inline
+struct ltt_ust_context *trace_ust_create_context(
+ const struct lttng_event_context *ctx __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+int trace_ust_match_context(
+ const struct ltt_ust_context *uctx __attribute__((unused)),
+ const struct lttng_event_context *ctx __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+struct ltt_ust_event *trace_ust_find_event(
+ struct lttng_ht *ht __attribute__((unused)),
+ char *name __attribute__((unused)),
+ struct lttng_bytecode *filter __attribute__((unused)),
+ enum lttng_ust_abi_loglevel_type loglevel_type __attribute__((unused)),
+ int loglevel_value __attribute__((unused)),
+ struct lttng_event_exclusion *exclusion __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+void trace_ust_delete_channel(
+ struct lttng_ht *ht __attribute__((unused)),
+ struct ltt_ust_channel *channel __attribute__((unused)))
+{
+ return;
+}
+
+static inline
+struct agent *trace_ust_find_agent(
+ struct ltt_ust_session *session __attribute__((unused)),
+ enum lttng_domain_type domain_type __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline int trace_ust_id_tracker_lookup(
+ enum lttng_process_attr process_attr __attribute__((unused)),
+ struct ltt_ust_session *session __attribute__((unused)),
+ int id __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_set_tracking_policy(
+ struct ltt_ust_session *session __attribute__((unused)),
+ enum lttng_process_attr process_attr __attribute__((unused)),
+ enum lttng_tracking_policy policy __attribute__((unused)))
+{
+ return LTTNG_OK;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_add_value(
+ struct ltt_ust_session *session __attribute__((unused)),
+ enum lttng_process_attr process_attr __attribute__((unused)),
+ const struct process_attr_value *value __attribute__((unused)))
+{
+ return LTTNG_OK;
+}
+
+static inline enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_remove_value(
+ struct ltt_ust_session *session __attribute__((unused)),
+ enum lttng_process_attr process_attr __attribute__((unused)),
+ const struct process_attr_value *value __attribute__((unused)))
+{
+ return LTTNG_OK;
+}
+
+static inline const struct process_attr_tracker *
+trace_ust_get_process_attr_tracker(
+ struct ltt_ust_session *session __attribute__((unused)),
+ enum lttng_process_attr process_attr __attribute__((unused)))
+{
+ return NULL;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTT_TRACE_UST_H */
*/
#include "lttng/tracker.h"
-#include "common/dynamic-array.h"
-#include "common/macros.h"
+#include "common/dynamic-array.hpp"
+#include "common/macros.hpp"
#define _LGPL_SOURCE
#include <grp.h>
#include <pwd.h>
#include <urcu/list.h>
#include <urcu/rculfhash.h>
-#include "tracker.h"
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/tracker.h>
+#include "tracker.hpp"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/tracker.hpp>
#include <lttng/lttng-error.h>
struct process_attr_tracker_value_node {
+++ /dev/null
-/*
- * Copyright (C) 2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_TRACKER_H
-#define _LTT_TRACKER_H
-
-#include <common/tracker.h>
-#include <lttng/tracker.h>
-
-struct process_attr_tracker;
-
-enum process_attr_tracker_status {
- PROCESS_ATTR_TRACKER_STATUS_OK,
- PROCESS_ATTR_TRACKER_STATUS_ERROR,
- PROCESS_ATTR_TRACKER_STATUS_EXISTS,
- PROCESS_ATTR_TRACKER_STATUS_MISSING,
- PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY,
-};
-
-struct process_attr_tracker *process_attr_tracker_create(void);
-void process_attr_tracker_destroy(struct process_attr_tracker *tracker);
-
-enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
- const struct process_attr_tracker *tracker);
-int process_attr_tracker_set_tracking_policy(
- struct process_attr_tracker *tracker,
- enum lttng_tracking_policy tracking_policy);
-
-enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
- struct process_attr_tracker *tracker,
- const struct process_attr_value *value);
-enum process_attr_tracker_status
-process_attr_tracker_inclusion_set_remove_value(
- struct process_attr_tracker *tracker,
- const struct process_attr_value *value);
-
-enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
- const struct process_attr_tracker *tracker,
- struct lttng_process_attr_values **values);
-
-#endif /* _LTT_TRACKER_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_TRACKER_H
+#define _LTT_TRACKER_H
+
+#include <common/tracker.hpp>
+#include <lttng/tracker.h>
+
+struct process_attr_tracker;
+
+enum process_attr_tracker_status {
+ PROCESS_ATTR_TRACKER_STATUS_OK,
+ PROCESS_ATTR_TRACKER_STATUS_ERROR,
+ PROCESS_ATTR_TRACKER_STATUS_EXISTS,
+ PROCESS_ATTR_TRACKER_STATUS_MISSING,
+ PROCESS_ATTR_TRACKER_STATUS_INVALID_TRACKING_POLICY,
+};
+
+struct process_attr_tracker *process_attr_tracker_create(void);
+void process_attr_tracker_destroy(struct process_attr_tracker *tracker);
+
+enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
+ const struct process_attr_tracker *tracker);
+int process_attr_tracker_set_tracking_policy(
+ struct process_attr_tracker *tracker,
+ enum lttng_tracking_policy tracking_policy);
+
+enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
+ struct process_attr_tracker *tracker,
+ const struct process_attr_value *value);
+enum process_attr_tracker_status
+process_attr_tracker_inclusion_set_remove_value(
+ struct process_attr_tracker *tracker,
+ const struct process_attr_value *value);
+
+enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
+ const struct process_attr_tracker *tracker,
+ struct lttng_process_attr_values **values);
+
+#endif /* _LTT_TRACKER_H */
*
*/
-#include "event-notifier-error-accounting.h"
-#include <lttng/error-query-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/action/action-internal.h>
+#include "event-notifier-error-accounting.hpp"
+#include <lttng/error-query-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/action/action-internal.hpp>
enum lttng_trigger_status lttng_trigger_add_error_results(
const struct lttng_trigger *trigger __attribute__((unused)),
+++ /dev/null
-/*
- * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- * Copied from LTTng-UST lttng/ust-abi.h
- *
- * LTTng-UST ABI header
- *
- */
-
-#ifndef LTTNG_UST_ABI_INTERNAL_H
-#define LTTNG_UST_ABI_INTERNAL_H
-
-#include <stdint.h>
-#include <common/macros.h>
-
-#ifndef LTTNG_PACKED
-#error "LTTNG_PACKED should be defined"
-#endif
-
-#ifndef __ust_stringify
-#define __ust_stringify1(x) #x
-#define __ust_stringify(x) __ust_stringify1(x)
-#endif /* __ust_stringify */
-
-#define LTTNG_UST_ABI_SYM_NAME_LEN 256
-#define LTTNG_UST_ABI_PROCNAME_LEN 16
-
-/* UST comm magic number, used to validate protocol and endianness. */
-#define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
-
-/* Version for ABI between liblttng-ust, sessiond, consumerd */
-#define LTTNG_UST_ABI_MAJOR_VERSION 9
-#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
-#define LTTNG_UST_ABI_MINOR_VERSION 0
-
-enum lttng_ust_abi_instrumentation {
- LTTNG_UST_ABI_TRACEPOINT = 0,
- LTTNG_UST_ABI_PROBE = 1,
- LTTNG_UST_ABI_FUNCTION = 2,
-};
-
-enum lttng_ust_abi_loglevel_type {
- LTTNG_UST_ABI_LOGLEVEL_ALL = 0,
- LTTNG_UST_ABI_LOGLEVEL_RANGE = 1,
- LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2,
-};
-
-enum lttng_ust_abi_output {
- LTTNG_UST_ABI_MMAP = 0,
-};
-
-enum lttng_ust_abi_chan_type {
- LTTNG_UST_ABI_CHAN_PER_CPU = 0,
- LTTNG_UST_ABI_CHAN_METADATA = 1,
-};
-
-struct lttng_ust_abi_tracer_version {
- uint32_t major;
- uint32_t minor;
- uint32_t patchlevel;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-/*
- * Given that the consumerd is limited to 64k file descriptors, we
- * cannot expect much more than 1MB channel structure size. This size is
- * depends on the number of streams within a channel, which depends on
- * the number of possible CPUs on the system.
- */
-#define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
-struct lttng_ust_abi_channel {
- uint64_t len;
- int32_t type; /* enum lttng_ust_abi_chan_type */
- char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
- char data[]; /* variable sized data */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_stream {
- uint64_t len; /* shm len */
- uint32_t stream_nr; /* stream number */
- char padding[LTTNG_UST_ABI_STREAM_PADDING1];
- /*
- * shm_fd and wakeup_fd are send over unix socket as file
- * descriptors after this structure.
- */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
-
-enum lttng_ust_abi_counter_arithmetic {
- LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
- LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
-};
-
-enum lttng_ust_abi_counter_bitness {
- LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
- LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
-};
-
-struct lttng_ust_abi_counter_dimension {
- uint64_t size;
- uint64_t underflow_index;
- uint64_t overflow_index;
- uint8_t has_underflow;
- uint8_t has_overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
-struct lttng_ust_abi_counter_conf {
- uint32_t arithmetic; /* enum lttng_ust_abi_counter_arithmetic */
- uint32_t bitness; /* enum lttng_ust_abi_counter_bitness */
- uint32_t number_dimensions;
- int64_t global_sum_step;
- struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
- uint8_t coalesce_hits;
- char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
-} LTTNG_PACKED;
-
-struct lttng_ust_abi_counter_value {
- uint32_t number_dimensions;
- uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
- int64_t value;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_PADDING1 8
-#define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_event {
- int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */
- char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */
-
- int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */
- int32_t loglevel; /* value, -1: all */
- uint64_t token; /* User-provided token */
- char padding[LTTNG_UST_ABI_EVENT_PADDING1];
-
- /* Per instrumentation type configuration */
- union {
- char padding[LTTNG_UST_ABI_EVENT_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
-struct lttng_ust_abi_event_notifier {
- struct lttng_ust_abi_event event;
- uint64_t error_counter_index;
- char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
-struct lttng_ust_abi_event_notifier_notification {
- uint64_t token;
- uint16_t capture_buf_size;
- char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-#define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
-struct lttng_ust_abi_counter {
- uint64_t len;
- char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
- char data[]; /* variable sized data */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_counter_global {
- uint64_t len; /* shm len */
- char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_counter_cpu {
- uint64_t len; /* shm len */
- uint32_t cpu_nr;
- char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_field_type {
- LTTNG_UST_ABI_FIELD_OTHER = 0,
- LTTNG_UST_ABI_FIELD_INTEGER = 1,
- LTTNG_UST_ABI_FIELD_ENUM = 2,
- LTTNG_UST_ABI_FIELD_FLOAT = 3,
- LTTNG_UST_ABI_FIELD_STRING = 4,
-};
-
-#define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
-struct lttng_ust_abi_field_iter {
- char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- int32_t type; /* enum lttng_ust_abi_field_type */
- int loglevel; /* event loglevel */
- int nowrite;
- char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_context_type {
- LTTNG_UST_ABI_CONTEXT_VTID = 0,
- LTTNG_UST_ABI_CONTEXT_VPID = 1,
- LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2,
- LTTNG_UST_ABI_CONTEXT_PROCNAME = 3,
- LTTNG_UST_ABI_CONTEXT_IP = 4,
- LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5,
- LTTNG_UST_ABI_CONTEXT_CPU_ID = 6,
- LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7,
- LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8,
- LTTNG_UST_ABI_CONTEXT_IPC_NS = 9,
- LTTNG_UST_ABI_CONTEXT_MNT_NS = 10,
- LTTNG_UST_ABI_CONTEXT_NET_NS = 11,
- LTTNG_UST_ABI_CONTEXT_PID_NS = 12,
- LTTNG_UST_ABI_CONTEXT_USER_NS = 13,
- LTTNG_UST_ABI_CONTEXT_UTS_NS = 14,
- LTTNG_UST_ABI_CONTEXT_VUID = 15,
- LTTNG_UST_ABI_CONTEXT_VEUID = 16,
- LTTNG_UST_ABI_CONTEXT_VSUID = 17,
- LTTNG_UST_ABI_CONTEXT_VGID = 18,
- LTTNG_UST_ABI_CONTEXT_VEGID = 19,
- LTTNG_UST_ABI_CONTEXT_VSGID = 20,
- LTTNG_UST_ABI_CONTEXT_TIME_NS = 21,
-};
-
-struct lttng_ust_abi_perf_counter_ctx {
- uint32_t type;
- uint64_t config;
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CONTEXT_PADDING1 16
-#define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_context {
- int32_t ctx; /* enum lttng_ust_abi_context_type */
- char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
-
- union {
- struct lttng_ust_abi_perf_counter_ctx perf_counter;
- struct {
- /* Includes trailing '\0'. */
- uint32_t provider_name_len;
- uint32_t ctx_name_len;
- } app_ctx;
- char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-/*
- * Tracer channel attributes.
- */
-#define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_channel_attr {
- uint64_t subbuf_size; /* bytes */
- uint64_t num_subbuf; /* power of 2 */
- int overwrite; /* 1: overwrite, 0: discard */
- unsigned int switch_timer_interval; /* usec */
- unsigned int read_timer_interval; /* usec */
- int32_t output; /* enum lttng_ust_abi_output */
- union {
- struct {
- int64_t blocking_timeout; /* Blocking timeout (usec) */
- } s;
- char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
- } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
-struct lttng_ust_abi_tracepoint_iter {
- char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */
- int loglevel;
- char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_object_type {
- LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
- LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
- LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
- LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
- LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
- LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
- LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
- LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
- LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
- LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
-};
-
-#define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
-#define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-
-struct lttng_ust_abi_object_data {
- int32_t type; /* enum lttng_ust_abi_object_type */
- int handle;
- uint64_t size;
- char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
- union {
- struct {
- void *data;
- int32_t type; /* enum lttng_ust_abi_chan_type */
- int wakeup_fd;
- } channel;
- struct {
- int shm_fd;
- int wakeup_fd;
- uint32_t stream_nr;
- } stream;
- struct {
- void *data;
- } counter;
- struct {
- int shm_fd;
- } counter_global;
- struct {
- int shm_fd;
- uint32_t cpu_nr;
- } counter_cpu;
- char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-enum lttng_ust_abi_calibrate_type {
- LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
-};
-
-#define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
-#define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
-struct lttng_ust_abi_calibrate {
- enum lttng_ust_abi_calibrate_type type; /* type (input) */
- char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
-
- union {
- char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
-#define LTTNG_UST_ABI_FILTER_PADDING 32
-struct lttng_ust_abi_filter_bytecode {
- uint32_t len;
- uint32_t reloc_offset;
- uint64_t seqnum;
- char padding[LTTNG_UST_ABI_FILTER_PADDING];
- char data[0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
-#define LTTNG_UST_ABI_CAPTURE_PADDING 32
-struct lttng_ust_abi_capture_bytecode {
- uint32_t len;
- uint32_t reloc_offset;
- uint64_t seqnum;
- char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
- char data[0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_EXCLUSION_PADDING 32
-struct lttng_ust_abi_event_exclusion {
- uint32_t count;
- char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
- char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_ABI_CMD(minor) (minor)
-#define LTTNG_UST_ABI_CMDR(minor, type) (minor)
-#define LTTNG_UST_ABI_CMDW(minor, type) (minor)
-
-/* Handled by object descriptor */
-#define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
-
-/* Handled by object cmd */
-
-/* LTTng-UST commands */
-#define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
-#define LTTNG_UST_ABI_TRACER_VERSION \
- LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
-#define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
-#define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
-#define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
-#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
- LTTNG_UST_ABI_CMD(0x46)
-
-/* Session commands */
-#define LTTNG_UST_ABI_CHANNEL \
- LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
-#define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
-#define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
-#define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
-
-/* Channel commands */
-#define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
-#define LTTNG_UST_ABI_EVENT \
- LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
-
-/* Event and channel commands */
-#define LTTNG_UST_ABI_CONTEXT \
- LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
-#define LTTNG_UST_ABI_FLUSH_BUFFER \
- LTTNG_UST_ABI_CMD(0x71)
-
-/* Event, event notifier, channel and session commands */
-#define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
-#define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
-
-/* Tracepoint list commands */
-#define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
-#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
-
-/* Event and event notifier commands */
-#define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
-#define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
-
-/* Event notifier group commands */
-#define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
- LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
-
-/* Event notifier commands */
-#define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
-
-/* Session and event notifier group commands */
-#define LTTNG_UST_ABI_COUNTER \
- LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
-
-/* Counter commands */
-#define LTTNG_UST_ABI_COUNTER_GLOBAL \
- LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
-#define LTTNG_UST_ABI_COUNTER_CPU \
- LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
-
-#define LTTNG_UST_ABI_ROOT_HANDLE 0
-
-#endif /* LTTNG_UST_ABI_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Copied from LTTng-UST lttng/ust-abi.h
+ *
+ * LTTng-UST ABI header
+ *
+ */
+
+#ifndef LTTNG_UST_ABI_INTERNAL_H
+#define LTTNG_UST_ABI_INTERNAL_H
+
+#include <stdint.h>
+#include <common/macros.hpp>
+
+#ifndef LTTNG_PACKED
+#error "LTTNG_PACKED should be defined"
+#endif
+
+#ifndef __ust_stringify
+#define __ust_stringify1(x) #x
+#define __ust_stringify(x) __ust_stringify1(x)
+#endif /* __ust_stringify */
+
+#define LTTNG_UST_ABI_SYM_NAME_LEN 256
+#define LTTNG_UST_ABI_PROCNAME_LEN 16
+
+/* UST comm magic number, used to validate protocol and endianness. */
+#define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
+
+/* Version for ABI between liblttng-ust, sessiond, consumerd */
+#define LTTNG_UST_ABI_MAJOR_VERSION 9
+#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
+#define LTTNG_UST_ABI_MINOR_VERSION 0
+
+enum lttng_ust_abi_instrumentation {
+ LTTNG_UST_ABI_TRACEPOINT = 0,
+ LTTNG_UST_ABI_PROBE = 1,
+ LTTNG_UST_ABI_FUNCTION = 2,
+};
+
+enum lttng_ust_abi_loglevel_type {
+ LTTNG_UST_ABI_LOGLEVEL_ALL = 0,
+ LTTNG_UST_ABI_LOGLEVEL_RANGE = 1,
+ LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2,
+};
+
+enum lttng_ust_abi_output {
+ LTTNG_UST_ABI_MMAP = 0,
+};
+
+enum lttng_ust_abi_chan_type {
+ LTTNG_UST_ABI_CHAN_PER_CPU = 0,
+ LTTNG_UST_ABI_CHAN_METADATA = 1,
+};
+
+struct lttng_ust_abi_tracer_version {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patchlevel;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+/*
+ * Given that the consumerd is limited to 64k file descriptors, we
+ * cannot expect much more than 1MB channel structure size. This size is
+ * depends on the number of streams within a channel, which depends on
+ * the number of possible CPUs on the system.
+ */
+#define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
+struct lttng_ust_abi_channel {
+ uint64_t len;
+ int32_t type; /* enum lttng_ust_abi_chan_type */
+ char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
+ char data[]; /* variable sized data */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_stream {
+ uint64_t len; /* shm len */
+ uint32_t stream_nr; /* stream number */
+ char padding[LTTNG_UST_ABI_STREAM_PADDING1];
+ /*
+ * shm_fd and wakeup_fd are send over unix socket as file
+ * descriptors after this structure.
+ */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
+
+enum lttng_ust_abi_counter_arithmetic {
+ LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
+ LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
+};
+
+enum lttng_ust_abi_counter_bitness {
+ LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
+ LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
+};
+
+struct lttng_ust_abi_counter_dimension {
+ uint64_t size;
+ uint64_t underflow_index;
+ uint64_t overflow_index;
+ uint8_t has_underflow;
+ uint8_t has_overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
+struct lttng_ust_abi_counter_conf {
+ uint32_t arithmetic; /* enum lttng_ust_abi_counter_arithmetic */
+ uint32_t bitness; /* enum lttng_ust_abi_counter_bitness */
+ uint32_t number_dimensions;
+ int64_t global_sum_step;
+ struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
+ uint8_t coalesce_hits;
+ char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
+} LTTNG_PACKED;
+
+struct lttng_ust_abi_counter_value {
+ uint32_t number_dimensions;
+ uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
+ int64_t value;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_PADDING1 8
+#define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_event {
+ int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */
+
+ int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */
+ int32_t loglevel; /* value, -1: all */
+ uint64_t token; /* User-provided token */
+ char padding[LTTNG_UST_ABI_EVENT_PADDING1];
+
+ /* Per instrumentation type configuration */
+ union {
+ char padding[LTTNG_UST_ABI_EVENT_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
+struct lttng_ust_abi_event_notifier {
+ struct lttng_ust_abi_event event;
+ uint64_t error_counter_index;
+ char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
+struct lttng_ust_abi_event_notifier_notification {
+ uint64_t token;
+ uint16_t capture_buf_size;
+ char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+#define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
+struct lttng_ust_abi_counter {
+ uint64_t len;
+ char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
+ char data[]; /* variable sized data */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_counter_global {
+ uint64_t len; /* shm len */
+ char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_counter_cpu {
+ uint64_t len; /* shm len */
+ uint32_t cpu_nr;
+ char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_field_type {
+ LTTNG_UST_ABI_FIELD_OTHER = 0,
+ LTTNG_UST_ABI_FIELD_INTEGER = 1,
+ LTTNG_UST_ABI_FIELD_ENUM = 2,
+ LTTNG_UST_ABI_FIELD_FLOAT = 3,
+ LTTNG_UST_ABI_FIELD_STRING = 4,
+};
+
+#define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
+struct lttng_ust_abi_field_iter {
+ char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ int32_t type; /* enum lttng_ust_abi_field_type */
+ int loglevel; /* event loglevel */
+ int nowrite;
+ char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_context_type {
+ LTTNG_UST_ABI_CONTEXT_VTID = 0,
+ LTTNG_UST_ABI_CONTEXT_VPID = 1,
+ LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2,
+ LTTNG_UST_ABI_CONTEXT_PROCNAME = 3,
+ LTTNG_UST_ABI_CONTEXT_IP = 4,
+ LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5,
+ LTTNG_UST_ABI_CONTEXT_CPU_ID = 6,
+ LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7,
+ LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8,
+ LTTNG_UST_ABI_CONTEXT_IPC_NS = 9,
+ LTTNG_UST_ABI_CONTEXT_MNT_NS = 10,
+ LTTNG_UST_ABI_CONTEXT_NET_NS = 11,
+ LTTNG_UST_ABI_CONTEXT_PID_NS = 12,
+ LTTNG_UST_ABI_CONTEXT_USER_NS = 13,
+ LTTNG_UST_ABI_CONTEXT_UTS_NS = 14,
+ LTTNG_UST_ABI_CONTEXT_VUID = 15,
+ LTTNG_UST_ABI_CONTEXT_VEUID = 16,
+ LTTNG_UST_ABI_CONTEXT_VSUID = 17,
+ LTTNG_UST_ABI_CONTEXT_VGID = 18,
+ LTTNG_UST_ABI_CONTEXT_VEGID = 19,
+ LTTNG_UST_ABI_CONTEXT_VSGID = 20,
+ LTTNG_UST_ABI_CONTEXT_TIME_NS = 21,
+};
+
+struct lttng_ust_abi_perf_counter_ctx {
+ uint32_t type;
+ uint64_t config;
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CONTEXT_PADDING1 16
+#define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_context {
+ int32_t ctx; /* enum lttng_ust_abi_context_type */
+ char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
+
+ union {
+ struct lttng_ust_abi_perf_counter_ctx perf_counter;
+ struct {
+ /* Includes trailing '\0'. */
+ uint32_t provider_name_len;
+ uint32_t ctx_name_len;
+ } app_ctx;
+ char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+/*
+ * Tracer channel attributes.
+ */
+#define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_channel_attr {
+ uint64_t subbuf_size; /* bytes */
+ uint64_t num_subbuf; /* power of 2 */
+ int overwrite; /* 1: overwrite, 0: discard */
+ unsigned int switch_timer_interval; /* usec */
+ unsigned int read_timer_interval; /* usec */
+ int32_t output; /* enum lttng_ust_abi_output */
+ union {
+ struct {
+ int64_t blocking_timeout; /* Blocking timeout (usec) */
+ } s;
+ char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
+ } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
+struct lttng_ust_abi_tracepoint_iter {
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */
+ int loglevel;
+ char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_object_type {
+ LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
+ LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
+ LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
+ LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
+ LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
+ LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
+ LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
+ LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
+ LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
+ LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
+};
+
+#define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
+#define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+
+struct lttng_ust_abi_object_data {
+ int32_t type; /* enum lttng_ust_abi_object_type */
+ int handle;
+ uint64_t size;
+ char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
+ union {
+ struct {
+ void *data;
+ int32_t type; /* enum lttng_ust_abi_chan_type */
+ int wakeup_fd;
+ } channel;
+ struct {
+ int shm_fd;
+ int wakeup_fd;
+ uint32_t stream_nr;
+ } stream;
+ struct {
+ void *data;
+ } counter;
+ struct {
+ int shm_fd;
+ } counter_global;
+ struct {
+ int shm_fd;
+ uint32_t cpu_nr;
+ } counter_cpu;
+ char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+enum lttng_ust_abi_calibrate_type {
+ LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
+};
+
+#define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
+#define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
+struct lttng_ust_abi_calibrate {
+ enum lttng_ust_abi_calibrate_type type; /* type (input) */
+ char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
+
+ union {
+ char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
+#define LTTNG_UST_ABI_FILTER_PADDING 32
+struct lttng_ust_abi_filter_bytecode {
+ uint32_t len;
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ char padding[LTTNG_UST_ABI_FILTER_PADDING];
+ char data[0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
+#define LTTNG_UST_ABI_CAPTURE_PADDING 32
+struct lttng_ust_abi_capture_bytecode {
+ uint32_t len;
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
+ char data[0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_EXCLUSION_PADDING 32
+struct lttng_ust_abi_event_exclusion {
+ uint32_t count;
+ char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
+ char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_ABI_CMD(minor) (minor)
+#define LTTNG_UST_ABI_CMDR(minor, type) (minor)
+#define LTTNG_UST_ABI_CMDW(minor, type) (minor)
+
+/* Handled by object descriptor */
+#define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
+
+/* Handled by object cmd */
+
+/* LTTng-UST commands */
+#define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
+#define LTTNG_UST_ABI_TRACER_VERSION \
+ LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
+#define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
+#define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
+#define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
+#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
+ LTTNG_UST_ABI_CMD(0x46)
+
+/* Session commands */
+#define LTTNG_UST_ABI_CHANNEL \
+ LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
+#define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
+#define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
+#define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
+
+/* Channel commands */
+#define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
+#define LTTNG_UST_ABI_EVENT \
+ LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
+
+/* Event and channel commands */
+#define LTTNG_UST_ABI_CONTEXT \
+ LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
+#define LTTNG_UST_ABI_FLUSH_BUFFER \
+ LTTNG_UST_ABI_CMD(0x71)
+
+/* Event, event notifier, channel and session commands */
+#define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
+#define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
+
+/* Tracepoint list commands */
+#define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
+#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
+
+/* Event and event notifier commands */
+#define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
+#define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
+
+/* Event notifier group commands */
+#define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
+ LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
+
+/* Event notifier commands */
+#define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
+
+/* Session and event notifier group commands */
+#define LTTNG_UST_ABI_COUNTER \
+ LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
+
+/* Counter commands */
+#define LTTNG_UST_ABI_COUNTER_GLOBAL \
+ LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
+#define LTTNG_UST_ABI_COUNTER_CPU \
+ LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
+
+#define LTTNG_UST_ABI_ROOT_HANDLE 0
+
+#endif /* LTTNG_UST_ABI_INTERNAL_H */
#include <urcu/compiler.h>
#include <signal.h>
-#include <common/bytecode/bytecode.h>
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/user-tracepoint.h>
#include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "buffer-registry.h"
-#include "condition-internal.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "ust-app.h"
-#include "ust-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
-#include "session.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
-#include "rotate.h"
-#include "event.h"
-#include "event-notifier-error-accounting.h"
-#include "ust-field-utils.h"
+#include <lttng/trigger/trigger-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include "buffer-registry.hpp"
+#include "condition-internal.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "ust-app.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotate.hpp"
+#include "event.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "ust-field-utils.hpp"
struct lttng_ht *ust_app_ht;
struct lttng_ht *ust_app_ht_by_sock;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_UST_APP_H
-#define _LTT_UST_APP_H
-
-#include <stdint.h>
-
-#include <common/index-allocator.h>
-#include <common/uuid.h>
-
-#include "trace-ust.h"
-#include "ust-registry.h"
-#include "session.h"
-
-#define UST_APP_EVENT_LIST_SIZE 32
-
-/* Process name (short). */
-#define UST_APP_PROCNAME_LEN 16
-
-struct lttng_bytecode;
-struct lttng_ust_filter_bytecode;
-
-extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
-
-/*
- * Object used to close the notify socket in a call_rcu(). Since the
- * application might not be found, we need an independant object containing the
- * notify socket fd.
- */
-struct ust_app_notify_sock_obj {
- int fd;
- struct rcu_head head;
-};
-
-struct ust_app_ht_key {
- const char *name;
- const struct lttng_bytecode *filter;
- enum lttng_ust_abi_loglevel_type loglevel_type;
- const struct lttng_event_exclusion *exclusion;
-};
-
-/*
- * Application registration data structure.
- */
-struct ust_register_msg {
- enum lttng_ust_ctl_socket_type type;
- uint32_t major;
- uint32_t minor;
- uint32_t abi_major;
- uint32_t abi_minor;
- pid_t pid;
- pid_t ppid;
- uid_t uid;
- gid_t gid;
- uint32_t bits_per_long;
- uint32_t uint8_t_alignment;
- uint32_t uint16_t_alignment;
- uint32_t uint32_t_alignment;
- uint32_t uint64_t_alignment;
- uint32_t long_alignment;
- int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
- char name[LTTNG_UST_ABI_PROCNAME_LEN];
-};
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * PID using the pid_n node and pid value of an ust_app.
- */
-extern struct lttng_ht *ust_app_ht;
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * socket using the sock_n node and sock value of an ust_app.
- *
- * The 'sock' in question here is the 'command' socket.
- */
-extern struct lttng_ht *ust_app_ht_by_sock;
-
-/*
- * Global applications HT used by the session daemon. This table is indexed by
- * socket using the notify_sock_n node and notify_sock value of an ust_app.
- */
-extern struct lttng_ht *ust_app_ht_by_notify_sock;
-
-/* Stream list containing ust_app_stream. */
-struct ust_app_stream_list {
- unsigned int count;
- struct cds_list_head head;
-};
-
-struct ust_app_ctx {
- int handle;
- struct lttng_ust_context_attr ctx;
- struct lttng_ust_abi_object_data *obj;
- struct lttng_ht_node_ulong node;
- struct cds_list_head list;
-};
-
-struct ust_app_event {
- int enabled;
- int handle;
- struct lttng_ust_abi_object_data *obj;
- struct lttng_ust_abi_event attr;
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ht_node_str node;
- struct lttng_bytecode *filter;
- struct lttng_event_exclusion *exclusion;
-};
-
-struct ust_app_event_notifier_rule {
- int enabled;
- uint64_t error_counter_index;
- int handle;
- struct lttng_ust_abi_object_data *obj;
- /* Holds a strong reference. */
- struct lttng_trigger *trigger;
- /* Unique ID returned by the tracer to identify this event notifier. */
- uint64_t token;
- struct lttng_ht_node_u64 node;
- /* The trigger object owns the filter. */
- const struct lttng_bytecode *filter;
- /* Owned by this. */
- struct lttng_event_exclusion *exclusion;
- /* For delayed reclaim. */
- struct rcu_head rcu_head;
-};
-
-struct ust_app_stream {
- int handle;
- char pathname[PATH_MAX];
- /* Format is %s_%d respectively channel name and CPU number. */
- char name[DEFAULT_STREAM_NAME_LEN];
- struct lttng_ust_abi_object_data *obj;
- /* Using a list of streams to keep order. */
- struct cds_list_head list;
-};
-
-struct ust_app_channel {
- int enabled;
- int handle;
- /* Channel and streams were sent to the UST tracer. */
- int is_sent;
- /*
- * Unique key used to identify the channel on the consumer side.
- * 0 is a reserved 'invalid' value used to indicate that the consumer
- * does not know about this channel (i.e. an error occurred).
- */
- uint64_t key;
- /* Id of the tracing channel set on creation. */
- uint64_t tracing_channel_id;
- /* Number of stream that this channel is expected to receive. */
- unsigned int expected_stream_count;
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ust_abi_object_data *obj;
- struct lttng_ust_ctl_consumer_channel_attr attr;
- struct ust_app_stream_list streams;
- /* Session pointer that owns this object. */
- struct ust_app_session *session;
- /*
- * Contexts are kept in a hash table for fast lookup and in an ordered list
- * so we are able to enable them on the tracer side in the same order the
- * user added them.
- */
- struct lttng_ht *ctx;
- struct cds_list_head ctx_list;
-
- struct lttng_ht *events;
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- uint64_t monitor_timer_interval;
- /*
- * Node indexed by channel name in the channels' hash table of a session.
- */
- struct lttng_ht_node_str node;
- /*
- * Node indexed by UST channel object descriptor (handle). Stored in the
- * ust_objd hash table in the ust_app object.
- */
- struct lttng_ht_node_ulong ust_objd_node;
- /* For delayed reclaim */
- struct rcu_head rcu_head;
-};
-
-struct ust_app_session {
- /*
- * Lock protecting this session's ust app interaction. Held
- * across command send/recv to/from app. Never nests within the
- * session registry lock.
- */
- pthread_mutex_t lock;
-
- int enabled;
- /* started: has the session been in started state at any time ? */
- int started; /* allows detection of start vs restart. */
- int handle; /* used has unique identifier for app session */
-
- bool deleted; /* Session deleted flag. Check with lock held. */
-
- /*
- * Tracing session ID. Multiple ust app session can have the same tracing
- * session id making this value NOT unique to the object.
- */
- uint64_t tracing_id;
- uint64_t id; /* Unique session identifier */
- struct lttng_ht *channels; /* Registered channels */
- struct lttng_ht_node_u64 node;
- /*
- * Node indexed by UST session object descriptor (handle). Stored in the
- * ust_sessions_objd hash table in the ust_app object.
- */
- struct lttng_ht_node_ulong ust_objd_node;
- /* Starts with 'ust'; no leading slash. */
- char path[PATH_MAX];
- /* UID/GID of the application owning the session */
- struct lttng_credentials real_credentials;
- /* Effective UID and GID. Same as the tracing session. */
- struct lttng_credentials effective_credentials;
- struct cds_list_head teardown_node;
- /*
- * Once at least *one* session is created onto the application, the
- * corresponding consumer is set so we can use it on unregistration.
- */
- struct consumer_output *consumer;
- enum lttng_buffer_type buffer_type;
- /* ABI of the session. Same value as the application. */
- uint32_t bits_per_long;
- /* For delayed reclaim */
- struct rcu_head rcu_head;
- /* If the channel's streams have to be outputed or not. */
- unsigned int output_traces;
- unsigned int live_timer_interval; /* usec */
-
- /* Metadata channel attributes. */
- struct lttng_ust_ctl_consumer_channel_attr metadata_attr;
-
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
-};
-
-/*
- * Registered traceable applications. Libust registers to the session daemon
- * and a linked list is kept of all running traceable app.
- */
-struct ust_app {
- int sock;
- pthread_mutex_t sock_lock; /* Protects sock protocol. */
-
- int notify_sock;
- pid_t pid;
- pid_t ppid;
- uid_t uid; /* User ID that owns the apps */
- gid_t gid; /* Group ID that owns the apps */
-
- /* App ABI */
- uint32_t bits_per_long;
- uint32_t uint8_t_alignment;
- uint32_t uint16_t_alignment;
- uint32_t uint32_t_alignment;
- uint32_t uint64_t_alignment;
- uint32_t long_alignment;
- int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
-
- int compatible; /* If the lttng-ust tracer version does not match the
- supported version of the session daemon, this flag is
- set to 0 (NOT compatible) else 1. */
- struct lttng_ust_abi_tracer_version version;
- uint32_t v_major; /* Version major number */
- uint32_t v_minor; /* Version minor number */
- /* Extra for the NULL byte. */
- char name[UST_APP_PROCNAME_LEN + 1];
- /* Type of buffer this application uses. */
- enum lttng_buffer_type buffer_type;
- struct lttng_ht *sessions;
- struct lttng_ht_node_ulong pid_n;
- struct lttng_ht_node_ulong sock_n;
- struct lttng_ht_node_ulong notify_sock_n;
- /*
- * This is a list of ust app session that, once the app is going into
- * teardown mode, in the RCU call, each node in this list is removed and
- * deleted.
- *
- * Element of the list are added when an application unregisters after each
- * ht_del of ust_app_session associated to this app. This list is NOT used
- * when a session is destroyed.
- */
- struct cds_list_head teardown_head;
- /*
- * Hash table containing ust_app_channel indexed by channel objd.
- */
- struct lttng_ht *ust_objd;
- /*
- * Hash table containing ust_app_session indexed by objd.
- */
- struct lttng_ht *ust_sessions_objd;
-
- /*
- * If this application is of the agent domain and this is non negative then
- * a lookup MUST be done to acquire a read side reference to the
- * corresponding agent app object. If the lookup fails, this should be set
- * to a negative value indicating that the agent application is gone.
- */
- int agent_app_sock;
- /*
- * Time at which the app is registred.
- * Used for path creation
- */
- time_t registration_time;
- /*
- * Event notifier
- */
- struct {
- /*
- * Handle to the lttng_ust object representing the event
- * notifier group.
- */
- struct lttng_ust_abi_object_data *object;
- struct lttng_pipe *event_pipe;
- struct lttng_ust_abi_object_data *counter;
- struct lttng_ust_abi_object_data **counter_cpu;
- int nr_counter_cpu;
- } event_notifier_group;
- /*
- * Hashtable indexing the application's event notifier rule's
- * (ust_app_event_notifier_rule) by their token's value.
- */
- struct lttng_ht *token_to_event_notifier_rule_ht;
-};
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int ust_app_register(struct ust_register_msg *msg, int sock);
-int ust_app_register_done(struct ust_app *app);
-int ust_app_version(struct ust_app *app);
-void ust_app_unregister(int sock);
-int ust_app_start_trace_all(struct ltt_ust_session *usess);
-int ust_app_stop_trace_all(struct ltt_ust_session *usess);
-int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
-int ust_app_list_events(struct lttng_event **events);
-int ust_app_list_event_fields(struct lttng_event_field **fields);
-int ust_app_create_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan);
-int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan);
-int ust_app_enable_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_disable_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
-int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
-void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
-void ust_app_global_update_all(struct ltt_ust_session *usess);
-void ust_app_global_update_event_notifier_rules(struct ust_app *app);
-void ust_app_global_update_all_event_notifier_rules(void);
-
-void ust_app_clean_list(void);
-int ust_app_ht_alloc(void);
-struct ust_app *ust_app_find_by_pid(pid_t pid);
-struct ust_app_stream *ust_app_alloc_stream(void);
-int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
-int ust_app_recv_notify(int sock);
-void ust_app_add(struct ust_app *app);
-struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
-void ust_app_notify_sock_unregister(int sock);
-ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
- struct consumer_socket *socket, int send_zero_data);
-void ust_app_destroy(struct ust_app *app);
-enum lttng_error_code ust_app_snapshot_record(
- const struct ltt_ust_session *usess,
- const struct consumer_output *output,
- uint64_t nb_packets_per_stream);
-uint64_t ust_app_get_size_one_more_packet_per_stream(
- const struct ltt_ust_session *usess, uint64_t cur_nr_packets);
-struct ust_app *ust_app_find_by_sock(int sock);
-int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
- struct cds_list_head *buffer_reg_uid_list,
- struct consumer_output *consumer, uint64_t uchan_id,
- int overwrite, uint64_t *discarded, uint64_t *lost);
-int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan,
- struct consumer_output *consumer,
- int overwrite, uint64_t *discarded, uint64_t *lost);
-int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
-enum lttng_error_code ust_app_rotate_session(struct ltt_session *session);
-enum lttng_error_code ust_app_create_channel_subdirectories(
- const struct ltt_ust_session *session);
-int ust_app_release_object(struct ust_app *app,
- struct lttng_ust_abi_object_data *data);
-enum lttng_error_code ust_app_clear_session(struct ltt_session *session);
-enum lttng_error_code ust_app_open_packets(struct ltt_session *session);
-
-int ust_app_setup_event_notifier_group(struct ust_app *app);
-
-static inline
-int ust_app_supported(void)
-{
- return 1;
-}
-
-bool ust_app_supports_notifiers(const struct ust_app *app);
-bool ust_app_supports_counters(const struct ust_app *app);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-int ust_app_destroy_trace_all(
- struct ltt_ust_session *usess __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_start_trace(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ust_app *app __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_start_trace_all(
- struct ltt_ust_session *usess __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_stop_trace_all(
- struct ltt_ust_session *usess __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_list_events(
- struct lttng_event **events __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int ust_app_list_event_fields(
- struct lttng_event_field **fields __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int ust_app_register(
- struct ust_register_msg *msg __attribute__((unused)),
- int sock __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int ust_app_register_done(struct ust_app *app __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int ust_app_version(struct ust_app *app __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void ust_app_unregister(int sock __attribute__((unused)))
-{
-}
-
-static inline
-void ust_app_clean_list(void)
-{
-}
-
-static inline
-struct ust_app_list *ust_app_get_list(void)
-{
- return NULL;
-}
-
-static inline
-struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-int ust_app_ht_alloc(void)
-{
- return 0;
-}
-
-static inline
-void ust_app_global_update(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ust_app *app __attribute__((unused)))
-{}
-
-static inline
-void ust_app_global_update_event_notifier_rules(
- struct ust_app *app __attribute__((unused)))
-{}
-
-static inline
-void ust_app_global_update_all_event_notifier_rules(void)
-{}
-
-static inline
-int ust_app_setup_event_notifier_group(
- struct ust_app *app __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_disable_channel_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_enable_channel_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_create_event_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct ltt_ust_event *uevent __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_disable_event_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct ltt_ust_event *uevent __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_enable_event_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct ltt_ust_event *uevent __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_add_ctx_channel_glb(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct ltt_ust_context *uctx __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_enable_event_pid(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct ltt_ust_event *uevent __attribute__((unused)),
- pid_t pid __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_recv_registration(
- int sock __attribute__((unused)),
- struct ust_register_msg *msg __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_recv_notify(int sock __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-struct ust_app *ust_app_create(
- struct ust_register_msg *msg __attribute__((unused)),
- int sock __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-void ust_app_add(struct ust_app *app __attribute__((unused)))
-{
-}
-
-static inline
-void ust_app_notify_sock_unregister(int sock __attribute__((unused)))
-{
-}
-
-static inline
-ssize_t ust_app_push_metadata(
- struct ust_registry_session *registry __attribute__((unused)),
- struct consumer_socket *socket __attribute__((unused)),
- int send_zero_data __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-void ust_app_destroy(struct ust_app *app __attribute__((unused)))
-{
- return;
-}
-
-static inline
-enum lttng_error_code ust_app_snapshot_record(
- struct ltt_ust_session *usess __attribute__((unused)),
- const struct consumer_output *output __attribute__((unused)),
- uint64_t max_stream_size __attribute__((unused)))
-{
- return LTTNG_ERR_UNK;
-}
-
-static inline
-unsigned int ust_app_get_nb_stream(
- struct ltt_ust_session *usess __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-void ust_app_update_event_notifier_error_count(
- struct lttng_trigger *lttng_trigger __attribute__((unused)))
-{
- return;
-}
-
-static inline
-int ust_app_supported(void)
-{
- return 0;
-}
-
-static inline
-bool ust_app_supports_notifiers(
- const struct ust_app *app __attribute__((unused)))
-{
- return false;
-}
-
-static inline
-bool ust_app_supports_counters(
- const struct ust_app *app __attribute__((unused)))
-{
- return false;
-}
-
-static inline
-struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-uint64_t ust_app_get_size_one_more_packet_per_stream(
- const struct ltt_ust_session *usess __attribute__((unused)),
- uint64_t cur_nr_packets __attribute__((unused))) {
- return 0;
-}
-
-static inline
-int ust_app_uid_get_channel_runtime_stats(
- uint64_t ust_session_id __attribute__((unused)),
- struct cds_list_head *buffer_reg_uid_list __attribute__((unused)),
- struct consumer_output *consumer __attribute__((unused)),
- int overwrite __attribute__((unused)),
- uint64_t uchan_id __attribute__((unused)),
- uint64_t *discarded __attribute__((unused)),
- uint64_t *lost __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_pid_get_channel_runtime_stats(
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ltt_ust_channel *uchan __attribute__((unused)),
- struct consumer_output *consumer __attribute__((unused)),
- int overwrite __attribute__((unused)),
- uint64_t *discarded __attribute__((unused)),
- uint64_t *lost __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_app_regenerate_statedump_all(
- struct ltt_ust_session *usess __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-enum lttng_error_code ust_app_rotate_session(
- struct ltt_session *session __attribute__((unused)))
-{
- return LTTNG_ERR_UNK;
-}
-
-static inline
-enum lttng_error_code ust_app_create_channel_subdirectories(
- const struct ltt_ust_session *session __attribute__((unused)))
-{
- return LTTNG_ERR_UNK;
-}
-
-static inline
-int ust_app_release_object(struct ust_app *app __attribute__((unused)),
- struct lttng_ust_abi_object_data *data __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-enum lttng_error_code ust_app_clear_session(
- struct ltt_session *session __attribute__((unused)))
-{
- return LTTNG_ERR_UNK;
-}
-
-static inline
-enum lttng_error_code ust_app_open_packets(
- struct ltt_session *session __attribute__((unused)))
-{
- return LTTNG_ERR_UNK;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTT_UST_APP_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_UST_APP_H
+#define _LTT_UST_APP_H
+
+#include <stdint.h>
+
+#include <common/index-allocator.hpp>
+#include <common/uuid.hpp>
+
+#include "trace-ust.hpp"
+#include "ust-registry.hpp"
+#include "session.hpp"
+
+#define UST_APP_EVENT_LIST_SIZE 32
+
+/* Process name (short). */
+#define UST_APP_PROCNAME_LEN 16
+
+struct lttng_bytecode;
+struct lttng_ust_filter_bytecode;
+
+extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
+
+/*
+ * Object used to close the notify socket in a call_rcu(). Since the
+ * application might not be found, we need an independant object containing the
+ * notify socket fd.
+ */
+struct ust_app_notify_sock_obj {
+ int fd;
+ struct rcu_head head;
+};
+
+struct ust_app_ht_key {
+ const char *name;
+ const struct lttng_bytecode *filter;
+ enum lttng_ust_abi_loglevel_type loglevel_type;
+ const struct lttng_event_exclusion *exclusion;
+};
+
+/*
+ * Application registration data structure.
+ */
+struct ust_register_msg {
+ enum lttng_ust_ctl_socket_type type;
+ uint32_t major;
+ uint32_t minor;
+ uint32_t abi_major;
+ uint32_t abi_minor;
+ pid_t pid;
+ pid_t ppid;
+ uid_t uid;
+ gid_t gid;
+ uint32_t bits_per_long;
+ uint32_t uint8_t_alignment;
+ uint32_t uint16_t_alignment;
+ uint32_t uint32_t_alignment;
+ uint32_t uint64_t_alignment;
+ uint32_t long_alignment;
+ int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
+ char name[LTTNG_UST_ABI_PROCNAME_LEN];
+};
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * PID using the pid_n node and pid value of an ust_app.
+ */
+extern struct lttng_ht *ust_app_ht;
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * socket using the sock_n node and sock value of an ust_app.
+ *
+ * The 'sock' in question here is the 'command' socket.
+ */
+extern struct lttng_ht *ust_app_ht_by_sock;
+
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * socket using the notify_sock_n node and notify_sock value of an ust_app.
+ */
+extern struct lttng_ht *ust_app_ht_by_notify_sock;
+
+/* Stream list containing ust_app_stream. */
+struct ust_app_stream_list {
+ unsigned int count;
+ struct cds_list_head head;
+};
+
+struct ust_app_ctx {
+ int handle;
+ struct lttng_ust_context_attr ctx;
+ struct lttng_ust_abi_object_data *obj;
+ struct lttng_ht_node_ulong node;
+ struct cds_list_head list;
+};
+
+struct ust_app_event {
+ int enabled;
+ int handle;
+ struct lttng_ust_abi_object_data *obj;
+ struct lttng_ust_abi_event attr;
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ht_node_str node;
+ struct lttng_bytecode *filter;
+ struct lttng_event_exclusion *exclusion;
+};
+
+struct ust_app_event_notifier_rule {
+ int enabled;
+ uint64_t error_counter_index;
+ int handle;
+ struct lttng_ust_abi_object_data *obj;
+ /* Holds a strong reference. */
+ struct lttng_trigger *trigger;
+ /* Unique ID returned by the tracer to identify this event notifier. */
+ uint64_t token;
+ struct lttng_ht_node_u64 node;
+ /* The trigger object owns the filter. */
+ const struct lttng_bytecode *filter;
+ /* Owned by this. */
+ struct lttng_event_exclusion *exclusion;
+ /* For delayed reclaim. */
+ struct rcu_head rcu_head;
+};
+
+struct ust_app_stream {
+ int handle;
+ char pathname[PATH_MAX];
+ /* Format is %s_%d respectively channel name and CPU number. */
+ char name[DEFAULT_STREAM_NAME_LEN];
+ struct lttng_ust_abi_object_data *obj;
+ /* Using a list of streams to keep order. */
+ struct cds_list_head list;
+};
+
+struct ust_app_channel {
+ int enabled;
+ int handle;
+ /* Channel and streams were sent to the UST tracer. */
+ int is_sent;
+ /*
+ * Unique key used to identify the channel on the consumer side.
+ * 0 is a reserved 'invalid' value used to indicate that the consumer
+ * does not know about this channel (i.e. an error occurred).
+ */
+ uint64_t key;
+ /* Id of the tracing channel set on creation. */
+ uint64_t tracing_channel_id;
+ /* Number of stream that this channel is expected to receive. */
+ unsigned int expected_stream_count;
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ust_abi_object_data *obj;
+ struct lttng_ust_ctl_consumer_channel_attr attr;
+ struct ust_app_stream_list streams;
+ /* Session pointer that owns this object. */
+ struct ust_app_session *session;
+ /*
+ * Contexts are kept in a hash table for fast lookup and in an ordered list
+ * so we are able to enable them on the tracer side in the same order the
+ * user added them.
+ */
+ struct lttng_ht *ctx;
+ struct cds_list_head ctx_list;
+
+ struct lttng_ht *events;
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ uint64_t monitor_timer_interval;
+ /*
+ * Node indexed by channel name in the channels' hash table of a session.
+ */
+ struct lttng_ht_node_str node;
+ /*
+ * Node indexed by UST channel object descriptor (handle). Stored in the
+ * ust_objd hash table in the ust_app object.
+ */
+ struct lttng_ht_node_ulong ust_objd_node;
+ /* For delayed reclaim */
+ struct rcu_head rcu_head;
+};
+
+struct ust_app_session {
+ /*
+ * Lock protecting this session's ust app interaction. Held
+ * across command send/recv to/from app. Never nests within the
+ * session registry lock.
+ */
+ pthread_mutex_t lock;
+
+ int enabled;
+ /* started: has the session been in started state at any time ? */
+ int started; /* allows detection of start vs restart. */
+ int handle; /* used has unique identifier for app session */
+
+ bool deleted; /* Session deleted flag. Check with lock held. */
+
+ /*
+ * Tracing session ID. Multiple ust app session can have the same tracing
+ * session id making this value NOT unique to the object.
+ */
+ uint64_t tracing_id;
+ uint64_t id; /* Unique session identifier */
+ struct lttng_ht *channels; /* Registered channels */
+ struct lttng_ht_node_u64 node;
+ /*
+ * Node indexed by UST session object descriptor (handle). Stored in the
+ * ust_sessions_objd hash table in the ust_app object.
+ */
+ struct lttng_ht_node_ulong ust_objd_node;
+ /* Starts with 'ust'; no leading slash. */
+ char path[PATH_MAX];
+ /* UID/GID of the application owning the session */
+ struct lttng_credentials real_credentials;
+ /* Effective UID and GID. Same as the tracing session. */
+ struct lttng_credentials effective_credentials;
+ struct cds_list_head teardown_node;
+ /*
+ * Once at least *one* session is created onto the application, the
+ * corresponding consumer is set so we can use it on unregistration.
+ */
+ struct consumer_output *consumer;
+ enum lttng_buffer_type buffer_type;
+ /* ABI of the session. Same value as the application. */
+ uint32_t bits_per_long;
+ /* For delayed reclaim */
+ struct rcu_head rcu_head;
+ /* If the channel's streams have to be outputed or not. */
+ unsigned int output_traces;
+ unsigned int live_timer_interval; /* usec */
+
+ /* Metadata channel attributes. */
+ struct lttng_ust_ctl_consumer_channel_attr metadata_attr;
+
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+};
+
+/*
+ * Registered traceable applications. Libust registers to the session daemon
+ * and a linked list is kept of all running traceable app.
+ */
+struct ust_app {
+ int sock;
+ pthread_mutex_t sock_lock; /* Protects sock protocol. */
+
+ int notify_sock;
+ pid_t pid;
+ pid_t ppid;
+ uid_t uid; /* User ID that owns the apps */
+ gid_t gid; /* Group ID that owns the apps */
+
+ /* App ABI */
+ uint32_t bits_per_long;
+ uint32_t uint8_t_alignment;
+ uint32_t uint16_t_alignment;
+ uint32_t uint32_t_alignment;
+ uint32_t uint64_t_alignment;
+ uint32_t long_alignment;
+ int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
+
+ int compatible; /* If the lttng-ust tracer version does not match the
+ supported version of the session daemon, this flag is
+ set to 0 (NOT compatible) else 1. */
+ struct lttng_ust_abi_tracer_version version;
+ uint32_t v_major; /* Version major number */
+ uint32_t v_minor; /* Version minor number */
+ /* Extra for the NULL byte. */
+ char name[UST_APP_PROCNAME_LEN + 1];
+ /* Type of buffer this application uses. */
+ enum lttng_buffer_type buffer_type;
+ struct lttng_ht *sessions;
+ struct lttng_ht_node_ulong pid_n;
+ struct lttng_ht_node_ulong sock_n;
+ struct lttng_ht_node_ulong notify_sock_n;
+ /*
+ * This is a list of ust app session that, once the app is going into
+ * teardown mode, in the RCU call, each node in this list is removed and
+ * deleted.
+ *
+ * Element of the list are added when an application unregisters after each
+ * ht_del of ust_app_session associated to this app. This list is NOT used
+ * when a session is destroyed.
+ */
+ struct cds_list_head teardown_head;
+ /*
+ * Hash table containing ust_app_channel indexed by channel objd.
+ */
+ struct lttng_ht *ust_objd;
+ /*
+ * Hash table containing ust_app_session indexed by objd.
+ */
+ struct lttng_ht *ust_sessions_objd;
+
+ /*
+ * If this application is of the agent domain and this is non negative then
+ * a lookup MUST be done to acquire a read side reference to the
+ * corresponding agent app object. If the lookup fails, this should be set
+ * to a negative value indicating that the agent application is gone.
+ */
+ int agent_app_sock;
+ /*
+ * Time at which the app is registred.
+ * Used for path creation
+ */
+ time_t registration_time;
+ /*
+ * Event notifier
+ */
+ struct {
+ /*
+ * Handle to the lttng_ust object representing the event
+ * notifier group.
+ */
+ struct lttng_ust_abi_object_data *object;
+ struct lttng_pipe *event_pipe;
+ struct lttng_ust_abi_object_data *counter;
+ struct lttng_ust_abi_object_data **counter_cpu;
+ int nr_counter_cpu;
+ } event_notifier_group;
+ /*
+ * Hashtable indexing the application's event notifier rule's
+ * (ust_app_event_notifier_rule) by their token's value.
+ */
+ struct lttng_ht *token_to_event_notifier_rule_ht;
+};
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int ust_app_register(struct ust_register_msg *msg, int sock);
+int ust_app_register_done(struct ust_app *app);
+int ust_app_version(struct ust_app *app);
+void ust_app_unregister(int sock);
+int ust_app_start_trace_all(struct ltt_ust_session *usess);
+int ust_app_stop_trace_all(struct ltt_ust_session *usess);
+int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
+int ust_app_list_events(struct lttng_event **events);
+int ust_app_list_event_fields(struct lttng_event_field **fields);
+int ust_app_create_event_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
+int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
+int ust_app_enable_event_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_disable_event_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
+int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
+void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
+void ust_app_global_update_all(struct ltt_ust_session *usess);
+void ust_app_global_update_event_notifier_rules(struct ust_app *app);
+void ust_app_global_update_all_event_notifier_rules(void);
+
+void ust_app_clean_list(void);
+int ust_app_ht_alloc(void);
+struct ust_app *ust_app_find_by_pid(pid_t pid);
+struct ust_app_stream *ust_app_alloc_stream(void);
+int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
+int ust_app_recv_notify(int sock);
+void ust_app_add(struct ust_app *app);
+struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
+void ust_app_notify_sock_unregister(int sock);
+ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
+ struct consumer_socket *socket, int send_zero_data);
+void ust_app_destroy(struct ust_app *app);
+enum lttng_error_code ust_app_snapshot_record(
+ const struct ltt_ust_session *usess,
+ const struct consumer_output *output,
+ uint64_t nb_packets_per_stream);
+uint64_t ust_app_get_size_one_more_packet_per_stream(
+ const struct ltt_ust_session *usess, uint64_t cur_nr_packets);
+struct ust_app *ust_app_find_by_sock(int sock);
+int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
+ struct cds_list_head *buffer_reg_uid_list,
+ struct consumer_output *consumer, uint64_t uchan_id,
+ int overwrite, uint64_t *discarded, uint64_t *lost);
+int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan,
+ struct consumer_output *consumer,
+ int overwrite, uint64_t *discarded, uint64_t *lost);
+int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
+enum lttng_error_code ust_app_rotate_session(struct ltt_session *session);
+enum lttng_error_code ust_app_create_channel_subdirectories(
+ const struct ltt_ust_session *session);
+int ust_app_release_object(struct ust_app *app,
+ struct lttng_ust_abi_object_data *data);
+enum lttng_error_code ust_app_clear_session(struct ltt_session *session);
+enum lttng_error_code ust_app_open_packets(struct ltt_session *session);
+
+int ust_app_setup_event_notifier_group(struct ust_app *app);
+
+static inline
+int ust_app_supported(void)
+{
+ return 1;
+}
+
+bool ust_app_supports_notifiers(const struct ust_app *app);
+bool ust_app_supports_counters(const struct ust_app *app);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+int ust_app_destroy_trace_all(
+ struct ltt_ust_session *usess __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_start_trace(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ust_app *app __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_start_trace_all(
+ struct ltt_ust_session *usess __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_stop_trace_all(
+ struct ltt_ust_session *usess __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_list_events(
+ struct lttng_event **events __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int ust_app_list_event_fields(
+ struct lttng_event_field **fields __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int ust_app_register(
+ struct ust_register_msg *msg __attribute__((unused)),
+ int sock __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int ust_app_register_done(struct ust_app *app __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int ust_app_version(struct ust_app *app __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void ust_app_unregister(int sock __attribute__((unused)))
+{
+}
+
+static inline
+void ust_app_clean_list(void)
+{
+}
+
+static inline
+struct ust_app_list *ust_app_get_list(void)
+{
+ return NULL;
+}
+
+static inline
+struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+int ust_app_ht_alloc(void)
+{
+ return 0;
+}
+
+static inline
+void ust_app_global_update(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ust_app *app __attribute__((unused)))
+{}
+
+static inline
+void ust_app_global_update_event_notifier_rules(
+ struct ust_app *app __attribute__((unused)))
+{}
+
+static inline
+void ust_app_global_update_all_event_notifier_rules(void)
+{}
+
+static inline
+int ust_app_setup_event_notifier_group(
+ struct ust_app *app __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_disable_channel_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_enable_channel_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_create_event_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct ltt_ust_event *uevent __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_disable_event_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct ltt_ust_event *uevent __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_enable_event_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct ltt_ust_event *uevent __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_add_ctx_channel_glb(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct ltt_ust_context *uctx __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_enable_event_pid(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct ltt_ust_event *uevent __attribute__((unused)),
+ pid_t pid __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_recv_registration(
+ int sock __attribute__((unused)),
+ struct ust_register_msg *msg __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_recv_notify(int sock __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+struct ust_app *ust_app_create(
+ struct ust_register_msg *msg __attribute__((unused)),
+ int sock __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+void ust_app_add(struct ust_app *app __attribute__((unused)))
+{
+}
+
+static inline
+void ust_app_notify_sock_unregister(int sock __attribute__((unused)))
+{
+}
+
+static inline
+ssize_t ust_app_push_metadata(
+ struct ust_registry_session *registry __attribute__((unused)),
+ struct consumer_socket *socket __attribute__((unused)),
+ int send_zero_data __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+void ust_app_destroy(struct ust_app *app __attribute__((unused)))
+{
+ return;
+}
+
+static inline
+enum lttng_error_code ust_app_snapshot_record(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ const struct consumer_output *output __attribute__((unused)),
+ uint64_t max_stream_size __attribute__((unused)))
+{
+ return LTTNG_ERR_UNK;
+}
+
+static inline
+unsigned int ust_app_get_nb_stream(
+ struct ltt_ust_session *usess __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+void ust_app_update_event_notifier_error_count(
+ struct lttng_trigger *lttng_trigger __attribute__((unused)))
+{
+ return;
+}
+
+static inline
+int ust_app_supported(void)
+{
+ return 0;
+}
+
+static inline
+bool ust_app_supports_notifiers(
+ const struct ust_app *app __attribute__((unused)))
+{
+ return false;
+}
+
+static inline
+bool ust_app_supports_counters(
+ const struct ust_app *app __attribute__((unused)))
+{
+ return false;
+}
+
+static inline
+struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+uint64_t ust_app_get_size_one_more_packet_per_stream(
+ const struct ltt_ust_session *usess __attribute__((unused)),
+ uint64_t cur_nr_packets __attribute__((unused))) {
+ return 0;
+}
+
+static inline
+int ust_app_uid_get_channel_runtime_stats(
+ uint64_t ust_session_id __attribute__((unused)),
+ struct cds_list_head *buffer_reg_uid_list __attribute__((unused)),
+ struct consumer_output *consumer __attribute__((unused)),
+ int overwrite __attribute__((unused)),
+ uint64_t uchan_id __attribute__((unused)),
+ uint64_t *discarded __attribute__((unused)),
+ uint64_t *lost __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_pid_get_channel_runtime_stats(
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ltt_ust_channel *uchan __attribute__((unused)),
+ struct consumer_output *consumer __attribute__((unused)),
+ int overwrite __attribute__((unused)),
+ uint64_t *discarded __attribute__((unused)),
+ uint64_t *lost __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_app_regenerate_statedump_all(
+ struct ltt_ust_session *usess __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+enum lttng_error_code ust_app_rotate_session(
+ struct ltt_session *session __attribute__((unused)))
+{
+ return LTTNG_ERR_UNK;
+}
+
+static inline
+enum lttng_error_code ust_app_create_channel_subdirectories(
+ const struct ltt_ust_session *session __attribute__((unused)))
+{
+ return LTTNG_ERR_UNK;
+}
+
+static inline
+int ust_app_release_object(struct ust_app *app __attribute__((unused)),
+ struct lttng_ust_abi_object_data *data __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+enum lttng_error_code ust_app_clear_session(
+ struct ltt_session *session __attribute__((unused)))
+{
+ return LTTNG_ERR_UNK;
+}
+
+static inline
+enum lttng_error_code ust_app_open_packets(
+ struct ltt_session *session __attribute__((unused)))
+{
+ return LTTNG_ERR_UNK;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTT_UST_APP_H */
+++ /dev/null
-/*
- * Copyright (C) 2010 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _UST_CLOCK_H
-#define _UST_CLOCK_H
-
-#include <common/compat/time.h>
-#include <sys/time.h>
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <urcu/system.h>
-#include <urcu/arch.h>
-#include <lttng/ust-clock.h>
-
-#include <common/uuid.h>
-
-static __inline__
-uint64_t trace_clock_read64(void)
-{
- uint64_t clock_value = 0;
- lttng_ust_clock_read64_function read64_cb;
-
- if (lttng_ust_trace_clock_get_read64_cb(&read64_cb)) {
- goto end;
- }
-
- clock_value = read64_cb();
-end:
- return clock_value;
-}
-
-static __inline__
-uint64_t trace_clock_freq(void)
-{
- uint64_t frequency = 0;
- lttng_ust_clock_freq_function get_freq_cb;
-
- if (lttng_ust_trace_clock_get_freq_cb(&get_freq_cb)) {
- goto end;
- }
-
- frequency = get_freq_cb();
-end:
- return frequency;
-}
-
-static __inline__
-int trace_clock_uuid(char *uuid)
-{
- int ret;
- lttng_ust_clock_uuid_function get_uuid_cb;
-
- if (lttng_ust_trace_clock_get_uuid_cb(&get_uuid_cb)) {
- ret = -EINVAL;
- goto end;
- }
-
- ret = get_uuid_cb(uuid);
-end:
- return ret;
-
-}
-
-static __inline__
-const char *trace_clock_name(void)
-{
- const char *name;
- lttng_ust_clock_name_function get_name_cb;
-
- if (lttng_ust_trace_clock_get_name_cb(&get_name_cb)) {
- name = NULL;
- goto end;
- }
-
- name = get_name_cb();
-end:
- return name;
-}
-
-static __inline__
-const char *trace_clock_description(void)
-{
- const char *description;
- lttng_ust_clock_description_function get_description_cb;
-
- if (lttng_ust_trace_clock_get_description_cb(&get_description_cb)) {
- description = NULL;
- goto end;
- }
-
- description = get_description_cb();
-end:
- return description;
-}
-
-#endif /* _UST_CLOCK_H */
--- /dev/null
+/*
+ * Copyright (C) 2010 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _UST_CLOCK_H
+#define _UST_CLOCK_H
+
+#include <common/compat/time.hpp>
+#include <sys/time.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <urcu/system.h>
+#include <urcu/arch.h>
+#include <lttng/ust-clock.h>
+
+#include <common/uuid.hpp>
+
+static __inline__
+uint64_t trace_clock_read64(void)
+{
+ uint64_t clock_value = 0;
+ lttng_ust_clock_read64_function read64_cb;
+
+ if (lttng_ust_trace_clock_get_read64_cb(&read64_cb)) {
+ goto end;
+ }
+
+ clock_value = read64_cb();
+end:
+ return clock_value;
+}
+
+static __inline__
+uint64_t trace_clock_freq(void)
+{
+ uint64_t frequency = 0;
+ lttng_ust_clock_freq_function get_freq_cb;
+
+ if (lttng_ust_trace_clock_get_freq_cb(&get_freq_cb)) {
+ goto end;
+ }
+
+ frequency = get_freq_cb();
+end:
+ return frequency;
+}
+
+static __inline__
+int trace_clock_uuid(char *uuid)
+{
+ int ret;
+ lttng_ust_clock_uuid_function get_uuid_cb;
+
+ if (lttng_ust_trace_clock_get_uuid_cb(&get_uuid_cb)) {
+ ret = -EINVAL;
+ goto end;
+ }
+
+ ret = get_uuid_cb(uuid);
+end:
+ return ret;
+
+}
+
+static __inline__
+const char *trace_clock_name(void)
+{
+ const char *name;
+ lttng_ust_clock_name_function get_name_cb;
+
+ if (lttng_ust_trace_clock_get_name_cb(&get_name_cb)) {
+ name = NULL;
+ goto end;
+ }
+
+ name = get_name_cb();
+end:
+ return name;
+}
+
+static __inline__
+const char *trace_clock_description(void)
+{
+ const char *description;
+ lttng_ust_clock_description_function get_description_cb;
+
+ if (lttng_ust_trace_clock_get_description_cb(&get_description_cb)) {
+ description = NULL;
+ goto end;
+ }
+
+ description = get_description_cb();
+end:
+ return description;
+}
+
+#endif /* _UST_CLOCK_H */
#include <unistd.h>
#include <inttypes.h>
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/consumer/consumer.h>
-#include <common/defaults.h>
-
-#include "consumer.h"
-#include "health-sessiond.h"
-#include "ust-consumer.h"
-#include "lttng-ust-error.h"
-#include "buffer-registry.h"
-#include "session.h"
-#include "lttng-sessiond.h"
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/defaults.hpp>
+
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-error.hpp"
+#include "buffer-registry.hpp"
+#include "session.hpp"
+#include "lttng-sessiond.hpp"
/*
* Send a single channel to the consumer using command ASK_CHANNEL_CREATION.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _UST_CONSUMER_H
-#define _UST_CONSUMER_H
-
-#include "consumer.h"
-#include "ust-app.h"
-#include <stdint.h>
-#include <common/trace-chunk.h>
-
-int ust_consumer_ask_channel(struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan,
- struct consumer_output *consumer,
- struct consumer_socket *socket,
- struct ust_registry_session *registry,
- struct lttng_trace_chunk *trace_chunk);
-
-int ust_consumer_get_channel(struct consumer_socket *socket,
- struct ust_app_channel *ua_chan);
-
-int ust_consumer_destroy_channel(struct consumer_socket *socket,
- struct ust_app_channel *ua_chan);
-
-int ust_consumer_send_stream_to_ust(struct ust_app *app,
- struct ust_app_channel *channel, struct ust_app_stream *stream);
-
-int ust_consumer_send_channel_to_ust(struct ust_app *app,
- struct ust_app_session *ua_sess, struct ust_app_channel *channel);
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-int ust_consumer_metadata_request(struct consumer_socket *sock);
-#else
-static inline
-int ust_consumer_metadata_request(
- struct consumer_socket *sock __attribute__((unused)))
-{
- return -ENOSYS;
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _UST_CONSUMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _UST_CONSUMER_H
+#define _UST_CONSUMER_H
+
+#include "consumer.hpp"
+#include "ust-app.hpp"
+#include <stdint.h>
+#include <common/trace-chunk.hpp>
+
+int ust_consumer_ask_channel(struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan,
+ struct consumer_output *consumer,
+ struct consumer_socket *socket,
+ struct ust_registry_session *registry,
+ struct lttng_trace_chunk *trace_chunk);
+
+int ust_consumer_get_channel(struct consumer_socket *socket,
+ struct ust_app_channel *ua_chan);
+
+int ust_consumer_destroy_channel(struct consumer_socket *socket,
+ struct ust_app_channel *ua_chan);
+
+int ust_consumer_send_stream_to_ust(struct ust_app *app,
+ struct ust_app_channel *channel, struct ust_app_stream *stream);
+
+int ust_consumer_send_channel_to_ust(struct ust_app *app,
+ struct ust_app_session *ua_sess, struct ust_app_channel *channel);
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+int ust_consumer_metadata_request(struct consumer_socket *sock);
+#else
+static inline
+int ust_consumer_metadata_request(
+ struct consumer_socket *sock __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _UST_CONSUMER_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_CTL_INTERNAL_H
-#define LTTNG_UST_CTL_INTERNAL_H
-
-#include <sys/types.h>
-#include <limits.h>
-
-#include "lttng-ust-abi.h"
-
-#ifndef LTTNG_UST_UUID_LEN
-#define LTTNG_UST_UUID_LEN 16
-#endif
-
-/* Default unix socket path */
-#define LTTNG_UST_SOCK_FILENAME \
- "lttng-ust-sock-" \
- __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
-
-/*
- * Shared memory files path are automatically related to shm root, e.g.
- * /dev/shm under linux.
- */
-#define LTTNG_UST_WAIT_FILENAME \
- "lttng-ust-wait-" \
- __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
-
-struct lttng_ust_shm_handle;
-struct lttng_ust_lib_ring_buffer;
-
-struct lttng_ust_ctl_consumer_channel_attr {
- enum lttng_ust_abi_chan_type type;
- uint64_t subbuf_size; /* bytes */
- uint64_t num_subbuf; /* power of 2 */
- int overwrite; /* 1: overwrite, 0: discard */
- unsigned int switch_timer_interval; /* usec */
- unsigned int read_timer_interval; /* usec */
- enum lttng_ust_abi_output output; /* splice, mmap */
- uint32_t chan_id; /* channel ID */
- unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
- int64_t blocking_timeout; /* Blocking timeout (usec) */
-} LTTNG_PACKED;
-
-/*
- * API used by sessiond.
- */
-
-struct lttng_ust_context_attr {
- enum lttng_ust_abi_context_type ctx;
- union {
- struct lttng_ust_abi_perf_counter_ctx perf_counter;
- struct {
- char *provider_name;
- char *ctx_name;
- } app_ctx;
- } u;
-};
-
-/*
- * Error values: all the following functions return:
- * >= 0: Success (LTTNG_UST_OK)
- * < 0: error code.
- */
-int lttng_ust_ctl_register_done(int sock);
-int lttng_ust_ctl_create_session(int sock);
-int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev,
- struct lttng_ust_abi_object_data *channel_data,
- struct lttng_ust_abi_object_data **event_data);
-int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
- struct lttng_ust_abi_object_data *obj_data,
- struct lttng_ust_abi_object_data **context_data);
-int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
- struct lttng_ust_abi_object_data *obj_data);
-int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
- struct lttng_ust_abi_object_data *obj_data);
-int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
- struct lttng_ust_abi_object_data *obj_data);
-
-int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object);
-int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object);
-int lttng_ust_ctl_start_session(int sock, int handle);
-int lttng_ust_ctl_stop_session(int sock, int handle);
-
-/*
- * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It
- * establishes the connection with the application by providing a file
- * descriptor of the pipe to be used by the application when a event notifier
- * of that group is fired. It returns a handle to be used when creating event
- * notifier in that group.
- */
-int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd,
- struct lttng_ust_abi_object_data **event_notifier_group);
-
-/*
- * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier
- * group giving a event notifier description and a event notifier group handle.
- * It returns a event notifier handle to be used when enabling the event
- * notifier, attaching filter, attaching exclusion, and disabling the event
- * notifier.
- */
-int lttng_ust_ctl_create_event_notifier(int sock,
- struct lttng_ust_abi_event_notifier *event_notifier,
- struct lttng_ust_abi_object_data *event_notifier_group,
- struct lttng_ust_abi_object_data **event_notifier_data);
-
-/*
- * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative
- * error value.
- */
-int lttng_ust_ctl_tracepoint_list(int sock);
-
-/*
- * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list
- * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle,
- struct lttng_ust_abi_tracepoint_iter *iter);
-
-/*
- * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle,
- * or negative error value.
- */
-int lttng_ust_ctl_tracepoint_field_list(int sock);
-
-/*
- * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field
- * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
- struct lttng_ust_abi_field_iter *iter);
-
-int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
-int lttng_ust_ctl_wait_quiescent(int sock);
-
-int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
-
-int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
-
-/* Release object created by members of this API. */
-int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
-/* Release handle returned by create session. */
-int lttng_ust_ctl_release_handle(int sock, int handle);
-
-int lttng_ust_ctl_recv_channel_from_consumer(int sock,
- struct lttng_ust_abi_object_data **channel_data);
-int lttng_ust_ctl_recv_stream_from_consumer(int sock,
- struct lttng_ust_abi_object_data **stream_data);
-int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle,
- struct lttng_ust_abi_object_data *channel_data);
-int lttng_ust_ctl_send_stream_to_ust(int sock,
- struct lttng_ust_abi_object_data *channel_data,
- struct lttng_ust_abi_object_data *stream_data);
-
-/*
- * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if
- * it succeeds (returns 0). It must be released using
- * lttng_ust_ctl_release_object() and then freed with free().
- */
-int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
- struct lttng_ust_abi_object_data *src);
-
-/*
- * API used by consumer.
- */
-
-struct lttng_ust_ctl_consumer_channel;
-struct lttng_ust_ctl_consumer_stream;
-struct lttng_ust_ctl_consumer_channel_attr;
-
-int lttng_ust_ctl_get_nr_stream_per_channel(void);
-
-struct lttng_ust_ctl_consumer_channel *
- lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr,
- const int *stream_fds, int nr_stream_fds);
-/*
- * Each stream created needs to be destroyed before calling
- * lttng_ust_ctl_destroy_channel().
- */
-void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan);
-
-int lttng_ust_ctl_send_channel_to_sessiond(int sock,
- struct lttng_ust_ctl_consumer_channel *channel);
-int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
-
-int lttng_ust_ctl_write_metadata_to_channel(
- struct lttng_ust_ctl_consumer_channel *channel,
- const char *metadata_str, /* NOT null-terminated */
- size_t len); /* metadata length */
-ssize_t lttng_ust_ctl_write_one_packet_to_channel(
- struct lttng_ust_ctl_consumer_channel *channel,
- const char *metadata_str, /* NOT null-terminated */
- size_t len); /* metadata length */
-
-/*
- * Send a NULL stream to finish iteration over all streams of a given
- * channel.
- */
-int lttng_ust_ctl_send_stream_to_sessiond(int sock,
- struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* Create/destroy stream buffers for read */
-struct lttng_ust_ctl_consumer_stream *
- lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel,
- int cpu);
-void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* For mmap mode, readable without "get" operation */
-int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *len);
-int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *len);
-
-/*
- * For mmap mode, operate on the current packet (between get/put or
- * get_next/put_next).
- */
-void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *off);
-int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *len);
-int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *len);
-int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* snapshot */
-
-int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream);
-int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *pos);
-int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *pos);
-int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
- unsigned long *pos);
-int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
-
-int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
- int producer_active);
-int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
-
-/* index */
-
-/*
- * Getters which need to be used on the current packet (between get/put
- * or get_next/put_next.
- */
-
-int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *timestamp_begin);
-int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *timestamp_end);
-int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *events_discarded);
-int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *content_size);
-int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *packet_size);
-int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *seq);
-
-/*
- * Getter returning state invariant for the stream, which can be used
- * without "get" operation.
- */
-
-int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *stream_id);
-int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *id);
-
-/*
- * Getter returning the current timestamp as perceived from the
- * tracer.
- */
-int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream,
- uint64_t *ts);
-
-/* returns whether UST has perf counters support. */
-int lttng_ust_ctl_has_perf_counters(void);
-
-/* Regenerate the statedump. */
-int lttng_ust_ctl_regenerate_statedump(int sock, int handle);
-
-/* event registry management */
-
-enum lttng_ust_ctl_socket_type {
- LTTNG_UST_CTL_SOCKET_CMD = 0,
- LTTNG_UST_CTL_SOCKET_NOTIFY = 1,
-};
-
-enum lttng_ust_ctl_notify_cmd {
- LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0,
- LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1,
- LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2,
-};
-
-enum lttng_ust_ctl_channel_header {
- LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN = 0,
- LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT = 1,
- LTTNG_UST_CTL_CHANNEL_HEADER_LARGE = 2,
-};
-
-/* event type structures */
-
-enum lttng_ust_ctl_abstract_types {
- lttng_ust_ctl_atype_integer,
- lttng_ust_ctl_atype_enum, /* legacy */
- lttng_ust_ctl_atype_array, /* legacy */
- lttng_ust_ctl_atype_sequence, /* legacy */
- lttng_ust_ctl_atype_string,
- lttng_ust_ctl_atype_float,
- lttng_ust_ctl_atype_variant, /* legacy */
- lttng_ust_ctl_atype_struct, /* legacy */
- lttng_ust_ctl_atype_enum_nestable,
- lttng_ust_ctl_atype_array_nestable,
- lttng_ust_ctl_atype_sequence_nestable,
- lttng_ust_ctl_atype_struct_nestable,
- lttng_ust_ctl_atype_variant_nestable,
- NR_LTTNG_UST_CTL_ABSTRACT_TYPES,
-};
-
-enum lttng_ust_ctl_string_encodings {
- lttng_ust_ctl_encode_none = 0,
- lttng_ust_ctl_encode_UTF8 = 1,
- lttng_ust_ctl_encode_ASCII = 2,
- NR_LTTNG_UST_CTL_STRING_ENCODINGS,
-};
-
-#define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24
-struct lttng_ust_ctl_integer_type {
- uint32_t size; /* in bits */
- uint32_t signedness;
- uint32_t reverse_byte_order;
- uint32_t base; /* 2, 8, 10, 16, for pretty print */
- int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
- uint16_t alignment; /* in bits */
- char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING 24
-struct lttng_ust_ctl_float_type {
- uint32_t exp_dig; /* exponent digits, in bits */
- uint32_t mant_dig; /* mantissa digits, in bits */
- uint32_t reverse_byte_order;
- uint16_t alignment; /* in bits */
- char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING 15
-struct lttng_ust_ctl_enum_value {
- uint64_t value;
- uint8_t signedness;
- char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_ctl_ust_enum_entry_options {
- LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
-};
-
-#define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING 32
-struct lttng_ust_ctl_enum_entry {
- struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */
- char string[LTTNG_UST_ABI_SYM_NAME_LEN];
- union {
- struct {
- uint32_t options;
- } LTTNG_PACKED extra;
- char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING];
- } u;
-} LTTNG_PACKED;
-
-/* legacy */
-#define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING 296
-union _lttng_ust_ctl_basic_type {
- struct lttng_ust_ctl_integer_type integer;
- struct {
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ust_ctl_integer_type container_type;
- uint64_t id; /* enum ID in sessiond. */
- } enumeration;
- struct {
- int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
- } string;
- struct lttng_ust_ctl_float_type _float;
- char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING];
-} LTTNG_PACKED;
-
-/* legacy */
-struct lttng_ust_ctl_basic_type {
- enum lttng_ust_ctl_abstract_types atype;
- union {
- union _lttng_ust_ctl_basic_type basic;
- } u;
-} LTTNG_PACKED;
-
-/*
- * Padding is derived from largest member: u.legacy.sequence which
- * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING.
- */
-#define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING)
-struct lttng_ust_ctl_type {
- enum lttng_ust_ctl_abstract_types atype;
- union {
- struct lttng_ust_ctl_integer_type integer;
- struct lttng_ust_ctl_float_type _float;
- struct {
- int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
- } string;
- struct {
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- uint64_t id; /* enum ID in sessiond. */
- /* container_type follows after this struct lttng_ust_ctl_field. */
- } enum_nestable;
- struct {
- uint32_t length; /* num. elems. */
- uint32_t alignment;
- /* elem_type follows after this struct lttng_ust_ctl_field. */
- } array_nestable;
- struct {
- char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- uint32_t alignment; /* Alignment before elements. */
- /* elem_type follows after the length_type. */
- } sequence_nestable;
- struct {
- uint32_t nr_fields;
- uint32_t alignment;
- /* Followed by nr_fields struct lttng_ust_ctl_field. */
- } struct_nestable;
- struct {
- uint32_t nr_choices;
- char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- uint32_t alignment;
- /* Followed by nr_choices struct lttng_ust_ctl_field. */
- } variant_nestable;
-
- /* Legacy ABI */
- union {
- union _lttng_ust_ctl_basic_type basic;
- struct {
- struct lttng_ust_ctl_basic_type elem_type;
- uint32_t length; /* num. elems. */
- } array;
- struct {
- struct lttng_ust_ctl_basic_type length_type;
- struct lttng_ust_ctl_basic_type elem_type;
- } sequence;
- struct {
- uint32_t nr_fields;
- /* Followed by nr_fields struct lttng_ust_ctl_field. */
- } _struct;
- struct {
- uint32_t nr_choices;
- char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
- /* Followed by nr_choices struct lttng_ust_ctl_field. */
- } variant;
- } legacy;
- char padding[LTTNG_UST_CTL_UST_TYPE_PADDING];
- } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CTL_UST_FIELD_PADDING 28
-struct lttng_ust_ctl_field {
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ust_ctl_type type;
- char padding[LTTNG_UST_CTL_UST_FIELD_PADDING];
-} LTTNG_PACKED;
-
-/*
- * Returns 0 on success, negative error value on error.
- * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
- * the output fields are not populated.
- */
-int lttng_ust_ctl_recv_reg_msg(int sock,
- enum lttng_ust_ctl_socket_type *type,
- uint32_t *major,
- uint32_t *minor,
- uint32_t *pid,
- uint32_t *ppid,
- uint32_t *uid,
- uint32_t *gid,
- uint32_t *bits_per_long,
- uint32_t *uint8_t_alignment,
- uint32_t *uint16_t_alignment,
- uint32_t *uint32_t_alignment,
- uint32_t *uint64_t_alignment,
- uint32_t *long_alignment,
- int *byte_order,
- char *name); /* size LTTNG_UST_ABI_PROCNAME_LEN */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- * Receive the notification command. The "notify_cmd" can then be used
- * by the caller to find out which lttng_ust_ctl_recv_* function should be
- * called to receive the notification, and which lttng_ust_ctl_reply_* is
- * appropriate.
- */
-int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_event(int sock,
- int *session_objd, /* session descriptor (output) */
- int *channel_objd, /* channel descriptor (output) */
- char *event_name, /*
- * event name (output,
- * size LTTNG_UST_ABI_SYM_NAME_LEN)
- */
- int *loglevel,
- char **signature, /*
- * event signature
- * (output, dynamically
- * allocated, must be free(3)'d
- * by the caller if function
- * returns success.)
- */
- size_t *nr_fields,
- struct lttng_ust_ctl_field **fields,
- char **model_emf_uri);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_event(int sock,
- uint32_t id, /* event id (input) */
- int ret_code); /* return code. 0 ok, negative error */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_enum(int sock,
- int *session_objd,
- char *enum_name,
- struct lttng_ust_ctl_enum_entry **entries,
- size_t *nr_entries);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_enum(int sock,
- uint64_t id, /* enum id (input) */
- int ret_code);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int lttng_ust_ctl_recv_register_channel(int sock,
- int *session_objd, /* session descriptor (output) */
- int *channel_objd, /* channel descriptor (output) */
- size_t *nr_fields, /* context fields */
- struct lttng_ust_ctl_field **fields);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int lttng_ust_ctl_reply_register_channel(int sock,
- uint32_t chan_id,
- enum lttng_ust_ctl_channel_header header_type,
- int ret_code); /* return code. 0 ok, negative error */
-
-/*
- * Counter API.
- */
-
-enum lttng_ust_ctl_counter_bitness {
- LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0,
- LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1,
-};
-
-enum lttng_ust_ctl_counter_arithmetic {
- LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR = 0,
- LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION = 1,
-};
-
-/* Used as alloc flags. */
-enum lttng_ust_ctl_counter_alloc {
- LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
- LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
-};
-
-struct lttng_ust_ctl_daemon_counter;
-
-int lttng_ust_ctl_get_nr_cpu_per_counter(void);
-
-struct lttng_ust_ctl_counter_dimension {
- uint64_t size;
- uint64_t underflow_index;
- uint64_t overflow_index;
- uint8_t has_underflow;
- uint8_t has_overflow;
-};
-
-struct lttng_ust_ctl_daemon_counter *
- lttng_ust_ctl_create_counter(size_t nr_dimensions,
- const struct lttng_ust_ctl_counter_dimension *dimensions,
- int64_t global_sum_step,
- int global_counter_fd,
- int nr_counter_cpu_fds,
- const int *counter_cpu_fds,
- enum lttng_ust_ctl_counter_bitness bitness,
- enum lttng_ust_ctl_counter_arithmetic arithmetic,
- uint32_t alloc_flags,
- bool coalesce_hits);
-
-int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter,
- struct lttng_ust_abi_object_data **counter_data);
-
-int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter,
- struct lttng_ust_abi_object_data **counter_global_data);
-int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu,
- struct lttng_ust_abi_object_data **counter_cpu_data);
-
-/*
- * Each counter data and counter cpu data created need to be destroyed
- * before calling lttng_ust_ctl_destroy_counter().
- */
-void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter);
-
-int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle,
- struct lttng_ust_abi_object_data *counter_data);
-int lttng_ust_ctl_send_counter_global_data_to_ust(int sock,
- struct lttng_ust_abi_object_data *counter_data,
- struct lttng_ust_abi_object_data *counter_global_data);
-int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock,
- struct lttng_ust_abi_object_data *counter_data,
- struct lttng_ust_abi_object_data *counter_cpu_data);
-
-int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter,
- const size_t *dimension_indexes,
- int cpu, int64_t *value,
- bool *overflow, bool *underflow);
-int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter,
- const size_t *dimension_indexes,
- int64_t *value,
- bool *overflow, bool *underflow);
-int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
- const size_t *dimension_indexes);
-
-void lttng_ust_ctl_sigbus_handle(void *addr);
-
-#endif /* LTTNG_UST_CTL_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_CTL_INTERNAL_H
+#define LTTNG_UST_CTL_INTERNAL_H
+
+#include <sys/types.h>
+#include <limits.h>
+
+#include "lttng-ust-abi.hpp"
+
+#ifndef LTTNG_UST_UUID_LEN
+#define LTTNG_UST_UUID_LEN 16
+#endif
+
+/* Default unix socket path */
+#define LTTNG_UST_SOCK_FILENAME \
+ "lttng-ust-sock-" \
+ __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
+
+/*
+ * Shared memory files path are automatically related to shm root, e.g.
+ * /dev/shm under linux.
+ */
+#define LTTNG_UST_WAIT_FILENAME \
+ "lttng-ust-wait-" \
+ __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE)
+
+struct lttng_ust_shm_handle;
+struct lttng_ust_lib_ring_buffer;
+
+struct lttng_ust_ctl_consumer_channel_attr {
+ enum lttng_ust_abi_chan_type type;
+ uint64_t subbuf_size; /* bytes */
+ uint64_t num_subbuf; /* power of 2 */
+ int overwrite; /* 1: overwrite, 0: discard */
+ unsigned int switch_timer_interval; /* usec */
+ unsigned int read_timer_interval; /* usec */
+ enum lttng_ust_abi_output output; /* splice, mmap */
+ uint32_t chan_id; /* channel ID */
+ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
+ int64_t blocking_timeout; /* Blocking timeout (usec) */
+} LTTNG_PACKED;
+
+/*
+ * API used by sessiond.
+ */
+
+struct lttng_ust_context_attr {
+ enum lttng_ust_abi_context_type ctx;
+ union {
+ struct lttng_ust_abi_perf_counter_ctx perf_counter;
+ struct {
+ char *provider_name;
+ char *ctx_name;
+ } app_ctx;
+ } u;
+};
+
+/*
+ * Error values: all the following functions return:
+ * >= 0: Success (LTTNG_UST_OK)
+ * < 0: error code.
+ */
+int lttng_ust_ctl_register_done(int sock);
+int lttng_ust_ctl_create_session(int sock);
+int lttng_ust_ctl_create_event(int sock, struct lttng_ust_abi_event *ev,
+ struct lttng_ust_abi_object_data *channel_data,
+ struct lttng_ust_abi_object_data **event_data);
+int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
+ struct lttng_ust_abi_object_data *obj_data,
+ struct lttng_ust_abi_object_data **context_data);
+int lttng_ust_ctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
+ struct lttng_ust_abi_object_data *obj_data);
+int lttng_ust_ctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
+ struct lttng_ust_abi_object_data *obj_data);
+int lttng_ust_ctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
+ struct lttng_ust_abi_object_data *obj_data);
+
+int lttng_ust_ctl_enable(int sock, struct lttng_ust_abi_object_data *object);
+int lttng_ust_ctl_disable(int sock, struct lttng_ust_abi_object_data *object);
+int lttng_ust_ctl_start_session(int sock, int handle);
+int lttng_ust_ctl_stop_session(int sock, int handle);
+
+/*
+ * lttng_ust_ctl_create_event notifier_group creates a event notifier group. It
+ * establishes the connection with the application by providing a file
+ * descriptor of the pipe to be used by the application when a event notifier
+ * of that group is fired. It returns a handle to be used when creating event
+ * notifier in that group.
+ */
+int lttng_ust_ctl_create_event_notifier_group(int sock, int pipe_fd,
+ struct lttng_ust_abi_object_data **event_notifier_group);
+
+/*
+ * lttng_ust_ctl_create_event notifier creates a event notifier in a event notifier
+ * group giving a event notifier description and a event notifier group handle.
+ * It returns a event notifier handle to be used when enabling the event
+ * notifier, attaching filter, attaching exclusion, and disabling the event
+ * notifier.
+ */
+int lttng_ust_ctl_create_event_notifier(int sock,
+ struct lttng_ust_abi_event_notifier *event_notifier,
+ struct lttng_ust_abi_object_data *event_notifier_group,
+ struct lttng_ust_abi_object_data **event_notifier_data);
+
+/*
+ * lttng_ust_ctl_tracepoint_list returns a tracepoint list handle, or negative
+ * error value.
+ */
+int lttng_ust_ctl_tracepoint_list(int sock);
+
+/*
+ * lttng_ust_ctl_tracepoint_list_get is used to iterate on the tp list
+ * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int lttng_ust_ctl_tracepoint_list_get(int sock, int tp_list_handle,
+ struct lttng_ust_abi_tracepoint_iter *iter);
+
+/*
+ * lttng_ust_ctl_tracepoint_field_list returns a tracepoint field list handle,
+ * or negative error value.
+ */
+int lttng_ust_ctl_tracepoint_field_list(int sock);
+
+/*
+ * lttng_ust_ctl_tracepoint_field_list_get is used to iterate on the tp field
+ * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int lttng_ust_ctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
+ struct lttng_ust_abi_field_iter *iter);
+
+int lttng_ust_ctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
+int lttng_ust_ctl_wait_quiescent(int sock);
+
+int lttng_ust_ctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
+
+int lttng_ust_ctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
+
+/* Release object created by members of this API. */
+int lttng_ust_ctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
+/* Release handle returned by create session. */
+int lttng_ust_ctl_release_handle(int sock, int handle);
+
+int lttng_ust_ctl_recv_channel_from_consumer(int sock,
+ struct lttng_ust_abi_object_data **channel_data);
+int lttng_ust_ctl_recv_stream_from_consumer(int sock,
+ struct lttng_ust_abi_object_data **stream_data);
+int lttng_ust_ctl_send_channel_to_ust(int sock, int session_handle,
+ struct lttng_ust_abi_object_data *channel_data);
+int lttng_ust_ctl_send_stream_to_ust(int sock,
+ struct lttng_ust_abi_object_data *channel_data,
+ struct lttng_ust_abi_object_data *stream_data);
+
+/*
+ * lttng_ust_ctl_duplicate_ust_object_data allocated a new object in "dest" if
+ * it succeeds (returns 0). It must be released using
+ * lttng_ust_ctl_release_object() and then freed with free().
+ */
+int lttng_ust_ctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
+ struct lttng_ust_abi_object_data *src);
+
+/*
+ * API used by consumer.
+ */
+
+struct lttng_ust_ctl_consumer_channel;
+struct lttng_ust_ctl_consumer_stream;
+struct lttng_ust_ctl_consumer_channel_attr;
+
+int lttng_ust_ctl_get_nr_stream_per_channel(void);
+
+struct lttng_ust_ctl_consumer_channel *
+ lttng_ust_ctl_create_channel(struct lttng_ust_ctl_consumer_channel_attr *attr,
+ const int *stream_fds, int nr_stream_fds);
+/*
+ * Each stream created needs to be destroyed before calling
+ * lttng_ust_ctl_destroy_channel().
+ */
+void lttng_ust_ctl_destroy_channel(struct lttng_ust_ctl_consumer_channel *chan);
+
+int lttng_ust_ctl_send_channel_to_sessiond(int sock,
+ struct lttng_ust_ctl_consumer_channel *channel);
+int lttng_ust_ctl_channel_close_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_close_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_get_wait_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+int lttng_ust_ctl_channel_get_wakeup_fd(struct lttng_ust_ctl_consumer_channel *consumer_chan);
+
+int lttng_ust_ctl_write_metadata_to_channel(
+ struct lttng_ust_ctl_consumer_channel *channel,
+ const char *metadata_str, /* NOT null-terminated */
+ size_t len); /* metadata length */
+ssize_t lttng_ust_ctl_write_one_packet_to_channel(
+ struct lttng_ust_ctl_consumer_channel *channel,
+ const char *metadata_str, /* NOT null-terminated */
+ size_t len); /* metadata length */
+
+/*
+ * Send a NULL stream to finish iteration over all streams of a given
+ * channel.
+ */
+int lttng_ust_ctl_send_stream_to_sessiond(int sock,
+ struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_close_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_close_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_get_wait_fd(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_stream_get_wakeup_fd(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* Create/destroy stream buffers for read */
+struct lttng_ust_ctl_consumer_stream *
+ lttng_ust_ctl_create_stream(struct lttng_ust_ctl_consumer_channel *channel,
+ int cpu);
+void lttng_ust_ctl_destroy_stream(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* For mmap mode, readable without "get" operation */
+int lttng_ust_ctl_get_mmap_len(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *len);
+int lttng_ust_ctl_get_max_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *len);
+
+/*
+ * For mmap mode, operate on the current packet (between get/put or
+ * get_next/put_next).
+ */
+void *lttng_ust_ctl_get_mmap_base(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_get_mmap_read_offset(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *off);
+int lttng_ust_ctl_get_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *len);
+int lttng_ust_ctl_get_padded_subbuf_size(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *len);
+int lttng_ust_ctl_get_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_put_next_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* snapshot */
+
+int lttng_ust_ctl_snapshot(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_snapshot_sample_positions(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_snapshot_get_consumed(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_ust_ctl_snapshot_get_produced(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
+
+int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
+ int producer_active);
+int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
+
+/* index */
+
+/*
+ * Getters which need to be used on the current packet (between get/put
+ * or get_next/put_next.
+ */
+
+int lttng_ust_ctl_get_timestamp_begin(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *timestamp_begin);
+int lttng_ust_ctl_get_timestamp_end(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *timestamp_end);
+int lttng_ust_ctl_get_events_discarded(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *events_discarded);
+int lttng_ust_ctl_get_content_size(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *content_size);
+int lttng_ust_ctl_get_packet_size(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *packet_size);
+int lttng_ust_ctl_get_sequence_number(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *seq);
+
+/*
+ * Getter returning state invariant for the stream, which can be used
+ * without "get" operation.
+ */
+
+int lttng_ust_ctl_get_stream_id(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *stream_id);
+int lttng_ust_ctl_get_instance_id(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *id);
+
+/*
+ * Getter returning the current timestamp as perceived from the
+ * tracer.
+ */
+int lttng_ust_ctl_get_current_timestamp(struct lttng_ust_ctl_consumer_stream *stream,
+ uint64_t *ts);
+
+/* returns whether UST has perf counters support. */
+int lttng_ust_ctl_has_perf_counters(void);
+
+/* Regenerate the statedump. */
+int lttng_ust_ctl_regenerate_statedump(int sock, int handle);
+
+/* event registry management */
+
+enum lttng_ust_ctl_socket_type {
+ LTTNG_UST_CTL_SOCKET_CMD = 0,
+ LTTNG_UST_CTL_SOCKET_NOTIFY = 1,
+};
+
+enum lttng_ust_ctl_notify_cmd {
+ LTTNG_UST_CTL_NOTIFY_CMD_EVENT = 0,
+ LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL = 1,
+ LTTNG_UST_CTL_NOTIFY_CMD_ENUM = 2,
+};
+
+enum lttng_ust_ctl_channel_header {
+ LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN = 0,
+ LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT = 1,
+ LTTNG_UST_CTL_CHANNEL_HEADER_LARGE = 2,
+};
+
+/* event type structures */
+
+enum lttng_ust_ctl_abstract_types {
+ lttng_ust_ctl_atype_integer,
+ lttng_ust_ctl_atype_enum, /* legacy */
+ lttng_ust_ctl_atype_array, /* legacy */
+ lttng_ust_ctl_atype_sequence, /* legacy */
+ lttng_ust_ctl_atype_string,
+ lttng_ust_ctl_atype_float,
+ lttng_ust_ctl_atype_variant, /* legacy */
+ lttng_ust_ctl_atype_struct, /* legacy */
+ lttng_ust_ctl_atype_enum_nestable,
+ lttng_ust_ctl_atype_array_nestable,
+ lttng_ust_ctl_atype_sequence_nestable,
+ lttng_ust_ctl_atype_struct_nestable,
+ lttng_ust_ctl_atype_variant_nestable,
+ NR_LTTNG_UST_CTL_ABSTRACT_TYPES,
+};
+
+enum lttng_ust_ctl_string_encodings {
+ lttng_ust_ctl_encode_none = 0,
+ lttng_ust_ctl_encode_UTF8 = 1,
+ lttng_ust_ctl_encode_ASCII = 2,
+ NR_LTTNG_UST_CTL_STRING_ENCODINGS,
+};
+
+#define LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING 24
+struct lttng_ust_ctl_integer_type {
+ uint32_t size; /* in bits */
+ uint32_t signedness;
+ uint32_t reverse_byte_order;
+ uint32_t base; /* 2, 8, 10, 16, for pretty print */
+ int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
+ uint16_t alignment; /* in bits */
+ char padding[LTTNG_UST_CTL_UST_INTEGER_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING 24
+struct lttng_ust_ctl_float_type {
+ uint32_t exp_dig; /* exponent digits, in bits */
+ uint32_t mant_dig; /* mantissa digits, in bits */
+ uint32_t reverse_byte_order;
+ uint16_t alignment; /* in bits */
+ char padding[LTTNG_UST_CTL_UST_FLOAT_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING 15
+struct lttng_ust_ctl_enum_value {
+ uint64_t value;
+ uint8_t signedness;
+ char padding[LTTNG_UST_CTL_UST_ENUM_VALUE_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_ctl_ust_enum_entry_options {
+ LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
+};
+
+#define LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING 32
+struct lttng_ust_ctl_enum_entry {
+ struct lttng_ust_ctl_enum_value start, end; /* start and end are inclusive */
+ char string[LTTNG_UST_ABI_SYM_NAME_LEN];
+ union {
+ struct {
+ uint32_t options;
+ } LTTNG_PACKED extra;
+ char padding[LTTNG_UST_CTL_UST_ENUM_ENTRY_PADDING];
+ } u;
+} LTTNG_PACKED;
+
+/* legacy */
+#define LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING 296
+union _lttng_ust_ctl_basic_type {
+ struct lttng_ust_ctl_integer_type integer;
+ struct {
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ust_ctl_integer_type container_type;
+ uint64_t id; /* enum ID in sessiond. */
+ } enumeration;
+ struct {
+ int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
+ } string;
+ struct lttng_ust_ctl_float_type _float;
+ char padding[LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING];
+} LTTNG_PACKED;
+
+/* legacy */
+struct lttng_ust_ctl_basic_type {
+ enum lttng_ust_ctl_abstract_types atype;
+ union {
+ union _lttng_ust_ctl_basic_type basic;
+ } u;
+} LTTNG_PACKED;
+
+/*
+ * Padding is derived from largest member: u.legacy.sequence which
+ * contains two basic types, each with LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING.
+ */
+#define LTTNG_UST_CTL_UST_TYPE_PADDING (2 * LTTNG_UST_CTL_UST_BASIC_TYPE_PADDING)
+struct lttng_ust_ctl_type {
+ enum lttng_ust_ctl_abstract_types atype;
+ union {
+ struct lttng_ust_ctl_integer_type integer;
+ struct lttng_ust_ctl_float_type _float;
+ struct {
+ int32_t encoding; /* enum lttng_ust_ctl_string_encodings */
+ } string;
+ struct {
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ uint64_t id; /* enum ID in sessiond. */
+ /* container_type follows after this struct lttng_ust_ctl_field. */
+ } enum_nestable;
+ struct {
+ uint32_t length; /* num. elems. */
+ uint32_t alignment;
+ /* elem_type follows after this struct lttng_ust_ctl_field. */
+ } array_nestable;
+ struct {
+ char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ uint32_t alignment; /* Alignment before elements. */
+ /* elem_type follows after the length_type. */
+ } sequence_nestable;
+ struct {
+ uint32_t nr_fields;
+ uint32_t alignment;
+ /* Followed by nr_fields struct lttng_ust_ctl_field. */
+ } struct_nestable;
+ struct {
+ uint32_t nr_choices;
+ char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ uint32_t alignment;
+ /* Followed by nr_choices struct lttng_ust_ctl_field. */
+ } variant_nestable;
+
+ /* Legacy ABI */
+ union {
+ union _lttng_ust_ctl_basic_type basic;
+ struct {
+ struct lttng_ust_ctl_basic_type elem_type;
+ uint32_t length; /* num. elems. */
+ } array;
+ struct {
+ struct lttng_ust_ctl_basic_type length_type;
+ struct lttng_ust_ctl_basic_type elem_type;
+ } sequence;
+ struct {
+ uint32_t nr_fields;
+ /* Followed by nr_fields struct lttng_ust_ctl_field. */
+ } _struct;
+ struct {
+ uint32_t nr_choices;
+ char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ /* Followed by nr_choices struct lttng_ust_ctl_field. */
+ } variant;
+ } legacy;
+ char padding[LTTNG_UST_CTL_UST_TYPE_PADDING];
+ } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CTL_UST_FIELD_PADDING 28
+struct lttng_ust_ctl_field {
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ust_ctl_type type;
+ char padding[LTTNG_UST_CTL_UST_FIELD_PADDING];
+} LTTNG_PACKED;
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
+ * the output fields are not populated.
+ */
+int lttng_ust_ctl_recv_reg_msg(int sock,
+ enum lttng_ust_ctl_socket_type *type,
+ uint32_t *major,
+ uint32_t *minor,
+ uint32_t *pid,
+ uint32_t *ppid,
+ uint32_t *uid,
+ uint32_t *gid,
+ uint32_t *bits_per_long,
+ uint32_t *uint8_t_alignment,
+ uint32_t *uint16_t_alignment,
+ uint32_t *uint32_t_alignment,
+ uint32_t *uint64_t_alignment,
+ uint32_t *long_alignment,
+ int *byte_order,
+ char *name); /* size LTTNG_UST_ABI_PROCNAME_LEN */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ * Receive the notification command. The "notify_cmd" can then be used
+ * by the caller to find out which lttng_ust_ctl_recv_* function should be
+ * called to receive the notification, and which lttng_ust_ctl_reply_* is
+ * appropriate.
+ */
+int lttng_ust_ctl_recv_notify(int sock, enum lttng_ust_ctl_notify_cmd *notify_cmd);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_event(int sock,
+ int *session_objd, /* session descriptor (output) */
+ int *channel_objd, /* channel descriptor (output) */
+ char *event_name, /*
+ * event name (output,
+ * size LTTNG_UST_ABI_SYM_NAME_LEN)
+ */
+ int *loglevel,
+ char **signature, /*
+ * event signature
+ * (output, dynamically
+ * allocated, must be free(3)'d
+ * by the caller if function
+ * returns success.)
+ */
+ size_t *nr_fields,
+ struct lttng_ust_ctl_field **fields,
+ char **model_emf_uri);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_event(int sock,
+ uint32_t id, /* event id (input) */
+ int ret_code); /* return code. 0 ok, negative error */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_enum(int sock,
+ int *session_objd,
+ char *enum_name,
+ struct lttng_ust_ctl_enum_entry **entries,
+ size_t *nr_entries);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_enum(int sock,
+ uint64_t id, /* enum id (input) */
+ int ret_code);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int lttng_ust_ctl_recv_register_channel(int sock,
+ int *session_objd, /* session descriptor (output) */
+ int *channel_objd, /* channel descriptor (output) */
+ size_t *nr_fields, /* context fields */
+ struct lttng_ust_ctl_field **fields);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int lttng_ust_ctl_reply_register_channel(int sock,
+ uint32_t chan_id,
+ enum lttng_ust_ctl_channel_header header_type,
+ int ret_code); /* return code. 0 ok, negative error */
+
+/*
+ * Counter API.
+ */
+
+enum lttng_ust_ctl_counter_bitness {
+ LTTNG_UST_CTL_COUNTER_BITNESS_32 = 0,
+ LTTNG_UST_CTL_COUNTER_BITNESS_64 = 1,
+};
+
+enum lttng_ust_ctl_counter_arithmetic {
+ LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR = 0,
+ LTTNG_UST_CTL_COUNTER_ARITHMETIC_SATURATION = 1,
+};
+
+/* Used as alloc flags. */
+enum lttng_ust_ctl_counter_alloc {
+ LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
+ LTTNG_UST_CTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
+};
+
+struct lttng_ust_ctl_daemon_counter;
+
+int lttng_ust_ctl_get_nr_cpu_per_counter(void);
+
+struct lttng_ust_ctl_counter_dimension {
+ uint64_t size;
+ uint64_t underflow_index;
+ uint64_t overflow_index;
+ uint8_t has_underflow;
+ uint8_t has_overflow;
+};
+
+struct lttng_ust_ctl_daemon_counter *
+ lttng_ust_ctl_create_counter(size_t nr_dimensions,
+ const struct lttng_ust_ctl_counter_dimension *dimensions,
+ int64_t global_sum_step,
+ int global_counter_fd,
+ int nr_counter_cpu_fds,
+ const int *counter_cpu_fds,
+ enum lttng_ust_ctl_counter_bitness bitness,
+ enum lttng_ust_ctl_counter_arithmetic arithmetic,
+ uint32_t alloc_flags,
+ bool coalesce_hits);
+
+int lttng_ust_ctl_create_counter_data(struct lttng_ust_ctl_daemon_counter *counter,
+ struct lttng_ust_abi_object_data **counter_data);
+
+int lttng_ust_ctl_create_counter_global_data(struct lttng_ust_ctl_daemon_counter *counter,
+ struct lttng_ust_abi_object_data **counter_global_data);
+int lttng_ust_ctl_create_counter_cpu_data(struct lttng_ust_ctl_daemon_counter *counter, int cpu,
+ struct lttng_ust_abi_object_data **counter_cpu_data);
+
+/*
+ * Each counter data and counter cpu data created need to be destroyed
+ * before calling lttng_ust_ctl_destroy_counter().
+ */
+void lttng_ust_ctl_destroy_counter(struct lttng_ust_ctl_daemon_counter *counter);
+
+int lttng_ust_ctl_send_counter_data_to_ust(int sock, int parent_handle,
+ struct lttng_ust_abi_object_data *counter_data);
+int lttng_ust_ctl_send_counter_global_data_to_ust(int sock,
+ struct lttng_ust_abi_object_data *counter_data,
+ struct lttng_ust_abi_object_data *counter_global_data);
+int lttng_ust_ctl_send_counter_cpu_data_to_ust(int sock,
+ struct lttng_ust_abi_object_data *counter_data,
+ struct lttng_ust_abi_object_data *counter_cpu_data);
+
+int lttng_ust_ctl_counter_read(struct lttng_ust_ctl_daemon_counter *counter,
+ const size_t *dimension_indexes,
+ int cpu, int64_t *value,
+ bool *overflow, bool *underflow);
+int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter,
+ const size_t *dimension_indexes,
+ int64_t *value,
+ bool *overflow, bool *underflow);
+int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
+ const size_t *dimension_indexes);
+
+void lttng_ust_ctl_sigbus_handle(void *addr);
+
+#endif /* LTTNG_UST_CTL_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTTNG_UST_ERROR_H
-#define _LTTNG_UST_ERROR_H
-
-/*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
- */
-
-#include <limits.h>
-#include <unistd.h>
-
-#include "lttng-ust-abi.h"
-
-/*
- * ustcomm error code.
- */
-enum lttng_ust_error_code {
- LTTNG_UST_OK = 0, /* Ok */
- LTTNG_UST_ERR = 1024, /* Unknown Error */
- LTTNG_UST_ERR_NOENT = 1025, /* No entry */
- LTTNG_UST_ERR_EXIST = 1026, /* Object exists */
- LTTNG_UST_ERR_INVAL = 1027, /* Invalid argument */
- LTTNG_UST_ERR_PERM = 1028, /* Permission denied */
- LTTNG_UST_ERR_NOSYS = 1029, /* Not implemented */
- LTTNG_UST_ERR_EXITING = 1030, /* Process is exiting */
-
- LTTNG_UST_ERR_INVAL_MAGIC = 1031, /* Invalid magic number */
- LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
- LTTNG_UST_ERR_UNSUP_MAJOR = 1033, /* Unsupported major version */
-
- /* MUST be last element */
- LTTNG_UST_ERR_NR, /* Last element */
-};
-
-/*
- * Return a human-readable error message for an lttng-ust error code.
- * code must be a positive value (or 0).
- */
-extern const char *lttng_ust_strerror(int code);
-
-#endif /* _LTTNG_UST_ERROR_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTTNG_UST_ERROR_H
+#define _LTTNG_UST_ERROR_H
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+
+#include "lttng-ust-abi.hpp"
+
+/*
+ * ustcomm error code.
+ */
+enum lttng_ust_error_code {
+ LTTNG_UST_OK = 0, /* Ok */
+ LTTNG_UST_ERR = 1024, /* Unknown Error */
+ LTTNG_UST_ERR_NOENT = 1025, /* No entry */
+ LTTNG_UST_ERR_EXIST = 1026, /* Object exists */
+ LTTNG_UST_ERR_INVAL = 1027, /* Invalid argument */
+ LTTNG_UST_ERR_PERM = 1028, /* Permission denied */
+ LTTNG_UST_ERR_NOSYS = 1029, /* Not implemented */
+ LTTNG_UST_ERR_EXITING = 1030, /* Process is exiting */
+
+ LTTNG_UST_ERR_INVAL_MAGIC = 1031, /* Invalid magic number */
+ LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
+ LTTNG_UST_ERR_UNSUP_MAJOR = 1033, /* Unsupported major version */
+
+ /* MUST be last element */
+ LTTNG_UST_ERR_NR, /* Last element */
+};
+
+/*
+ * Return a human-readable error message for an lttng-ust error code.
+ * code must be a positive value (or 0).
+ */
+extern const char *lttng_ust_strerror(int code);
+
+#endif /* _LTTNG_UST_ERROR_H */
#include <stdbool.h>
#include <string.h>
-#include "ust-field-utils.h"
+#include "ust-field-utils.hpp"
/*
* The lttng_ust_ctl_field is made of a combination of C basic types
+++ /dev/null
-/*
- * Copyright (C) 2018 Francis Deslauriers francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_FIELD_UTILS_H
-#define LTTNG_UST_FIELD_UTILS_H
-
-#include "lttng-ust-ctl.h"
-
-/*
- * Compare two UST fields.
- * Return 1 if both fields have identical definition, 0 otherwise.
- */
-int match_lttng_ust_ctl_field(const struct lttng_ust_ctl_field *first,
- const struct lttng_ust_ctl_field *second);
-
-/*
- * Compare two arrays of UST fields.
- * Return true if both arrays have identical field definitions, false otherwise.
- */
-bool match_lttng_ust_ctl_field_array(const struct lttng_ust_ctl_field *first,
- size_t nr_first,
- const struct lttng_ust_ctl_field *second,
- size_t nr_second);
-
-#endif /* LTTNG_UST_FIELD_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Francis Deslauriers francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_FIELD_UTILS_H
+#define LTTNG_UST_FIELD_UTILS_H
+
+#include "lttng-ust-ctl.hpp"
+
+/*
+ * Compare two UST fields.
+ * Return 1 if both fields have identical definition, 0 otherwise.
+ */
+int match_lttng_ust_ctl_field(const struct lttng_ust_ctl_field *first,
+ const struct lttng_ust_ctl_field *second);
+
+/*
+ * Compare two arrays of UST fields.
+ * Return true if both arrays have identical field definitions, false otherwise.
+ */
+bool match_lttng_ust_ctl_field_array(const struct lttng_ust_ctl_field *first,
+ size_t nr_first,
+ const struct lttng_ust_ctl_field *second,
+ size_t nr_second);
+
+#endif /* LTTNG_UST_FIELD_UTILS_H */
#include <limits.h>
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/time.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
-#include "ust-registry.h"
-#include "ust-clock.h"
-#include "ust-app.h"
+#include "ust-registry.hpp"
+#include "ust-clock.hpp"
+#include "ust-app.hpp"
#ifndef max_t
#define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b)))
#define _LGPL_SOURCE
#include <inttypes.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
#include <lttng/lttng.h>
-#include "ust-registry.h"
-#include "ust-app.h"
-#include "ust-field-utils.h"
-#include "utils.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-commands.h"
+#include "ust-registry.hpp"
+#include "ust-app.hpp"
+#include "ust-field-utils.hpp"
+#include "utils.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
/*
* Hash table match function for event in the registry.
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_REGISTRY_H
-#define LTTNG_UST_REGISTRY_H
-
-#include <pthread.h>
-#include <stdint.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/uuid.h>
-
-#include "lttng-ust-ctl.h"
-
-#define CTF_SPEC_MAJOR 1
-#define CTF_SPEC_MINOR 8
-
-struct ust_app;
-
-struct ust_registry_session {
- /*
- * With multiple writers and readers, use this lock to access
- * the registry. Can nest within the ust app session lock.
- * Also acts as a registry serialization lock. Used by registry
- * readers to serialize the registry information sent from the
- * sessiond to the consumerd.
- * The consumer socket lock nests within this lock.
- */
- pthread_mutex_t lock;
- /* Next channel ID available for a newly registered channel. */
- uint32_t next_channel_id;
- /* Once this value reaches UINT32_MAX, no more id can be allocated. */
- uint32_t used_channel_id;
- /* Next enumeration ID available. */
- uint64_t next_enum_id;
- /* Universal unique identifier used by the tracer. */
- unsigned char uuid[LTTNG_UUID_LEN];
-
- /* session ABI description */
-
- /* Size of long, in bits */
- unsigned int bits_per_long;
- /* Alignment, in bits */
- unsigned int uint8_t_alignment,
- uint16_t_alignment,
- uint32_t_alignment,
- uint64_t_alignment,
- long_alignment;
- /* endianness */
- int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
-
- /* Generated metadata. */
- char *metadata; /* NOT null-terminated ! Use memcpy. */
- size_t metadata_len, metadata_alloc_len;
- /* Length of bytes sent to the consumer. */
- size_t metadata_len_sent;
- /* Current version of the metadata. */
- uint64_t metadata_version;
-
- /*
- * Those fields are only used when a session is created with
- * the --shm-path option. In this case, the metadata is output
- * twice: once to the consumer, as ususal, but a second time
- * also in the shm path directly. This is done so that a copy
- * of the metadata that is as fresh as possible is available
- * on the event of a crash.
- *
- * root_shm_path contains the shm-path provided by the user, along with
- * the session's name and timestamp:
- * e.g. /tmp/my_shm/my_session-20180612-135822
- *
- * shm_path contains the full path of the memory buffers:
- * e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit
- *
- * metadata_path contains the full path to the metadata file that
- * is kept for the "crash buffer" extraction:
- * e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit/metadata
- *
- * Note that this is not the trace's final metadata file. It is
- * only meant to be used to read the contents of the ring buffers
- * in the event of a crash.
- *
- * metadata_fd is a file descriptor that points to the file at
- * 'metadata_path'.
- */
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
- char metadata_path[PATH_MAX];
- int metadata_fd; /* file-backed metadata FD */
-
- /*
- * Hash table containing channels sent by the UST tracer. MUST
- * be accessed with a RCU read side lock acquired.
- */
- struct lttng_ht *channels;
- /*
- * Unique key to identify the metadata on the consumer side.
- */
- uint64_t metadata_key;
- /*
- * Indicates if the metadata is closed on the consumer side. This is to
- * avoid double close of metadata when an application unregisters AND
- * deletes its sessions.
- */
- unsigned int metadata_closed;
-
- /* User and group owning the session. */
- uid_t uid;
- gid_t gid;
-
- /* Enumerations table. */
- struct lttng_ht *enums;
-
- /*
- * Copy of the tracer version when the first app is registered.
- * It is used if we need to regenerate the metadata.
- */
- uint32_t major;
- uint32_t minor;
-
- /* The id of the parent session */
- uint64_t tracing_id;
- uid_t tracing_uid;
-};
-
-struct ust_registry_channel {
- uint64_t key;
- uint64_t consumer_key;
- /* Id set when replying to a register channel. */
- uint32_t chan_id;
- enum lttng_ust_ctl_channel_header header_type;
-
- /*
- * Flag for this channel if the metadata was dumped once during
- * registration. 0 means no, 1 yes.
- */
- unsigned int metadata_dumped;
- /* Indicates if this channel registry has already been registered. */
- unsigned int register_done;
-
- /*
- * Hash table containing events sent by the UST tracer. MUST be accessed
- * with a RCU read side lock acquired.
- */
- struct lttng_ht *ht;
- /* Next event ID available for a newly registered event. */
- uint32_t next_event_id;
- /* Once this value reaches UINT32_MAX, no more id can be allocated. */
- uint32_t used_event_id;
- /*
- * Context fields of the registry. Context are per channel. Allocated by a
- * register channel notification from the UST tracer.
- */
- size_t nr_ctx_fields;
- struct lttng_ust_ctl_field *ctx_fields;
- struct lttng_ht_node_u64 node;
- /* For delayed reclaim */
- struct rcu_head rcu_head;
-};
-
-/*
- * Event registered from a UST tracer sent to the session daemon. This is
- * indexed and matched by <event_name/signature>.
- */
-struct ust_registry_event {
- int id;
- /* Both objd are set by the tracer. */
- int session_objd;
- int channel_objd;
- /* Name of the event returned by the tracer. */
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- char *signature;
- int loglevel_value;
- size_t nr_fields;
- struct lttng_ust_ctl_field *fields;
- char *model_emf_uri;
- /*
- * Flag for this channel if the metadata was dumped once during
- * registration. 0 means no, 1 yes.
- */
- unsigned int metadata_dumped;
- /*
- * Node in the ust-registry hash table. The event name is used to
- * initialize the node and the event_name/signature for the match function.
- */
- struct lttng_ht_node_u64 node;
-};
-
-struct ust_registry_enum {
- char name[LTTNG_UST_ABI_SYM_NAME_LEN];
- struct lttng_ust_ctl_enum_entry *entries;
- size_t nr_entries;
- uint64_t id; /* enum id in session */
- /* Enumeration node in session hash table. */
- struct lttng_ht_node_str node;
- /* For delayed reclaim. */
- struct rcu_head rcu_head;
-};
-
-/*
- * Validate that the id has reached the maximum allowed or not.
- *
- * Return 0 if NOT else 1.
- */
-static inline int ust_registry_is_max_id(uint32_t id)
-{
- return (id == UINT32_MAX) ? 1 : 0;
-}
-
-/*
- * Return next available event id and increment the used counter. The
- * ust_registry_is_max_id function MUST be called before in order to validate
- * if the maximum number of IDs have been reached. If not, it is safe to call
- * this function.
- *
- * Return a unique channel ID. If max is reached, the used_event_id counter is
- * returned.
- */
-static inline uint32_t ust_registry_get_next_event_id(
- struct ust_registry_channel *r)
-{
- if (ust_registry_is_max_id(r->used_event_id)) {
- return r->used_event_id;
- }
-
- r->used_event_id++;
- return r->next_event_id++;
-}
-
-/*
- * Return next available channel id and increment the used counter. The
- * ust_registry_is_max_id function MUST be called before in order to validate
- * if the maximum number of IDs have been reached. If not, it is safe to call
- * this function.
- *
- * Return a unique channel ID. If max is reached, the used_channel_id counter
- * is returned.
- */
-static inline uint32_t ust_registry_get_next_chan_id(
- struct ust_registry_session *r)
-{
- if (ust_registry_is_max_id(r->used_channel_id)) {
- return r->used_channel_id;
- }
-
- r->used_channel_id++;
- return r->next_channel_id++;
-}
-
-/*
- * Return registry event count. This is read atomically.
- */
-static inline uint32_t ust_registry_get_event_count(
- struct ust_registry_channel *r)
-{
- return (uint32_t) uatomic_read(&r->used_event_id);
-}
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-void ust_registry_channel_destroy(struct ust_registry_session *session,
- struct ust_registry_channel *chan);
-struct ust_registry_channel *ust_registry_channel_find(
- struct ust_registry_session *session, uint64_t key);
-int ust_registry_channel_add(struct ust_registry_session *session,
- uint64_t key);
-void ust_registry_channel_del_free(struct ust_registry_session *session,
- uint64_t key, bool notif);
-
-int ust_registry_session_init(struct ust_registry_session **sessionp,
- struct ust_app *app,
- uint32_t bits_per_long,
- uint32_t uint8_t_alignment,
- uint32_t uint16_t_alignment,
- uint32_t uint32_t_alignment,
- uint32_t uint64_t_alignment,
- uint32_t long_alignment,
- int byte_order,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id,
- uid_t tracing_uid);
-void ust_registry_session_destroy(struct ust_registry_session *session);
-
-int ust_registry_create_event(struct ust_registry_session *session,
- uint64_t chan_key, int session_objd, int channel_objd, char *name,
- char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields,
- int loglevel_value, char *model_emf_uri, int buffer_type,
- uint32_t *event_id_p, struct ust_app *app);
-struct ust_registry_event *ust_registry_find_event(
- struct ust_registry_channel *chan, char *name, char *sig);
-void ust_registry_destroy_event(struct ust_registry_channel *chan,
- struct ust_registry_event *event);
-
-/* app can be NULL for registry shared across applications. */
-int ust_metadata_session_statedump(struct ust_registry_session *session,
- struct ust_app *app, uint32_t major, uint32_t minor);
-int ust_metadata_channel_statedump(struct ust_registry_session *session,
- struct ust_registry_channel *chan);
-int ust_metadata_event_statedump(struct ust_registry_session *session,
- struct ust_registry_channel *chan,
- struct ust_registry_event *event);
-int ust_registry_create_or_find_enum(struct ust_registry_session *session,
- int session_objd, char *name,
- struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries,
- uint64_t *enum_id);
-struct ust_registry_enum *
- ust_registry_lookup_enum_by_id(struct ust_registry_session *session,
- const char *name, uint64_t id);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-void ust_registry_channel_destroy(
- struct ust_registry_session *session __attribute__((unused)),
- struct ust_registry_channel *chan __attribute__((unused)))
-{}
-
-static inline
-struct ust_registry_channel *ust_registry_channel_find(
- struct ust_registry_session *session __attribute__((unused)),
- uint64_t key __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-int ust_registry_channel_add(
- struct ust_registry_session *session __attribute__((unused)),
- uint64_t key __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-void ust_registry_channel_del_free(
- struct ust_registry_session *session __attribute__((unused)),
- uint64_t key __attribute__((unused)),
- bool notif __attribute__((unused)))
-{}
-
-static inline
-int ust_registry_session_init(
- struct ust_registry_session **sessionp __attribute__((unused)),
- struct ust_app *app __attribute__((unused)),
- uint32_t bits_per_long __attribute__((unused)),
- uint32_t uint8_t_alignment __attribute__((unused)),
- uint32_t uint16_t_alignment __attribute__((unused)),
- uint32_t uint32_t_alignment __attribute__((unused)),
- uint32_t uint64_t_alignment __attribute__((unused)),
- uint32_t long_alignment __attribute__((unused)),
- int byte_order __attribute__((unused)),
- uint32_t major __attribute__((unused)),
- uint32_t minor __attribute__((unused)),
- const char *root_shm_path __attribute__((unused)),
- const char *shm_path __attribute__((unused)),
- uid_t euid __attribute__((unused)),
- gid_t egid __attribute__((unused)),
- uint64_t tracing_id __attribute__((unused)),
- uid_t tracing_uid __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-void ust_registry_session_destroy(
- struct ust_registry_session *session __attribute__((unused)))
-{}
-
-static inline
-int ust_registry_create_event(
- struct ust_registry_session *session __attribute__((unused)),
- uint64_t chan_key __attribute__((unused)),
- int session_objd __attribute__((unused)),
- int channel_objd __attribute__((unused)),
- char *name __attribute__((unused)),
- char *sig __attribute__((unused)),
- size_t nr_fields __attribute__((unused)),
- struct lttng_ust_ctl_field *fields __attribute__((unused)),
- int loglevel_value __attribute__((unused)),
- char *model_emf_uri __attribute__((unused)),
- int buffer_type __attribute__((unused)),
- uint32_t *event_id_p __attribute__((unused)))
-{
- return 0;
-}
-static inline
-struct ust_registry_event *ust_registry_find_event(
- struct ust_registry_channel *chan __attribute__((unused)),
- char *name __attribute__((unused)),
- char *sig __attribute__((unused)))
-{
- return NULL;
-}
-
-static inline
-void ust_registry_destroy_event(
- struct ust_registry_channel *chan __attribute__((unused)),
- struct ust_registry_event *event __attribute__((unused)))
-{}
-
-/* The app object can be NULL for registry shared across applications. */
-static inline
-int ust_metadata_session_statedump(
- struct ust_registry_session *session __attribute__((unused)),
- struct ust_app *app __attribute__((unused)),
- uint32_t major __attribute__((unused)),
- uint32_t minor __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_metadata_channel_statedump(
- struct ust_registry_session *session __attribute__((unused)),
- struct ust_registry_channel *chan __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_metadata_event_statedump(
- struct ust_registry_session *session __attribute__((unused)),
- struct ust_registry_channel *chan __attribute__((unused)),
- struct ust_registry_event *event __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-int ust_registry_create_or_find_enum(
- struct ust_registry_session *session __attribute__((unused)),
- int session_objd __attribute__((unused)),
- char *name __attribute__((unused)),
- struct lttng_ust_ctl_enum_entry *entries __attribute__((unused)),
- size_t nr_entries __attribute__((unused)),
- uint64_t *enum_id __attribute__((unused)))
-{
- return 0;
-}
-
-static inline
-struct ust_registry_enum *
- ust_registry_lookup_enum_by_id(
- struct ust_registry_session *session __attribute__((unused)),
- const char *name __attribute__((unused)),
- uint64_t id __attribute__((unused)))
-{
- return NULL;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_REGISTRY_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_REGISTRY_H
+#define LTTNG_UST_REGISTRY_H
+
+#include <pthread.h>
+#include <stdint.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/uuid.hpp>
+
+#include "lttng-ust-ctl.hpp"
+
+#define CTF_SPEC_MAJOR 1
+#define CTF_SPEC_MINOR 8
+
+struct ust_app;
+
+struct ust_registry_session {
+ /*
+ * With multiple writers and readers, use this lock to access
+ * the registry. Can nest within the ust app session lock.
+ * Also acts as a registry serialization lock. Used by registry
+ * readers to serialize the registry information sent from the
+ * sessiond to the consumerd.
+ * The consumer socket lock nests within this lock.
+ */
+ pthread_mutex_t lock;
+ /* Next channel ID available for a newly registered channel. */
+ uint32_t next_channel_id;
+ /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+ uint32_t used_channel_id;
+ /* Next enumeration ID available. */
+ uint64_t next_enum_id;
+ /* Universal unique identifier used by the tracer. */
+ unsigned char uuid[LTTNG_UUID_LEN];
+
+ /* session ABI description */
+
+ /* Size of long, in bits */
+ unsigned int bits_per_long;
+ /* Alignment, in bits */
+ unsigned int uint8_t_alignment,
+ uint16_t_alignment,
+ uint32_t_alignment,
+ uint64_t_alignment,
+ long_alignment;
+ /* endianness */
+ int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */
+
+ /* Generated metadata. */
+ char *metadata; /* NOT null-terminated ! Use memcpy. */
+ size_t metadata_len, metadata_alloc_len;
+ /* Length of bytes sent to the consumer. */
+ size_t metadata_len_sent;
+ /* Current version of the metadata. */
+ uint64_t metadata_version;
+
+ /*
+ * Those fields are only used when a session is created with
+ * the --shm-path option. In this case, the metadata is output
+ * twice: once to the consumer, as ususal, but a second time
+ * also in the shm path directly. This is done so that a copy
+ * of the metadata that is as fresh as possible is available
+ * on the event of a crash.
+ *
+ * root_shm_path contains the shm-path provided by the user, along with
+ * the session's name and timestamp:
+ * e.g. /tmp/my_shm/my_session-20180612-135822
+ *
+ * shm_path contains the full path of the memory buffers:
+ * e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit
+ *
+ * metadata_path contains the full path to the metadata file that
+ * is kept for the "crash buffer" extraction:
+ * e.g. /tmp/my_shm/my_session-20180612-135822/ust/uid/1000/64-bit/metadata
+ *
+ * Note that this is not the trace's final metadata file. It is
+ * only meant to be used to read the contents of the ring buffers
+ * in the event of a crash.
+ *
+ * metadata_fd is a file descriptor that points to the file at
+ * 'metadata_path'.
+ */
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+ char metadata_path[PATH_MAX];
+ int metadata_fd; /* file-backed metadata FD */
+
+ /*
+ * Hash table containing channels sent by the UST tracer. MUST
+ * be accessed with a RCU read side lock acquired.
+ */
+ struct lttng_ht *channels;
+ /*
+ * Unique key to identify the metadata on the consumer side.
+ */
+ uint64_t metadata_key;
+ /*
+ * Indicates if the metadata is closed on the consumer side. This is to
+ * avoid double close of metadata when an application unregisters AND
+ * deletes its sessions.
+ */
+ unsigned int metadata_closed;
+
+ /* User and group owning the session. */
+ uid_t uid;
+ gid_t gid;
+
+ /* Enumerations table. */
+ struct lttng_ht *enums;
+
+ /*
+ * Copy of the tracer version when the first app is registered.
+ * It is used if we need to regenerate the metadata.
+ */
+ uint32_t major;
+ uint32_t minor;
+
+ /* The id of the parent session */
+ uint64_t tracing_id;
+ uid_t tracing_uid;
+};
+
+struct ust_registry_channel {
+ uint64_t key;
+ uint64_t consumer_key;
+ /* Id set when replying to a register channel. */
+ uint32_t chan_id;
+ enum lttng_ust_ctl_channel_header header_type;
+
+ /*
+ * Flag for this channel if the metadata was dumped once during
+ * registration. 0 means no, 1 yes.
+ */
+ unsigned int metadata_dumped;
+ /* Indicates if this channel registry has already been registered. */
+ unsigned int register_done;
+
+ /*
+ * Hash table containing events sent by the UST tracer. MUST be accessed
+ * with a RCU read side lock acquired.
+ */
+ struct lttng_ht *ht;
+ /* Next event ID available for a newly registered event. */
+ uint32_t next_event_id;
+ /* Once this value reaches UINT32_MAX, no more id can be allocated. */
+ uint32_t used_event_id;
+ /*
+ * Context fields of the registry. Context are per channel. Allocated by a
+ * register channel notification from the UST tracer.
+ */
+ size_t nr_ctx_fields;
+ struct lttng_ust_ctl_field *ctx_fields;
+ struct lttng_ht_node_u64 node;
+ /* For delayed reclaim */
+ struct rcu_head rcu_head;
+};
+
+/*
+ * Event registered from a UST tracer sent to the session daemon. This is
+ * indexed and matched by <event_name/signature>.
+ */
+struct ust_registry_event {
+ int id;
+ /* Both objd are set by the tracer. */
+ int session_objd;
+ int channel_objd;
+ /* Name of the event returned by the tracer. */
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ char *signature;
+ int loglevel_value;
+ size_t nr_fields;
+ struct lttng_ust_ctl_field *fields;
+ char *model_emf_uri;
+ /*
+ * Flag for this channel if the metadata was dumped once during
+ * registration. 0 means no, 1 yes.
+ */
+ unsigned int metadata_dumped;
+ /*
+ * Node in the ust-registry hash table. The event name is used to
+ * initialize the node and the event_name/signature for the match function.
+ */
+ struct lttng_ht_node_u64 node;
+};
+
+struct ust_registry_enum {
+ char name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ struct lttng_ust_ctl_enum_entry *entries;
+ size_t nr_entries;
+ uint64_t id; /* enum id in session */
+ /* Enumeration node in session hash table. */
+ struct lttng_ht_node_str node;
+ /* For delayed reclaim. */
+ struct rcu_head rcu_head;
+};
+
+/*
+ * Validate that the id has reached the maximum allowed or not.
+ *
+ * Return 0 if NOT else 1.
+ */
+static inline int ust_registry_is_max_id(uint32_t id)
+{
+ return (id == UINT32_MAX) ? 1 : 0;
+}
+
+/*
+ * Return next available event id and increment the used counter. The
+ * ust_registry_is_max_id function MUST be called before in order to validate
+ * if the maximum number of IDs have been reached. If not, it is safe to call
+ * this function.
+ *
+ * Return a unique channel ID. If max is reached, the used_event_id counter is
+ * returned.
+ */
+static inline uint32_t ust_registry_get_next_event_id(
+ struct ust_registry_channel *r)
+{
+ if (ust_registry_is_max_id(r->used_event_id)) {
+ return r->used_event_id;
+ }
+
+ r->used_event_id++;
+ return r->next_event_id++;
+}
+
+/*
+ * Return next available channel id and increment the used counter. The
+ * ust_registry_is_max_id function MUST be called before in order to validate
+ * if the maximum number of IDs have been reached. If not, it is safe to call
+ * this function.
+ *
+ * Return a unique channel ID. If max is reached, the used_channel_id counter
+ * is returned.
+ */
+static inline uint32_t ust_registry_get_next_chan_id(
+ struct ust_registry_session *r)
+{
+ if (ust_registry_is_max_id(r->used_channel_id)) {
+ return r->used_channel_id;
+ }
+
+ r->used_channel_id++;
+ return r->next_channel_id++;
+}
+
+/*
+ * Return registry event count. This is read atomically.
+ */
+static inline uint32_t ust_registry_get_event_count(
+ struct ust_registry_channel *r)
+{
+ return (uint32_t) uatomic_read(&r->used_event_id);
+}
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+void ust_registry_channel_destroy(struct ust_registry_session *session,
+ struct ust_registry_channel *chan);
+struct ust_registry_channel *ust_registry_channel_find(
+ struct ust_registry_session *session, uint64_t key);
+int ust_registry_channel_add(struct ust_registry_session *session,
+ uint64_t key);
+void ust_registry_channel_del_free(struct ust_registry_session *session,
+ uint64_t key, bool notif);
+
+int ust_registry_session_init(struct ust_registry_session **sessionp,
+ struct ust_app *app,
+ uint32_t bits_per_long,
+ uint32_t uint8_t_alignment,
+ uint32_t uint16_t_alignment,
+ uint32_t uint32_t_alignment,
+ uint32_t uint64_t_alignment,
+ uint32_t long_alignment,
+ int byte_order,
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id,
+ uid_t tracing_uid);
+void ust_registry_session_destroy(struct ust_registry_session *session);
+
+int ust_registry_create_event(struct ust_registry_session *session,
+ uint64_t chan_key, int session_objd, int channel_objd, char *name,
+ char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields,
+ int loglevel_value, char *model_emf_uri, int buffer_type,
+ uint32_t *event_id_p, struct ust_app *app);
+struct ust_registry_event *ust_registry_find_event(
+ struct ust_registry_channel *chan, char *name, char *sig);
+void ust_registry_destroy_event(struct ust_registry_channel *chan,
+ struct ust_registry_event *event);
+
+/* app can be NULL for registry shared across applications. */
+int ust_metadata_session_statedump(struct ust_registry_session *session,
+ struct ust_app *app, uint32_t major, uint32_t minor);
+int ust_metadata_channel_statedump(struct ust_registry_session *session,
+ struct ust_registry_channel *chan);
+int ust_metadata_event_statedump(struct ust_registry_session *session,
+ struct ust_registry_channel *chan,
+ struct ust_registry_event *event);
+int ust_registry_create_or_find_enum(struct ust_registry_session *session,
+ int session_objd, char *name,
+ struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries,
+ uint64_t *enum_id);
+struct ust_registry_enum *
+ ust_registry_lookup_enum_by_id(struct ust_registry_session *session,
+ const char *name, uint64_t id);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+void ust_registry_channel_destroy(
+ struct ust_registry_session *session __attribute__((unused)),
+ struct ust_registry_channel *chan __attribute__((unused)))
+{}
+
+static inline
+struct ust_registry_channel *ust_registry_channel_find(
+ struct ust_registry_session *session __attribute__((unused)),
+ uint64_t key __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+int ust_registry_channel_add(
+ struct ust_registry_session *session __attribute__((unused)),
+ uint64_t key __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+void ust_registry_channel_del_free(
+ struct ust_registry_session *session __attribute__((unused)),
+ uint64_t key __attribute__((unused)),
+ bool notif __attribute__((unused)))
+{}
+
+static inline
+int ust_registry_session_init(
+ struct ust_registry_session **sessionp __attribute__((unused)),
+ struct ust_app *app __attribute__((unused)),
+ uint32_t bits_per_long __attribute__((unused)),
+ uint32_t uint8_t_alignment __attribute__((unused)),
+ uint32_t uint16_t_alignment __attribute__((unused)),
+ uint32_t uint32_t_alignment __attribute__((unused)),
+ uint32_t uint64_t_alignment __attribute__((unused)),
+ uint32_t long_alignment __attribute__((unused)),
+ int byte_order __attribute__((unused)),
+ uint32_t major __attribute__((unused)),
+ uint32_t minor __attribute__((unused)),
+ const char *root_shm_path __attribute__((unused)),
+ const char *shm_path __attribute__((unused)),
+ uid_t euid __attribute__((unused)),
+ gid_t egid __attribute__((unused)),
+ uint64_t tracing_id __attribute__((unused)),
+ uid_t tracing_uid __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+void ust_registry_session_destroy(
+ struct ust_registry_session *session __attribute__((unused)))
+{}
+
+static inline
+int ust_registry_create_event(
+ struct ust_registry_session *session __attribute__((unused)),
+ uint64_t chan_key __attribute__((unused)),
+ int session_objd __attribute__((unused)),
+ int channel_objd __attribute__((unused)),
+ char *name __attribute__((unused)),
+ char *sig __attribute__((unused)),
+ size_t nr_fields __attribute__((unused)),
+ struct lttng_ust_ctl_field *fields __attribute__((unused)),
+ int loglevel_value __attribute__((unused)),
+ char *model_emf_uri __attribute__((unused)),
+ int buffer_type __attribute__((unused)),
+ uint32_t *event_id_p __attribute__((unused)))
+{
+ return 0;
+}
+static inline
+struct ust_registry_event *ust_registry_find_event(
+ struct ust_registry_channel *chan __attribute__((unused)),
+ char *name __attribute__((unused)),
+ char *sig __attribute__((unused)))
+{
+ return NULL;
+}
+
+static inline
+void ust_registry_destroy_event(
+ struct ust_registry_channel *chan __attribute__((unused)),
+ struct ust_registry_event *event __attribute__((unused)))
+{}
+
+/* The app object can be NULL for registry shared across applications. */
+static inline
+int ust_metadata_session_statedump(
+ struct ust_registry_session *session __attribute__((unused)),
+ struct ust_app *app __attribute__((unused)),
+ uint32_t major __attribute__((unused)),
+ uint32_t minor __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_metadata_channel_statedump(
+ struct ust_registry_session *session __attribute__((unused)),
+ struct ust_registry_channel *chan __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_metadata_event_statedump(
+ struct ust_registry_session *session __attribute__((unused)),
+ struct ust_registry_channel *chan __attribute__((unused)),
+ struct ust_registry_event *event __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+int ust_registry_create_or_find_enum(
+ struct ust_registry_session *session __attribute__((unused)),
+ int session_objd __attribute__((unused)),
+ char *name __attribute__((unused)),
+ struct lttng_ust_ctl_enum_entry *entries __attribute__((unused)),
+ size_t nr_entries __attribute__((unused)),
+ uint64_t *enum_id __attribute__((unused)))
+{
+ return 0;
+}
+
+static inline
+struct ust_registry_enum *
+ ust_registry_lookup_enum_by_id(
+ struct ust_registry_session *session __attribute__((unused)),
+ const char *name __attribute__((unused)),
+ uint64_t id __attribute__((unused)))
+{
+ return NULL;
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_REGISTRY_H */
#include <lttng/ust-sigbus.h>
#include <lttng/ust-ctl.h>
#include <lttng/lttng-export.h>
-#include "ust-sigbus.h"
+#include "ust-sigbus.hpp"
LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
+++ /dev/null
-/*
- * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_UST_SIGBUS_H
-#define LTTNG_UST_SIGBUS_H
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-void lttng_ust_handle_sigbus(void *address);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-void lttng_ust_handle_sigbus(void *address __attribute__((unused)))
-{
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* LTTNG_UST_SIGBUS_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_SIGBUS_H
+#define LTTNG_UST_SIGBUS_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+void lttng_ust_handle_sigbus(void *address);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+void lttng_ust_handle_sigbus(void *address __attribute__((unused)))
+{
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_SIGBUS_H */
#include <stdlib.h>
#include <unistd.h>
-#include <common/error.h>
+#include <common/error.hpp>
-#include "utils.h"
-#include "snapshot.h"
-#include "lttng-sessiond.h"
+#include "utils.hpp"
+#include "snapshot.hpp"
+#include "lttng-sessiond.hpp"
/*
* Write to writable pipe used to notify a thread.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_UTILS_H
-#define _LTT_UTILS_H
-
-struct lttng_ht;
-struct ltt_session;
-struct consumer_output;
-
-const char *get_home_dir(void);
-int notify_thread_pipe(int wpipe);
-int loglevels_match(int a_loglevel_type, int a_loglevel_value,
- int b_loglevel_type, int b_loglevel_value, int loglevel_all_type);
-const char *session_get_base_path(const struct ltt_session *session);
-const char *consumer_output_get_base_path(const struct consumer_output *output);
-
-#endif /* _LTT_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_UTILS_H
+#define _LTT_UTILS_H
+
+struct lttng_ht;
+struct ltt_session;
+struct consumer_output;
+
+const char *get_home_dir(void);
+int notify_thread_pipe(int wpipe);
+int loglevels_match(int a_loglevel_type, int a_loglevel_value,
+ int b_loglevel_type, int b_loglevel_value, int loglevel_all_type);
+const char *session_get_base_path(const struct ltt_session *session);
+const char *consumer_output_get_base_path(const struct consumer_output *output);
+
+#endif /* _LTT_UTILS_H */
bin_PROGRAMS = lttng
-lttng_SOURCES = command.h conf.cpp conf.h commands/start.cpp \
+lttng_SOURCES = command.hpp conf.cpp conf.hpp commands/start.cpp \
commands/list.cpp commands/create.cpp commands/destroy.cpp \
commands/stop.cpp commands/enable_events.cpp \
commands/disable_events.cpp commands/enable_channels.cpp \
commands/enable_rotation.cpp \
commands/disable_rotation.cpp \
commands/clear.cpp \
- loglevel.cpp loglevel.h \
+ loglevel.cpp loglevel.hpp \
commands/add_trigger.cpp \
commands/list_triggers.cpp \
commands/remove_trigger.cpp \
- utils.cpp utils.h lttng.cpp \
- uprobe.cpp uprobe.h
+ utils.cpp utils.hpp lttng.cpp \
+ uprobe.cpp uprobe.hpp
lttng_CXXFLAGS = $(AM_CXXFLAGS) $(POPT_CFLAGS)
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CMD_H
-#define _LTTNG_CMD_H
-
-#include <lttng/lttng.h>
-#include <common/common.h>
-#include <common/defaults.h>
-
-#include "conf.h"
-#include "utils.h"
-
-#define DECL_COMMAND(_name) \
- extern int cmd_##_name(int, const char **)
-
-#ifdef LTTNG_EMBED_HELP
-# define HELP_MSG_NAME help_msg
-# define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]);
-#else
-# define HELP_MSG_NAME NULL
-# define SHOW_HELP_ERROR_LINE ;
-#endif
-
-#define SHOW_HELP() \
- do { \
- ret = show_cmd_help(argv[0], HELP_MSG_NAME); \
- \
- if (ret) { \
- SHOW_HELP_ERROR_LINE \
- ret = CMD_ERROR; \
- } \
- } while (0)
-
-enum cmd_error_code {
- CMD_SUCCESS = 0,
- CMD_ERROR,
- CMD_UNDEFINED,
- CMD_FATAL,
- CMD_WARNING,
- CMD_UNSUPPORTED,
-};
-
-struct cmd_struct {
- const char *name;
- int (*func)(int argc, const char **argv);
-};
-
-DECL_COMMAND(list);
-DECL_COMMAND(status);
-DECL_COMMAND(create);
-DECL_COMMAND(destroy);
-DECL_COMMAND(start);
-DECL_COMMAND(stop);
-DECL_COMMAND(enable_events);
-DECL_COMMAND(disable_events);
-DECL_COMMAND(enable_channels);
-DECL_COMMAND(disable_channels);
-DECL_COMMAND(add_context);
-DECL_COMMAND(set_session);
-DECL_COMMAND(version);
-DECL_COMMAND(view);
-DECL_COMMAND(enable_consumer);
-DECL_COMMAND(disable_consumer);
-DECL_COMMAND(snapshot);
-DECL_COMMAND(save);
-DECL_COMMAND(load);
-DECL_COMMAND(track);
-DECL_COMMAND(untrack);
-DECL_COMMAND(metadata);
-DECL_COMMAND(regenerate);
-DECL_COMMAND(rotate);
-DECL_COMMAND(enable_rotation);
-DECL_COMMAND(disable_rotation);
-DECL_COMMAND(clear);
-DECL_COMMAND(add_trigger);
-DECL_COMMAND(list_triggers);
-DECL_COMMAND(remove_trigger);
-
-extern int cmd_help(int argc, const char **argv,
- const struct cmd_struct commands[]);
-
-#endif /* _LTTNG_CMD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CMD_H
+#define _LTTNG_CMD_H
+
+#include <lttng/lttng.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+
+#include "conf.hpp"
+#include "utils.hpp"
+
+#define DECL_COMMAND(_name) \
+ extern int cmd_##_name(int, const char **)
+
+#ifdef LTTNG_EMBED_HELP
+# define HELP_MSG_NAME help_msg
+# define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]);
+#else
+# define HELP_MSG_NAME NULL
+# define SHOW_HELP_ERROR_LINE ;
+#endif
+
+#define SHOW_HELP() \
+ do { \
+ ret = show_cmd_help(argv[0], HELP_MSG_NAME); \
+ \
+ if (ret) { \
+ SHOW_HELP_ERROR_LINE \
+ ret = CMD_ERROR; \
+ } \
+ } while (0)
+
+enum cmd_error_code {
+ CMD_SUCCESS = 0,
+ CMD_ERROR,
+ CMD_UNDEFINED,
+ CMD_FATAL,
+ CMD_WARNING,
+ CMD_UNSUPPORTED,
+};
+
+struct cmd_struct {
+ const char *name;
+ int (*func)(int argc, const char **argv);
+};
+
+DECL_COMMAND(list);
+DECL_COMMAND(status);
+DECL_COMMAND(create);
+DECL_COMMAND(destroy);
+DECL_COMMAND(start);
+DECL_COMMAND(stop);
+DECL_COMMAND(enable_events);
+DECL_COMMAND(disable_events);
+DECL_COMMAND(enable_channels);
+DECL_COMMAND(disable_channels);
+DECL_COMMAND(add_context);
+DECL_COMMAND(set_session);
+DECL_COMMAND(version);
+DECL_COMMAND(view);
+DECL_COMMAND(enable_consumer);
+DECL_COMMAND(disable_consumer);
+DECL_COMMAND(snapshot);
+DECL_COMMAND(save);
+DECL_COMMAND(load);
+DECL_COMMAND(track);
+DECL_COMMAND(untrack);
+DECL_COMMAND(metadata);
+DECL_COMMAND(regenerate);
+DECL_COMMAND(rotate);
+DECL_COMMAND(enable_rotation);
+DECL_COMMAND(disable_rotation);
+DECL_COMMAND(clear);
+DECL_COMMAND(add_trigger);
+DECL_COMMAND(list_triggers);
+DECL_COMMAND(remove_trigger);
+
+extern int cmd_help(int argc, const char **argv,
+ const struct cmd_struct commands[]);
+
+#endif /* _LTTNG_CMD_H */
#include <urcu/list.h>
-#include <lttng/domain-internal.h>
-#include <common/mi-lttng.h>
+#include <lttng/domain-internal.hpp>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_channel_name;
static char *opt_session_name;
#include <string.h>
#include <stdarg.h>
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
#include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
-#include "common/string-utils/string-utils.h"
-#include "common/utils.h"
-#include <lttng/domain-internal.h>
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "common/utils.hpp"
+#include <lttng/domain-internal.hpp>
/* For lttng_event_rule_type_str(). */
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/lttng.h>
-#include "common/filter/filter-ast.h"
-#include "common/filter/filter-ir.h"
-#include "common/dynamic-array.h"
+#include "common/filter/filter-ast.hpp"
+#include "common/filter/filter-ir.hpp"
+#include "common/dynamic-array.hpp"
#if (LTTNG_SYMBOL_NAME_LEN == 256)
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#include <stdbool.h>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
static int opt_clear_all;
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
#include <lttng/lttng.h>
static char *opt_output_path;
#include <stdbool.h>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
static char *opt_session_name;
static int opt_destroy_all;
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <lttng/domain-internal.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_channels;
static int opt_kernel;
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <lttng/domain-internal.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_event_list;
static int opt_kernel;
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
#include <lttng/lttng.h>
static char *opt_session_name;
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.h>
+#include <lttng/domain-internal.hpp>
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
static struct lttng_channel chan_opts;
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/string.h>
-#include <common/compat/getenv.h>
-#include <common/string-utils/string-utils.h>
-#include <common/utils.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/compat/string.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/utils.hpp>
/* Mi dependancy */
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.h>
-#include <lttng/event-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/event-internal.hpp>
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
#if (LTTNG_SYMBOL_NAME_LEN == 256)
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
-#include <common/utils.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/utils.hpp>
-#include "../command.h"
+#include "../command.hpp"
#include <lttng/lttng.h>
static char *opt_session_name;
#include <stdlib.h>
#include <string.h>
-#include "../command.h"
-#include <common/utils.h>
+#include "../command.hpp"
+#include <common/utils.hpp>
#ifdef LTTNG_EMBED_HELP
static const char *help_msg =
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.h>
-#include <common/time.h>
-#include <common/tracker.h>
-#include <lttng/domain-internal.h>
+#include <common/mi-lttng.hpp>
+#include <common/time.hpp>
+#include <common/tracker.hpp>
+#include <lttng/domain-internal.hpp>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
static int opt_userspace;
static int opt_kernel;
#include <stdio.h>
-#include "../command.h"
+#include "../command.hpp"
#include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
/* For lttng_condition_type_str(). */
-#include "lttng/condition/condition-internal.h"
+#include "lttng/condition/condition-internal.hpp"
#include "lttng/condition/event-rule-matches.h"
-#include "lttng/condition/event-rule-matches-internal.h"
+#include "lttng/condition/event-rule-matches-internal.hpp"
/* For lttng_domain_type_str(). */
-#include "lttng/domain-internal.h"
+#include "lttng/domain-internal.hpp"
/* For lttng_event_rule_kernel_syscall_emission_site_str() */
-#include "lttng/event-rule/kernel-syscall-internal.h"
-#include "../loglevel.h"
+#include "lttng/event-rule/kernel-syscall-internal.hpp"
+#include "../loglevel.hpp"
#include <lttng/lttng.h>
#ifdef LTTNG_EMBED_HELP
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.h>
-#include <common/config/session-config.h>
+#include <common/mi-lttng.hpp>
+#include <common/config/session-config.hpp>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
static char *the_opt_input_path;
static char *the_opt_override_url;
#include <string.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_session_name;
static char *session_name = NULL;
#include <string.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_session_name;
static char *session_name = NULL;
*
*/
-#include "../command.h"
+#include "../command.hpp"
#include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/mi-lttng.h"
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/mi-lttng.hpp"
#include <lttng/lttng.h>
#include <stdio.h>
#include <inttypes.h>
#include <ctype.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
#include <lttng/lttng.h>
static char *opt_session_name;
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
#include <lttng/lttng.h>
static char *opt_output_path;
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_session_name;
#include <sys/types.h>
#include <unistd.h>
-#include <common/utils.h>
-#include <common/mi-lttng.h>
+#include <common/utils.hpp>
+#include <common/mi-lttng.hpp>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
static const char *opt_session_name;
static const char *opt_output_name;
#include <sys/types.h>
#include <unistd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_session_name;
#include <sys/types.h>
#include <unistd.h>
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
#include <config.h>
#ifdef LTTNG_EMBED_HELP
#include <sys/types.h>
#include <unistd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
+#include "../command.hpp"
static char *opt_session_name;
static int opt_no_wait;
#include <urcu/list.h>
-#include <common/dynamic-array.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/dynamic-buffer.h>
-#include <common/tracker.h>
+#include <common/dynamic-array.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/tracker.hpp>
#include <lttng/lttng.h>
-#include "../command.h"
+#include "../command.hpp"
struct process_attr_command_args {
enum lttng_process_attr process_attr;
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
-#include "../command.h"
-#include "version.h"
+#include "../command.hpp"
+#include "version.hpp"
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <sys/types.h>
#include <unistd.h>
-#include <common/spawn-viewer.h>
-#include "../command.h"
+#include <common/spawn-viewer.hpp>
+#include "../command.hpp"
static char *opt_session_name;
static char *opt_viewer;
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/utils.h>
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/utils.hpp>
-#include "conf.h"
+#include "conf.hpp"
/*
* Returns the path with '/CONFIG_FILENAME' added to it;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_CONFIG_H
-#define _LTTNG_CONFIG_H
-
-#define CONFIG_FILENAME ".lttngrc"
-
-void config_destroy(const char *path);
-void config_destroy_default(void);
-int config_exists(const char *path);
-int config_init(const char *path);
-int config_add_session_name(const char *path, const char *name);
-
-/* Must free() the return pointer */
-char *config_read_session_name(const char *path);
-char *config_read_session_name_quiet(const char *path);
-char *config_get_file_path(const char *path);
-
-#endif /* _LTTNG_CONFIG_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_CONFIG_H
+#define _LTTNG_CONFIG_H
+
+#define CONFIG_FILENAME ".lttngrc"
+
+void config_destroy(const char *path);
+void config_destroy_default(void);
+int config_exists(const char *path);
+int config_init(const char *path);
+int config_add_session_name(const char *path, const char *name);
+
+/* Must free() the return pointer */
+char *config_read_session_name(const char *path);
+char *config_read_session_name_quiet(const char *path);
+char *config_get_file_path(const char *path);
+
+#endif /* _LTTNG_CONFIG_H */
*
*/
-#include "loglevel.h"
+#include "loglevel.hpp"
#include <string.h>
#include <strings.h>
#include <ctype.h>
+++ /dev/null
-/*
- * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_LOGLEVEL_UTILS_H
-#define _LTTNG_LOGLEVEL_UTILS_H
-
-#include <lttng/lttng.h>
-#include <common/macros.h>
-
-int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel);
-
-bool loglevel_parse_range_string(const char *str,
- enum lttng_loglevel *min,
- enum lttng_loglevel *max);
-
-int loglevel_log4j_name_to_value(
- const char *name, enum lttng_loglevel_log4j *loglevel);
-
-bool loglevel_log4j_parse_range_string(const char *str,
- enum lttng_loglevel_log4j *min,
- enum lttng_loglevel_log4j *max);
-
-int loglevel_jul_name_to_value(
- const char *name, enum lttng_loglevel_jul *loglevel);
-
-bool loglevel_jul_parse_range_string(const char *str,
- enum lttng_loglevel_jul *min,
- enum lttng_loglevel_jul *max);
-
-int loglevel_python_name_to_value(
- const char *name, enum lttng_loglevel_python *loglevel);
-
-bool loglevel_python_parse_range_string(const char *str,
- enum lttng_loglevel_python *min,
- enum lttng_loglevel_python *max);
-
-const char *loglevel_value_to_name(int loglevel);
-
-const char *loglevel_log4j_value_to_name(int loglevel);
-
-const char *loglevel_jul_value_to_name(int loglevel);
-
-const char *loglevel_python_value_to_name(int loglevel);
-
-#endif /* _LTTNG_LOGLEVEL_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_LOGLEVEL_UTILS_H
+#define _LTTNG_LOGLEVEL_UTILS_H
+
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+
+int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel);
+
+bool loglevel_parse_range_string(const char *str,
+ enum lttng_loglevel *min,
+ enum lttng_loglevel *max);
+
+int loglevel_log4j_name_to_value(
+ const char *name, enum lttng_loglevel_log4j *loglevel);
+
+bool loglevel_log4j_parse_range_string(const char *str,
+ enum lttng_loglevel_log4j *min,
+ enum lttng_loglevel_log4j *max);
+
+int loglevel_jul_name_to_value(
+ const char *name, enum lttng_loglevel_jul *loglevel);
+
+bool loglevel_jul_parse_range_string(const char *str,
+ enum lttng_loglevel_jul *min,
+ enum lttng_loglevel_jul *max);
+
+int loglevel_python_name_to_value(
+ const char *name, enum lttng_loglevel_python *loglevel);
+
+bool loglevel_python_parse_range_string(const char *str,
+ enum lttng_loglevel_python *min,
+ enum lttng_loglevel_python *max);
+
+const char *loglevel_value_to_name(int loglevel);
+
+const char *loglevel_log4j_value_to_name(int loglevel);
+
+const char *loglevel_jul_value_to_name(int loglevel);
+
+const char *loglevel_python_value_to_name(int loglevel);
+
+#endif /* _LTTNG_LOGLEVEL_UTILS_H */
#include <ctype.h>
#include <lttng/lttng.h>
-#include <common/error.h>
-#include <common/compat/getenv.h>
-#include <common/utils.h>
+#include <common/error.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/utils.hpp>
-#include "command.h"
-#include "version.h"
+#include "command.hpp"
+#include "version.hpp"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
*
*/
-#include "uprobe.h"
+#include "uprobe.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include "common/compat/getenv.h"
-#include "common/string-utils/string-utils.h"
-#include "common/utils.h"
-#include "common/path.h"
+#include "common/compat/getenv.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "common/utils.hpp"
+#include "common/path.hpp"
#include "lttng/constant.h"
-#include "command.h"
+#include "command.hpp"
/*
* Walk the directories in the PATH environment variable to find the target
+++ /dev/null
-/*
- * Copyright (C) 2020 EfficiOS, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef SRC_BIN_LTTNG_UPROBE_H
-#define SRC_BIN_LTTNG_UPROBE_H
-
-#include <common/macros.h>
-
-struct lttng_userspace_probe_location;
-
-int parse_userspace_probe_opts(const char *opt,
- struct lttng_userspace_probe_location **uprobe_loc);
-
-#endif /* SRC_BIN_LTTNG_UPROBE_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 EfficiOS, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef SRC_BIN_LTTNG_UPROBE_H
+#define SRC_BIN_LTTNG_UPROBE_H
+
+#include <common/macros.hpp>
+
+struct lttng_userspace_probe_location;
+
+int parse_userspace_probe_opts(const char *opt,
+ struct lttng_userspace_probe_location **uprobe_loc);
+
+#endif /* SRC_BIN_LTTNG_UPROBE_H */
#include <inttypes.h>
#include <unistd.h>
-#include <common/error.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
-#include "conf.h"
-#include "utils.h"
-#include "command.h"
+#include "conf.hpp"
+#include "utils.hpp"
+#include "command.hpp"
static const char *str_all = "ALL";
static const char *str_tracepoint = "Tracepoint";
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_UTILS_H
-#define _LTTNG_UTILS_H
-
-#include <popt.h>
-#include <common/argpar/argpar.h>
-#include <common/dynamic-array.h>
-
-#include <lttng/lttng.h>
-
-extern char *opt_relayd_path;
-extern int opt_no_sessiond;
-extern char * opt_sessiond_path;
-extern pid_t sessiond_pid;
-
-struct cmd_struct;
-
-char *get_session_name(void);
-char *get_session_name_quiet(void);
-void list_commands(struct cmd_struct *commands, FILE *ofp);
-void list_cmd_options(FILE *ofp, struct poptOption *options);
-void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_u32(uint32_t x);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_u64(uint64_t x);
-
-/*
- * Return the minimum order for which x <= (1UL << order).
- * Return -1 if x is 0.
- */
-int get_count_order_ulong(unsigned long x);
-
-const char *get_event_type_str(enum lttng_event_type event_type);
-
-int print_missing_or_multiple_domains(unsigned int domain_count,
- bool include_agent_domains);
-
-int spawn_relayd(const char *pathname, int port);
-int check_relayd(void);
-void print_session_stats(const char *session_name);
-int get_session_stats_str(const char *session_name, char **str);
-int show_cmd_help(const char *cmd_name, const char *help_msg);
-
-int print_trace_archive_location(
- const struct lttng_trace_archive_location *location,
- const char *session_name);
-
-int validate_exclusion_list(const char *event_name,
- const struct lttng_dynamic_pointer_array *exclusions);
-
-#endif /* _LTTNG_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_UTILS_H
+#define _LTTNG_UTILS_H
+
+#include <popt.h>
+#include <common/argpar/argpar.h>
+#include <common/dynamic-array.hpp>
+
+#include <lttng/lttng.h>
+
+extern char *opt_relayd_path;
+extern int opt_no_sessiond;
+extern char * opt_sessiond_path;
+extern pid_t sessiond_pid;
+
+struct cmd_struct;
+
+char *get_session_name(void);
+char *get_session_name_quiet(void);
+void list_commands(struct cmd_struct *commands, FILE *ofp);
+void list_cmd_options(FILE *ofp, struct poptOption *options);
+void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_u32(uint32_t x);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_u64(uint64_t x);
+
+/*
+ * Return the minimum order for which x <= (1UL << order).
+ * Return -1 if x is 0.
+ */
+int get_count_order_ulong(unsigned long x);
+
+const char *get_event_type_str(enum lttng_event_type event_type);
+
+int print_missing_or_multiple_domains(unsigned int domain_count,
+ bool include_agent_domains);
+
+int spawn_relayd(const char *pathname, int port);
+int check_relayd(void);
+void print_session_stats(const char *session_name);
+int get_session_stats_str(const char *session_name, char **str);
+int show_cmd_help(const char *cmd_name, const char *help_msg);
+
+int print_trace_archive_location(
+ const struct lttng_trace_archive_location *location,
+ const char *session_name);
+
+int validate_exclusion_list(const char *event_name,
+ const struct lttng_dynamic_pointer_array *exclusions);
+
+#endif /* _LTTNG_UTILS_H */
BUILT_SOURCES =
noinst_HEADERS = \
- align.h \
- bug.h \
- defaults.h \
- error.h \
- futex.h \
- lttng-kernel.h \
- lttng-kernel-old.h \
- macros.h \
- time.h \
- uri.h \
- utils.h
+ align.hpp \
+ bug.hpp \
+ defaults.hpp \
+ error.hpp \
+ futex.hpp \
+ lttng-kernel.hpp \
+ lttng-kernel-old.hpp \
+ macros.hpp \
+ time.hpp \
+ uri.hpp \
+ utils.hpp
# libargpar
noinst_LTLIBRARIES += libargpar-utils.la
libargpar_utils_la_SOURCES = \
argpar-utils/argpar-utils.cpp \
- argpar-utils/argpar-utils.h
+ argpar-utils/argpar-utils.hpp
# libbytecode
noinst_LTLIBRARIES += libbytecode.la
libbytecode_la_SOURCES = \
bytecode/bytecode.cpp \
- bytecode/bytecode.h
+ bytecode/bytecode.hpp
# The libcommon-lgpl static archive contains only LGPLv2.1 code. It is
actions/start-session.cpp \
actions/stop-session.cpp \
actions/rate-policy.cpp \
- buffer-view.h buffer-view.cpp \
+ buffer-view.hpp buffer-view.cpp \
channel.cpp \
conditions/buffer-usage.cpp \
conditions/condition.cpp \
conditions/event-rule-matches.cpp \
conditions/session-consumed-size.cpp \
conditions/session-rotation.cpp \
- credentials.cpp credentials.h \
+ credentials.cpp credentials.hpp \
defaults.cpp \
domain.cpp \
- dynamic-array.cpp dynamic-array.h \
- dynamic-buffer.cpp dynamic-buffer.h \
+ dynamic-array.cpp dynamic-array.hpp \
+ dynamic-buffer.cpp dynamic-buffer.hpp \
endpoint.cpp \
- error.cpp error.h \
+ error.cpp error.hpp \
error-query.cpp \
evaluation.cpp \
event.cpp \
event-rule/log4j-logging.cpp \
event-rule/jul-logging.cpp \
event-rule/python-logging.cpp \
- fd-handle.cpp fd-handle.h \
+ fd-handle.cpp fd-handle.hpp\
kernel-probe.cpp \
location.cpp \
log-level-rule.cpp \
- mi-lttng.cpp mi-lttng.h \
+ mi-lttng.cpp mi-lttng.hpp \
notification.cpp \
- payload.cpp payload.h \
- payload-view.cpp payload-view.h \
- readwrite.cpp readwrite.h \
- runas.cpp runas.h \
+ payload.cpp payload.hpp \
+ payload-view.cpp payload-view.hpp \
+ readwrite.cpp readwrite.hpp \
+ runas.cpp runas.hpp \
session-descriptor.cpp \
- snapshot.cpp snapshot.h \
- spawn-viewer.cpp spawn-viewer.h \
- thread.cpp thread.h \
+ snapshot.cpp snapshot.hpp \
+ spawn-viewer.cpp spawn-viewer.hpp \
+ thread.cpp thread.hpp \
time.cpp \
- tracker.cpp tracker.h \
+ tracker.cpp tracker.hpp \
trigger.cpp \
- unix.cpp unix.h \
- uri.cpp uri.h \
+ unix.cpp unix.hpp \
+ uri.cpp uri.hpp \
userspace-probe.cpp \
- utils.cpp utils.h
+ utils.cpp utils.hpp
if HAVE_ELF_H
libcommon_lgpl_la_SOURCES += \
- lttng-elf.cpp lttng-elf.h
+ lttng-elf.cpp lttng-elf.hpp
endif
libcommon_lgpl_la_LIBADD = \
# meant to be used by GPL executables.
noinst_LTLIBRARIES += libpath.la
libpath_la_SOURCES = \
- path.cpp path.h
+ path.cpp path.hpp
# The libcommon-gpl static archive contains GPLv2 compatible code. It is
# meant to be used by GPL executables.
noinst_LTLIBRARIES += libcommon-gpl.la
libcommon_gpl_la_SOURCES = \
- common.h \
- context.cpp context.h \
- daemonize.cpp daemonize.h \
- filter.cpp filter.h \
- fs-handle.cpp fs-handle.h fs-handle-internal.h \
- futex.cpp futex.h \
- index-allocator.cpp index-allocator.h \
- optional.h \
- pipe.cpp pipe.h \
- shm.cpp shm.h \
- trace-chunk.cpp trace-chunk.h \
- trace-chunk-registry.h \
- uuid.cpp uuid.h \
- waiter.cpp waiter.h
+ common.hpp \
+ context.cpp context.hpp \
+ daemonize.cpp daemonize.hpp \
+ filter.cpp filter.hpp \
+ fs-handle.cpp fs-handle.hpp fs-handle-internal.hpp \
+ futex.cpp futex.hpp \
+ index-allocator.cpp index-allocator.hpp \
+ optional.hpp \
+ pipe.cpp pipe.hpp \
+ shm.cpp shm.hpp \
+ trace-chunk.cpp trace-chunk.hpp \
+ trace-chunk-registry.hpp \
+ uuid.cpp uuid.hpp \
+ waiter.cpp waiter.hpp
libcommon_gpl_la_LIBADD = \
libcommon-lgpl.la \
libcompat_la_SOURCES = \
compat/compat-fcntl.cpp \
compat/directory-handle.cpp \
- compat/directory-handle.h \
- compat/dirent.h \
- compat/endian.h \
- compat/errno.h \
- compat/fcntl.h \
- compat/getenv.h \
- compat/mman.h \
- compat/netdb.h \
- compat/path.h \
- compat/paths.h \
+ compat/directory-handle.hpp \
+ compat/dirent.hpp \
+ compat/endian.hpp \
+ compat/errno.hpp \
+ compat/fcntl.hpp \
+ compat/getenv.hpp \
+ compat/mman.hpp \
+ compat/netdb.hpp \
+ compat/path.hpp \
+ compat/paths.hpp \
compat/poll.cpp \
- compat/poll.h \
- compat/pthread.h \
- compat/socket.h \
- compat/string.h \
- compat/tid.h \
- compat/time.h
+ compat/poll.hpp \
+ compat/pthread.hpp \
+ compat/socket.hpp \
+ compat/string.hpp \
+ compat/tid.hpp \
+ compat/time.hpp
# libconfig
noinst_LTLIBRARIES += libconfig.la
libconfig_la_SOURCES = \
- config/config-internal.h \
- config/config-session-abi.h \
+ config/config-internal.hpp \
+ config/config-session-abi.hpp \
config/session-config.cpp \
- config/session-config.h
+ config/session-config.hpp
libconfig_la_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS)
libconfig_la_LIBADD = ${libxml2_LIBS}
libconsumer_la_SOURCES = \
consumer/consumer.cpp \
- consumer/consumer.h \
+ consumer/consumer.hpp \
consumer/consumer-metadata-cache.cpp \
- consumer/consumer-metadata-cache.h \
+ consumer/consumer-metadata-cache.hpp \
consumer/consumer-stream.cpp \
- consumer/consumer-stream.h \
- consumer/consumer-testpoint.h \
+ consumer/consumer-stream.hpp \
+ consumer/consumer-testpoint.hpp \
consumer/consumer-timer.cpp \
- consumer/consumer-timer.h \
+ consumer/consumer-timer.hpp \
consumer/metadata-bucket.cpp \
- consumer/metadata-bucket.h
+ consumer/metadata-bucket.hpp
libconsumer_la_LIBADD = \
libkernel-consumer.la \
noinst_LTLIBRARIES += libfd-tracker.la
libfd_tracker_la_SOURCES = \
fd-tracker/fd-tracker.cpp \
- fd-tracker/fd-tracker.h \
+ fd-tracker/fd-tracker.hpp \
fd-tracker/inode.cpp \
- fd-tracker/inode.h \
+ fd-tracker/inode.hpp \
fd-tracker/utils.cpp \
- fd-tracker/utils.h \
+ fd-tracker/utils.hpp \
fd-tracker/utils-poll.cpp
noinst_LTLIBRARIES += libfilter.la
libfilter_la_SOURCES = \
- filter/filter-ast.h \
- filter/filter-ir.h \
+ filter/filter-ast.hpp \
+ filter/filter-ir.hpp \
filter/filter-lexer.lpp \
filter/filter-parser.ypp \
- filter/filter-symbols.h \
+ filter/filter-symbols.hpp \
filter/filter-visitor-generate-bytecode.cpp \
filter/filter-visitor-generate-ir.cpp \
filter/filter-visitor-ir-check-binary-op-nesting.cpp \
filter/filter-visitor-ir-validate-globbing.cpp \
filter/filter-visitor-ir-validate-string.cpp \
filter/filter-visitor-xml.cpp \
- filter/memstream.h
+ filter/memstream.hpp
BUILT_SOURCES += filter/filter-parser.hpp
-Wno-unused-parameter
libfilter_la_CFLAGS = $(AM_CFLAGS) $(FILTER_WARN_FLAGS)
-libfilter_la_CXXFLAGS = -include filter-symbols.h $(AM_CXXFLAGS) $(FILTER_WARN_FLAGS)
+libfilter_la_CXXFLAGS = -include filter-symbols.hpp $(AM_CXXFLAGS) $(FILTER_WARN_FLAGS)
libfilter_la_CPPFLAGS = -I$(srcdir)/filter -I$(builddir)/filter $(AM_CPPFLAGS)
libfilter_la_LIBADD = libstring-utils.la
libhashtable_lgpl_la_SOURCES = \
hashtable/seed.cpp \
hashtable/utils.cpp \
- hashtable/utils.h
+ hashtable/utils.hpp
noinst_LTLIBRARIES += libhashtable-gpl.la
libhashtable_gpl_la_SOURCES = \
hashtable/hashtable.cpp \
- hashtable/hashtable.h \
- hashtable/hashtable-symbols.h
+ hashtable/hashtable.hpp \
+ hashtable/hashtable-symbols.hpp
libhashtable_gpl_la_LIBADD = \
$(URCU_LIBS) \
noinst_LTLIBRARIES += libini-config.la
libini_config_la_SOURCES = \
ini-config/ini.cpp \
- ini-config/ini.h \
+ ini-config/ini.hpp \
ini-config/ini-config.cpp \
- ini-config/ini-config.h
+ ini-config/ini-config.hpp
if BUILD_LIB_INDEX
noinst_LTLIBRARIES += libindex.la
libindex_la_SOURCES = \
- index/ctf-index.h \
+ index/ctf-index.hpp \
index/index.cpp \
- index/index.h
+ index/index.hpp
endif
libkernel_ctl_la_SOURCES = \
kernel-ctl/kernel-ctl.cpp \
- kernel-ctl/kernel-ctl.h \
- kernel-ctl/kernel-ioctl.h
+ kernel-ctl/kernel-ctl.hpp \
+ kernel-ctl/kernel-ioctl.hpp
endif
if BUILD_LIB_SESSIOND_COMM
noinst_LTLIBRARIES += libsessiond-comm.la
libsessiond_comm_la_SOURCES = \
- sessiond-comm/agent.h \
+ sessiond-comm/agent.hpp \
sessiond-comm/inet.cpp \
- sessiond-comm/inet.h \
+ sessiond-comm/inet.hpp \
sessiond-comm/inet6.cpp \
- sessiond-comm/inet6.h \
- sessiond-comm/relayd.h \
+ sessiond-comm/inet6.hpp \
+ sessiond-comm/relayd.hpp \
sessiond-comm/sessiond-comm.cpp \
- sessiond-comm/sessiond-comm.h
+ sessiond-comm/sessiond-comm.hpp
endif
if BUILD_LIB_RELAYD
librelayd_la_SOURCES = \
relayd/relayd.cpp \
- relayd/relayd.h
+ relayd/relayd.hpp
librelayd_la_LIBADD = libsessiond-comm.la
endif
libkernel_consumer_la_SOURCES = \
kernel-consumer/kernel-consumer.cpp \
- kernel-consumer/kernel-consumer.h
+ kernel-consumer/kernel-consumer.hpp
libkernel_consumer_la_LIBADD = \
libkernel-ctl.la
libust_consumer_la_SOURCES = \
ust-consumer/ust-consumer.cpp \
- ust-consumer/ust-consumer.h
+ ust-consumer/ust-consumer.hpp
libust_consumer_la_LIBADD = \
$(UST_CTL_LIBS)
libtestpoint_la_SOURCES = \
testpoint/testpoint.cpp \
- testpoint/testpoint.h
+ testpoint/testpoint.hpp
libtestpoint_la_LIBADD = $(DL_LIBS)
endif
# libstring-utils
noinst_LTLIBRARIES += libstring-utils.la
libstring_utils_la_SOURCES = \
- string-utils/format.h \
+ string-utils/format.hpp \
string-utils/string-utils.cpp \
- string-utils/string-utils.h
+ string-utils/string-utils.hpp
noinst_PROGRAMS = filter-grammar-test
*
*/
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <lttng/action/rate-policy-internal.h>
-#include <lttng/action/rotate-session-internal.h>
-#include <lttng/action/snapshot-session-internal.h>
-#include <lttng/action/start-session-internal.h>
-#include <lttng/action/stop-session-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/action/notify-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
+#include <lttng/action/rotate-session-internal.hpp>
+#include <lttng/action/snapshot-session-internal.hpp>
+#include <lttng/action/start-session-internal.hpp>
+#include <lttng/action/stop-session-internal.hpp>
+#include <lttng/error-query-internal.hpp>
const char *lttng_action_type_string(enum lttng_action_type action_type)
{
*
*/
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
#include <lttng/action/list.h>
#define IS_LIST_ACTION(action) \
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/notify-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/notify-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/lttng-error.h>
#define IS_NOTIFY_ACTION(action) \
*
*/
-#include <lttng/action/path-internal.h>
+#include <lttng/action/path-internal.hpp>
struct lttng_action_path_comm {
uint32_t index_count;
*
*/
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <limits.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
#include <stdbool.h>
#include <sys/types.h>
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
-#include <lttng/action/rotate-session-internal.h>
+#include <lttng/action/rotate-session-internal.hpp>
#include <lttng/action/rotate-session.h>
#define IS_ROTATE_SESSION_ACTION(action) \
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/snapshot.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/snapshot.hpp>
#include <inttypes.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
-#include <lttng/action/snapshot-session-internal.h>
+#include <lttng/action/snapshot-session-internal.hpp>
#include <lttng/action/snapshot-session.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
#include <lttng/snapshot.h>
#define IS_SNAPSHOT_SESSION_ACTION(action) \
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
-#include <lttng/action/start-session-internal.h>
+#include <lttng/action/start-session-internal.hpp>
#include <lttng/action/start-session.h>
#define IS_START_SESSION_ACTION(action) \
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
-#include <lttng/action/stop-session-internal.h>
+#include <lttng/action/stop-session-internal.hpp>
#include <lttng/action/stop-session.h>
#define IS_STOP_SESSION_ACTION(action) \
+++ /dev/null
-/*
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_ALIGN_H
-#define _LTTNG_ALIGN_H
-
-#include "bug.h"
-
-/*
- * Align value to the next multiple of align. Returns val if it already is a
- * multiple of align. Align must be a power of two.
- */
-#define __lttng_align_ceil_mask(v, mask) (((v) + (mask)) & ~(mask))
-
-#define lttng_align_ceil(v, align) \
- __lttng_align_ceil_mask(v, (__typeof__(v)) (align) - 1)
-
-/*
- * Align value to the previous multiple of align. Returns val if it already is a
- * multiple of align. Align must be a power of two.
- */
-#define __lttng_align_floor_mask(v, mask) ((v) & ~(mask))
-
-#define lttng_align_floor(v, align) \
- __lttng_align_floor_mask(v, (__typeof__(v)) (align) - 1)
-
-/**
- * lttng_offset_align - Calculate the offset needed to align an object on its natural
- * alignment towards higher addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be added to align towards higher
- * addresses.
- */
-#define lttng_offset_align(align_drift, alignment) \
- ({ \
- LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((alignment) - (align_drift)) & ((alignment) - 1)); \
- })
-
-/**
- * lttng_offset_align_floor - Calculate the offset needed to align an object
- * on its natural alignment towards lower addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be substracted to align towards lower addresses.
- */
-#define lttng_offset_align_floor(align_drift, alignment) \
- ({ \
- LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((align_drift) - (alignment)) & ((alignment) - 1)); \
- })
-
-#endif /* _LTTNG_ALIGN_H */
--- /dev/null
+/*
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_ALIGN_H
+#define _LTTNG_ALIGN_H
+
+#include "bug.hpp"
+
+/*
+ * Align value to the next multiple of align. Returns val if it already is a
+ * multiple of align. Align must be a power of two.
+ */
+#define __lttng_align_ceil_mask(v, mask) (((v) + (mask)) & ~(mask))
+
+#define lttng_align_ceil(v, align) \
+ __lttng_align_ceil_mask(v, (__typeof__(v)) (align) - 1)
+
+/*
+ * Align value to the previous multiple of align. Returns val if it already is a
+ * multiple of align. Align must be a power of two.
+ */
+#define __lttng_align_floor_mask(v, mask) ((v) & ~(mask))
+
+#define lttng_align_floor(v, align) \
+ __lttng_align_floor_mask(v, (__typeof__(v)) (align) - 1)
+
+/**
+ * lttng_offset_align - Calculate the offset needed to align an object on its natural
+ * alignment towards higher addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define lttng_offset_align(align_drift, alignment) \
+ ({ \
+ LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((alignment) - (align_drift)) & ((alignment) - 1)); \
+ })
+
+/**
+ * lttng_offset_align_floor - Calculate the offset needed to align an object
+ * on its natural alignment towards lower addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define lttng_offset_align_floor(align_drift, alignment) \
+ ({ \
+ LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((align_drift) - (alignment)) & ((alignment) - 1)); \
+ })
+
+#endif /* _LTTNG_ALIGN_H */
*
*/
-#include "argpar-utils.h"
+#include "argpar-utils.hpp"
#include <stdio.h>
-#include <common/error.h>
-#include <common/string-utils/string-utils.h>
+#include <common/error.hpp>
+#include <common/string-utils/string-utils.hpp>
/*
* Given argpar error status `status` and error `error`, return a formatted
+++ /dev/null
-/*
- * Copyright (C) 2021 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef COMMON_ARGPAR_UTILS_H
-#define COMMON_ARGPAR_UTILS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdarg.h>
-
-#include <common/macros.h>
-#include <common/argpar/argpar.h>
-#include <common/string-utils/format.h>
-
-#define WHILE_PARSING_ARG_N_ARG_FMT "While parsing argument #%d (`%s`): "
-
-enum parse_next_item_status
-{
- PARSE_NEXT_ITEM_STATUS_OK = 0,
- PARSE_NEXT_ITEM_STATUS_END = 1,
- PARSE_NEXT_ITEM_STATUS_ERROR = -1,
- PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY = -2,
-};
-
-/*
- * Parse the next argpar item using `iter`.
- *
- * The item in `*item` is always freed and cleared on entry.
- *
- * If an item is parsed successfully, return the new item in `*item` and return
- * PARSE_NEXT_ITEM_STATUS_OK.
- *
- * If the end of the argument list is reached, return
- * PARSE_NEXT_ITEM_STATUS_END.
- *
- * On error, print a descriptive error message and return
- * PARSE_NEXT_ITEM_STATUS_ERROR. If `context_fmt` is non-NULL, it is formatted
- * using the following arguments and prepended to the error message.
- * Add `argc_offset` to the argument index mentioned in the error message.
- *
- * If `unknown_opt_is_error` is true, an unknown option is considered an error.
- * Otherwise, it is considered as the end of the argument list.
- *
- * If `error_out` is given and PARSE_NEXT_ITEM_STATUS_ERROR is returned, set
- * `*error_out` to the argpar_error object corresponding to the error. The
- * caller must free the object with `argpar_error_destroy`.
- */
-ATTR_FORMAT_PRINTF(7, 8)
-enum parse_next_item_status parse_next_item(struct argpar_iter *iter,
- const struct argpar_item **item, int argc_offset,
- const char **argv, bool unknown_opt_is_error,
- const struct argpar_error **error_out,
- const char *context_fmt, ...);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- /dev/null
+/*
+ * Copyright (C) 2021 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef COMMON_ARGPAR_UTILS_H
+#define COMMON_ARGPAR_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdarg.h>
+
+#include <common/macros.hpp>
+#include <common/argpar/argpar.h>
+#include <common/string-utils/format.hpp>
+
+#define WHILE_PARSING_ARG_N_ARG_FMT "While parsing argument #%d (`%s`): "
+
+enum parse_next_item_status
+{
+ PARSE_NEXT_ITEM_STATUS_OK = 0,
+ PARSE_NEXT_ITEM_STATUS_END = 1,
+ PARSE_NEXT_ITEM_STATUS_ERROR = -1,
+ PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY = -2,
+};
+
+/*
+ * Parse the next argpar item using `iter`.
+ *
+ * The item in `*item` is always freed and cleared on entry.
+ *
+ * If an item is parsed successfully, return the new item in `*item` and return
+ * PARSE_NEXT_ITEM_STATUS_OK.
+ *
+ * If the end of the argument list is reached, return
+ * PARSE_NEXT_ITEM_STATUS_END.
+ *
+ * On error, print a descriptive error message and return
+ * PARSE_NEXT_ITEM_STATUS_ERROR. If `context_fmt` is non-NULL, it is formatted
+ * using the following arguments and prepended to the error message.
+ * Add `argc_offset` to the argument index mentioned in the error message.
+ *
+ * If `unknown_opt_is_error` is true, an unknown option is considered an error.
+ * Otherwise, it is considered as the end of the argument list.
+ *
+ * If `error_out` is given and PARSE_NEXT_ITEM_STATUS_ERROR is returned, set
+ * `*error_out` to the argpar_error object corresponding to the error. The
+ * caller must free the object with `argpar_error_destroy`.
+ */
+ATTR_FORMAT_PRINTF(7, 8)
+enum parse_next_item_status parse_next_item(struct argpar_iter *iter,
+ const struct argpar_item **item, int argc_offset,
+ const char **argv, bool unknown_opt_is_error,
+ const struct argpar_error **error_out,
+ const char *context_fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
*
*/
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
struct lttng_buffer_view lttng_buffer_view_init(
const char *src, size_t offset, ptrdiff_t len)
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_BUFFER_VIEW_H
-#define LTTNG_BUFFER_VIEW_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-struct lttng_dynamic_buffer;
-
-struct lttng_buffer_view {
- const char *data;
- size_t size;
-};
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by a raw
- * pointer.
- *
- * @src Source buffer to reference
- * @offset Offset to apply to the source memory buffer
- * @len Length of the memory contents to reference.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_init(
- const char *src, size_t offset, ptrdiff_t len);
-
-/**
- * Checks if a buffer view is safe to access.
- *
- * After calling the buffer view creation functions, callers should verify
- * if the resquested length (if any is explicitly provided) could be mapped
- * to a new view.
- *
- * @view Buffer view to validate
- */
-bool lttng_buffer_view_is_valid(const struct lttng_buffer_view *view);
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by another
- * view.
- *
- * @src Source view to reference
- * @offset Offset to apply to the source memory content
- * @len Length of the memory contents to reference. Passing -1 will
- * cause the view to reference the whole view from the offset
- * provided.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_from_view(
- const struct lttng_buffer_view *src, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a buffer view referencing a subset of the memory referenced by a
- * dynamic buffer.
- *
- * @src Source dynamic buffer to reference
- * @offset Offset to apply to the source memory content
- * @len Length of the memory contents to reference. Passing -1 will
- * cause the view to reference the whole dynamic buffer from the
- * offset provided.
- *
- * Note that a buffer view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *src, size_t offset,
- ptrdiff_t len);
-
-/**
- * Verify that `buf` contains a string starting at `str` of length
- * `len_with_null_terminator`.
- *
- * @buf The buffer view
- * @str The start of the string
- * @len_with_null_terminator Expected length of the string, including the
- * NULL terminator.
- */
-bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
- const char *str,
- size_t len_with_null_terminator);
-
-#endif /* LTTNG_BUFFER_VIEW_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_BUFFER_VIEW_H
+#define LTTNG_BUFFER_VIEW_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+struct lttng_dynamic_buffer;
+
+struct lttng_buffer_view {
+ const char *data;
+ size_t size;
+};
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by a raw
+ * pointer.
+ *
+ * @src Source buffer to reference
+ * @offset Offset to apply to the source memory buffer
+ * @len Length of the memory contents to reference.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_init(
+ const char *src, size_t offset, ptrdiff_t len);
+
+/**
+ * Checks if a buffer view is safe to access.
+ *
+ * After calling the buffer view creation functions, callers should verify
+ * if the resquested length (if any is explicitly provided) could be mapped
+ * to a new view.
+ *
+ * @view Buffer view to validate
+ */
+bool lttng_buffer_view_is_valid(const struct lttng_buffer_view *view);
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by another
+ * view.
+ *
+ * @src Source view to reference
+ * @offset Offset to apply to the source memory content
+ * @len Length of the memory contents to reference. Passing -1 will
+ * cause the view to reference the whole view from the offset
+ * provided.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_from_view(
+ const struct lttng_buffer_view *src, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a buffer view referencing a subset of the memory referenced by a
+ * dynamic buffer.
+ *
+ * @src Source dynamic buffer to reference
+ * @offset Offset to apply to the source memory content
+ * @len Length of the memory contents to reference. Passing -1 will
+ * cause the view to reference the whole dynamic buffer from the
+ * offset provided.
+ *
+ * Note that a buffer view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
+ const struct lttng_dynamic_buffer *src, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Verify that `buf` contains a string starting at `str` of length
+ * `len_with_null_terminator`.
+ *
+ * @buf The buffer view
+ * @str The start of the string
+ * @len_with_null_terminator Expected length of the string, including the
+ * NULL terminator.
+ */
+bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
+ const char *str,
+ size_t len_with_null_terminator);
+
+#endif /* LTTNG_BUFFER_VIEW_H */
+++ /dev/null
-/*
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_BUG_H
-#define _LTTNG_BUG_H
-
-#include <urcu/compiler.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define LTTNG_BUG_ON(condition) \
- do { \
- if (caa_unlikely(condition)) { \
- fprintf(stderr, \
- "LTTng BUG in file %s, line %d.\n", \
- __FILE__, __LINE__); \
- exit(EXIT_FAILURE); \
- } \
- } while (0)
-
-#define LTTNG_BUILD_BUG_ON(condition) \
- ((void) sizeof(char[-!!(condition)]))
-
-/**
- * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
- * @condition: the condition which should be false.
- *
- * If the condition is a constant and true, the compiler will generate a build
- * error. If the condition is not constant, a BUG will be triggered at runtime
- * if the condition is ever true. If the condition is constant and false, no
- * code is emitted.
- */
-#define LTTNG_BUILD_RUNTIME_BUG_ON(condition) \
- do { \
- if (__builtin_constant_p(condition)) \
- LTTNG_BUILD_BUG_ON(condition); \
- else \
- LTTNG_BUG_ON(condition); \
- } while (0)
-
-#endif
--- /dev/null
+/*
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_BUG_H
+#define _LTTNG_BUG_H
+
+#include <urcu/compiler.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LTTNG_BUG_ON(condition) \
+ do { \
+ if (caa_unlikely(condition)) { \
+ fprintf(stderr, \
+ "LTTng BUG in file %s, line %d.\n", \
+ __FILE__, __LINE__); \
+ exit(EXIT_FAILURE); \
+ } \
+ } while (0)
+
+#define LTTNG_BUILD_BUG_ON(condition) \
+ ((void) sizeof(char[-!!(condition)]))
+
+/**
+ * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
+ * @condition: the condition which should be false.
+ *
+ * If the condition is a constant and true, the compiler will generate a build
+ * error. If the condition is not constant, a BUG will be triggered at runtime
+ * if the condition is ever true. If the condition is constant and false, no
+ * code is emitted.
+ */
+#define LTTNG_BUILD_RUNTIME_BUG_ON(condition) \
+ do { \
+ if (__builtin_constant_p(condition)) \
+ LTTNG_BUILD_BUG_ON(condition); \
+ else \
+ LTTNG_BUG_ON(condition); \
+ } while (0)
+
+#endif
*
*/
-#include "bytecode.h"
+#include "bytecode.hpp"
#include <errno.h>
#include <algorithm>
-#include "common/align.h"
+#include "common/align.hpp"
#define INIT_ALLOC_SIZE 4
+++ /dev/null
-/*
- * Copyright 2020 EfficiOS, Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_COMMON_BYTECODE_H
-#define LTTNG_COMMON_BYTECODE_H
-
-#include <stdint.h>
-
-#include "common/macros.h"
-#include "common/sessiond-comm/sessiond-comm.h"
-
-/*
- * offsets are absolute from start of bytecode.
- */
-
-struct field_ref {
- /* Initially, symbol offset. After link, field offset. */
- uint16_t offset;
-} LTTNG_PACKED;
-
-struct get_symbol {
- /* Symbol offset. */
- uint16_t offset;
-} LTTNG_PACKED;
-
-struct get_index_u16 {
- uint16_t index;
-} LTTNG_PACKED;
-
-struct get_index_u64 {
- uint64_t index;
-} LTTNG_PACKED;
-
-struct literal_numeric {
- int64_t v;
-} LTTNG_PACKED;
-
-struct literal_double {
- double v;
-} LTTNG_PACKED;
-
-enum bytecode_op {
- BYTECODE_OP_UNKNOWN = 0,
-
- BYTECODE_OP_RETURN = 1,
-
- /* binary */
- BYTECODE_OP_MUL = 2,
- BYTECODE_OP_DIV = 3,
- BYTECODE_OP_MOD = 4,
- BYTECODE_OP_PLUS = 5,
- BYTECODE_OP_MINUS = 6,
- BYTECODE_OP_BIT_RSHIFT = 7,
- BYTECODE_OP_BIT_LSHIFT = 8,
- BYTECODE_OP_BIT_AND = 9,
- BYTECODE_OP_BIT_OR = 10,
- BYTECODE_OP_BIT_XOR = 11,
-
- /* binary comparators */
- BYTECODE_OP_EQ = 12,
- BYTECODE_OP_NE = 13,
- BYTECODE_OP_GT = 14,
- BYTECODE_OP_LT = 15,
- BYTECODE_OP_GE = 16,
- BYTECODE_OP_LE = 17,
-
- /* string binary comparator: apply to */
- BYTECODE_OP_EQ_STRING = 18,
- BYTECODE_OP_NE_STRING = 19,
- BYTECODE_OP_GT_STRING = 20,
- BYTECODE_OP_LT_STRING = 21,
- BYTECODE_OP_GE_STRING = 22,
- BYTECODE_OP_LE_STRING = 23,
-
- /* s64 binary comparator */
- BYTECODE_OP_EQ_S64 = 24,
- BYTECODE_OP_NE_S64 = 25,
- BYTECODE_OP_GT_S64 = 26,
- BYTECODE_OP_LT_S64 = 27,
- BYTECODE_OP_GE_S64 = 28,
- BYTECODE_OP_LE_S64 = 29,
-
- /* double binary comparator */
- BYTECODE_OP_EQ_DOUBLE = 30,
- BYTECODE_OP_NE_DOUBLE = 31,
- BYTECODE_OP_GT_DOUBLE = 32,
- BYTECODE_OP_LT_DOUBLE = 33,
- BYTECODE_OP_GE_DOUBLE = 34,
- BYTECODE_OP_LE_DOUBLE = 35,
-
- /* Mixed S64-double binary comparators */
- BYTECODE_OP_EQ_DOUBLE_S64 = 36,
- BYTECODE_OP_NE_DOUBLE_S64 = 37,
- BYTECODE_OP_GT_DOUBLE_S64 = 38,
- BYTECODE_OP_LT_DOUBLE_S64 = 39,
- BYTECODE_OP_GE_DOUBLE_S64 = 40,
- BYTECODE_OP_LE_DOUBLE_S64 = 41,
-
- BYTECODE_OP_EQ_S64_DOUBLE = 42,
- BYTECODE_OP_NE_S64_DOUBLE = 43,
- BYTECODE_OP_GT_S64_DOUBLE = 44,
- BYTECODE_OP_LT_S64_DOUBLE = 45,
- BYTECODE_OP_GE_S64_DOUBLE = 46,
- BYTECODE_OP_LE_S64_DOUBLE = 47,
-
- /* unary */
- BYTECODE_OP_UNARY_PLUS = 48,
- BYTECODE_OP_UNARY_MINUS = 49,
- BYTECODE_OP_UNARY_NOT = 50,
- BYTECODE_OP_UNARY_PLUS_S64 = 51,
- BYTECODE_OP_UNARY_MINUS_S64 = 52,
- BYTECODE_OP_UNARY_NOT_S64 = 53,
- BYTECODE_OP_UNARY_PLUS_DOUBLE = 54,
- BYTECODE_OP_UNARY_MINUS_DOUBLE = 55,
- BYTECODE_OP_UNARY_NOT_DOUBLE = 56,
-
- /* logical */
- BYTECODE_OP_AND = 57,
- BYTECODE_OP_OR = 58,
-
- /* load field ref */
- BYTECODE_OP_LOAD_FIELD_REF = 59,
- BYTECODE_OP_LOAD_FIELD_REF_STRING = 60,
- BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE = 61,
- BYTECODE_OP_LOAD_FIELD_REF_S64 = 62,
- BYTECODE_OP_LOAD_FIELD_REF_DOUBLE = 63,
-
- /* load immediate from operand */
- BYTECODE_OP_LOAD_STRING = 64,
- BYTECODE_OP_LOAD_S64 = 65,
- BYTECODE_OP_LOAD_DOUBLE = 66,
-
- /* cast */
- BYTECODE_OP_CAST_TO_S64 = 67,
- BYTECODE_OP_CAST_DOUBLE_TO_S64 = 68,
- BYTECODE_OP_CAST_NOP = 69,
-
- /* get context ref */
- BYTECODE_OP_GET_CONTEXT_REF = 70,
- BYTECODE_OP_GET_CONTEXT_REF_STRING = 71,
- BYTECODE_OP_GET_CONTEXT_REF_S64 = 72,
- BYTECODE_OP_GET_CONTEXT_REF_DOUBLE = 73,
-
- /* load userspace field ref */
- BYTECODE_OP_LOAD_FIELD_REF_USER_STRING = 74,
- BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75,
-
- /*
- * load immediate star globbing pattern (literal string)
- * from immediate
- */
- BYTECODE_OP_LOAD_STAR_GLOB_STRING = 76,
-
- /* globbing pattern binary operator: apply to */
- BYTECODE_OP_EQ_STAR_GLOB_STRING = 77,
- BYTECODE_OP_NE_STAR_GLOB_STRING = 78,
-
- /*
- * Instructions for recursive traversal through composed types.
- */
- BYTECODE_OP_GET_CONTEXT_ROOT = 79,
- BYTECODE_OP_GET_APP_CONTEXT_ROOT = 80,
- BYTECODE_OP_GET_PAYLOAD_ROOT = 81,
-
- BYTECODE_OP_GET_SYMBOL = 82,
- BYTECODE_OP_GET_SYMBOL_FIELD = 83,
- BYTECODE_OP_GET_INDEX_U16 = 84,
- BYTECODE_OP_GET_INDEX_U64 = 85,
-
- BYTECODE_OP_LOAD_FIELD = 86,
- BYTECODE_OP_LOAD_FIELD_S8 = 87,
- BYTECODE_OP_LOAD_FIELD_S16 = 88,
- BYTECODE_OP_LOAD_FIELD_S32 = 89,
- BYTECODE_OP_LOAD_FIELD_S64 = 90,
- BYTECODE_OP_LOAD_FIELD_U8 = 91,
- BYTECODE_OP_LOAD_FIELD_U16 = 92,
- BYTECODE_OP_LOAD_FIELD_U32 = 93,
- BYTECODE_OP_LOAD_FIELD_U64 = 94,
- BYTECODE_OP_LOAD_FIELD_STRING = 95,
- BYTECODE_OP_LOAD_FIELD_SEQUENCE = 96,
- BYTECODE_OP_LOAD_FIELD_DOUBLE = 97,
-
- BYTECODE_OP_UNARY_BIT_NOT = 98,
-
- BYTECODE_OP_RETURN_S64 = 99,
-
- NR_BYTECODE_OPS,
-};
-
-typedef uint8_t bytecode_opcode_t;
-
-struct load_op {
- bytecode_opcode_t op;
-
- /*
- * data to load. Size known by enum bytecode_opcode_t and null-term
- * char.
- */
- char data[0];
-} LTTNG_PACKED;
-
-struct binary_op {
- bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct unary_op {
- bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-/* skip_offset is absolute from start of bytecode */
-struct logical_op {
- bytecode_opcode_t op;
- uint16_t skip_offset; /* bytecode insn, if skip second test */
-} LTTNG_PACKED;
-
-struct cast_op {
- bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct return_op {
- bytecode_opcode_t op;
-} LTTNG_PACKED;
-
-struct lttng_bytecode_alloc {
- uint32_t alloc_len;
- struct lttng_bytecode b;
-};
-
-int bytecode_init(struct lttng_bytecode_alloc **fb);
-int bytecode_push(struct lttng_bytecode_alloc **fb,
- const void *data, uint32_t align, uint32_t len);
-int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
- struct logical_op *data, uint32_t align, uint32_t len,
- uint16_t *skip_offset);
-struct lttng_bytecode *lttng_bytecode_copy(
- const struct lttng_bytecode *orig_f);
-
-int bytecode_push_get_payload_root(
- struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_context_root(
- struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_app_context_root(
- struct lttng_bytecode_alloc **bytecode);
-int bytecode_push_get_index_u64(
- struct lttng_bytecode_alloc **bytecode, uint64_t index);
-int bytecode_push_get_symbol(
- struct lttng_bytecode_alloc **bytecode,
- struct lttng_bytecode_alloc **bytecode_reloc,
- const char *symbol);
-
-static inline
-unsigned int bytecode_get_len(struct lttng_bytecode *bytecode)
-{
- return bytecode->len;
-}
-
-#endif /* LTTNG_COMMON_BYTECODE_H */
--- /dev/null
+/*
+ * Copyright 2020 EfficiOS, Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_BYTECODE_H
+#define LTTNG_COMMON_BYTECODE_H
+
+#include <stdint.h>
+
+#include "common/macros.hpp"
+#include "common/sessiond-comm/sessiond-comm.hpp"
+
+/*
+ * offsets are absolute from start of bytecode.
+ */
+
+struct field_ref {
+ /* Initially, symbol offset. After link, field offset. */
+ uint16_t offset;
+} LTTNG_PACKED;
+
+struct get_symbol {
+ /* Symbol offset. */
+ uint16_t offset;
+} LTTNG_PACKED;
+
+struct get_index_u16 {
+ uint16_t index;
+} LTTNG_PACKED;
+
+struct get_index_u64 {
+ uint64_t index;
+} LTTNG_PACKED;
+
+struct literal_numeric {
+ int64_t v;
+} LTTNG_PACKED;
+
+struct literal_double {
+ double v;
+} LTTNG_PACKED;
+
+enum bytecode_op {
+ BYTECODE_OP_UNKNOWN = 0,
+
+ BYTECODE_OP_RETURN = 1,
+
+ /* binary */
+ BYTECODE_OP_MUL = 2,
+ BYTECODE_OP_DIV = 3,
+ BYTECODE_OP_MOD = 4,
+ BYTECODE_OP_PLUS = 5,
+ BYTECODE_OP_MINUS = 6,
+ BYTECODE_OP_BIT_RSHIFT = 7,
+ BYTECODE_OP_BIT_LSHIFT = 8,
+ BYTECODE_OP_BIT_AND = 9,
+ BYTECODE_OP_BIT_OR = 10,
+ BYTECODE_OP_BIT_XOR = 11,
+
+ /* binary comparators */
+ BYTECODE_OP_EQ = 12,
+ BYTECODE_OP_NE = 13,
+ BYTECODE_OP_GT = 14,
+ BYTECODE_OP_LT = 15,
+ BYTECODE_OP_GE = 16,
+ BYTECODE_OP_LE = 17,
+
+ /* string binary comparator: apply to */
+ BYTECODE_OP_EQ_STRING = 18,
+ BYTECODE_OP_NE_STRING = 19,
+ BYTECODE_OP_GT_STRING = 20,
+ BYTECODE_OP_LT_STRING = 21,
+ BYTECODE_OP_GE_STRING = 22,
+ BYTECODE_OP_LE_STRING = 23,
+
+ /* s64 binary comparator */
+ BYTECODE_OP_EQ_S64 = 24,
+ BYTECODE_OP_NE_S64 = 25,
+ BYTECODE_OP_GT_S64 = 26,
+ BYTECODE_OP_LT_S64 = 27,
+ BYTECODE_OP_GE_S64 = 28,
+ BYTECODE_OP_LE_S64 = 29,
+
+ /* double binary comparator */
+ BYTECODE_OP_EQ_DOUBLE = 30,
+ BYTECODE_OP_NE_DOUBLE = 31,
+ BYTECODE_OP_GT_DOUBLE = 32,
+ BYTECODE_OP_LT_DOUBLE = 33,
+ BYTECODE_OP_GE_DOUBLE = 34,
+ BYTECODE_OP_LE_DOUBLE = 35,
+
+ /* Mixed S64-double binary comparators */
+ BYTECODE_OP_EQ_DOUBLE_S64 = 36,
+ BYTECODE_OP_NE_DOUBLE_S64 = 37,
+ BYTECODE_OP_GT_DOUBLE_S64 = 38,
+ BYTECODE_OP_LT_DOUBLE_S64 = 39,
+ BYTECODE_OP_GE_DOUBLE_S64 = 40,
+ BYTECODE_OP_LE_DOUBLE_S64 = 41,
+
+ BYTECODE_OP_EQ_S64_DOUBLE = 42,
+ BYTECODE_OP_NE_S64_DOUBLE = 43,
+ BYTECODE_OP_GT_S64_DOUBLE = 44,
+ BYTECODE_OP_LT_S64_DOUBLE = 45,
+ BYTECODE_OP_GE_S64_DOUBLE = 46,
+ BYTECODE_OP_LE_S64_DOUBLE = 47,
+
+ /* unary */
+ BYTECODE_OP_UNARY_PLUS = 48,
+ BYTECODE_OP_UNARY_MINUS = 49,
+ BYTECODE_OP_UNARY_NOT = 50,
+ BYTECODE_OP_UNARY_PLUS_S64 = 51,
+ BYTECODE_OP_UNARY_MINUS_S64 = 52,
+ BYTECODE_OP_UNARY_NOT_S64 = 53,
+ BYTECODE_OP_UNARY_PLUS_DOUBLE = 54,
+ BYTECODE_OP_UNARY_MINUS_DOUBLE = 55,
+ BYTECODE_OP_UNARY_NOT_DOUBLE = 56,
+
+ /* logical */
+ BYTECODE_OP_AND = 57,
+ BYTECODE_OP_OR = 58,
+
+ /* load field ref */
+ BYTECODE_OP_LOAD_FIELD_REF = 59,
+ BYTECODE_OP_LOAD_FIELD_REF_STRING = 60,
+ BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE = 61,
+ BYTECODE_OP_LOAD_FIELD_REF_S64 = 62,
+ BYTECODE_OP_LOAD_FIELD_REF_DOUBLE = 63,
+
+ /* load immediate from operand */
+ BYTECODE_OP_LOAD_STRING = 64,
+ BYTECODE_OP_LOAD_S64 = 65,
+ BYTECODE_OP_LOAD_DOUBLE = 66,
+
+ /* cast */
+ BYTECODE_OP_CAST_TO_S64 = 67,
+ BYTECODE_OP_CAST_DOUBLE_TO_S64 = 68,
+ BYTECODE_OP_CAST_NOP = 69,
+
+ /* get context ref */
+ BYTECODE_OP_GET_CONTEXT_REF = 70,
+ BYTECODE_OP_GET_CONTEXT_REF_STRING = 71,
+ BYTECODE_OP_GET_CONTEXT_REF_S64 = 72,
+ BYTECODE_OP_GET_CONTEXT_REF_DOUBLE = 73,
+
+ /* load userspace field ref */
+ BYTECODE_OP_LOAD_FIELD_REF_USER_STRING = 74,
+ BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE = 75,
+
+ /*
+ * load immediate star globbing pattern (literal string)
+ * from immediate
+ */
+ BYTECODE_OP_LOAD_STAR_GLOB_STRING = 76,
+
+ /* globbing pattern binary operator: apply to */
+ BYTECODE_OP_EQ_STAR_GLOB_STRING = 77,
+ BYTECODE_OP_NE_STAR_GLOB_STRING = 78,
+
+ /*
+ * Instructions for recursive traversal through composed types.
+ */
+ BYTECODE_OP_GET_CONTEXT_ROOT = 79,
+ BYTECODE_OP_GET_APP_CONTEXT_ROOT = 80,
+ BYTECODE_OP_GET_PAYLOAD_ROOT = 81,
+
+ BYTECODE_OP_GET_SYMBOL = 82,
+ BYTECODE_OP_GET_SYMBOL_FIELD = 83,
+ BYTECODE_OP_GET_INDEX_U16 = 84,
+ BYTECODE_OP_GET_INDEX_U64 = 85,
+
+ BYTECODE_OP_LOAD_FIELD = 86,
+ BYTECODE_OP_LOAD_FIELD_S8 = 87,
+ BYTECODE_OP_LOAD_FIELD_S16 = 88,
+ BYTECODE_OP_LOAD_FIELD_S32 = 89,
+ BYTECODE_OP_LOAD_FIELD_S64 = 90,
+ BYTECODE_OP_LOAD_FIELD_U8 = 91,
+ BYTECODE_OP_LOAD_FIELD_U16 = 92,
+ BYTECODE_OP_LOAD_FIELD_U32 = 93,
+ BYTECODE_OP_LOAD_FIELD_U64 = 94,
+ BYTECODE_OP_LOAD_FIELD_STRING = 95,
+ BYTECODE_OP_LOAD_FIELD_SEQUENCE = 96,
+ BYTECODE_OP_LOAD_FIELD_DOUBLE = 97,
+
+ BYTECODE_OP_UNARY_BIT_NOT = 98,
+
+ BYTECODE_OP_RETURN_S64 = 99,
+
+ NR_BYTECODE_OPS,
+};
+
+typedef uint8_t bytecode_opcode_t;
+
+struct load_op {
+ bytecode_opcode_t op;
+
+ /*
+ * data to load. Size known by enum bytecode_opcode_t and null-term
+ * char.
+ */
+ char data[0];
+} LTTNG_PACKED;
+
+struct binary_op {
+ bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct unary_op {
+ bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+/* skip_offset is absolute from start of bytecode */
+struct logical_op {
+ bytecode_opcode_t op;
+ uint16_t skip_offset; /* bytecode insn, if skip second test */
+} LTTNG_PACKED;
+
+struct cast_op {
+ bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct return_op {
+ bytecode_opcode_t op;
+} LTTNG_PACKED;
+
+struct lttng_bytecode_alloc {
+ uint32_t alloc_len;
+ struct lttng_bytecode b;
+};
+
+int bytecode_init(struct lttng_bytecode_alloc **fb);
+int bytecode_push(struct lttng_bytecode_alloc **fb,
+ const void *data, uint32_t align, uint32_t len);
+int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
+ struct logical_op *data, uint32_t align, uint32_t len,
+ uint16_t *skip_offset);
+struct lttng_bytecode *lttng_bytecode_copy(
+ const struct lttng_bytecode *orig_f);
+
+int bytecode_push_get_payload_root(
+ struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_context_root(
+ struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_app_context_root(
+ struct lttng_bytecode_alloc **bytecode);
+int bytecode_push_get_index_u64(
+ struct lttng_bytecode_alloc **bytecode, uint64_t index);
+int bytecode_push_get_symbol(
+ struct lttng_bytecode_alloc **bytecode,
+ struct lttng_bytecode_alloc **bytecode_reloc,
+ const char *symbol);
+
+static inline
+unsigned int bytecode_get_len(struct lttng_bytecode *bytecode)
+{
+ return bytecode->len;
+}
+
+#endif /* LTTNG_COMMON_BYTECODE_H */
*
*/
-#include <common/macros.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/channel-internal.hpp>
#include <lttng/channel.h>
#include <lttng/constant.h>
-#include <lttng/channel-internal.h>
-#include <lttng/userspace-probe-internal.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <assert.h>
-#include <string.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/dynamic-array.h>
-#include <common/buffer-view.h>
+#include <lttng/userspace-probe-internal.hpp>
static enum lttng_error_code flatten_lttng_channels(
struct lttng_dynamic_pointer_array *channels,
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-#include "error.h"
-#include "macros.h"
-#include "runas.h"
-#include "readwrite.h"
-#include "time.h"
-
-#endif /* _COMMON_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#include "error.hpp"
+#include "macros.hpp"
+#include "runas.hpp"
+#include "readwrite.hpp"
+#include "time.hpp"
+
+#endif /* _COMMON_H */
*/
#define _LGPL_SOURCE
-#include <common/compat/fcntl.h>
-#include <common/macros.h>
+#include <common/compat/fcntl.hpp>
+#include <common/macros.hpp>
#include <unistd.h>
#ifdef __linux__
*
*/
-#include <common/compat/directory-handle.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/runas.h>
-#include <common/credentials.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/runas.hpp>
+#include <common/credentials.hpp>
#include <lttng/constant.h>
-#include <common/dynamic-array.h>
+#include <common/dynamic-array.hpp>
#include <sys/types.h>
#include <sys/stat.h>
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_DIRECTORY_HANDLE_H
-#define _COMPAT_DIRECTORY_HANDLE_H
-
-#include <common/credentials.h>
-#include <common/macros.h>
-#include <sys/stat.h>
-#include <urcu/ref.h>
-
-enum lttng_directory_handle_rmdir_recursive_flags {
- LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG = (1U << 0),
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG = (1U << 1),
-};
-
-/*
- * Some platforms, such as Solaris 10, do not support directory file descriptors
- * and their associated functions (*at(...)), which are defined in POSIX.2008.
- *
- * This wrapper provides a handle that is either a copy of a directory's path
- * or a directory file descriptors, depending on the platform's capabilities.
- */
-#ifdef HAVE_DIRFD
-
-struct lttng_directory_handle;
-
-typedef void (*lttng_directory_handle_destroy_cb)(
- struct lttng_directory_handle *handle, void *data);
-
-struct lttng_directory_handle {
- struct urcu_ref ref;
- ino_t directory_inode;
- int dirfd;
- lttng_directory_handle_destroy_cb destroy_cb;
- void *destroy_cb_data;
-};
-
-static inline
-int lttng_directory_handle_get_dirfd(
- const struct lttng_directory_handle *handle)
-{
- return handle->dirfd;
-}
-
-#else
-struct lttng_directory_handle {
- struct urcu_ref ref;
- char *base_path;
-};
-#endif
-
-/*
- * Create a directory handle to the provided path. Passing a NULL path
- * returns a handle to the current working directory.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create(
- const char *path);
-
-/*
- * Create a new directory handle to a path relative to an existing handle.
- *
- * The provided path must already exist. Note that the creation of a
- * subdirectory and the creation of a handle are kept as separate operations
- * to highlight the fact that there is an inherent race between the creation of
- * a directory and the creation of a handle to it.
- *
- * Passing a NULL path effectively copies the original handle.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
- const char *path,
- const struct lttng_directory_handle *ref_handle);
-
-/*
- * Create a new directory handle from an existing directory fd.
- *
- * The new directory handle assumes the ownership of the directory fd.
- * Note that this method should only be used in very specific cases, such as
- * re-creating a directory handle from a dirfd passed over a unix socket.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
- int dirfd);
-
-/*
- * Copy a directory handle.
- *
- * The reference to the directory handle must be released using
- * lttng_directory_handle_put().
- */
-struct lttng_directory_handle *lttng_directory_handle_copy(
- const struct lttng_directory_handle *handle);
-
-/*
- * Acquire a reference to a directory handle.
- */
-bool lttng_directory_handle_get(struct lttng_directory_handle *handle);
-
-/*
- * Release a reference to a directory handle.
- */
-void lttng_directory_handle_put(struct lttng_directory_handle *handle);
-
-/*
- * Create a subdirectory relative to a directory handle.
- */
-int lttng_directory_handle_create_subdirectory(
- const struct lttng_directory_handle *handle,
- const char *subdirectory,
- mode_t mode);
-
-/*
- * Create a subdirectory relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_create_subdirectory_as_user(
- const struct lttng_directory_handle *handle,
- const char *subdirectory,
- mode_t mode, const struct lttng_credentials *creds);
-
-/*
- * Recursively create a directory relative to a directory handle.
- */
-int lttng_directory_handle_create_subdirectory_recursive(
- const struct lttng_directory_handle *handle,
- const char *subdirectory_path,
- mode_t mode);
-
-/*
- * Recursively create a directory relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_create_subdirectory_recursive_as_user(
- const struct lttng_directory_handle *handle,
- const char *subdirectory_path,
- mode_t mode, const struct lttng_credentials *creds);
-
-/*
- * Open a file descriptor to a path relative to a directory handle.
- */
-int lttng_directory_handle_open_file(
- const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode);
-
-/*
- * Open a file descriptor to a path relative to a directory handle
- * as a given user.
- */
-int lttng_directory_handle_open_file_as_user(
- const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode,
- const struct lttng_credentials *creds);
-
-/*
- * Unlink a file to a path relative to a directory handle.
- */
-int lttng_directory_handle_unlink_file(
- const struct lttng_directory_handle *handle,
- const char *filename);
-
-/*
- * Unlink a file to a path relative to a directory handle as a given user.
- */
-int lttng_directory_handle_unlink_file_as_user(
- const struct lttng_directory_handle *handle,
- const char *filename,
- const struct lttng_credentials *creds);
-
-/*
- * Rename a file from a path relative to a directory handle to a new
- * name relative to another directory handle.
- */
-int lttng_directory_handle_rename(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name);
-
-/*
- * Rename a file from a path relative to a directory handle to a new
- * name relative to another directory handle as a given user.
- */
-int lttng_directory_handle_rename_as_user(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name,
- const struct lttng_credentials *creds);
-
-/*
- * Remove a subdirectory relative to a directory handle.
- */
-int lttng_directory_handle_remove_subdirectory(
- const struct lttng_directory_handle *handle,
- const char *name);
-
-/*
- * Remove a subdirectory relative to a directory handle as a given user.
- */
-int lttng_directory_handle_remove_subdirectory_as_user(
- const struct lttng_directory_handle *handle,
- const char *name,
- const struct lttng_credentials *creds);
-
-/*
- * Remove a subdirectory and remove its contents if it only
- * consists in empty directories.
- * @flags: enum lttng_directory_handle_rmdir_recursive_flags
- */
-int lttng_directory_handle_remove_subdirectory_recursive(
- const struct lttng_directory_handle *handle,
- const char *name, int flags);
-
-/*
- * Remove a subdirectory and remove its contents if it only
- * consists in empty directories as a given user.
- * @flags: enum lttng_directory_handle_rmdir_recursive_flags
- */
-int lttng_directory_handle_remove_subdirectory_recursive_as_user(
- const struct lttng_directory_handle *handle,
- const char *name,
- const struct lttng_credentials *creds,
- int flags);
-
-/*
- * stat() a file relative to a directory handle.
- */
-int lttng_directory_handle_stat(
- const struct lttng_directory_handle *handle,
- const char *name,
- struct stat *stat_buf);
-
-/*
- * Returns true if this directory handle is backed by a file
- * descriptor, false otherwise.
- */
-bool lttng_directory_handle_uses_fd(
- const struct lttng_directory_handle *handle);
-
-/*
- * Compare two directory handles.
- *
- * Returns true if the two directory handles are equal, false otherwise.
- */
-bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
- const struct lttng_directory_handle *rhs);
-
-
-#endif /* _COMPAT_PATH_HANDLE_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_DIRECTORY_HANDLE_H
+#define _COMPAT_DIRECTORY_HANDLE_H
+
+#include <common/credentials.hpp>
+#include <common/macros.hpp>
+#include <sys/stat.h>
+#include <urcu/ref.h>
+
+enum lttng_directory_handle_rmdir_recursive_flags {
+ LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG = (1U << 0),
+ LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG = (1U << 1),
+};
+
+/*
+ * Some platforms, such as Solaris 10, do not support directory file descriptors
+ * and their associated functions (*at(...)), which are defined in POSIX.2008.
+ *
+ * This wrapper provides a handle that is either a copy of a directory's path
+ * or a directory file descriptors, depending on the platform's capabilities.
+ */
+#ifdef HAVE_DIRFD
+
+struct lttng_directory_handle;
+
+typedef void (*lttng_directory_handle_destroy_cb)(
+ struct lttng_directory_handle *handle, void *data);
+
+struct lttng_directory_handle {
+ struct urcu_ref ref;
+ ino_t directory_inode;
+ int dirfd;
+ lttng_directory_handle_destroy_cb destroy_cb;
+ void *destroy_cb_data;
+};
+
+static inline
+int lttng_directory_handle_get_dirfd(
+ const struct lttng_directory_handle *handle)
+{
+ return handle->dirfd;
+}
+
+#else
+struct lttng_directory_handle {
+ struct urcu_ref ref;
+ char *base_path;
+};
+#endif
+
+/*
+ * Create a directory handle to the provided path. Passing a NULL path
+ * returns a handle to the current working directory.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create(
+ const char *path);
+
+/*
+ * Create a new directory handle to a path relative to an existing handle.
+ *
+ * The provided path must already exist. Note that the creation of a
+ * subdirectory and the creation of a handle are kept as separate operations
+ * to highlight the fact that there is an inherent race between the creation of
+ * a directory and the creation of a handle to it.
+ *
+ * Passing a NULL path effectively copies the original handle.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
+ const char *path,
+ const struct lttng_directory_handle *ref_handle);
+
+/*
+ * Create a new directory handle from an existing directory fd.
+ *
+ * The new directory handle assumes the ownership of the directory fd.
+ * Note that this method should only be used in very specific cases, such as
+ * re-creating a directory handle from a dirfd passed over a unix socket.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
+ int dirfd);
+
+/*
+ * Copy a directory handle.
+ *
+ * The reference to the directory handle must be released using
+ * lttng_directory_handle_put().
+ */
+struct lttng_directory_handle *lttng_directory_handle_copy(
+ const struct lttng_directory_handle *handle);
+
+/*
+ * Acquire a reference to a directory handle.
+ */
+bool lttng_directory_handle_get(struct lttng_directory_handle *handle);
+
+/*
+ * Release a reference to a directory handle.
+ */
+void lttng_directory_handle_put(struct lttng_directory_handle *handle);
+
+/*
+ * Create a subdirectory relative to a directory handle.
+ */
+int lttng_directory_handle_create_subdirectory(
+ const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ mode_t mode);
+
+/*
+ * Create a subdirectory relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_create_subdirectory_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ mode_t mode, const struct lttng_credentials *creds);
+
+/*
+ * Recursively create a directory relative to a directory handle.
+ */
+int lttng_directory_handle_create_subdirectory_recursive(
+ const struct lttng_directory_handle *handle,
+ const char *subdirectory_path,
+ mode_t mode);
+
+/*
+ * Recursively create a directory relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_create_subdirectory_recursive_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *subdirectory_path,
+ mode_t mode, const struct lttng_credentials *creds);
+
+/*
+ * Open a file descriptor to a path relative to a directory handle.
+ */
+int lttng_directory_handle_open_file(
+ const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags, mode_t mode);
+
+/*
+ * Open a file descriptor to a path relative to a directory handle
+ * as a given user.
+ */
+int lttng_directory_handle_open_file_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags, mode_t mode,
+ const struct lttng_credentials *creds);
+
+/*
+ * Unlink a file to a path relative to a directory handle.
+ */
+int lttng_directory_handle_unlink_file(
+ const struct lttng_directory_handle *handle,
+ const char *filename);
+
+/*
+ * Unlink a file to a path relative to a directory handle as a given user.
+ */
+int lttng_directory_handle_unlink_file_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *filename,
+ const struct lttng_credentials *creds);
+
+/*
+ * Rename a file from a path relative to a directory handle to a new
+ * name relative to another directory handle.
+ */
+int lttng_directory_handle_rename(
+ const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name);
+
+/*
+ * Rename a file from a path relative to a directory handle to a new
+ * name relative to another directory handle as a given user.
+ */
+int lttng_directory_handle_rename_as_user(
+ const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name,
+ const struct lttng_credentials *creds);
+
+/*
+ * Remove a subdirectory relative to a directory handle.
+ */
+int lttng_directory_handle_remove_subdirectory(
+ const struct lttng_directory_handle *handle,
+ const char *name);
+
+/*
+ * Remove a subdirectory relative to a directory handle as a given user.
+ */
+int lttng_directory_handle_remove_subdirectory_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *name,
+ const struct lttng_credentials *creds);
+
+/*
+ * Remove a subdirectory and remove its contents if it only
+ * consists in empty directories.
+ * @flags: enum lttng_directory_handle_rmdir_recursive_flags
+ */
+int lttng_directory_handle_remove_subdirectory_recursive(
+ const struct lttng_directory_handle *handle,
+ const char *name, int flags);
+
+/*
+ * Remove a subdirectory and remove its contents if it only
+ * consists in empty directories as a given user.
+ * @flags: enum lttng_directory_handle_rmdir_recursive_flags
+ */
+int lttng_directory_handle_remove_subdirectory_recursive_as_user(
+ const struct lttng_directory_handle *handle,
+ const char *name,
+ const struct lttng_credentials *creds,
+ int flags);
+
+/*
+ * stat() a file relative to a directory handle.
+ */
+int lttng_directory_handle_stat(
+ const struct lttng_directory_handle *handle,
+ const char *name,
+ struct stat *stat_buf);
+
+/*
+ * Returns true if this directory handle is backed by a file
+ * descriptor, false otherwise.
+ */
+bool lttng_directory_handle_uses_fd(
+ const struct lttng_directory_handle *handle);
+
+/*
+ * Compare two directory handles.
+ *
+ * Returns true if the two directory handles are equal, false otherwise.
+ */
+bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
+ const struct lttng_directory_handle *rhs);
+
+
+#endif /* _COMPAT_PATH_HANDLE_H */
+++ /dev/null
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_DIRENT_H
-#define _COMPAT_DIRENT_H
-
-#include <dirent.h>
-
-#ifdef HAVE_DIRFD
-static inline
-int lttng_dirfd(DIR *dir) {
- return dirfd(dir);
-}
-#else
-# ifndef __XOPEN_OR_POSIX
-static inline
-int lttng_dirfd(DIR *dir) {
- return dir->dd_fd;
-}
-# else
-static inline
-int lttng_dirfd(DIR *dir) {
- return dir->d_fd;
-}
-# endif
-#endif
-
-#endif /* _COMPAT_DIRENT_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_DIRENT_H
+#define _COMPAT_DIRENT_H
+
+#include <dirent.h>
+
+#ifdef HAVE_DIRFD
+static inline
+int lttng_dirfd(DIR *dir) {
+ return dirfd(dir);
+}
+#else
+# ifndef __XOPEN_OR_POSIX
+static inline
+int lttng_dirfd(DIR *dir) {
+ return dir->dd_fd;
+}
+# else
+static inline
+int lttng_dirfd(DIR *dir) {
+ return dir->d_fd;
+}
+# endif
+#endif
+
+#endif /* _COMPAT_DIRENT_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-/*
- * This compat header provides the following defines:
- *
- * LITTLE_ENDIAN
- * BIG_ENDIAN
- * BYTE_ORDER
- *
- * And functions / macros :
- *
- * bswap_16()
- * bswap_32()
- * bswap_64()
- *
- * htobe16()
- * htole16()
- * be16toh()
- * le16toh()
- *
- * htobe32()
- * htole32()
- * be32toh()
- * le32toh()
- *
- * htobe64()
- * htole64()
- * be64toh()
- * le64toh()
- */
-
-#ifndef _COMPAT_ENDIAN_H
-#define _COMPAT_ENDIAN_H
-
-#if defined(__linux__) || defined(__CYGWIN__)
-#include <endian.h>
-#include <byteswap.h>
-
-/*
- * htobe/betoh are not defined for glibc <2.9, so add them
- * explicitly if they are missing.
- */
-#ifdef __USE_BSD
-/* Conversion interfaces. */
-# include <byteswap.h>
-
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# ifndef htobe16
-# define htobe16(x) __bswap_16(x)
-# endif
-# ifndef htole16
-# define htole16(x) (x)
-# endif
-# ifndef be16toh
-# define be16toh(x) __bswap_16(x)
-# endif
-# ifndef le16toh
-# define le16toh(x) (x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) __bswap_32(x)
-# endif
-# ifndef htole32
-# define htole32(x) (x)
-# endif
-# ifndef be32toh
-# define be32toh(x) __bswap_32(x)
-# endif
-# ifndef le32toh
-# define le32toh(x) (x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) __bswap_64(x)
-# endif
-# ifndef htole64
-# define htole64(x) (x)
-# endif
-# ifndef be64toh
-# define be64toh(x) __bswap_64(x)
-# endif
-# ifndef le64toh
-# define le64toh(x) (x)
-# endif
-
-# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-# ifndef htobe16
-# define htobe16(x) (x)
-# endif
-# ifndef htole16
-# define htole16(x) __bswap_16(x)
-# endif
-# ifndef be16toh
-# define be16toh(x) (x)
-# endif
-# ifndef le16toh
-# define le16toh(x) __bswap_16(x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) (x)
-# endif
-# ifndef htole32
-# define htole32(x) __bswap_32(x)
-# endif
-# ifndef be32toh
-# define be32toh(x) (x)
-# endif
-# ifndef le32toh
-# define le32toh(x) __bswap_32(x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) (x)
-# endif
-# ifndef htole64
-# define htole64(x) __bswap_64(x)
-# endif
-# ifndef be64toh
-# define be64toh(x) (x)
-# endif
-# ifndef le64toh
-# define le64toh(x) __bswap_64(x)
-# endif
-
-# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
-#endif /* __USE_BSD */
-
-#elif defined(__FreeBSD__)
-#include <sys/endian.h>
-
-#define bswap_16(x) bswap16(x)
-#define bswap_32(x) bswap32(x)
-#define bswap_64(x) bswap64(x)
-
-#elif defined(__sun__)
-#include <sys/byteorder.h>
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif /* __BIG_ENDIAN */
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif /* __LITTLE_ENDIAN */
-
-#ifdef _LITTLE_ENDIAN
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif /* _LITTLE_ENDIAN */
-#ifdef _BIG_ENDIAN
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif /* _BIG_ENDIAN */
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#define betoh16(x) BE_16(x)
-#define letoh16(x) LE_16(x)
-#define betoh32(x) BE_32(x)
-#define letoh32(x) LE_32(x)
-#define betoh64(x) BE_64(x)
-#define letoh64(x) LE_64(x)
-#define htobe16(x) BE_16(x)
-#define be16toh(x) BE_16(x)
-#define htobe32(x) BE_32(x)
-#define be32toh(x) BE_32(x)
-#define htobe64(x) BE_64(x)
-#define be64toh(x) BE_64(x)
-
-#elif defined(__APPLE__)
-# include <machine/endian.h>
-# include <libkern/OSByteOrder.h>
-
-# if BYTE_ORDER == LITTLE_ENDIAN
-# define htobe16(x) OSSwapConstInt16(x)
-# define htole16(x) (x)
-# define be16toh(x) OSSwapConstInt16(x)
-# define le16toh(x) (x)
-
-# define htobe32(x) OSSwapConstInt32(x)
-# define htole32(x) (x)
-# define be32toh(x) OSSwapConstInt32(x)
-# define le32toh(x) (x)
-
-# define htobe64(x) OSSwapConstInt64(x)
-# define htole64(x) (x)
-# define be64toh(x) OSSwapConstInt64(x)
-# define le64toh(x) (x)
-
-# else /* BYTE_ORDER == LITTLE_ENDIAN */
-# define htobe16(x) (x)
-# define htole16(x) OSSwapConstInt16(x)
-# define be16toh(x) (x)
-# define le16toh(x) OSSwapConstInt16(x)
-
-# define htobe32(x) (x)
-# define htole32(x) OSSwapConstInt32(x)
-# define be32toh(x) (x)
-# define le32toh(x) OSSwapConstInt32(x)
-
-# define htobe64(x) (x)
-# define htole64(x) OSSwapConstInt64(x)
-# define be64toh(x) (x)
-# define le64toh(x) OSSwapConstInt64(x)
-# endif
-
-#else
-#error "Please add support for your OS."
-#endif
-
-#endif /* _COMPAT_ENDIAN_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+/*
+ * This compat header provides the following defines:
+ *
+ * LITTLE_ENDIAN
+ * BIG_ENDIAN
+ * BYTE_ORDER
+ *
+ * And functions / macros :
+ *
+ * bswap_16()
+ * bswap_32()
+ * bswap_64()
+ *
+ * htobe16()
+ * htole16()
+ * be16toh()
+ * le16toh()
+ *
+ * htobe32()
+ * htole32()
+ * be32toh()
+ * le32toh()
+ *
+ * htobe64()
+ * htole64()
+ * be64toh()
+ * le64toh()
+ */
+
+#ifndef _COMPAT_ENDIAN_H
+#define _COMPAT_ENDIAN_H
+
+#if defined(__linux__) || defined(__CYGWIN__)
+#include <endian.h>
+#include <byteswap.h>
+
+/*
+ * htobe/betoh are not defined for glibc <2.9, so add them
+ * explicitly if they are missing.
+ */
+#ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef htobe16
+# define htobe16(x) __bswap_16(x)
+# endif
+# ifndef htole16
+# define htole16(x) (x)
+# endif
+# ifndef be16toh
+# define be16toh(x) __bswap_16(x)
+# endif
+# ifndef le16toh
+# define le16toh(x) (x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) __bswap_32(x)
+# endif
+# ifndef htole32
+# define htole32(x) (x)
+# endif
+# ifndef be32toh
+# define be32toh(x) __bswap_32(x)
+# endif
+# ifndef le32toh
+# define le32toh(x) (x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) __bswap_64(x)
+# endif
+# ifndef htole64
+# define htole64(x) (x)
+# endif
+# ifndef be64toh
+# define be64toh(x) __bswap_64(x)
+# endif
+# ifndef le64toh
+# define le64toh(x) (x)
+# endif
+
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+# ifndef htobe16
+# define htobe16(x) (x)
+# endif
+# ifndef htole16
+# define htole16(x) __bswap_16(x)
+# endif
+# ifndef be16toh
+# define be16toh(x) (x)
+# endif
+# ifndef le16toh
+# define le16toh(x) __bswap_16(x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) (x)
+# endif
+# ifndef htole32
+# define htole32(x) __bswap_32(x)
+# endif
+# ifndef be32toh
+# define be32toh(x) (x)
+# endif
+# ifndef le32toh
+# define le32toh(x) __bswap_32(x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) (x)
+# endif
+# ifndef htole64
+# define htole64(x) __bswap_64(x)
+# endif
+# ifndef be64toh
+# define be64toh(x) (x)
+# endif
+# ifndef le64toh
+# define le64toh(x) __bswap_64(x)
+# endif
+
+# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#endif /* __USE_BSD */
+
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+
+#define bswap_16(x) bswap16(x)
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+
+#elif defined(__sun__)
+#include <sys/byteorder.h>
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif /* __BIG_ENDIAN */
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif /* __LITTLE_ENDIAN */
+
+#ifdef _LITTLE_ENDIAN
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif /* _LITTLE_ENDIAN */
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif /* _BIG_ENDIAN */
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#define betoh16(x) BE_16(x)
+#define letoh16(x) LE_16(x)
+#define betoh32(x) BE_32(x)
+#define letoh32(x) LE_32(x)
+#define betoh64(x) BE_64(x)
+#define letoh64(x) LE_64(x)
+#define htobe16(x) BE_16(x)
+#define be16toh(x) BE_16(x)
+#define htobe32(x) BE_32(x)
+#define be32toh(x) BE_32(x)
+#define htobe64(x) BE_64(x)
+#define be64toh(x) BE_64(x)
+
+#elif defined(__APPLE__)
+# include <machine/endian.h>
+# include <libkern/OSByteOrder.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define htobe16(x) OSSwapConstInt16(x)
+# define htole16(x) (x)
+# define be16toh(x) OSSwapConstInt16(x)
+# define le16toh(x) (x)
+
+# define htobe32(x) OSSwapConstInt32(x)
+# define htole32(x) (x)
+# define be32toh(x) OSSwapConstInt32(x)
+# define le32toh(x) (x)
+
+# define htobe64(x) OSSwapConstInt64(x)
+# define htole64(x) (x)
+# define be64toh(x) OSSwapConstInt64(x)
+# define le64toh(x) (x)
+
+# else /* BYTE_ORDER == LITTLE_ENDIAN */
+# define htobe16(x) (x)
+# define htole16(x) OSSwapConstInt16(x)
+# define be16toh(x) (x)
+# define le16toh(x) OSSwapConstInt16(x)
+
+# define htobe32(x) (x)
+# define htole32(x) OSSwapConstInt32(x)
+# define be32toh(x) (x)
+# define le32toh(x) OSSwapConstInt32(x)
+
+# define htobe64(x) (x)
+# define htole64(x) OSSwapConstInt64(x)
+# define be64toh(x) (x)
+# define le64toh(x) OSSwapConstInt64(x)
+# endif
+
+#else
+#error "Please add support for your OS."
+#endif
+
+#endif /* _COMPAT_ENDIAN_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_ERRNO_H
-#define _COMPAT_ERRNO_H
-
-#include <errno.h>
-
-/* Missing on FreeBSD */
-#ifndef ENODATA
-#define ENODATA ENOATTR
-#endif
-
-#endif /* _COMPAT_ERRNO_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_ERRNO_H
+#define _COMPAT_ERRNO_H
+
+#include <errno.h>
+
+/* Missing on FreeBSD */
+#ifndef ENODATA
+#define ENODATA ENOATTR
+#endif
+
+#endif /* _COMPAT_ERRNO_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_FCNTL_H
-#define _COMPAT_FCNTL_H
-
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include <common/compat/errno.h>
-
-#if (defined(__CYGWIN__))
-typedef long long off64_t;
-#endif
-
-#if (defined(__FreeBSD__) || defined(__sun__))
-typedef off64_t loff_t;
-#endif
-
-#ifdef __linux__
-extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
- unsigned int flags);
-#define lttng_sync_file_range(fd, offset, nbytes, flags) \
- compat_sync_file_range(fd, offset, nbytes, flags)
-
-#endif /* __linux__ */
-
-#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrapper.
- */
-#define SYNC_FILE_RANGE_WAIT_AFTER 0
-#define SYNC_FILE_RANGE_WAIT_BEFORE 0
-#define SYNC_FILE_RANGE_WRITE 0
-
-static inline int lttng_sync_file_range(
- int fd __attribute__((unused)),
- off64_t offset __attribute__((unused)),
- off64_t nbytes __attribute__((unused)),
- unsigned int flags __attribute__((unused)))
-{
- return -ENOSYS;
-}
-#endif
-
-#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrappers.
- */
-#define SPLICE_F_MOVE 0
-#define SPLICE_F_NONBLOCK 0
-#define SPLICE_F_MORE 0
-#define SPLICE_F_GIFT 0
-
-static inline ssize_t splice(
- int fd_in __attribute__((unused)),
- loff_t *off_in __attribute__((unused)),
- int fd_out __attribute__((unused)),
- loff_t *off_out __attribute__((unused)),
- size_t len __attribute__((unused)),
- unsigned int flags __attribute__((unused)))
-{
- return -ENOSYS;
-}
-#endif
-
-#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
-#error "Please add support for your OS."
-#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
-
-#endif /* _COMPAT_FCNTL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_FCNTL_H
+#define _COMPAT_FCNTL_H
+
+#include <fcntl.h>
+#include <sys/types.h>
+
+#include <common/compat/errno.hpp>
+
+#if (defined(__CYGWIN__))
+typedef long long off64_t;
+#endif
+
+#if (defined(__FreeBSD__) || defined(__sun__))
+typedef off64_t loff_t;
+#endif
+
+#ifdef __linux__
+extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
+ unsigned int flags);
+#define lttng_sync_file_range(fd, offset, nbytes, flags) \
+ compat_sync_file_range(fd, offset, nbytes, flags)
+
+#endif /* __linux__ */
+
+#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
+/*
+ * Possible flags under Linux. Simply nullify them and avoid wrapper.
+ */
+#define SYNC_FILE_RANGE_WAIT_AFTER 0
+#define SYNC_FILE_RANGE_WAIT_BEFORE 0
+#define SYNC_FILE_RANGE_WRITE 0
+
+static inline int lttng_sync_file_range(
+ int fd __attribute__((unused)),
+ off64_t offset __attribute__((unused)),
+ off64_t nbytes __attribute__((unused)),
+ unsigned int flags __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+#endif
+
+#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
+/*
+ * Possible flags under Linux. Simply nullify them and avoid wrappers.
+ */
+#define SPLICE_F_MOVE 0
+#define SPLICE_F_NONBLOCK 0
+#define SPLICE_F_MORE 0
+#define SPLICE_F_GIFT 0
+
+static inline ssize_t splice(
+ int fd_in __attribute__((unused)),
+ loff_t *off_in __attribute__((unused)),
+ int fd_out __attribute__((unused)),
+ loff_t *off_out __attribute__((unused)),
+ size_t len __attribute__((unused)),
+ unsigned int flags __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+#endif
+
+#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
+#error "Please add support for your OS."
+#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
+
+#endif /* _COMPAT_FCNTL_H */
+++ /dev/null
-#ifndef _COMPAT_GETENV_H
-#define _COMPAT_GETENV_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <common/error.h>
-
-static inline
-int lttng_is_setuid_setgid(void)
-{
- return geteuid() != getuid() || getegid() != getgid();
-}
-
-static inline
-char *lttng_secure_getenv(const char *name)
-{
- if (lttng_is_setuid_setgid()) {
- WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
- name);
- return NULL;
- }
- return getenv(name);
-}
-
-#endif /* _COMPAT_GETENV_H */
--- /dev/null
+#ifndef _COMPAT_GETENV_H
+#define _COMPAT_GETENV_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <common/error.hpp>
+
+static inline
+int lttng_is_setuid_setgid(void)
+{
+ return geteuid() != getuid() || getegid() != getgid();
+}
+
+static inline
+char *lttng_secure_getenv(const char *name)
+{
+ if (lttng_is_setuid_setgid()) {
+ WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
+ name);
+ return NULL;
+ }
+ return getenv(name);
+}
+
+#endif /* _COMPAT_GETENV_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_MMAN_H
-#define _COMPAT_MMAN_H
-
-#include <sys/mman.h>
-
-#ifdef __linux__
-
-#elif defined(__FreeBSD__)
-
-#define MAP_GROWSDOWN 0
-#define MAP_ANONYMOUS MAP_ANON
-
-#elif defined(__CYGWIN__) || defined(__sun__)
-
-#define MAP_GROWSDOWN 0
-
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ */
-
-#endif /* _COMPAT_MMAN_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_MMAN_H
+#define _COMPAT_MMAN_H
+
+#include <sys/mman.h>
+
+#ifdef __linux__
+
+#elif defined(__FreeBSD__)
+
+#define MAP_GROWSDOWN 0
+#define MAP_ANONYMOUS MAP_ANON
+
+#elif defined(__CYGWIN__) || defined(__sun__)
+
+#define MAP_GROWSDOWN 0
+
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ */
+
+#endif /* _COMPAT_MMAN_H */
+++ /dev/null
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_NETDB_H
-#define _COMPAT_NETDB_H
-
-#include <netdb.h>
-
-#ifdef HAVE_GETHOSTBYNAME2
-static inline
-struct hostent *lttng_gethostbyname2(const char *name, int af) {
- return gethostbyname2(name, af);
-}
-#elif HAVE_GETIPNODEBYNAME
-static inline
-struct hostent *lttng_gethostbyname2(const char *name, int af) {
- int unused;
-
- return getipnodebyname(name, af, AI_DEFAULT, &unused);
-}
-#else
-# error "Missing compat for gethostbyname2()"
-#endif
-
-#endif /* _COMPAT_NETDB_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_NETDB_H
+#define _COMPAT_NETDB_H
+
+#include <netdb.h>
+
+#ifdef HAVE_GETHOSTBYNAME2
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+ return gethostbyname2(name, af);
+}
+#elif HAVE_GETIPNODEBYNAME
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+ int unused;
+
+ return getipnodebyname(name, af, AI_DEFAULT, &unused);
+}
+#else
+# error "Missing compat for gethostbyname2()"
+#endif
+
+#endif /* _COMPAT_NETDB_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PATH_H
-#define _COMPAT_PATH_H
-
-/* Build platform's preferred path separator. */
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define LTTNG_PATH_SEPARATOR '\\'
-#else
-#define LTTNG_PATH_SEPARATOR '/'
-#endif
-
-#endif /* _COMPAT_PATH_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PATH_H
+#define _COMPAT_PATH_H
+
+/* Build platform's preferred path separator. */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define LTTNG_PATH_SEPARATOR '\\'
+#else
+#define LTTNG_PATH_SEPARATOR '/'
+#endif
+
+#endif /* _COMPAT_PATH_H */
+++ /dev/null
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PATHS_H
-#define _COMPAT_PATHS_H
-
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#else
-# define _PATH_DEVNULL "/dev/null"
-#endif
-
-#endif /* _COMPAT_PATHS_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PATHS_H
+#define _COMPAT_PATHS_H
+
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#else
+# define _PATH_DEVNULL "/dev/null"
+#endif
+
+#endif /* _COMPAT_PATHS_H */
#include <stdlib.h>
#include <stdbool.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
-#include "poll.h"
+#include "poll.hpp"
#ifdef HAVE_EPOLL
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTT_POLL_H
-#define _LTT_POLL_H
-
-#include <string.h>
-#include <unistd.h>
-
-#include <common/common.h>
-
-/*
- * Used by lttng_poll_clean to free the events structure in a lttng_poll_event.
- */
-static inline void __lttng_poll_free(void *events)
-{
- free(events);
-}
-
-/*
- * epoll(7) implementation.
- */
-#ifdef HAVE_EPOLL
-#include <sys/epoll.h>
-#include <stdio.h>
-#include <features.h>
-#include <common/compat/fcntl.h>
-
-/* See man epoll(7) for this define path */
-#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
-
-enum {
- /* Polling variables compatibility for epoll */
- LPOLLIN = EPOLLIN,
- LPOLLPRI = EPOLLPRI,
- LPOLLOUT = EPOLLOUT,
- LPOLLRDNORM = EPOLLRDNORM,
- LPOLLRDBAND = EPOLLRDBAND,
- LPOLLWRNORM = EPOLLWRNORM,
- LPOLLWRBAND = EPOLLWRBAND,
- LPOLLMSG = EPOLLMSG,
- LPOLLERR = EPOLLERR,
- LPOLLHUP = EPOLLHUP,
- LPOLLNVAL = EPOLLHUP,
- LPOLLRDHUP = EPOLLRDHUP,
- /* Close on exec feature of epoll */
-#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
- LTTNG_CLOEXEC = EPOLL_CLOEXEC,
-#else
- /*
- * EPOLL_CLOEXEC was added in glibc 2.8 (usually used in conjunction with
- * epoll_create1(..)), but since neither EPOLL_CLOEXEC exists nor
- * epoll_create1(..), we set it to FD_CLOEXEC so that we can pass it
- * directly to fcntl(..) instead.
- */
- LTTNG_CLOEXEC = FD_CLOEXEC,
-#endif
-};
-
-struct compat_epoll_event {
- int epfd;
- uint32_t nb_fd; /* Current number of fd in events */
- uint32_t alloc_size; /* Size of events array */
- uint32_t init_size; /* Initial size of events array */
- struct epoll_event *events;
-};
-#define lttng_poll_event compat_epoll_event
-
-static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
- int index, uint32_t nb_fd)
-{
- LTTNG_ASSERT(events);
- LTTNG_ASSERT(index != nb_fd);
-
- if (index == 0 || nb_fd == 0) {
- return -1;
- } else {
- return events->events[index - 1].data.fd;
- }
-}
-
-/*
- * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
- * being the index of the events array.
- */
-#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->events[i].data.fd
-#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->events[i].events
-#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->nb_fd
-#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->events_size
-#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
- __lttng_epoll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
-
-/* Create the epoll set. */
-extern int compat_epoll_create(struct lttng_poll_event *events,
- int size, int flags);
-#define lttng_poll_create(events, size, flags) \
- compat_epoll_create(events, size, flags)
-
-#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
-static inline int compat_glibc_epoll_create(int size __attribute__((unused)),
- int flags)
-{
- return epoll_create1(flags);
-}
-#else
-static inline int compat_glibc_epoll_create(int size, int flags)
-{
- /*
- * epoll_create1 was added in glibc 2.9, but unfortunatly reverting to
- * epoll_create(..) also means that we lose the possibility to
- * directly set the EPOLL_CLOEXEC, so try and do it anyway but through
- * fcntl(..).
- */
- int efd = epoll_create(size);
- LTTNG_ASSERT(fcntl(efd, F_SETFD, flags) != -1);
- return efd;
-}
-#endif
-
-/*
- * Wait on epoll set with the number of fd registered to the lttng_poll_event
- * data structure (events).
- */
-extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible);
-#define lttng_poll_wait(events, timeout) \
- compat_epoll_wait(events, timeout, false)
-#define lttng_poll_wait_interruptible(events, timeout) \
- compat_epoll_wait(events, timeout, true)
-
-/*
- * Add a fd to the epoll set and resize the epoll_event structure if needed.
- */
-extern int compat_epoll_add(struct lttng_poll_event *events,
- int fd, uint32_t req_events);
-#define lttng_poll_add(events, fd, req_events) \
- compat_epoll_add(events, fd, req_events)
-
-/*
- * Remove a fd from the epoll set.
- */
-extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
-#define lttng_poll_del(events, fd) \
- compat_epoll_del(events, fd)
-
-/*
- * Modify an fd's events in the epoll set.
- */
-extern int compat_epoll_mod(struct lttng_poll_event *events,
- int fd, uint32_t req_events);
-#define lttng_poll_mod(events, fd, req_events) \
- compat_epoll_mod(events, fd, req_events)
-
-/*
- * Set up the poll set limits variable poll_max_size
- */
-extern int compat_epoll_set_max_size(void);
-#define lttng_poll_set_max_size() \
- compat_epoll_set_max_size()
-
-/*
- * This function memset with zero the structure since it can be reused at each
- * round of a main loop. Being in a loop and using a non static number of fds,
- * this function must be called to insure coherent events with associted fds.
- */
-static inline void lttng_poll_reset(struct lttng_poll_event *events)
-{
- if (events && events->events) {
- memset(events->events, 0,
- events->nb_fd * sizeof(struct epoll_event));
- }
-}
-
-/*
- * Initialize an already allocated poll event data structure. For epoll(), the
- * epfd is set to -1 to indicate that it's not usable.
- */
-static inline void lttng_poll_init(struct lttng_poll_event *events)
-{
- memset(events, 0, sizeof(struct lttng_poll_event));
- /* Set fd to -1 so if clean before created, we don't close 0. */
- events->epfd = -1;
-}
-
-/*
- * Clean the events structure of a lttng_poll_event. It's the caller
- * responsability to free the lttng_poll_event memory.
- */
-static inline void lttng_poll_clean(struct lttng_poll_event *events)
-{
- int ret;
-
- if (!events) {
- return;
- }
-
- if (events->epfd >= 0) {
- ret = close(events->epfd);
- if (ret) {
- PERROR("close");
- }
- }
-
- __lttng_poll_free((void *) events->events);
-}
-
-#else /* HAVE_EPOLL */
-/*
- * Fallback on poll(2) API
- */
-
-/* Needed for some poll event values */
-#ifndef __USE_XOPEN
-#define __USE_XOPEN
-#endif
-
-/* Needed for some poll event values */
-#ifndef __USE_GNU
-#define __USE_GNU
-#endif
-
-#include <poll.h>
-#include <stdint.h>
-
-enum {
- /* Polling variables compatibility for poll */
- LPOLLIN = POLLIN,
- LPOLLPRI = POLLPRI,
- LPOLLOUT = POLLOUT,
- LPOLLRDNORM = POLLRDNORM,
- LPOLLRDBAND = POLLRDBAND,
- LPOLLWRNORM = POLLWRNORM,
- LPOLLWRBAND = POLLWRBAND,
-#ifdef __linux__
- LPOLLMSG = POLLMSG,
- LPOLLRDHUP = POLLRDHUP,
-#elif (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
- LPOLLMSG = 0,
- LPOLLRDHUP = 0,
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ */
- LPOLLERR = POLLERR,
- LPOLLHUP = POLLHUP | POLLNVAL,
- /* Close on exec feature does not exist for poll(2) */
- LTTNG_CLOEXEC = 0xdead,
-};
-
-struct compat_poll_event_array {
- uint32_t nb_fd; /* Current number of fd in events */
- uint32_t alloc_size; /* Size of events array */
- /* Initial size of the pollset. We never shrink below that. */
- uint32_t init_size;
- struct pollfd *events;
-};
-
-struct compat_poll_event {
- /*
- * Modified by the wait action. Updated using current fields if the
- * need_update flag is set.
- */
- struct compat_poll_event_array wait;
- /*
- * This is modified by add/del actions being the _current_ flow of
- * execution before a poll wait is done.
- */
- struct compat_poll_event_array current;
-
- /* Indicate if wait.events need to be updated from current. */
- int need_update:1;
-};
-#define lttng_poll_event compat_poll_event
-
-static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
- int index, uint32_t nb_fd)
-{
- LTTNG_ASSERT(events);
- LTTNG_ASSERT(index != nb_fd);
-
- if (index == 0 || nb_fd == 0) {
- return -1;
- } else {
- return events->current.events[index - 1].fd;
- }
-}
-
-/*
- * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
- * being the index of the events array.
- * LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the
- * current list for test compatibility purposes.
- */
-#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->wait.events[i].fd
-#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->wait.events[i].revents
-#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->current.nb_fd
-#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->wait.events_size
-#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
- __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
-
-/*
- * Create a pollfd structure of size 'size'.
- */
-extern int compat_poll_create(struct lttng_poll_event *events, int size);
-#define lttng_poll_create(events, size, flags) \
- compat_poll_create(events, size)
-
-/*
- * Wait on poll(2) event with nb_fd registered to the lttng_poll_event data
- * structure.
- */
-extern int compat_poll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible);
-#define lttng_poll_wait(events, timeout) \
- compat_poll_wait(events, timeout, false)
-#define lttng_poll_wait_interruptible(events, timeout) \
- compat_poll_wait(events, timeout, true)
-
-/*
- * Add the fd to the pollfd structure. Resize if needed.
- */
-extern int compat_poll_add(struct lttng_poll_event *events,
- int fd, uint32_t req_events);
-#define lttng_poll_add(events, fd, req_events) \
- compat_poll_add(events, fd, req_events)
-
-/*
- * Remove the fd from the pollfd. Memory allocation is done to recreate a new
- * pollfd, data is copied from the old pollfd to the new and, finally, the old
- * one is freed().
- */
-extern int compat_poll_del(struct lttng_poll_event *events, int fd);
-#define lttng_poll_del(events, fd) \
- compat_poll_del(events, fd)
-
-/*
- * Modify an fd's events in the poll set.
- */
-extern int compat_poll_mod(struct lttng_poll_event *events,
- int fd, uint32_t req_events);
-#define lttng_poll_mod(events, fd, req_events) \
- compat_poll_mod(events, fd, req_events)
-
-/*
- * Set up the poll set limits variable poll_max_size
- */
-extern int compat_poll_set_max_size(void);
-#define lttng_poll_set_max_size() \
- compat_poll_set_max_size()
-
-/*
- * No need to reset a pollfd structure for poll(2)
- */
-static inline void lttng_poll_reset(
- struct lttng_poll_event *events __attribute__((unused)))
-{}
-
-/*
- * Initialize an already allocated poll event data structure.
- */
-static inline void lttng_poll_init(struct lttng_poll_event *events)
-{
- memset(events, 0, sizeof(struct lttng_poll_event));
-}
-
-/*
- * Clean the events structure of a lttng_poll_event. It's the caller
- * responsability to free the lttng_poll_event memory.
- */
-static inline void lttng_poll_clean(struct lttng_poll_event *events)
-{
- if (events) {
- __lttng_poll_free((void *) events->wait.events);
- __lttng_poll_free((void *) events->current.events);
- }
-}
-
-#endif /* HAVE_EPOLL */
-
-#endif /* _LTT_POLL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTT_POLL_H
+#define _LTT_POLL_H
+
+#include <string.h>
+#include <unistd.h>
+
+#include <common/common.hpp>
+
+/*
+ * Used by lttng_poll_clean to free the events structure in a lttng_poll_event.
+ */
+static inline void __lttng_poll_free(void *events)
+{
+ free(events);
+}
+
+/*
+ * epoll(7) implementation.
+ */
+#ifdef HAVE_EPOLL
+#include <sys/epoll.h>
+#include <stdio.h>
+#include <features.h>
+#include <common/compat/fcntl.hpp>
+
+/* See man epoll(7) for this define path */
+#define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
+
+enum {
+ /* Polling variables compatibility for epoll */
+ LPOLLIN = EPOLLIN,
+ LPOLLPRI = EPOLLPRI,
+ LPOLLOUT = EPOLLOUT,
+ LPOLLRDNORM = EPOLLRDNORM,
+ LPOLLRDBAND = EPOLLRDBAND,
+ LPOLLWRNORM = EPOLLWRNORM,
+ LPOLLWRBAND = EPOLLWRBAND,
+ LPOLLMSG = EPOLLMSG,
+ LPOLLERR = EPOLLERR,
+ LPOLLHUP = EPOLLHUP,
+ LPOLLNVAL = EPOLLHUP,
+ LPOLLRDHUP = EPOLLRDHUP,
+ /* Close on exec feature of epoll */
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
+ LTTNG_CLOEXEC = EPOLL_CLOEXEC,
+#else
+ /*
+ * EPOLL_CLOEXEC was added in glibc 2.8 (usually used in conjunction with
+ * epoll_create1(..)), but since neither EPOLL_CLOEXEC exists nor
+ * epoll_create1(..), we set it to FD_CLOEXEC so that we can pass it
+ * directly to fcntl(..) instead.
+ */
+ LTTNG_CLOEXEC = FD_CLOEXEC,
+#endif
+};
+
+struct compat_epoll_event {
+ int epfd;
+ uint32_t nb_fd; /* Current number of fd in events */
+ uint32_t alloc_size; /* Size of events array */
+ uint32_t init_size; /* Initial size of events array */
+ struct epoll_event *events;
+};
+#define lttng_poll_event compat_epoll_event
+
+static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
+ int index, uint32_t nb_fd)
+{
+ LTTNG_ASSERT(events);
+ LTTNG_ASSERT(index != nb_fd);
+
+ if (index == 0 || nb_fd == 0) {
+ return -1;
+ } else {
+ return events->events[index - 1].data.fd;
+ }
+}
+
+/*
+ * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
+ * being the index of the events array.
+ */
+#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->events[i].data.fd
+#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->events[i].events
+#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->nb_fd
+#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->events_size
+#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
+ __lttng_epoll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
+
+/* Create the epoll set. */
+extern int compat_epoll_create(struct lttng_poll_event *events,
+ int size, int flags);
+#define lttng_poll_create(events, size, flags) \
+ compat_epoll_create(events, size, flags)
+
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
+static inline int compat_glibc_epoll_create(int size __attribute__((unused)),
+ int flags)
+{
+ return epoll_create1(flags);
+}
+#else
+static inline int compat_glibc_epoll_create(int size, int flags)
+{
+ /*
+ * epoll_create1 was added in glibc 2.9, but unfortunatly reverting to
+ * epoll_create(..) also means that we lose the possibility to
+ * directly set the EPOLL_CLOEXEC, so try and do it anyway but through
+ * fcntl(..).
+ */
+ int efd = epoll_create(size);
+ LTTNG_ASSERT(fcntl(efd, F_SETFD, flags) != -1);
+ return efd;
+}
+#endif
+
+/*
+ * Wait on epoll set with the number of fd registered to the lttng_poll_event
+ * data structure (events).
+ */
+extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible);
+#define lttng_poll_wait(events, timeout) \
+ compat_epoll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_epoll_wait(events, timeout, true)
+
+/*
+ * Add a fd to the epoll set and resize the epoll_event structure if needed.
+ */
+extern int compat_epoll_add(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_add(events, fd, req_events) \
+ compat_epoll_add(events, fd, req_events)
+
+/*
+ * Remove a fd from the epoll set.
+ */
+extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
+#define lttng_poll_del(events, fd) \
+ compat_epoll_del(events, fd)
+
+/*
+ * Modify an fd's events in the epoll set.
+ */
+extern int compat_epoll_mod(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+ compat_epoll_mod(events, fd, req_events)
+
+/*
+ * Set up the poll set limits variable poll_max_size
+ */
+extern int compat_epoll_set_max_size(void);
+#define lttng_poll_set_max_size() \
+ compat_epoll_set_max_size()
+
+/*
+ * This function memset with zero the structure since it can be reused at each
+ * round of a main loop. Being in a loop and using a non static number of fds,
+ * this function must be called to insure coherent events with associted fds.
+ */
+static inline void lttng_poll_reset(struct lttng_poll_event *events)
+{
+ if (events && events->events) {
+ memset(events->events, 0,
+ events->nb_fd * sizeof(struct epoll_event));
+ }
+}
+
+/*
+ * Initialize an already allocated poll event data structure. For epoll(), the
+ * epfd is set to -1 to indicate that it's not usable.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+ memset(events, 0, sizeof(struct lttng_poll_event));
+ /* Set fd to -1 so if clean before created, we don't close 0. */
+ events->epfd = -1;
+}
+
+/*
+ * Clean the events structure of a lttng_poll_event. It's the caller
+ * responsability to free the lttng_poll_event memory.
+ */
+static inline void lttng_poll_clean(struct lttng_poll_event *events)
+{
+ int ret;
+
+ if (!events) {
+ return;
+ }
+
+ if (events->epfd >= 0) {
+ ret = close(events->epfd);
+ if (ret) {
+ PERROR("close");
+ }
+ }
+
+ __lttng_poll_free((void *) events->events);
+}
+
+#else /* HAVE_EPOLL */
+/*
+ * Fallback on poll(2) API
+ */
+
+/* Needed for some poll event values */
+#ifndef __USE_XOPEN
+#define __USE_XOPEN
+#endif
+
+/* Needed for some poll event values */
+#ifndef __USE_GNU
+#define __USE_GNU
+#endif
+
+#include <poll.h>
+#include <stdint.h>
+
+enum {
+ /* Polling variables compatibility for poll */
+ LPOLLIN = POLLIN,
+ LPOLLPRI = POLLPRI,
+ LPOLLOUT = POLLOUT,
+ LPOLLRDNORM = POLLRDNORM,
+ LPOLLRDBAND = POLLRDBAND,
+ LPOLLWRNORM = POLLWRNORM,
+ LPOLLWRBAND = POLLWRBAND,
+#ifdef __linux__
+ LPOLLMSG = POLLMSG,
+ LPOLLRDHUP = POLLRDHUP,
+#elif (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
+ LPOLLMSG = 0,
+ LPOLLRDHUP = 0,
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ */
+ LPOLLERR = POLLERR,
+ LPOLLHUP = POLLHUP | POLLNVAL,
+ /* Close on exec feature does not exist for poll(2) */
+ LTTNG_CLOEXEC = 0xdead,
+};
+
+struct compat_poll_event_array {
+ uint32_t nb_fd; /* Current number of fd in events */
+ uint32_t alloc_size; /* Size of events array */
+ /* Initial size of the pollset. We never shrink below that. */
+ uint32_t init_size;
+ struct pollfd *events;
+};
+
+struct compat_poll_event {
+ /*
+ * Modified by the wait action. Updated using current fields if the
+ * need_update flag is set.
+ */
+ struct compat_poll_event_array wait;
+ /*
+ * This is modified by add/del actions being the _current_ flow of
+ * execution before a poll wait is done.
+ */
+ struct compat_poll_event_array current;
+
+ /* Indicate if wait.events need to be updated from current. */
+ int need_update:1;
+};
+#define lttng_poll_event compat_poll_event
+
+static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
+ int index, uint32_t nb_fd)
+{
+ LTTNG_ASSERT(events);
+ LTTNG_ASSERT(index != nb_fd);
+
+ if (index == 0 || nb_fd == 0) {
+ return -1;
+ } else {
+ return events->current.events[index - 1].fd;
+ }
+}
+
+/*
+ * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
+ * being the index of the events array.
+ * LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the
+ * current list for test compatibility purposes.
+ */
+#define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->wait.events[i].fd
+#define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->wait.events[i].revents
+#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->current.nb_fd
+#define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->wait.events_size
+#define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
+ __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
+
+/*
+ * Create a pollfd structure of size 'size'.
+ */
+extern int compat_poll_create(struct lttng_poll_event *events, int size);
+#define lttng_poll_create(events, size, flags) \
+ compat_poll_create(events, size)
+
+/*
+ * Wait on poll(2) event with nb_fd registered to the lttng_poll_event data
+ * structure.
+ */
+extern int compat_poll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible);
+#define lttng_poll_wait(events, timeout) \
+ compat_poll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_poll_wait(events, timeout, true)
+
+/*
+ * Add the fd to the pollfd structure. Resize if needed.
+ */
+extern int compat_poll_add(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_add(events, fd, req_events) \
+ compat_poll_add(events, fd, req_events)
+
+/*
+ * Remove the fd from the pollfd. Memory allocation is done to recreate a new
+ * pollfd, data is copied from the old pollfd to the new and, finally, the old
+ * one is freed().
+ */
+extern int compat_poll_del(struct lttng_poll_event *events, int fd);
+#define lttng_poll_del(events, fd) \
+ compat_poll_del(events, fd)
+
+/*
+ * Modify an fd's events in the poll set.
+ */
+extern int compat_poll_mod(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+ compat_poll_mod(events, fd, req_events)
+
+/*
+ * Set up the poll set limits variable poll_max_size
+ */
+extern int compat_poll_set_max_size(void);
+#define lttng_poll_set_max_size() \
+ compat_poll_set_max_size()
+
+/*
+ * No need to reset a pollfd structure for poll(2)
+ */
+static inline void lttng_poll_reset(
+ struct lttng_poll_event *events __attribute__((unused)))
+{}
+
+/*
+ * Initialize an already allocated poll event data structure.
+ */
+static inline void lttng_poll_init(struct lttng_poll_event *events)
+{
+ memset(events, 0, sizeof(struct lttng_poll_event));
+}
+
+/*
+ * Clean the events structure of a lttng_poll_event. It's the caller
+ * responsability to free the lttng_poll_event memory.
+ */
+static inline void lttng_poll_clean(struct lttng_poll_event *events)
+{
+ if (events) {
+ __lttng_poll_free((void *) events->wait.events);
+ __lttng_poll_free((void *) events->current.events);
+ }
+}
+
+#endif /* HAVE_EPOLL */
+
+#endif /* _LTT_POLL_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_PTHREAD_H
-#define _COMPAT_PTHREAD_H
-
-#include <pthread.h>
-#include <common/compat/errno.h>
-#include <string.h>
-
-#ifdef __FreeBSD__
-#include <pthread_np.h>
-#endif
-
-#define LTTNG_PTHREAD_NAMELEN 16
-
-#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /*
- * Some implementations don't error out, replicate this behavior for
- * consistency.
- */
- if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
- return ERANGE;
- }
-
- return pthread_setname_np(pthread_self(), name);
-}
-#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- return pthread_setname_np(name);
-}
-#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /* Replicate pthread_setname_np's behavior. */
- if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
- return ERANGE;
- }
-
- pthread_set_name_np(pthread_self(), name);
- return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- /* Replicate pthread_setname_np's behavior. */
- if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
- return ERANGE;
- }
- return prctl(PR_SET_NAME, name, 0, 0, 0);
-}
-#else
-/*
- * For platforms without thread name support, do nothing.
- */
-static inline
-int lttng_pthread_setname_np(const char *name)
-{
- return -ENOSYS;
-}
-#endif
-
-
-#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return pthread_getname_np(pthread_self(), name, len);
-}
-#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return pthread_getname_np(name, len);
-}
-#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- pthread_get_name_np(pthread_self(), name, len);
- return 0;
-}
-#elif defined(__linux__)
-
-/* Fallback on prtctl on Linux */
-#include <sys/prctl.h>
-
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return prctl(PR_GET_NAME, name, 0, 0, 0);
-}
-#else
-/*
- * For platforms without thread name support, do nothing.
- */
-static inline
-int lttng_pthread_getname_np(char *name, size_t len)
-{
- return -ENOSYS;
-}
-#endif
-
-#endif /* _COMPAT_PTHREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_PTHREAD_H
+#define _COMPAT_PTHREAD_H
+
+#include <pthread.h>
+#include <common/compat/errno.hpp>
+#include <string.h>
+
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif
+
+#define LTTNG_PTHREAD_NAMELEN 16
+
+#if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /*
+ * Some implementations don't error out, replicate this behavior for
+ * consistency.
+ */
+ if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
+ return ERANGE;
+ }
+
+ return pthread_setname_np(pthread_self(), name);
+}
+#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ return pthread_setname_np(name);
+}
+#elif defined(HAVE_PTHREAD_SET_NAME_NP_WITH_TID)
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /* Replicate pthread_setname_np's behavior. */
+ if (strnlen(name, LTTNG_PTHREAD_NAMELEN) >= LTTNG_PTHREAD_NAMELEN) {
+ return ERANGE;
+ }
+
+ pthread_set_name_np(pthread_self(), name);
+ return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ /* Replicate pthread_setname_np's behavior. */
+ if (strnlen(name, LTTNG_UST_ABI_PROCNAME_LEN) >= LTTNG_UST_ABI_PROCNAME_LEN) {
+ return ERANGE;
+ }
+ return prctl(PR_SET_NAME, name, 0, 0, 0);
+}
+#else
+/*
+ * For platforms without thread name support, do nothing.
+ */
+static inline
+int lttng_pthread_setname_np(const char *name)
+{
+ return -ENOSYS;
+}
+#endif
+
+
+#if defined(HAVE_PTHREAD_GETNAME_NP_WITH_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return pthread_getname_np(pthread_self(), name, len);
+}
+#elif defined(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return pthread_getname_np(name, len);
+}
+#elif defined(HAVE_PTHREAD_GET_NAME_NP_WITH_TID)
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ pthread_get_name_np(pthread_self(), name, len);
+ return 0;
+}
+#elif defined(__linux__)
+
+/* Fallback on prtctl on Linux */
+#include <sys/prctl.h>
+
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return prctl(PR_GET_NAME, name, 0, 0, 0);
+}
+#else
+/*
+ * For platforms without thread name support, do nothing.
+ */
+static inline
+int lttng_pthread_getname_np(char *name, size_t len)
+{
+ return -ENOSYS;
+}
+#endif
+
+#endif /* _COMPAT_PTHREAD_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMPAT_SOCKET_H
-#define _COMPAT_SOCKET_H
-
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-
-#include <common/macros.h>
-
-#ifndef MSG_NOSIGNAL
-# ifdef SO_NOSIGPIPE
-# define MSG_NOSIGNAL SO_NOSIGPIPE
-# endif
-#endif
-
-#if defined(MSG_NOSIGNAL)
-static inline
-ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
-{
- return recvmsg(sockfd, msg, MSG_NOSIGNAL);
-}
-#else
-
-#include <signal.h>
-#include <common/compat/errno.h>
-
-static inline
-ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
-{
- ssize_t received;
- int saved_err;
- sigset_t sigpipe_set, pending_set, old_set;
- int sigpipe_was_pending;
-
- /*
- * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
- * that might be already pending. If a bogus SIGPIPE is sent to
- * the entire process concurrently by a malicious user, it may
- * be simply discarded.
- */
- if (sigemptyset(&pending_set)) {
- return -1;
- }
- /*
- * sigpending returns the mask of signals that are _both_
- * blocked for the thread _and_ pending for either the thread or
- * the entire process.
- */
- if (sigpending(&pending_set)) {
- return -1;
- }
- sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
- /*
- * If sigpipe was pending, it means it was already blocked, so
- * no need to block it.
- */
- if (!sigpipe_was_pending) {
- if (sigemptyset(&sigpipe_set)) {
- return -1;
- }
- if (sigaddset(&sigpipe_set, SIGPIPE)) {
- return -1;
- }
- if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
- return -1;
- }
- }
-
- /* Send and save errno. */
- received = recvmsg(sockfd, msg, 0);
- saved_err = errno;
-
- if (received == -1 && errno == EPIPE && !sigpipe_was_pending) {
- struct timespec timeout = { 0, 0 };
- int ret;
-
- do {
- ret = sigtimedwait(&sigpipe_set, NULL,
- &timeout);
- } while (ret == -1 && errno == EINTR);
- }
- if (!sigpipe_was_pending) {
- if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
- return -1;
- }
- }
- /* Restore send() errno */
- errno = saved_err;
-
- return received;
-}
-#endif
-
-#ifdef __sun__
-
-# ifndef CMSG_ALIGN
-# ifdef _CMSG_DATA_ALIGN
-# define CMSG_ALIGN(len) _CMSG_DATA_ALIGN(len)
-# else
- /* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
-# define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & ~(sizeof (long) - 1))
-# endif
-# ifndef CMSG_SPACE
-# define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN (len))
-# endif
-# ifndef CMSG_LEN
-# define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
-# endif
-# endif
-
-#include <ucred.h>
-
-static inline
-int getpeereid(int s, uid_t *euid, gid_t *gid)
-{
- int ret = 0;
- ucred_t *ucred = NULL;
-
- ret = getpeerucred(s, &ucred);
- if (ret == -1) {
- goto end;
- }
-
- ret = ucred_geteuid(ucred);
- if (ret == -1) {
- goto free;
- }
- *euid = ret;
-
- ret = ucred_getrgid(ucred);
- if (ret == -1) {
- goto free;
- }
- *gid = ret;
-
- ret = 0;
-free:
- ucred_free(ucred);
-end:
- return ret;
-}
-#endif /* __sun__ */
-
-
-#if defined(__linux__) || defined(__CYGWIN__)
-
-#define LTTNG_SOCK_CREDS SCM_CREDENTIALS
-
-typedef struct ucred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
-#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
-#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
-
-#elif (defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__))
-
-struct lttng_sock_cred {
- uid_t uid;
- gid_t gid;
- pid_t pid;
-};
-
-typedef struct lttng_sock_cred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
-#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
-#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
-
-#ifdef __APPLE__
-
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
- socklen_t pid_len = (socklen_t) sizeof(*pid);
-
- /* The getsockopt LOCAL_PEERPID option is available since macOS 10.8. */
- return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid, &pid_len);
-}
-
-#elif defined(__sun__)
-
-/* Use the getpeerucreds interface on Solaris. */
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
- int ret = 0;
- ucred_t *ucred = NULL;
-
- ret = getpeerucred(s, &ucred);
- if (ret == -1) {
- goto end;
- }
-
- ret = ucred_getpid(ucred);
- if (ret == -1) {
- goto free;
- }
-
- *pid = ret;
- ret = 0;
-free:
- ucred_free(ucred);
-end:
- return ret;
-}
-
-#elif defined(__FreeBSD__)
-
-#include <sys/ucred.h>
-
-static inline
-int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
-{
- int ret;
- struct xucred sock_creds = {};
-
- /* Only available in FreeBSD 13.0 and up. */
- ret = getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERCRED, &sock_creds,
- &((socklen_t) {sizeof(sock_creds)}));
- if (ret) {
- goto end;
- }
-
- *pid = sock_creds.cr_pid;
-end:
- return ret;
-}
-
-#endif /* __APPLE__ */
-
-
-static inline
-int lttng_get_unix_socket_peer_creds(int socket_fd, struct lttng_sock_cred *creds)
-{
- int ret;
-
- /* This is a BSD extension that is supported by Cygwin. */
- ret = getpeereid(socket_fd, &creds->uid, &creds->gid);
- if (ret) {
- goto end;
- }
-
- /*
- * Getting a peer's PID is a bit more troublesome as it is platform
- * specific.
- */
- ret = lttng_get_unix_socket_peer_pid(socket_fd, &creds->pid);
-end:
- return ret;
-}
-
-#else
-#error "Please add support for your OS."
-#endif /* __linux__ , __FreeBSD__, __APPLE__ */
-
-#endif /* _COMPAT_SOCKET_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMPAT_SOCKET_H
+#define _COMPAT_SOCKET_H
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include <common/macros.hpp>
+
+#ifndef MSG_NOSIGNAL
+# ifdef SO_NOSIGPIPE
+# define MSG_NOSIGNAL SO_NOSIGPIPE
+# endif
+#endif
+
+#if defined(MSG_NOSIGNAL)
+static inline
+ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
+{
+ return recvmsg(sockfd, msg, MSG_NOSIGNAL);
+}
+#else
+
+#include <signal.h>
+#include <common/compat/errno.hpp>
+
+static inline
+ssize_t lttng_recvmsg_nosigpipe(int sockfd, struct msghdr *msg)
+{
+ ssize_t received;
+ int saved_err;
+ sigset_t sigpipe_set, pending_set, old_set;
+ int sigpipe_was_pending;
+
+ /*
+ * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
+ * that might be already pending. If a bogus SIGPIPE is sent to
+ * the entire process concurrently by a malicious user, it may
+ * be simply discarded.
+ */
+ if (sigemptyset(&pending_set)) {
+ return -1;
+ }
+ /*
+ * sigpending returns the mask of signals that are _both_
+ * blocked for the thread _and_ pending for either the thread or
+ * the entire process.
+ */
+ if (sigpending(&pending_set)) {
+ return -1;
+ }
+ sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
+ /*
+ * If sigpipe was pending, it means it was already blocked, so
+ * no need to block it.
+ */
+ if (!sigpipe_was_pending) {
+ if (sigemptyset(&sigpipe_set)) {
+ return -1;
+ }
+ if (sigaddset(&sigpipe_set, SIGPIPE)) {
+ return -1;
+ }
+ if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
+ return -1;
+ }
+ }
+
+ /* Send and save errno. */
+ received = recvmsg(sockfd, msg, 0);
+ saved_err = errno;
+
+ if (received == -1 && errno == EPIPE && !sigpipe_was_pending) {
+ struct timespec timeout = { 0, 0 };
+ int ret;
+
+ do {
+ ret = sigtimedwait(&sigpipe_set, NULL,
+ &timeout);
+ } while (ret == -1 && errno == EINTR);
+ }
+ if (!sigpipe_was_pending) {
+ if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
+ return -1;
+ }
+ }
+ /* Restore send() errno */
+ errno = saved_err;
+
+ return received;
+}
+#endif
+
+#ifdef __sun__
+
+# ifndef CMSG_ALIGN
+# ifdef _CMSG_DATA_ALIGN
+# define CMSG_ALIGN(len) _CMSG_DATA_ALIGN(len)
+# else
+ /* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
+# define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & ~(sizeof (long) - 1))
+# endif
+# ifndef CMSG_SPACE
+# define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN (len))
+# endif
+# ifndef CMSG_LEN
+# define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+# endif
+# endif
+
+#include <ucred.h>
+
+static inline
+int getpeereid(int s, uid_t *euid, gid_t *gid)
+{
+ int ret = 0;
+ ucred_t *ucred = NULL;
+
+ ret = getpeerucred(s, &ucred);
+ if (ret == -1) {
+ goto end;
+ }
+
+ ret = ucred_geteuid(ucred);
+ if (ret == -1) {
+ goto free;
+ }
+ *euid = ret;
+
+ ret = ucred_getrgid(ucred);
+ if (ret == -1) {
+ goto free;
+ }
+ *gid = ret;
+
+ ret = 0;
+free:
+ ucred_free(ucred);
+end:
+ return ret;
+}
+#endif /* __sun__ */
+
+
+#if defined(__linux__) || defined(__CYGWIN__)
+
+#define LTTNG_SOCK_CREDS SCM_CREDENTIALS
+
+typedef struct ucred lttng_sock_cred;
+
+#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
+#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
+#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
+
+#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
+#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
+#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
+
+#elif (defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__))
+
+struct lttng_sock_cred {
+ uid_t uid;
+ gid_t gid;
+ pid_t pid;
+};
+
+typedef struct lttng_sock_cred lttng_sock_cred;
+
+#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
+#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
+#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
+
+#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
+#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
+#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
+
+#ifdef __APPLE__
+
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+ socklen_t pid_len = (socklen_t) sizeof(*pid);
+
+ /* The getsockopt LOCAL_PEERPID option is available since macOS 10.8. */
+ return getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERPID, pid, &pid_len);
+}
+
+#elif defined(__sun__)
+
+/* Use the getpeerucreds interface on Solaris. */
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+ int ret = 0;
+ ucred_t *ucred = NULL;
+
+ ret = getpeerucred(s, &ucred);
+ if (ret == -1) {
+ goto end;
+ }
+
+ ret = ucred_getpid(ucred);
+ if (ret == -1) {
+ goto free;
+ }
+
+ *pid = ret;
+ ret = 0;
+free:
+ ucred_free(ucred);
+end:
+ return ret;
+}
+
+#elif defined(__FreeBSD__)
+
+#include <sys/ucred.h>
+
+static inline
+int lttng_get_unix_socket_peer_pid(int socket_fd, pid_t *pid)
+{
+ int ret;
+ struct xucred sock_creds = {};
+
+ /* Only available in FreeBSD 13.0 and up. */
+ ret = getsockopt(socket_fd, SOL_LOCAL, LOCAL_PEERCRED, &sock_creds,
+ &((socklen_t) {sizeof(sock_creds)}));
+ if (ret) {
+ goto end;
+ }
+
+ *pid = sock_creds.cr_pid;
+end:
+ return ret;
+}
+
+#endif /* __APPLE__ */
+
+
+static inline
+int lttng_get_unix_socket_peer_creds(int socket_fd, struct lttng_sock_cred *creds)
+{
+ int ret;
+
+ /* This is a BSD extension that is supported by Cygwin. */
+ ret = getpeereid(socket_fd, &creds->uid, &creds->gid);
+ if (ret) {
+ goto end;
+ }
+
+ /*
+ * Getting a peer's PID is a bit more troublesome as it is platform
+ * specific.
+ */
+ ret = lttng_get_unix_socket_peer_pid(socket_fd, &creds->pid);
+end:
+ return ret;
+}
+
+#else
+#error "Please add support for your OS."
+#endif /* __linux__ , __FreeBSD__, __APPLE__ */
+
+#endif /* _COMPAT_SOCKET_H */
+++ /dev/null
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_STRING_H
-#define _COMPAT_STRING_H
-
-#include <string.h>
-#include <stdlib.h>
-
-#ifdef HAVE_STRNLEN
-static inline
-size_t lttng_strnlen(const char *str, size_t max)
-{
- return strnlen(str, max);
-}
-#else
-static inline
-size_t lttng_strnlen(const char *str, size_t max)
-{
- size_t ret;
- const char *end;
-
- end = (const char *) memchr(str, 0, max);
-
- if (end) {
- ret = (size_t) (end - str);
- } else {
- ret = max;
- }
-
- return ret;
-}
-#endif /* HAVE_STRNLEN */
-
-#ifdef HAVE_STRNDUP
-static inline
-char *lttng_strndup(const char *s, size_t n)
-{
- return strndup(s, n);
-}
-#else
-static inline
-char *lttng_strndup(const char *s, size_t n)
-{
- char *ret;
- size_t navail;
-
- if (!s) {
- ret = NULL;
- goto end;
- }
-
- /* min() */
- navail = strlen(s) + 1;
- if ((n + 1) < navail) {
- navail = n + 1;
- }
-
- ret = (char *) malloc(navail);
- if (!ret) {
- goto end;
- }
-
- memcpy(ret, s, navail);
- ret[navail - 1] = '\0';
-end:
- return ret;
-}
-#endif /* HAVE_STRNDUP */
-
-#ifdef HAVE_FLS
-static inline int lttng_fls(int val)
-{
- return fls(val);
-}
-#else
-static inline int lttng_fls(int val)
-{
- int r = 32;
- unsigned int x = (unsigned int) val;
-
- if (!x)
- return 0;
- if (!(x & 0xFFFF0000U)) {
- x <<= 16;
- r -= 16;
- }
- if (!(x & 0xFF000000U)) {
- x <<= 8;
- r -= 8;
- }
- if (!(x & 0xF0000000U)) {
- x <<= 4;
- r -= 4;
- }
- if (!(x & 0xC0000000U)) {
- x <<= 2;
- r -= 2;
- }
- if (!(x & 0x80000000U)) {
- r -= 1;
- }
- return r;
-}
-#endif /* HAVE_FLS */
-
-#ifdef HAVE_MEMRCHR
-static inline
-void *lttng_memrchr(const void *s, int c, size_t n)
-{
- return (void *) memrchr(s, c, n);
-}
-#else
-static inline
-void *lttng_memrchr(const void *s, int c, size_t n)
-{
- int i;
- const char *str = (const char *) s;
- for (i = n-1; i >= 0; i--) {
- if (str[i] == (char)c) {
- return (void *)(str+i);
- }
- }
- return NULL;
-}
-#endif /* HAVE_MEMRCHR */
-
-#endif /* _COMPAT_STRING_H */
--- /dev/null
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_STRING_H
+#define _COMPAT_STRING_H
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef HAVE_STRNLEN
+static inline
+size_t lttng_strnlen(const char *str, size_t max)
+{
+ return strnlen(str, max);
+}
+#else
+static inline
+size_t lttng_strnlen(const char *str, size_t max)
+{
+ size_t ret;
+ const char *end;
+
+ end = (const char *) memchr(str, 0, max);
+
+ if (end) {
+ ret = (size_t) (end - str);
+ } else {
+ ret = max;
+ }
+
+ return ret;
+}
+#endif /* HAVE_STRNLEN */
+
+#ifdef HAVE_STRNDUP
+static inline
+char *lttng_strndup(const char *s, size_t n)
+{
+ return strndup(s, n);
+}
+#else
+static inline
+char *lttng_strndup(const char *s, size_t n)
+{
+ char *ret;
+ size_t navail;
+
+ if (!s) {
+ ret = NULL;
+ goto end;
+ }
+
+ /* min() */
+ navail = strlen(s) + 1;
+ if ((n + 1) < navail) {
+ navail = n + 1;
+ }
+
+ ret = (char *) malloc(navail);
+ if (!ret) {
+ goto end;
+ }
+
+ memcpy(ret, s, navail);
+ ret[navail - 1] = '\0';
+end:
+ return ret;
+}
+#endif /* HAVE_STRNDUP */
+
+#ifdef HAVE_FLS
+static inline int lttng_fls(int val)
+{
+ return fls(val);
+}
+#else
+static inline int lttng_fls(int val)
+{
+ int r = 32;
+ unsigned int x = (unsigned int) val;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xFFFF0000U)) {
+ x <<= 16;
+ r -= 16;
+ }
+ if (!(x & 0xFF000000U)) {
+ x <<= 8;
+ r -= 8;
+ }
+ if (!(x & 0xF0000000U)) {
+ x <<= 4;
+ r -= 4;
+ }
+ if (!(x & 0xC0000000U)) {
+ x <<= 2;
+ r -= 2;
+ }
+ if (!(x & 0x80000000U)) {
+ r -= 1;
+ }
+ return r;
+}
+#endif /* HAVE_FLS */
+
+#ifdef HAVE_MEMRCHR
+static inline
+void *lttng_memrchr(const void *s, int c, size_t n)
+{
+ return (void *) memrchr(s, c, n);
+}
+#else
+static inline
+void *lttng_memrchr(const void *s, int c, size_t n)
+{
+ int i;
+ const char *str = (const char *) s;
+ for (i = n-1; i >= 0; i--) {
+ if (str[i] == (char)c) {
+ return (void *)(str+i);
+ }
+ }
+ return NULL;
+}
+#endif /* HAVE_MEMRCHR */
+
+#endif /* _COMPAT_STRING_H */
+++ /dev/null
-/*
- * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_TID_H
-#define LTTNG_TID_H
-
-#ifdef __linux__
-#include <syscall.h>
-#endif
-
-#if defined(__NR_gettid)
-
-#include <unistd.h>
-static inline pid_t lttng_gettid(void)
-{
- return syscall(__NR_gettid);
-}
-
-#else
-
-#include <sys/types.h>
-#include <unistd.h>
-
-/* Fall-back on getpid for tid if not available. */
-static inline pid_t lttng_gettid(void)
-{
- return getpid();
-}
-
-#endif
-
-#endif /* LTTNG_TID_H */
--- /dev/null
+/*
+ * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_TID_H
+#define LTTNG_TID_H
+
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
+#if defined(__NR_gettid)
+
+#include <unistd.h>
+static inline pid_t lttng_gettid(void)
+{
+ return syscall(__NR_gettid);
+}
+
+#else
+
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Fall-back on getpid for tid if not available. */
+static inline pid_t lttng_gettid(void)
+{
+ return getpid();
+}
+
+#endif
+
+#endif /* LTTNG_TID_H */
+++ /dev/null
-/*
- * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _COMPAT_TIME_H
-#define _COMPAT_TIME_H
-
-#include <time.h>
-
-#ifdef __APPLE__
-
-typedef uint64_t timer_t;
-
-#include <mach/mach.h>
-#include <mach/clock.h>
-#include <common/compat/errno.h>
-
-#undef NSEC_PER_SEC
-#undef NSEC_PER_MSEC
-#undef NSEC_PER_USEC
-#undef USEC_PER_SEC
-
-#endif /* __APPLE__ */
-
-/* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */
-#if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME)
-
-typedef int clockid_t;
-#define CLOCK_REALTIME CALENDAR_CLOCK
-#define CLOCK_MONOTONIC SYSTEM_CLOCK
-
-static inline
-int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
- int ret = 0;
- clock_serv_t clock;
- mach_timespec_t now;
-
- if (clk_id != CLOCK_REALTIME && clk_id != CLOCK_MONOTONIC) {
- ret = -1;
- errno = EINVAL;
- goto end;
- }
-
- host_get_clock_service(mach_host_self(), clk_id, &clock);
-
- ret = clock_get_time(clock, &now);
- if (ret != KERN_SUCCESS) {
- ret = -1;
- goto deallocate;
- }
-
- tp->tv_sec = now.tv_sec;
- tp->tv_nsec = now.tv_nsec;
-
-deallocate:
- mach_port_deallocate(mach_task_self(), clock);
-end:
- return ret;
-}
-
-#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
-
-static inline
-int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
- return clock_gettime(clk_id, tp);
-}
-
-#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
-
-#endif /* _COMPAT_TIME_H */
--- /dev/null
+/*
+ * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _COMPAT_TIME_H
+#define _COMPAT_TIME_H
+
+#include <time.h>
+
+#ifdef __APPLE__
+
+typedef uint64_t timer_t;
+
+#include <mach/mach.h>
+#include <mach/clock.h>
+#include <common/compat/errno.hpp>
+
+#undef NSEC_PER_SEC
+#undef NSEC_PER_MSEC
+#undef NSEC_PER_USEC
+#undef USEC_PER_SEC
+
+#endif /* __APPLE__ */
+
+/* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */
+#if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME)
+
+typedef int clockid_t;
+#define CLOCK_REALTIME CALENDAR_CLOCK
+#define CLOCK_MONOTONIC SYSTEM_CLOCK
+
+static inline
+int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ int ret = 0;
+ clock_serv_t clock;
+ mach_timespec_t now;
+
+ if (clk_id != CLOCK_REALTIME && clk_id != CLOCK_MONOTONIC) {
+ ret = -1;
+ errno = EINVAL;
+ goto end;
+ }
+
+ host_get_clock_service(mach_host_self(), clk_id, &clock);
+
+ ret = clock_get_time(clock, &now);
+ if (ret != KERN_SUCCESS) {
+ ret = -1;
+ goto deallocate;
+ }
+
+ tp->tv_sec = now.tv_sec;
+ tp->tv_nsec = now.tv_nsec;
+
+deallocate:
+ mach_port_deallocate(mach_task_self(), clock);
+end:
+ return ret;
+}
+
+#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
+
+static inline
+int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ return clock_gettime(clk_id, tp);
+}
+
+#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
+
+#endif /* _COMPAT_TIME_H */
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
#include <float.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
#include <math.h>
#include <time.h>
*
*/
-#include <common/buffer-view.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/error-query-internal.hpp>
#include <stdbool.h>
enum lttng_condition_type lttng_condition_get_type(
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
#include <inttypes.h>
#include <limits.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/event-expr-internal.h>
+#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>
-#include <lttng/event-field-value-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-field-value-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/lttng-error.h>
#include <stdbool.h>
#include <stdint.h>
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
#include <float.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
#include <lttng/constant.h>
#include <math.h>
#include <time.h>
*
*/
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/location-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/location-internal.hpp>
#include <stdbool.h>
static
+++ /dev/null
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <libxml/xmlwriter.h>
-#include <stdio.h>
-
-struct config_writer {
- xmlTextWriterPtr writer;
-};
--- /dev/null
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <libxml/xmlwriter.h>
+#include <stdio.h>
+
+struct config_writer {
+ xmlTextWriterPtr writer;
+};
+++ /dev/null
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef CONFIG_SESSION_INTERNAL_H
-#define CONFIG_SESSION_INTERNAL_H
-
-#include <lttng/lttng-export.h>
-
-extern const char * const config_element_all;
-LTTNG_EXPORT extern const char * const config_element_channel;
-LTTNG_EXPORT extern const char * const config_element_channels;
-LTTNG_EXPORT extern const char * const config_element_domain;
-LTTNG_EXPORT extern const char * const config_element_domains;
-LTTNG_EXPORT extern const char * const config_element_event;
-LTTNG_EXPORT extern const char * const config_element_events;
-LTTNG_EXPORT extern const char * const config_element_context;
-LTTNG_EXPORT extern const char * const config_element_contexts;
-LTTNG_EXPORT extern const char * const config_element_attributes;
-LTTNG_EXPORT extern const char * const config_element_exclusion;
-LTTNG_EXPORT extern const char * const config_element_exclusions;
-LTTNG_EXPORT extern const char * const config_element_function_attributes;
-LTTNG_EXPORT extern const char * const config_element_probe_attributes;
-LTTNG_EXPORT extern const char * const config_element_symbol_name;
-LTTNG_EXPORT extern const char * const config_element_address;
-LTTNG_EXPORT extern const char * const config_element_offset;
-extern const char * const config_element_userspace_probe_lookup;
-extern const char * const config_element_userspace_probe_lookup_function_default;
-extern const char * const config_element_userspace_probe_lookup_function_elf;
-extern const char * const config_element_userspace_probe_lookup_tracepoint_sdt;
-extern const char * const config_element_userspace_probe_location_binary_path;
-extern const char * const config_element_userspace_probe_function_attributes;
-extern const char * const config_element_userspace_probe_function_location_function_name;
-extern const char * const config_element_userspace_probe_tracepoint_attributes;
-extern const char * const config_element_userspace_probe_tracepoint_location_provider_name;
-extern const char * const config_element_userspace_probe_tracepoint_location_probe_name;
-extern const char * const config_element_name;
-LTTNG_EXPORT extern const char * const config_element_enabled;
-LTTNG_EXPORT extern const char * const config_element_overwrite_mode;
-LTTNG_EXPORT extern const char * const config_element_subbuf_size;
-LTTNG_EXPORT extern const char * const config_element_num_subbuf;
-LTTNG_EXPORT extern const char * const config_element_switch_timer_interval;
-LTTNG_EXPORT extern const char * const config_element_read_timer_interval;
-extern const char * const config_element_monitor_timer_interval;
-extern const char * const config_element_blocking_timeout;
-LTTNG_EXPORT extern const char * const config_element_output;
-LTTNG_EXPORT extern const char * const config_element_output_type;
-LTTNG_EXPORT extern const char * const config_element_tracefile_size;
-LTTNG_EXPORT extern const char * const config_element_tracefile_count;
-LTTNG_EXPORT extern const char * const config_element_live_timer_interval;
-extern const char * const config_element_discarded_events;
-extern const char * const config_element_lost_packets;
-LTTNG_EXPORT extern const char * const config_element_type;
-LTTNG_EXPORT extern const char * const config_element_buffer_type;
-LTTNG_EXPORT extern const char * const config_element_session;
-LTTNG_EXPORT extern const char * const config_element_sessions;
-extern const char * const config_element_context_perf;
-extern const char * const config_element_context_app;
-extern const char * const config_element_context_app_provider_name;
-extern const char * const config_element_context_app_ctx_name;
-LTTNG_EXPORT extern const char * const config_element_config;
-LTTNG_EXPORT extern const char * const config_element_started;
-LTTNG_EXPORT extern const char * const config_element_snapshot_mode;
-LTTNG_EXPORT extern const char * const config_element_loglevel;
-LTTNG_EXPORT extern const char * const config_element_loglevel_type;
-LTTNG_EXPORT extern const char * const config_element_filter;
-extern const char * const config_element_filter_expression;
-LTTNG_EXPORT extern const char * const config_element_snapshot_outputs;
-LTTNG_EXPORT extern const char * const config_element_consumer_output;
-LTTNG_EXPORT extern const char * const config_element_destination;
-LTTNG_EXPORT extern const char * const config_element_path;
-LTTNG_EXPORT extern const char * const config_element_net_output;
-LTTNG_EXPORT extern const char * const config_element_control_uri;
-LTTNG_EXPORT extern const char * const config_element_data_uri;
-LTTNG_EXPORT extern const char * const config_element_max_size;
-LTTNG_EXPORT extern const char * const config_element_pid;
-extern const char * const config_element_process_attr_id;
-LTTNG_EXPORT extern const char * const config_element_pids;
-LTTNG_EXPORT extern const char * const config_element_name;
-LTTNG_EXPORT extern const char * const config_element_shared_memory_path;
-extern const char * const config_element_process_attr_tracker_pid;
-extern const char * const config_element_process_attr_tracker_vpid;
-extern const char * const config_element_process_attr_tracker_uid;
-extern const char * const config_element_process_attr_tracker_vuid;
-extern const char * const config_element_process_attr_tracker_gid;
-extern const char * const config_element_process_attr_tracker_vgid;
-extern const char * const config_element_process_attr_trackers;
-extern const char * const config_element_process_attr_values;
-extern const char * const config_element_process_attr_value_type;
-extern const char * const config_element_process_attr_pid_value;
-extern const char * const config_element_process_attr_vpid_value;
-extern const char * const config_element_process_attr_uid_value;
-extern const char * const config_element_process_attr_vuid_value;
-extern const char * const config_element_process_attr_gid_value;
-extern const char * const config_element_process_attr_vgid_value;
-extern const char * const config_element_process_attr_tracker_type;
-extern const char * const config_element_rotation_timer_interval;
-extern const char * const config_element_rotation_size;
-extern const char * const config_element_rotation_schedule;
-
-LTTNG_EXPORT extern const char * const config_domain_type_kernel;
-LTTNG_EXPORT extern const char * const config_domain_type_ust;
-LTTNG_EXPORT extern const char * const config_domain_type_jul;
-LTTNG_EXPORT extern const char * const config_domain_type_log4j;
-LTTNG_EXPORT extern const char * const config_domain_type_python;
-
-LTTNG_EXPORT extern const char * const config_buffer_type_per_pid;
-LTTNG_EXPORT extern const char * const config_buffer_type_per_uid;
-LTTNG_EXPORT extern const char * const config_buffer_type_global;
-
-LTTNG_EXPORT extern const char * const config_overwrite_mode_discard;
-LTTNG_EXPORT extern const char * const config_overwrite_mode_overwrite;
-
-LTTNG_EXPORT extern const char * const config_output_type_splice;
-LTTNG_EXPORT extern const char * const config_output_type_mmap;
-
-LTTNG_EXPORT extern const char * const config_loglevel_type_all;
-LTTNG_EXPORT extern const char * const config_loglevel_type_range;
-LTTNG_EXPORT extern const char * const config_loglevel_type_single;
-
-LTTNG_EXPORT extern const char * const config_event_type_all;
-LTTNG_EXPORT extern const char * const config_event_type_tracepoint;
-LTTNG_EXPORT extern const char * const config_event_type_probe;
-extern const char * const config_event_type_userspace_probe;
-LTTNG_EXPORT extern const char * const config_event_type_function;
-LTTNG_EXPORT extern const char * const config_event_type_function_entry;
-LTTNG_EXPORT extern const char * const config_event_type_noop;
-LTTNG_EXPORT extern const char * const config_event_type_syscall;
-LTTNG_EXPORT extern const char * const config_event_type_kprobe;
-LTTNG_EXPORT extern const char * const config_event_type_kretprobe;
-
-LTTNG_EXPORT extern const char * const config_event_context_pid;
-LTTNG_EXPORT extern const char * const config_event_context_procname;
-LTTNG_EXPORT extern const char * const config_event_context_prio;
-LTTNG_EXPORT extern const char * const config_event_context_nice;
-LTTNG_EXPORT extern const char * const config_event_context_vpid;
-LTTNG_EXPORT extern const char * const config_event_context_tid;
-LTTNG_EXPORT extern const char * const config_event_context_vtid;
-LTTNG_EXPORT extern const char * const config_event_context_ppid;
-LTTNG_EXPORT extern const char * const config_event_context_vppid;
-LTTNG_EXPORT extern const char * const config_event_context_pthread_id;
-LTTNG_EXPORT extern const char * const config_event_context_hostname;
-LTTNG_EXPORT extern const char * const config_event_context_ip;
-LTTNG_EXPORT extern const char * const config_event_context_perf_thread_counter;
-extern const char * const config_event_context_app;
-extern const char * const config_event_context_interruptible;
-extern const char * const config_event_context_preemptible;
-extern const char * const config_event_context_need_reschedule;
-extern const char * const config_event_context_migratable;
-extern const char * const config_event_context_callstack_user;
-extern const char * const config_event_context_callstack_kernel;
-
-extern const char * const config_element_rotation_schedules;
-extern const char * const config_element_rotation_schedule_periodic;
-extern const char * const config_element_rotation_schedule_periodic_time_us;
-extern const char * const config_element_rotation_schedule_size_threshold;
-extern const char * const config_element_rotation_schedule_size_threshold_bytes;
-extern const char * const config_event_context_cgroup_ns;
-extern const char * const config_event_context_ipc_ns;
-extern const char * const config_event_context_mnt_ns;
-extern const char * const config_event_context_net_ns;
-extern const char * const config_event_context_pid_ns;
-extern const char * const config_event_context_time_ns;
-extern const char * const config_event_context_user_ns;
-extern const char * const config_event_context_uts_ns;
-extern const char * const config_event_context_uid;
-extern const char * const config_event_context_euid;
-extern const char * const config_event_context_suid;
-extern const char * const config_event_context_gid;
-extern const char * const config_event_context_egid;
-extern const char * const config_event_context_sgid;
-extern const char * const config_event_context_vuid;
-extern const char * const config_event_context_veuid;
-extern const char * const config_event_context_vsuid;
-extern const char * const config_event_context_vgid;
-extern const char * const config_event_context_vegid;
-extern const char * const config_event_context_vsgid;
-
-#endif /* CONFIG_SESSION_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef CONFIG_SESSION_INTERNAL_H
+#define CONFIG_SESSION_INTERNAL_H
+
+#include <lttng/lttng-export.h>
+
+extern const char * const config_element_all;
+LTTNG_EXPORT extern const char * const config_element_channel;
+LTTNG_EXPORT extern const char * const config_element_channels;
+LTTNG_EXPORT extern const char * const config_element_domain;
+LTTNG_EXPORT extern const char * const config_element_domains;
+LTTNG_EXPORT extern const char * const config_element_event;
+LTTNG_EXPORT extern const char * const config_element_events;
+LTTNG_EXPORT extern const char * const config_element_context;
+LTTNG_EXPORT extern const char * const config_element_contexts;
+LTTNG_EXPORT extern const char * const config_element_attributes;
+LTTNG_EXPORT extern const char * const config_element_exclusion;
+LTTNG_EXPORT extern const char * const config_element_exclusions;
+LTTNG_EXPORT extern const char * const config_element_function_attributes;
+LTTNG_EXPORT extern const char * const config_element_probe_attributes;
+LTTNG_EXPORT extern const char * const config_element_symbol_name;
+LTTNG_EXPORT extern const char * const config_element_address;
+LTTNG_EXPORT extern const char * const config_element_offset;
+extern const char * const config_element_userspace_probe_lookup;
+extern const char * const config_element_userspace_probe_lookup_function_default;
+extern const char * const config_element_userspace_probe_lookup_function_elf;
+extern const char * const config_element_userspace_probe_lookup_tracepoint_sdt;
+extern const char * const config_element_userspace_probe_location_binary_path;
+extern const char * const config_element_userspace_probe_function_attributes;
+extern const char * const config_element_userspace_probe_function_location_function_name;
+extern const char * const config_element_userspace_probe_tracepoint_attributes;
+extern const char * const config_element_userspace_probe_tracepoint_location_provider_name;
+extern const char * const config_element_userspace_probe_tracepoint_location_probe_name;
+extern const char * const config_element_name;
+LTTNG_EXPORT extern const char * const config_element_enabled;
+LTTNG_EXPORT extern const char * const config_element_overwrite_mode;
+LTTNG_EXPORT extern const char * const config_element_subbuf_size;
+LTTNG_EXPORT extern const char * const config_element_num_subbuf;
+LTTNG_EXPORT extern const char * const config_element_switch_timer_interval;
+LTTNG_EXPORT extern const char * const config_element_read_timer_interval;
+extern const char * const config_element_monitor_timer_interval;
+extern const char * const config_element_blocking_timeout;
+LTTNG_EXPORT extern const char * const config_element_output;
+LTTNG_EXPORT extern const char * const config_element_output_type;
+LTTNG_EXPORT extern const char * const config_element_tracefile_size;
+LTTNG_EXPORT extern const char * const config_element_tracefile_count;
+LTTNG_EXPORT extern const char * const config_element_live_timer_interval;
+extern const char * const config_element_discarded_events;
+extern const char * const config_element_lost_packets;
+LTTNG_EXPORT extern const char * const config_element_type;
+LTTNG_EXPORT extern const char * const config_element_buffer_type;
+LTTNG_EXPORT extern const char * const config_element_session;
+LTTNG_EXPORT extern const char * const config_element_sessions;
+extern const char * const config_element_context_perf;
+extern const char * const config_element_context_app;
+extern const char * const config_element_context_app_provider_name;
+extern const char * const config_element_context_app_ctx_name;
+LTTNG_EXPORT extern const char * const config_element_config;
+LTTNG_EXPORT extern const char * const config_element_started;
+LTTNG_EXPORT extern const char * const config_element_snapshot_mode;
+LTTNG_EXPORT extern const char * const config_element_loglevel;
+LTTNG_EXPORT extern const char * const config_element_loglevel_type;
+LTTNG_EXPORT extern const char * const config_element_filter;
+extern const char * const config_element_filter_expression;
+LTTNG_EXPORT extern const char * const config_element_snapshot_outputs;
+LTTNG_EXPORT extern const char * const config_element_consumer_output;
+LTTNG_EXPORT extern const char * const config_element_destination;
+LTTNG_EXPORT extern const char * const config_element_path;
+LTTNG_EXPORT extern const char * const config_element_net_output;
+LTTNG_EXPORT extern const char * const config_element_control_uri;
+LTTNG_EXPORT extern const char * const config_element_data_uri;
+LTTNG_EXPORT extern const char * const config_element_max_size;
+LTTNG_EXPORT extern const char * const config_element_pid;
+extern const char * const config_element_process_attr_id;
+LTTNG_EXPORT extern const char * const config_element_pids;
+LTTNG_EXPORT extern const char * const config_element_name;
+LTTNG_EXPORT extern const char * const config_element_shared_memory_path;
+extern const char * const config_element_process_attr_tracker_pid;
+extern const char * const config_element_process_attr_tracker_vpid;
+extern const char * const config_element_process_attr_tracker_uid;
+extern const char * const config_element_process_attr_tracker_vuid;
+extern const char * const config_element_process_attr_tracker_gid;
+extern const char * const config_element_process_attr_tracker_vgid;
+extern const char * const config_element_process_attr_trackers;
+extern const char * const config_element_process_attr_values;
+extern const char * const config_element_process_attr_value_type;
+extern const char * const config_element_process_attr_pid_value;
+extern const char * const config_element_process_attr_vpid_value;
+extern const char * const config_element_process_attr_uid_value;
+extern const char * const config_element_process_attr_vuid_value;
+extern const char * const config_element_process_attr_gid_value;
+extern const char * const config_element_process_attr_vgid_value;
+extern const char * const config_element_process_attr_tracker_type;
+extern const char * const config_element_rotation_timer_interval;
+extern const char * const config_element_rotation_size;
+extern const char * const config_element_rotation_schedule;
+
+LTTNG_EXPORT extern const char * const config_domain_type_kernel;
+LTTNG_EXPORT extern const char * const config_domain_type_ust;
+LTTNG_EXPORT extern const char * const config_domain_type_jul;
+LTTNG_EXPORT extern const char * const config_domain_type_log4j;
+LTTNG_EXPORT extern const char * const config_domain_type_python;
+
+LTTNG_EXPORT extern const char * const config_buffer_type_per_pid;
+LTTNG_EXPORT extern const char * const config_buffer_type_per_uid;
+LTTNG_EXPORT extern const char * const config_buffer_type_global;
+
+LTTNG_EXPORT extern const char * const config_overwrite_mode_discard;
+LTTNG_EXPORT extern const char * const config_overwrite_mode_overwrite;
+
+LTTNG_EXPORT extern const char * const config_output_type_splice;
+LTTNG_EXPORT extern const char * const config_output_type_mmap;
+
+LTTNG_EXPORT extern const char * const config_loglevel_type_all;
+LTTNG_EXPORT extern const char * const config_loglevel_type_range;
+LTTNG_EXPORT extern const char * const config_loglevel_type_single;
+
+LTTNG_EXPORT extern const char * const config_event_type_all;
+LTTNG_EXPORT extern const char * const config_event_type_tracepoint;
+LTTNG_EXPORT extern const char * const config_event_type_probe;
+extern const char * const config_event_type_userspace_probe;
+LTTNG_EXPORT extern const char * const config_event_type_function;
+LTTNG_EXPORT extern const char * const config_event_type_function_entry;
+LTTNG_EXPORT extern const char * const config_event_type_noop;
+LTTNG_EXPORT extern const char * const config_event_type_syscall;
+LTTNG_EXPORT extern const char * const config_event_type_kprobe;
+LTTNG_EXPORT extern const char * const config_event_type_kretprobe;
+
+LTTNG_EXPORT extern const char * const config_event_context_pid;
+LTTNG_EXPORT extern const char * const config_event_context_procname;
+LTTNG_EXPORT extern const char * const config_event_context_prio;
+LTTNG_EXPORT extern const char * const config_event_context_nice;
+LTTNG_EXPORT extern const char * const config_event_context_vpid;
+LTTNG_EXPORT extern const char * const config_event_context_tid;
+LTTNG_EXPORT extern const char * const config_event_context_vtid;
+LTTNG_EXPORT extern const char * const config_event_context_ppid;
+LTTNG_EXPORT extern const char * const config_event_context_vppid;
+LTTNG_EXPORT extern const char * const config_event_context_pthread_id;
+LTTNG_EXPORT extern const char * const config_event_context_hostname;
+LTTNG_EXPORT extern const char * const config_event_context_ip;
+LTTNG_EXPORT extern const char * const config_event_context_perf_thread_counter;
+extern const char * const config_event_context_app;
+extern const char * const config_event_context_interruptible;
+extern const char * const config_event_context_preemptible;
+extern const char * const config_event_context_need_reschedule;
+extern const char * const config_event_context_migratable;
+extern const char * const config_event_context_callstack_user;
+extern const char * const config_event_context_callstack_kernel;
+
+extern const char * const config_element_rotation_schedules;
+extern const char * const config_element_rotation_schedule_periodic;
+extern const char * const config_element_rotation_schedule_periodic_time_us;
+extern const char * const config_element_rotation_schedule_size_threshold;
+extern const char * const config_element_rotation_schedule_size_threshold_bytes;
+extern const char * const config_event_context_cgroup_ns;
+extern const char * const config_event_context_ipc_ns;
+extern const char * const config_event_context_mnt_ns;
+extern const char * const config_event_context_net_ns;
+extern const char * const config_event_context_pid_ns;
+extern const char * const config_event_context_time_ns;
+extern const char * const config_event_context_user_ns;
+extern const char * const config_event_context_uts_ns;
+extern const char * const config_event_context_uid;
+extern const char * const config_event_context_euid;
+extern const char * const config_event_context_suid;
+extern const char * const config_event_context_gid;
+extern const char * const config_event_context_egid;
+extern const char * const config_event_context_sgid;
+extern const char * const config_event_context_vuid;
+extern const char * const config_event_context_veuid;
+extern const char * const config_event_context_vsuid;
+extern const char * const config_event_context_vgid;
+extern const char * const config_event_context_vegid;
+extern const char * const config_event_context_vsgid;
+
+#endif /* CONFIG_SESSION_INTERNAL_H */
#include <sys/stat.h>
#include <stdbool.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/utils.h>
-#include <common/dynamic-buffer.h>
-#include <common/compat/getenv.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/compat/getenv.hpp>
#include <lttng/lttng-error.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
#include <lttng/rotation.h>
#include <lttng/userspace-probe.h>
-#include "session-config.h"
-#include "config-internal.h"
+#include "session-config.hpp"
+#include "config-internal.hpp"
#define CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN 7
+++ /dev/null
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-#include <common/config/config-session-abi.h>
-#include <common/macros.h>
-#include <stdint.h>
-
-struct config_load_session_override_attr {
- char *path_url;
- char *ctrl_url;
- char *data_url;
- char *session_name;
-};
-
-/* Instance of a configuration writer. */
-struct config_writer;
-
-/*
- * Create an instance of a configuration writer.
- *
- * fd_output File to which the XML content must be written. fd_output is
- * owned by the caller.
- *
- * indent If other than 0 the XML will be pretty printed
- * with indentation and newline.
- *
- * Returns an instance of a configuration writer on success, NULL on
- * error.
- */
-struct config_writer *config_writer_create(int fd_output, int indent);
-
-/*
- * Destroy an instance of a configuration writer.
- *
- * writer An instance of a configuration writer.
- *
- * Returns zero if the XML document could be closed cleanly. Negative values
- * indicate an error.
- */
-int config_writer_destroy(struct config_writer *writer);
-
-/*
- * Open an element tag.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element tag name.
- *
- * Returns zero if the XML element could be opened.
- * Negative values indicate an error.
- */
-int config_writer_open_element(struct config_writer *writer,
- const char *element_name);
-
-/*
- * Write an element tag attribute.
- *
- * writer An instance of a configuration writer.
- *
- * name Attribute name.
- *
- * Returns zero if the XML element's attribute could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_attribute(struct config_writer *writer,
- const char *name, const char *value);
-
-/*
- * Close the current element tag.
- *
- * writer An instance of a configuration writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int config_writer_close_element(struct config_writer *writer);
-
-/*
- * Write an element of type unsigned int.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Unsigned int value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_unsigned_int(struct config_writer *writer,
- const char *element_name, uint64_t value);
-
-/*
- * Write an element of type signed int.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Signed int value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_signed_int(struct config_writer *writer,
- const char *element_name, int64_t value);
-
-/*
- * Write an element of type boolean.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value Boolean value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_bool(struct config_writer *writer,
- const char *element_name, int value);
-
-/*
- * Write an element of type string.
- *
- * writer An instance of a configuration writer.
- *
- * element_name Element name.
- *
- * value String value of the element
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int config_writer_write_element_string(struct config_writer *writer,
- const char *element_name, const char *value);
-
-/*
- * Write an element of type double.
- *
- * writer An instance of a configuration 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 config_writer_write_element_double(struct config_writer *writer,
- const char *element_name,
- double value);
-
-/*
- * Load session configurations from a file.
- *
- * path Path to an LTTng session configuration file. All *.lttng files
- * will be loaded if path is a directory. If path is NULL, the default
- * paths will be searched in the following order:
- * 1) $HOME/.lttng/sessions
- * 2) /etc/lttng/sessions
- *
- * session_name Name of the session to load. Will load all
- * sessions from path if NULL.
- *
- * overwrite Overwrite current session configuration if it exists.
- * autoload Tell to load the auto session(s).
- * overrides The override attribute structure specifying override parameters.
- *
- * Returns zero if the session could be loaded successfully. Returns
- * a negative LTTNG_ERR code on error.
- */
-int config_load_session(const char *path, const char *session_name,
- int overwrite, unsigned int autoload,
- const struct config_load_session_override_attr *overrides);
-
-#endif /* _CONFIG_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#include <common/config/config-session-abi.hpp>
+#include <common/macros.hpp>
+#include <stdint.h>
+
+struct config_load_session_override_attr {
+ char *path_url;
+ char *ctrl_url;
+ char *data_url;
+ char *session_name;
+};
+
+/* Instance of a configuration writer. */
+struct config_writer;
+
+/*
+ * Create an instance of a configuration writer.
+ *
+ * fd_output File to which the XML content must be written. fd_output is
+ * owned by the caller.
+ *
+ * indent If other than 0 the XML will be pretty printed
+ * with indentation and newline.
+ *
+ * Returns an instance of a configuration writer on success, NULL on
+ * error.
+ */
+struct config_writer *config_writer_create(int fd_output, int indent);
+
+/*
+ * Destroy an instance of a configuration writer.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative values
+ * indicate an error.
+ */
+int config_writer_destroy(struct config_writer *writer);
+
+/*
+ * Open an element tag.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element tag name.
+ *
+ * Returns zero if the XML element could be opened.
+ * Negative values indicate an error.
+ */
+int config_writer_open_element(struct config_writer *writer,
+ const char *element_name);
+
+/*
+ * Write an element tag attribute.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * name Attribute name.
+ *
+ * Returns zero if the XML element's attribute could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_attribute(struct config_writer *writer,
+ const char *name, const char *value);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int config_writer_close_element(struct config_writer *writer);
+
+/*
+ * Write an element of type unsigned int.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Unsigned int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_unsigned_int(struct config_writer *writer,
+ const char *element_name, uint64_t value);
+
+/*
+ * Write an element of type signed int.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Signed int value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_signed_int(struct config_writer *writer,
+ const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value Boolean value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_bool(struct config_writer *writer,
+ const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a configuration writer.
+ *
+ * element_name Element name.
+ *
+ * value String value of the element
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int config_writer_write_element_string(struct config_writer *writer,
+ const char *element_name, const char *value);
+
+/*
+ * Write an element of type double.
+ *
+ * writer An instance of a configuration 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 config_writer_write_element_double(struct config_writer *writer,
+ const char *element_name,
+ double value);
+
+/*
+ * Load session configurations from a file.
+ *
+ * path Path to an LTTng session configuration file. All *.lttng files
+ * will be loaded if path is a directory. If path is NULL, the default
+ * paths will be searched in the following order:
+ * 1) $HOME/.lttng/sessions
+ * 2) /etc/lttng/sessions
+ *
+ * session_name Name of the session to load. Will load all
+ * sessions from path if NULL.
+ *
+ * overwrite Overwrite current session configuration if it exists.
+ * autoload Tell to load the auto session(s).
+ * overrides The override attribute structure specifying override parameters.
+ *
+ * Returns zero if the session could be loaded successfully. Returns
+ * a negative LTTNG_ERR code on error.
+ */
+int config_load_session(const char *path, const char *session_name,
+ int overwrite, unsigned int autoload,
+ const struct config_load_session_override_attr *overrides);
+
+#endif /* _CONFIG_H */
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/consumer/consumer.h>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/consumer/consumer.hpp>
-#include "consumer-metadata-cache.h"
+#include "consumer-metadata-cache.hpp"
enum metadata_cache_update_version_status {
METADATA_CACHE_UPDATE_STATUS_VERSION_UPDATED,
+++ /dev/null
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMER_METADATA_CACHE_H
-#define CONSUMER_METADATA_CACHE_H
-
-#include <common/consumer/consumer.h>
-#include <common/dynamic-buffer.h>
-
-enum consumer_metadata_cache_write_status {
- CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
- /*
- * New metadata content was appended to the cache successfully.
- * Previously available content remains valid.
- */
- CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
- /*
- * The new content pushed to the cache invalidated the content that
- * was already present. The contents of the cache should be re-read.
- */
- CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
- /*
- * A metadata cache write can simply overwrite an already existing
- * section of the cache (and it should be a write-through with identical
- * data). From the caller's standpoint, there is no change to the state
- * of the cache.
- */
- CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
-};
-
-struct consumer_metadata_cache {
- /* Current version of the metadata cache. */
- uint64_t version;
- /*
- * Size is the upper-limit of data written inside the buffer.
- * All cached data is contiguous.
- */
- struct lttng_dynamic_buffer contents;
- /*
- * Lock to update the metadata cache and push into the ring_buffer
- * (lttng_ust_ctl_write_metadata_to_channel).
- *
- * This is nested INSIDE the consumer_data lock.
- */
- pthread_mutex_t lock;
-};
-
-enum consumer_metadata_cache_write_status
-consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
- unsigned int offset, unsigned int len, uint64_t version,
- const char *data);
-int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
-void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
-int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
- uint64_t offset, int timer);
-
-#endif /* CONSUMER_METADATA_CACHE_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMER_METADATA_CACHE_H
+#define CONSUMER_METADATA_CACHE_H
+
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-buffer.hpp>
+
+enum consumer_metadata_cache_write_status {
+ CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
+ /*
+ * New metadata content was appended to the cache successfully.
+ * Previously available content remains valid.
+ */
+ CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
+ /*
+ * The new content pushed to the cache invalidated the content that
+ * was already present. The contents of the cache should be re-read.
+ */
+ CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
+ /*
+ * A metadata cache write can simply overwrite an already existing
+ * section of the cache (and it should be a write-through with identical
+ * data). From the caller's standpoint, there is no change to the state
+ * of the cache.
+ */
+ CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
+};
+
+struct consumer_metadata_cache {
+ /* Current version of the metadata cache. */
+ uint64_t version;
+ /*
+ * Size is the upper-limit of data written inside the buffer.
+ * All cached data is contiguous.
+ */
+ struct lttng_dynamic_buffer contents;
+ /*
+ * Lock to update the metadata cache and push into the ring_buffer
+ * (lttng_ust_ctl_write_metadata_to_channel).
+ *
+ * This is nested INSIDE the consumer_data lock.
+ */
+ pthread_mutex_t lock;
+};
+
+enum consumer_metadata_cache_write_status
+consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
+ unsigned int offset, unsigned int len, uint64_t version,
+ const char *data);
+int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
+void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
+int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
+ uint64_t offset, int timer);
+
+#endif /* CONSUMER_METADATA_CACHE_H */
#include <sys/mman.h>
#include <unistd.h>
-#include <common/common.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/metadata-bucket.h>
-#include <common/consumer/metadata-bucket.h>
-#include <common/index/index.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/macros.h>
-#include <common/relayd/relayd.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/utils.h>
-
-#include "consumer-stream.h"
+#include <common/common.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+#include <common/index/index.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/macros.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/utils.hpp>
+
+#include "consumer-stream.hpp"
/*
* RCU call to free stream. MUST only be used with call_rcu().
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_CONSUMER_STREAM_H
-#define LTTNG_CONSUMER_STREAM_H
-
-#include "consumer.h"
-
-enum consumer_stream_open_packet_status {
- CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED,
- CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE,
- CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR,
-};
-
-/*
- * Create a consumer stream.
- *
- * The channel lock MUST be acquired.
- */
-struct lttng_consumer_stream *consumer_stream_create(
- struct lttng_consumer_channel *channel,
- uint64_t channel_key,
- uint64_t stream_key,
- const char *channel_name,
- uint64_t relayd_id,
- uint64_t session_id,
- struct lttng_trace_chunk *trace_chunk,
- int cpu,
- int *alloc_ret,
- enum consumer_channel_type type,
- unsigned int monitor);
-
-/*
- * Close stream's file descriptors and, if needed, close stream also on the
- * relayd side.
- *
- * The stream lock MUST be acquired.
- * The consumer data lock MUST be acquired.
- */
-void consumer_stream_close(struct lttng_consumer_stream *stream);
-
-/*
- * Close stream on the relayd side. This call can destroy a relayd if the
- * conditions are met.
- *
- * A RCU read side lock MUST be acquired if the relayd object was looked up in
- * a hash table before calling this.
- */
-void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
- struct consumer_relayd_sock_pair *relayd);
-
-/*
- * Delete the stream from all possible hash tables.
- *
- * The consumer data lock MUST be acquired.
- */
-void consumer_stream_delete(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht);
-
-/*
- * Free the given stream within a RCU call.
- */
-void consumer_stream_free(struct lttng_consumer_stream *stream);
-
-/*
- * Destroy a stream completely. This will delete, close and free the stream.
- * Once return, the stream is NO longer usable. Its channel may get destroyed
- * if conditions are met.
- *
- * This MUST be called WITHOUT the consumer data and stream lock acquired.
- */
-void consumer_stream_destroy(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht);
-
-/*
- * Destroy the stream's buffers on the tracer side. This is also called in a
- * stream destroy.
- */
-void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
-
-/*
- * Write index of a specific stream either on the relayd or local disk.
- */
-int consumer_stream_write_index(struct lttng_consumer_stream *stream,
- struct ctf_packet_index *index);
-
-int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
- uint64_t session_id);
-
-/*
- * Create the output files of a local stream.
- *
- * This must be called with the channel's and the stream's lock held.
- */
-int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
- bool create_index);
-
-/*
- * Rotate the output files of a local stream. This will change the
- * active output files of both the binary and index in accordance
- * with the stream's configuration (stream file count).
- *
- * This must be called with the channel's and the stream's lock held.
- */
-int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
-
-/*
- * Indicates whether or not a stream is logically deleted. A deleted stream
- * should no longer be used; its existence is only garanteed by the RCU lock
- * held by the caller.
- *
- * This function must be called with the RCU read side lock held.
- */
-bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
-
-/*
- * Enable metadata bucketization. This must only be enabled if the tracer
- * provides a reliable metadata `coherent` flag.
- *
- * This must be called on initialization before any subbuffer is consumed.
- */
-int consumer_stream_enable_metadata_bucketization(
- struct lttng_consumer_stream *stream);
-
-/*
- * Set the version of a metadata stream (i.e. following a metadata
- * regeneration).
- *
- * Changing the version of a metadata stream will cause any bucketized metadata
- * to be discarded and will mark the metadata stream for future `reset`.
- */
-void consumer_stream_metadata_set_version(
- struct lttng_consumer_stream *stream, uint64_t new_version);
-
-/*
- * Attempt to open a packet in a stream.
- *
- * This function must be called with the stream and channel locks held.
- */
-enum consumer_stream_open_packet_status consumer_stream_open_packet(
- struct lttng_consumer_stream *stream);
-
-/*
- * Flush a stream's buffer.
- *
- * producer_active: if true, causes a flush to occur only if there is
- * content present in the current sub-buffer. If false, forces a flush to take
- * place (otherwise known as "flush_empty").
- *
- * This function must be called with the stream and channel locks held.
- */
-int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
- bool producer_active);
-
-#endif /* LTTNG_CONSUMER_STREAM_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_CONSUMER_STREAM_H
+#define LTTNG_CONSUMER_STREAM_H
+
+#include "consumer.hpp"
+
+enum consumer_stream_open_packet_status {
+ CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED,
+ CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE,
+ CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR,
+};
+
+/*
+ * Create a consumer stream.
+ *
+ * The channel lock MUST be acquired.
+ */
+struct lttng_consumer_stream *consumer_stream_create(
+ struct lttng_consumer_channel *channel,
+ uint64_t channel_key,
+ uint64_t stream_key,
+ const char *channel_name,
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *trace_chunk,
+ int cpu,
+ int *alloc_ret,
+ enum consumer_channel_type type,
+ unsigned int monitor);
+
+/*
+ * Close stream's file descriptors and, if needed, close stream also on the
+ * relayd side.
+ *
+ * The stream lock MUST be acquired.
+ * The consumer data lock MUST be acquired.
+ */
+void consumer_stream_close(struct lttng_consumer_stream *stream);
+
+/*
+ * Close stream on the relayd side. This call can destroy a relayd if the
+ * conditions are met.
+ *
+ * A RCU read side lock MUST be acquired if the relayd object was looked up in
+ * a hash table before calling this.
+ */
+void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
+ struct consumer_relayd_sock_pair *relayd);
+
+/*
+ * Delete the stream from all possible hash tables.
+ *
+ * The consumer data lock MUST be acquired.
+ */
+void consumer_stream_delete(struct lttng_consumer_stream *stream,
+ struct lttng_ht *ht);
+
+/*
+ * Free the given stream within a RCU call.
+ */
+void consumer_stream_free(struct lttng_consumer_stream *stream);
+
+/*
+ * Destroy a stream completely. This will delete, close and free the stream.
+ * Once return, the stream is NO longer usable. Its channel may get destroyed
+ * if conditions are met.
+ *
+ * This MUST be called WITHOUT the consumer data and stream lock acquired.
+ */
+void consumer_stream_destroy(struct lttng_consumer_stream *stream,
+ struct lttng_ht *ht);
+
+/*
+ * Destroy the stream's buffers on the tracer side. This is also called in a
+ * stream destroy.
+ */
+void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
+
+/*
+ * Write index of a specific stream either on the relayd or local disk.
+ */
+int consumer_stream_write_index(struct lttng_consumer_stream *stream,
+ struct ctf_packet_index *index);
+
+int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
+ uint64_t session_id);
+
+/*
+ * Create the output files of a local stream.
+ *
+ * This must be called with the channel's and the stream's lock held.
+ */
+int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
+ bool create_index);
+
+/*
+ * Rotate the output files of a local stream. This will change the
+ * active output files of both the binary and index in accordance
+ * with the stream's configuration (stream file count).
+ *
+ * This must be called with the channel's and the stream's lock held.
+ */
+int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
+
+/*
+ * Indicates whether or not a stream is logically deleted. A deleted stream
+ * should no longer be used; its existence is only garanteed by the RCU lock
+ * held by the caller.
+ *
+ * This function must be called with the RCU read side lock held.
+ */
+bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
+
+/*
+ * Enable metadata bucketization. This must only be enabled if the tracer
+ * provides a reliable metadata `coherent` flag.
+ *
+ * This must be called on initialization before any subbuffer is consumed.
+ */
+int consumer_stream_enable_metadata_bucketization(
+ struct lttng_consumer_stream *stream);
+
+/*
+ * Set the version of a metadata stream (i.e. following a metadata
+ * regeneration).
+ *
+ * Changing the version of a metadata stream will cause any bucketized metadata
+ * to be discarded and will mark the metadata stream for future `reset`.
+ */
+void consumer_stream_metadata_set_version(
+ struct lttng_consumer_stream *stream, uint64_t new_version);
+
+/*
+ * Attempt to open a packet in a stream.
+ *
+ * This function must be called with the stream and channel locks held.
+ */
+enum consumer_stream_open_packet_status consumer_stream_open_packet(
+ struct lttng_consumer_stream *stream);
+
+/*
+ * Flush a stream's buffer.
+ *
+ * producer_active: if true, causes a flush to occur only if there is
+ * content present in the current sub-buffer. If false, forces a flush to take
+ * place (otherwise known as "flush_empty").
+ *
+ * This function must be called with the stream and channel locks held.
+ */
+int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
+ bool producer_active);
+
+#endif /* LTTNG_CONSUMER_STREAM_H */
+++ /dev/null
-#ifndef CONSUMERD_TESTPOINT_H
-#define CONSUMERD_TESTPOINT_H
-
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <common/testpoint/testpoint.h>
-
-/* Testpoints, internal use only */
-TESTPOINT_DECL(consumerd_thread_channel);
-TESTPOINT_DECL(consumerd_thread_metadata);
-TESTPOINT_DECL(consumerd_thread_data);
-TESTPOINT_DECL(consumerd_thread_data_poll);
-TESTPOINT_DECL(consumerd_thread_sessiond);
-TESTPOINT_DECL(consumerd_thread_metadata_timer);
-
-#endif /* CONSUMERD_TESTPOINT_H */
--- /dev/null
+#ifndef CONSUMERD_TESTPOINT_H
+#define CONSUMERD_TESTPOINT_H
+
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <common/testpoint/testpoint.hpp>
+
+/* Testpoints, internal use only */
+TESTPOINT_DECL(consumerd_thread_channel);
+TESTPOINT_DECL(consumerd_thread_metadata);
+TESTPOINT_DECL(consumerd_thread_data);
+TESTPOINT_DECL(consumerd_thread_data_poll);
+TESTPOINT_DECL(consumerd_thread_sessiond);
+TESTPOINT_DECL(consumerd_thread_metadata_timer);
+
+#endif /* CONSUMERD_TESTPOINT_H */
#include <inttypes.h>
#include <signal.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/compat/endian.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer-testpoint.h>
-#include <common/ust-consumer/ust-consumer.h>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer-testpoint.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
typedef int (*sample_positions_cb)(struct lttng_consumer_stream *stream);
typedef int (*get_consumed_cb)(struct lttng_consumer_stream *stream,
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef CONSUMER_TIMER_H
-#define CONSUMER_TIMER_H
-
-#include <pthread.h>
-
-#include "consumer.h"
-
-#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10
-#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11
-#define LTTNG_CONSUMER_SIG_LIVE SIGRTMIN + 12
-#define LTTNG_CONSUMER_SIG_MONITOR SIGRTMIN + 13
-#define LTTNG_CONSUMER_SIG_EXIT SIGRTMIN + 14
-
-#define CLOCKID CLOCK_MONOTONIC
-
-/*
- * Handle timer teardown race wrt memory free of private data by consumer
- * signals are handled by a single thread, which permits a synchronization
- * point between handling of each signal. Internal lock ensures mutual
- * exclusion.
- */
-struct timer_signal_data {
- pthread_t tid; /* thread id managing signals */
- int setup_done;
- int qs_done;
- pthread_mutex_t lock;
-};
-
-void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
- unsigned int switch_timer_interval_us);
-void consumer_timer_switch_stop(struct lttng_consumer_channel *channel);
-void consumer_timer_live_start(struct lttng_consumer_channel *channel,
- unsigned int live_timer_interval_us);
-void consumer_timer_live_stop(struct lttng_consumer_channel *channel);
-int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
- unsigned int monitor_timer_interval_us);
-int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel);
-void *consumer_timer_thread(void *data);
-int consumer_signal_init(void);
-
-int consumer_flush_kernel_index(struct lttng_consumer_stream *stream);
-int consumer_flush_ust_index(struct lttng_consumer_stream *stream);
-
-int consumer_timer_thread_get_channel_monitor_pipe(void);
-int consumer_timer_thread_set_channel_monitor_pipe(int fd);
-
-#endif /* CONSUMER_TIMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef CONSUMER_TIMER_H
+#define CONSUMER_TIMER_H
+
+#include <pthread.h>
+
+#include "consumer.hpp"
+
+#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10
+#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11
+#define LTTNG_CONSUMER_SIG_LIVE SIGRTMIN + 12
+#define LTTNG_CONSUMER_SIG_MONITOR SIGRTMIN + 13
+#define LTTNG_CONSUMER_SIG_EXIT SIGRTMIN + 14
+
+#define CLOCKID CLOCK_MONOTONIC
+
+/*
+ * Handle timer teardown race wrt memory free of private data by consumer
+ * signals are handled by a single thread, which permits a synchronization
+ * point between handling of each signal. Internal lock ensures mutual
+ * exclusion.
+ */
+struct timer_signal_data {
+ pthread_t tid; /* thread id managing signals */
+ int setup_done;
+ int qs_done;
+ pthread_mutex_t lock;
+};
+
+void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
+ unsigned int switch_timer_interval_us);
+void consumer_timer_switch_stop(struct lttng_consumer_channel *channel);
+void consumer_timer_live_start(struct lttng_consumer_channel *channel,
+ unsigned int live_timer_interval_us);
+void consumer_timer_live_stop(struct lttng_consumer_channel *channel);
+int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
+ unsigned int monitor_timer_interval_us);
+int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel);
+void *consumer_timer_thread(void *data);
+int consumer_signal_init(void);
+
+int consumer_flush_kernel_index(struct lttng_consumer_stream *stream);
+int consumer_flush_ust_index(struct lttng_consumer_stream *stream);
+
+int consumer_timer_thread_get_channel_monitor_pipe(void);
+int consumer_timer_thread_set_channel_monitor_pipe(int fd);
+
+#endif /* CONSUMER_TIMER_H */
*
*/
-#include "common/index/ctf-index.h"
-#include <stdint.h>
#define _LGPL_SOURCE
+#include <inttypes.h>
#include <poll.h>
#include <pthread.h>
+#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <signal.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/time.h>
-#include <common/compat/poll.h>
-#include <common/compat/endian.h>
-#include <common/index/index.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/kernel-consumer/kernel-consumer.h>
-#include <common/relayd/relayd.h>
-#include <common/ust-consumer/ust-consumer.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-testpoint.h>
-#include <common/align.h>
-#include <common/consumer/consumer-metadata-cache.h>
-#include <common/trace-chunk.h>
-#include <common/trace-chunk-registry.h>
-#include <common/string-utils/format.h>
-#include <common/dynamic-array.h>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/align.hpp>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/poll.hpp>
+#include <common/consumer/consumer-metadata-cache.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-testpoint.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/index/index.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/time.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/ust-consumer/ust-consumer.hpp>
+#include <common/utils.hpp>
lttng_consumer_global_data the_consumer_data;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LIB_CONSUMER_H
-#define LIB_CONSUMER_H
-
-#include <limits.h>
-#include <poll.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <urcu/list.h>
-
-#include <lttng/lttng.h>
-
-#include <common/hashtable/hashtable.h>
-#include <common/compat/fcntl.h>
-#include <common/uuid.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/pipe.h>
-#include <common/index/ctf-index.h>
-#include <common/trace-chunk-registry.h>
-#include <common/credentials.h>
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_consumer_local_data;
-
-/* Commands for consumer */
-enum lttng_consumer_command {
- LTTNG_CONSUMER_ADD_CHANNEL,
- LTTNG_CONSUMER_ADD_STREAM,
- /* pause, delete, active depending on fd state */
- LTTNG_CONSUMER_UPDATE_STREAM,
- /* inform the consumer to quit when all fd has hang up */
- LTTNG_CONSUMER_STOP, /* deprecated */
- LTTNG_CONSUMER_ADD_RELAYD_SOCKET,
- /* Inform the consumer to kill a specific relayd connection */
- LTTNG_CONSUMER_DESTROY_RELAYD,
- /* Return to the sessiond if there is data pending for a session */
- LTTNG_CONSUMER_DATA_PENDING,
- /* Consumer creates a channel and returns it to sessiond. */
- LTTNG_CONSUMER_ASK_CHANNEL_CREATION,
- LTTNG_CONSUMER_GET_CHANNEL,
- LTTNG_CONSUMER_DESTROY_CHANNEL,
- LTTNG_CONSUMER_PUSH_METADATA,
- LTTNG_CONSUMER_CLOSE_METADATA,
- LTTNG_CONSUMER_SETUP_METADATA,
- LTTNG_CONSUMER_FLUSH_CHANNEL,
- LTTNG_CONSUMER_SNAPSHOT_CHANNEL,
- LTTNG_CONSUMER_SNAPSHOT_METADATA,
- LTTNG_CONSUMER_STREAMS_SENT,
- LTTNG_CONSUMER_DISCARDED_EVENTS,
- LTTNG_CONSUMER_LOST_PACKETS,
- LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL,
- LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE,
- LTTNG_CONSUMER_ROTATE_CHANNEL,
- LTTNG_CONSUMER_INIT,
- LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
- LTTNG_CONSUMER_CLOSE_TRACE_CHUNK,
- LTTNG_CONSUMER_TRACE_CHUNK_EXISTS,
- LTTNG_CONSUMER_CLEAR_CHANNEL,
- LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS,
-};
-
-enum lttng_consumer_type {
- LTTNG_CONSUMER_UNKNOWN = 0,
- LTTNG_CONSUMER_KERNEL,
- LTTNG_CONSUMER64_UST,
- LTTNG_CONSUMER32_UST,
-};
-
-enum consumer_endpoint_status {
- CONSUMER_ENDPOINT_ACTIVE,
- CONSUMER_ENDPOINT_INACTIVE,
-};
-
-enum consumer_channel_output {
- CONSUMER_CHANNEL_MMAP = 0,
- CONSUMER_CHANNEL_SPLICE = 1,
-};
-
-enum consumer_channel_type {
- CONSUMER_CHANNEL_TYPE_METADATA = 0,
- CONSUMER_CHANNEL_TYPE_DATA = 1,
-};
-
-enum sync_metadata_status {
- SYNC_METADATA_STATUS_NEW_DATA,
- SYNC_METADATA_STATUS_NO_DATA,
- SYNC_METADATA_STATUS_ERROR,
-};
-
-extern struct lttng_consumer_global_data the_consumer_data;
-
-struct stream_list {
- struct cds_list_head head;
- unsigned int count;
-};
-
-/* Stub. */
-struct consumer_metadata_cache;
-
-struct lttng_consumer_channel {
- /* Is the channel published in the channel hash tables? */
- bool is_published;
- /*
- * Was the channel deleted (logically) and waiting to be reclaimed?
- * If this flag is set, no modification that is not cleaned-up by the
- * RCU reclamation callback should be made
- */
- bool is_deleted;
- /* HT node used for consumer_data.channel_ht */
- struct lttng_ht_node_u64 node;
- /* HT node used for consumer_data.channels_by_session_id_ht */
- struct lttng_ht_node_u64 channels_by_session_id_ht_node;
- /* Indexed key. Incremented value in the consumer. */
- uint64_t key;
- /* Number of streams referencing this channel */
- int refcount;
- /* Tracing session id on the session daemon side. */
- uint64_t session_id;
- /* Current trace chunk of the session in which this channel exists. */
- struct lttng_trace_chunk *trace_chunk;
- /*
- * Session id when requesting metadata to the session daemon for
- * a session with per-PID buffers.
- */
- uint64_t session_id_per_pid;
- /*
- * In the case of local streams, this field contains the channel's
- * output path; a path relative to the session's output path.
- * e.g. ust/uid/1000/64-bit
- *
- * In the case of remote streams, the contents of this field depends
- * on the version of the relay daemon peer. For 2.11+ peers, the
- * contents are the same as in the local case. However, for legacy
- * peers, this contains a path of the form:
- * /hostname/session_path/ust/uid/1000/64-bit
- */
- char pathname[PATH_MAX];
- /* Channel name. */
- char name[LTTNG_SYMBOL_NAME_LEN];
- /* Relayd id of the channel. -1ULL if it does not apply. */
- uint64_t relayd_id;
- /*
- * Number of streams NOT initialized yet. This is used in order to not
- * delete this channel if streams are getting initialized.
- */
- unsigned int nb_init_stream_left;
- /* Output type (mmap or splice). */
- enum consumer_channel_output output;
- /* Channel type for stream */
- enum consumer_channel_type type;
-
- /* For UST */
- uid_t ust_app_uid; /* Application UID. */
- struct lttng_ust_ctl_consumer_channel *uchan;
- unsigned char uuid[LTTNG_UUID_STR_LEN];
- /*
- * Temporary stream list used to store the streams once created and waiting
- * to be sent to the session daemon by receiving the
- * LTTNG_CONSUMER_GET_CHANNEL.
- */
- struct stream_list streams;
-
- /*
- * Set if the channel is metadata. We keep a reference to the stream
- * because we have to flush data once pushed by the session daemon. For a
- * regular channel, this is always set to NULL.
- */
- struct lttng_consumer_stream *metadata_stream;
-
- /* for UST */
- int wait_fd;
- /* Node within channel thread ht */
- struct lttng_ht_node_u64 wait_fd_node;
-
- /* Metadata cache is metadata channel */
- struct consumer_metadata_cache *metadata_cache;
-
- /* For UST metadata periodical flush */
- int switch_timer_enabled;
- timer_t switch_timer;
- int switch_timer_error;
-
- /* For the live mode */
- int live_timer_enabled;
- timer_t live_timer;
- int live_timer_error;
- /* Channel is part of a live session ? */
- bool is_live;
-
- /* For channel monitoring timer. */
- int monitor_timer_enabled;
- timer_t monitor_timer;
-
- /* On-disk circular buffer */
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- /*
- * Monitor or not the streams of this channel meaning this indicates if the
- * streams should be sent to the data/metadata thread or added to the no
- * monitor list of the channel.
- */
- unsigned int monitor;
-
- /*
- * Channel lock.
- *
- * This lock protects against concurrent update of channel.
- *
- * This is nested INSIDE the consumer data lock.
- * This is nested OUTSIDE the channel timer lock.
- * This is nested OUTSIDE the metadata cache lock.
- * This is nested OUTSIDE stream lock.
- * This is nested OUTSIDE consumer_relayd_sock_pair lock.
- */
- pthread_mutex_t lock;
-
- /*
- * Channel teardown lock.
- *
- * This lock protect against teardown of channel. It is _never_
- * taken by the timer handler.
- *
- * This is nested INSIDE the consumer data lock.
- * This is nested INSIDE the channel lock.
- * This is nested OUTSIDE the metadata cache lock.
- * This is nested OUTSIDE stream lock.
- * This is nested OUTSIDE consumer_relayd_sock_pair lock.
- */
- pthread_mutex_t timer_lock;
-
- /* Timer value in usec for live streaming. */
- unsigned int live_timer_interval;
-
- int *stream_fds;
- int nr_stream_fds;
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
- /* Only set for UST channels. */
- LTTNG_OPTIONAL(struct lttng_credentials) buffer_credentials;
- /* Total number of discarded events for that channel. */
- uint64_t discarded_events;
- /* Total number of missed packets due to overwriting (overwrite). */
- uint64_t lost_packets;
-
- bool streams_sent_to_relayd;
-};
-
-struct stream_subbuffer {
- union {
- /*
- * CONSUMER_CHANNEL_SPLICE
- * No ownership assumed.
- */
- int fd;
- /* CONSUMER_CHANNEL_MMAP */
- struct lttng_buffer_view buffer;
- } buffer;
- union {
- /*
- * Common members are fine to access through either
- * union entries (as per C11, Common Initial Sequence).
- */
- struct {
- unsigned long subbuf_size;
- unsigned long padded_subbuf_size;
- uint64_t version;
- /*
- * Left unset when unsupported.
- *
- * Indicates that this is the last sub-buffer of
- * a series of sub-buffer that makes-up a coherent
- * (parseable) unit of metadata.
- */
- LTTNG_OPTIONAL(bool) coherent;
- } metadata;
- struct {
- unsigned long subbuf_size;
- unsigned long padded_subbuf_size;
- uint64_t packet_size;
- uint64_t content_size;
- uint64_t timestamp_begin;
- uint64_t timestamp_end;
- uint64_t events_discarded;
- /* Left unset when unsupported. */
- LTTNG_OPTIONAL(uint64_t) sequence_number;
- uint64_t stream_id;
- /* Left unset when unsupported. */
- LTTNG_OPTIONAL(uint64_t) stream_instance_id;
- } data;
- } info;
-};
-
-enum get_next_subbuffer_status {
- GET_NEXT_SUBBUFFER_STATUS_OK,
- GET_NEXT_SUBBUFFER_STATUS_NO_DATA,
- GET_NEXT_SUBBUFFER_STATUS_ERROR,
-};
-
-/*
- * Perform any operation required to acknowledge
- * the wake-up of a consumer stream (e.g. consume a byte on a wake-up pipe).
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
-
-/*
- * Perform any operation required before a consumer stream is put
- * to sleep before awaiting a data availability notification.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*on_sleep_cb)(struct lttng_consumer_stream *,
- struct lttng_consumer_local_data *);
-
-/*
- * Acquire the subbuffer at the current 'consumed' position.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
- struct lttng_consumer_stream *, struct stream_subbuffer *);
-
-/*
- * Populate the stream_subbuffer's info member. The info to populate
- * depends on the type (metadata/data) of the stream.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*extract_subbuffer_info_cb)(
- struct lttng_consumer_stream *, struct stream_subbuffer *);
-
-/*
- * Invoked after a subbuffer's info has been filled.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*pre_consume_subbuffer_cb)(struct lttng_consumer_stream *,
- const struct stream_subbuffer *);
-
-/*
- * Consume subbuffer contents.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
- struct lttng_consumer_stream *,
- const struct stream_subbuffer *);
-
-/*
- * Release the current subbuffer and advance the 'consumed' position by
- * one subbuffer.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*put_next_subbuffer_cb)(struct lttng_consumer_stream *,
- struct stream_subbuffer *);
-
-/*
- * Invoked after consuming a subbuffer.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*post_consume_cb)(struct lttng_consumer_stream *,
- const struct stream_subbuffer *,
- struct lttng_consumer_local_data *);
-
-/*
- * Send a live beacon if no data is available.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef int (*send_live_beacon_cb)(struct lttng_consumer_stream *);
-
-/*
- * Lock the stream and channel locks and any other stream-type specific
- * lock that need to be acquired during the processing of an
- * availability notification.
- */
-typedef void (*lock_cb)(struct lttng_consumer_stream *);
-
-/*
- * Unlock the stream and channel locks and any other stream-type specific
- * lock before sleeping until the next availability notification.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef void (*unlock_cb)(struct lttng_consumer_stream *);
-
-/*
- * Assert that the stream and channel lock and any other stream type specific
- * lock that need to be acquired during the processing of a read_subbuffer
- * operation is acquired.
- */
-typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
-
-/*
- * Invoked when a subbuffer's metadata version does not match the last
- * known metadata version.
- *
- * Stream and channel locks are acquired during this call.
- */
-typedef void (*reset_metadata_cb)(struct lttng_consumer_stream *);
-
-/*
- * Internal representation of the streams, sessiond_key is used to identify
- * uniquely a stream.
- */
-struct lttng_consumer_stream {
- /* HT node used by the data_ht and metadata_ht */
- struct lttng_ht_node_u64 node;
- /* stream indexed per channel key node */
- struct lttng_ht_node_u64 node_channel_id;
- /* HT node used in consumer_data.stream_list_ht */
- struct lttng_ht_node_u64 node_session_id;
- /*
- * List used by channels to reference streams that are not yet globally
- * visible.
- */
- struct cds_list_head send_node;
- /* Pointer to associated channel. */
- struct lttng_consumer_channel *chan;
- /*
- * Current trace chunk. Holds a reference to the trace chunk.
- * `chunk` can be NULL when a stream is not associated to a chunk, e.g.
- * when it was created in the context of a no-output session.
- */
- struct lttng_trace_chunk *trace_chunk;
-
- /* Key by which the stream is indexed for 'node'. */
- uint64_t key;
- /*
- * File descriptor of the data output file. This can be either a file or a
- * socket fd for relayd streaming.
- */
- int out_fd; /* output file to write the data */
- /* Write position in the output file descriptor */
- off_t out_fd_offset;
- /* Amount of bytes written to the output */
- uint64_t output_written;
- int shm_fd_is_copy;
- int data_read;
- int hangup_flush_done;
-
- /*
- * Whether the stream is in a "complete" state (e.g. it does not have a
- * partially written sub-buffer.
- *
- * Initialized to "false" on stream creation (first packet is empty).
- *
- * The various transitions of the quiescent state are:
- * - On "start" tracing: set to false, since the stream is not
- * "complete".
- * - On "stop" tracing: if !quiescent -> flush FINAL (update
- * timestamp_end), and set to true; the stream has entered a
- * complete/quiescent state.
- * - On "destroy" or stream/application hang-up: if !quiescent ->
- * flush FINAL, and set to true.
- *
- * NOTE: Update and read are protected by the stream lock.
- */
- bool quiescent;
-
- /*
- * True if the sequence number is not available (lttng-modules < 2.8).
- */
- bool sequence_number_unavailable;
-
- /*
- * metadata_timer_lock protects flags waiting_on_metadata and
- * missed_metadata_flush.
- */
- pthread_mutex_t metadata_timer_lock;
- /*
- * Flag set when awaiting metadata to be pushed. Used in the
- * timer thread to skip waiting on the stream (and stream lock) to
- * ensure we can proceed to flushing metadata in live mode.
- */
- bool waiting_on_metadata;
- /* Raised when a timer misses a metadata flush. */
- bool missed_metadata_flush;
-
- enum lttng_event_output output;
- /* Maximum subbuffer size (in bytes). */
- unsigned long max_sb_size;
-
- /*
- * Still used by the kernel for MMAP output. For UST, the ustctl getter is
- * used for the mmap base and offset.
- */
- void *mmap_base;
- unsigned long mmap_len;
-
- /* For UST */
-
- int wait_fd;
- /* Network sequence number. Indicating on which relayd socket it goes. */
- uint64_t net_seq_idx;
- /*
- * Indicate if this stream was successfully sent to a relayd. This is set
- * after the refcount of the relayd is incremented and is checked when the
- * stream is closed before decrementing the refcount in order to avoid an
- * unbalanced state.
- */
- unsigned int sent_to_relayd;
-
- /* Identify if the stream is the metadata */
- unsigned int metadata_flag;
- /*
- * Last known metadata version, reset the metadata file in case
- * of change.
- */
- uint64_t metadata_version;
- /* Used when the stream is set for network streaming */
- uint64_t relayd_stream_id;
- /*
- * When sending a stream packet to a relayd, this number is used to track
- * the packet sent by the consumer and seen by the relayd. When sending the
- * data header to the relayd, this number is sent and if the transmission
- * was successful, it is incremented.
- *
- * Even if the full data is not fully transmitted it won't matter since
- * only two possible error can happen after that where either the relayd
- * died or a read error is detected on the stream making this value useless
- * after that.
- *
- * This value SHOULD be read/updated atomically or with the lock acquired.
- */
- uint64_t next_net_seq_num;
- /*
- * Lock to use the stream FDs since they are used between threads.
- *
- * This is nested INSIDE the consumer_data lock.
- * This is nested INSIDE the channel lock.
- * This is nested INSIDE the channel timer lock.
- * This is nested OUTSIDE the metadata cache lock.
- * This is nested OUTSIDE consumer_relayd_sock_pair lock.
- */
- pthread_mutex_t lock;
- /* Tracing session id */
- uint64_t session_id;
- /*
- * Indicates if the stream end point is still active or not (network
- * streaming or local file system). The thread "owning" the stream is
- * handling this status and can be notified of a state change through the
- * consumer data appropriate pipe.
- */
- enum consumer_endpoint_status endpoint_status;
- /* Stream name. Format is: <channel_name>_<cpu_number> */
- char name[LTTNG_SYMBOL_NAME_LEN];
- /* Internal state of libustctl. */
- struct lttng_ust_ctl_consumer_stream *ustream;
- /* On-disk circular buffer */
- uint64_t tracefile_size_current;
- uint64_t tracefile_count_current;
- /*
- * Monitor or not the streams of this channel meaning this indicates if the
- * streams should be sent to the data/metadata thread or added to the no
- * monitor list of the channel.
- */
- unsigned int monitor;
- /*
- * Indicate if the stream is globally visible meaning that it has been
- * added to the multiple hash tables. If *not* set, NO lock should be
- * acquired in the destroy path.
- */
- unsigned int globally_visible;
- /*
- * Pipe to wake up the metadata poll thread when the UST metadata
- * cache is updated.
- */
- int ust_metadata_poll_pipe[2];
- /*
- * How much metadata was read from the metadata cache and sent
- * to the channel.
- */
- uint64_t ust_metadata_pushed;
- /*
- * Copy of the last discarded event value to detect the overflow of
- * the counter.
- */
- uint64_t last_discarded_events;
- /* Copy of the sequence number of the last packet extracted. */
- uint64_t last_sequence_number;
- /*
- * Index file object of the index file for this stream.
- */
- struct lttng_index_file *index_file;
-
- /*
- * Local pipe to extract data when using splice.
- */
- int splice_pipe[2];
-
- /*
- * Rendez-vous point between data and metadata stream in live mode.
- */
- pthread_cond_t metadata_rdv;
- pthread_mutex_t metadata_rdv_lock;
-
- /*
- * rotate_position represents the packet sequence number of the last
- * packet which belongs to the current trace chunk prior to the rotation.
- * When that position is reached, this tracefile can be closed and a
- * new one is created in channel_read_only_attributes.path.
- */
- uint64_t rotate_position;
-
- /* Whether or not a packet was opened during the current trace chunk. */
- bool opened_packet_in_current_trace_chunk;
-
- /*
- * Read-only copies of channel values. We cannot safely access the
- * channel from a stream, so we need to have a local copy of these
- * fields in the stream object. These fields should be removed from
- * the stream objects when we introduce refcounting.
- */
- struct {
- uint64_t tracefile_size;
- } channel_read_only_attributes;
-
- /*
- * Flag to inform the data or metadata thread that a stream is
- * ready to be rotated.
- */
- bool rotate_ready;
-
- /* Indicate if the stream still has some data to be read. */
- unsigned int has_data:1;
- /*
- * Inform the consumer or relay to reset the metadata
- * file before writing in it (regeneration).
- */
- unsigned int reset_metadata_flag:1;
- struct {
- /*
- * Invoked in the order of declaration.
- * See callback type definitions.
- */
- lock_cb lock;
- on_wake_up_cb on_wake_up;
- get_next_subbuffer_cb get_next_subbuffer;
- extract_subbuffer_info_cb extract_subbuffer_info;
- pre_consume_subbuffer_cb pre_consume_subbuffer;
- reset_metadata_cb reset_metadata;
- consume_subbuffer_cb consume_subbuffer;
- put_next_subbuffer_cb put_next_subbuffer;
- struct lttng_dynamic_array post_consume_cbs;
- send_live_beacon_cb send_live_beacon;
- on_sleep_cb on_sleep;
- unlock_cb unlock;
- assert_locked_cb assert_locked;
- } read_subbuffer_ops;
- struct metadata_bucket *metadata_bucket;
-};
-
-/*
- * Internal representation of a relayd socket pair.
- */
-struct consumer_relayd_sock_pair {
- /* Network sequence number. */
- uint64_t net_seq_idx;
- /* Number of stream associated with this relayd */
- int refcount;
-
- /*
- * This flag indicates whether or not we should destroy this object. The
- * destruction should ONLY occurs when this flag is set and the refcount is
- * set to zero.
- */
- unsigned int destroy_flag;
-
- /*
- * Mutex protecting the control socket to avoid out of order packets
- * between threads sending data to the relayd. Since metadata data is sent
- * over that socket, at least two sendmsg() are needed (header + data)
- * creating a race for packets to overlap between threads using it.
- *
- * This is nested INSIDE the consumer_data lock.
- * This is nested INSIDE the stream lock.
- */
- pthread_mutex_t ctrl_sock_mutex;
-
- /* Control socket. Command and metadata are passed over it */
- struct lttcomm_relayd_sock control_sock;
-
- /*
- * We don't need a mutex at this point since we only splice or write single
- * large chunk of data with a header appended at the begining. Moreover,
- * this socket is for now only used in a single thread.
- */
- struct lttcomm_relayd_sock data_sock;
- struct lttng_ht_node_u64 node;
-
- /* Session id on both sides for the sockets. */
- uint64_t relayd_session_id;
- uint64_t sessiond_session_id;
- struct lttng_consumer_local_data *ctx;
-};
-
-/*
- * UST consumer local data to the program. One or more instance per
- * process.
- */
-struct lttng_consumer_local_data {
- /*
- * Function to call when data is available on a buffer.
- * Returns the number of bytes read, or negative error value.
- */
- ssize_t (*on_buffer_ready)(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx,
- bool locked_by_caller);
- /*
- * function to call when we receive a new channel, it receives a
- * newly allocated channel, depending on the return code of this
- * function, the new channel will be handled by the application
- * or the library.
- *
- * Returns:
- * > 0 (success, FD is kept by application)
- * == 0 (success, FD is left to library)
- * < 0 (error)
- */
- int (*on_recv_channel)(struct lttng_consumer_channel *channel);
- /*
- * function to call when we receive a new stream, it receives a
- * newly allocated stream, depending on the return code of this
- * function, the new stream will be handled by the application
- * or the library.
- *
- * Returns:
- * > 0 (success, FD is kept by application)
- * == 0 (success, FD is left to library)
- * < 0 (error)
- */
- int (*on_recv_stream)(struct lttng_consumer_stream *stream);
- /*
- * function to call when a stream is getting updated by the session
- * daemon, this function receives the sessiond key and the new
- * state, depending on the return code of this function the
- * update of state for the stream is handled by the application
- * or the library.
- *
- * Returns:
- * > 0 (success, FD is kept by application)
- * == 0 (success, FD is left to library)
- * < 0 (error)
- */
- int (*on_update_stream)(uint64_t sessiond_key, uint32_t state);
- enum lttng_consumer_type type;
- /* socket to communicate errors with sessiond */
- int consumer_error_socket;
- /* socket to ask metadata to sessiond. */
- int consumer_metadata_socket;
- /*
- * Protect consumer_metadata_socket.
- *
- * This is nested OUTSIDE the metadata cache lock.
- */
- pthread_mutex_t metadata_socket_lock;
- /* socket to exchange commands with sessiond */
- char *consumer_command_sock_path;
- /* communication with splice */
- int consumer_channel_pipe[2];
- /* Data stream poll thread pipe. To transfer data stream to the thread */
- struct lttng_pipe *consumer_data_pipe;
-
- /*
- * Data thread use that pipe to catch wakeup from read subbuffer that
- * detects that there is still data to be read for the stream encountered.
- * Before doing so, the stream is flagged to indicate that there is still
- * data to be read.
- *
- * Both pipes (read/write) are owned and used inside the data thread.
- */
- struct lttng_pipe *consumer_wakeup_pipe;
- /* Indicate if the wakeup thread has been notified. */
- unsigned int has_wakeup:1;
-
- /* to let the signal handler wake up the fd receiver thread */
- int consumer_should_quit[2];
- /* Metadata poll thread pipe. Transfer metadata stream to it */
- struct lttng_pipe *consumer_metadata_pipe;
- /*
- * Pipe used by the channel monitoring timers to provide state samples
- * to the session daemon (write-only).
- */
- int channel_monitor_pipe;
- LTTNG_OPTIONAL(lttng_uuid) sessiond_uuid;
-};
-
-/*
- * Library-level data. One instance per process.
- */
-struct lttng_consumer_global_data {
- /*
- * At this time, this lock is used to ensure coherence between the count
- * and number of element in the hash table. It's also a protection for
- * concurrent read/write between threads.
- *
- * This is nested OUTSIDE the stream lock.
- * This is nested OUTSIDE the consumer_relayd_sock_pair lock.
- */
- pthread_mutex_t lock {};
-
- /*
- * Number of streams in the data stream hash table declared outside.
- * Protected by consumer_data.lock.
- */
- int stream_count = 0;
-
- /* Channel hash table protected by consumer_data.lock. */
- struct lttng_ht *channel_ht = nullptr;
- /* Channel hash table indexed by session id. */
- struct lttng_ht *channels_by_session_id_ht = nullptr;
- /*
- * Flag specifying if the local array of FDs needs update in the
- * poll function. Protected by consumer_data.lock.
- */
- unsigned int need_update = 1;
- enum lttng_consumer_type type = LTTNG_CONSUMER_UNKNOWN;
-
- /*
- * Relayd socket(s) hashtable indexed by network sequence number. Each
- * stream has an index which associate the right relayd socket to use.
- */
- struct lttng_ht *relayd_ht = nullptr;
-
- /*
- * This hash table contains all streams (metadata and data) indexed by
- * session id. In other words, the ht is indexed by session id and each
- * bucket contains the list of associated streams.
- *
- * This HT uses the "node_session_id" of the consumer stream.
- */
- struct lttng_ht *stream_list_ht = nullptr;
-
- /*
- * This HT uses the "node_channel_id" of the consumer stream.
- */
- struct lttng_ht *stream_per_chan_id_ht = nullptr;
-
- /*
- * Trace chunk registry indexed by (session_id, chunk_id).
- */
- struct lttng_trace_chunk_registry *chunk_registry = nullptr;
-};
-
-/*
- * Set to nonzero when the consumer is exiting. Updated by signal
- * handler and thread exit, read by threads.
- */
-extern int consumer_quit;
-
-/*
- * Set to nonzero when the consumer is exiting. Updated by signal
- * handler and thread exit, read by threads.
- */
-extern int consumer_quit;
-
-/*
- * Flag used to temporarily pause data consumption from testpoints.
- *
- * This variable is dlsym-ed from a test, so needs to be exported.
- */
-LTTNG_EXPORT extern int data_consumption_paused;
-
-/* Return a human-readable consumer type string that is suitable for logging. */
-static inline
-const char *lttng_consumer_type_str(enum lttng_consumer_type type)
-{
- switch (type) {
- case LTTNG_CONSUMER_UNKNOWN:
- return "unknown";
- case LTTNG_CONSUMER_KERNEL:
- return "kernel";
- case LTTNG_CONSUMER32_UST:
- return "32-bit user space";
- case LTTNG_CONSUMER64_UST:
- return "64-bit user space";
- default:
- abort();
- }
-}
-
-/*
- * Init consumer data structures.
- */
-int lttng_consumer_init(void);
-
-/*
- * Set the error socket for communication with a session daemon.
- */
-void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx,
- int sock);
-
-/*
- * Set the command socket path for communication with a session daemon.
- */
-void lttng_consumer_set_command_sock_path(
- struct lttng_consumer_local_data *ctx, char *sock);
-
-/*
- * Send return code to session daemon.
- *
- * Returns the return code of sendmsg : the number of bytes transmitted or -1
- * on error.
- */
-int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
-
-/*
- * Called from signal handler to ensure a clean exit.
- */
-void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx);
-
-/*
- * Cleanup the daemon's socket on exit.
- */
-void lttng_consumer_cleanup(void);
-
-/*
- * Poll on the should_quit pipe and the command socket return -1 on error and
- * should exit, 0 if data is available on the command socket
- */
-int lttng_consumer_poll_socket(struct pollfd *kconsumer_sockpoll);
-
-/*
- * Copy the fields from the channel that need to be accessed (read-only)
- * directly from the stream.
- */
-void consumer_stream_update_channel_attributes(
- struct lttng_consumer_stream *stream,
- struct lttng_consumer_channel *channel);
-
-struct lttng_consumer_stream *consumer_allocate_stream(
- struct lttng_consumer_channel *channel,
- uint64_t channel_key,
- uint64_t stream_key,
- const char *channel_name,
- uint64_t relayd_id,
- uint64_t session_id,
- struct lttng_trace_chunk *trace_chunk,
- int cpu,
- int *alloc_ret,
- enum consumer_channel_type type,
- unsigned int monitor);
-struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
- uint64_t session_id,
- const uint64_t *chunk_id,
- const char *pathname,
- const char *name,
- uint64_t relayd_id,
- enum lttng_event_output output,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- uint64_t session_id_per_pid,
- unsigned int monitor,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- const char *root_shm_path,
- const char *shm_path);
-void consumer_del_stream(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht);
-void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht);
-int consumer_add_channel(struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx);
-void consumer_del_channel(struct lttng_consumer_channel *channel);
-
-/* lttng-relayd consumer command */
-struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
-int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
-int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
-void close_relayd_stream(struct lttng_consumer_stream *stream);
-struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
-int consumer_handle_stream_before_relayd(struct lttng_consumer_stream *stream,
- size_t data_size);
-void consumer_steal_stream_key(int key, struct lttng_ht *ht);
-
-struct lttng_consumer_local_data *lttng_consumer_create(
- enum lttng_consumer_type type,
- ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx,
- bool locked_by_caller),
- int (*recv_channel)(struct lttng_consumer_channel *channel),
- int (*recv_stream)(struct lttng_consumer_stream *stream),
- int (*update_stream)(uint64_t sessiond_key, uint32_t state));
-void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx);
-ssize_t lttng_consumer_on_read_subbuffer_mmap(
- struct lttng_consumer_stream *stream,
- const struct lttng_buffer_view *buffer,
- unsigned long padding);
-ssize_t lttng_consumer_on_read_subbuffer_splice(
- struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_stream *stream, unsigned long len,
- unsigned long padding);
-int lttng_consumer_sample_snapshot_positions(struct lttng_consumer_stream *stream);
-int lttng_consumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos);
-int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos);
-int lttng_ustconsumer_get_wakeup_fd(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_close_wakeup_fd(struct lttng_consumer_stream *stream);
-void *consumer_thread_metadata_poll(void *data);
-void *consumer_thread_data_poll(void *data);
-void *consumer_thread_sessiond_poll(void *data);
-void *consumer_thread_channel_poll(void *data);
-int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll);
-
-ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx,
- bool locked_by_caller);
-int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream);
-void consumer_add_relayd_socket(uint64_t net_seq_idx,
- int sock_type,
- struct lttng_consumer_local_data *ctx,
- int sock,
- struct pollfd *consumer_sockpoll,
- uint64_t sessiond_id,
- uint64_t relayd_session_id,
- uint32_t relayd_version_major,
- uint32_t relayd_version_minor,
- enum lttcomm_sock_proto relayd_socket_protocol);
-void consumer_flag_relayd_for_destroy(
- struct consumer_relayd_sock_pair *relayd);
-int consumer_data_pending(uint64_t id);
-int consumer_send_status_msg(int sock, int ret_code);
-int consumer_send_status_channel(int sock,
- struct lttng_consumer_channel *channel);
-void notify_thread_del_channel(struct lttng_consumer_local_data *ctx,
- uint64_t key);
-void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd);
-unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
- unsigned long produced_pos, uint64_t nb_packets_per_stream,
- uint64_t max_sb_size);
-void consumer_add_data_stream(struct lttng_consumer_stream *stream);
-void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
-void consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
-void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
-int consumer_create_index_file(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
- uint64_t key, uint64_t relayd_id);
-int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_stream(struct lttng_consumer_stream *stream);
-int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel,
- uint64_t key);
-void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream);
-enum lttcomm_return_code lttng_consumer_create_trace_chunk(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id,
- time_t chunk_creation_timestamp,
- const char *chunk_override_name,
- const struct lttng_credentials *credentials,
- struct lttng_directory_handle *chunk_directory_handle);
-enum lttcomm_return_code lttng_consumer_close_trace_chunk(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id, time_t chunk_close_timestamp,
- const enum lttng_trace_chunk_command_type *close_command,
- char *path);
-enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id);
-void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
-enum lttcomm_return_code lttng_consumer_init_command(
- struct lttng_consumer_local_data *ctx,
- const lttng_uuid sessiond_uuid);
-int lttng_consumer_clear_channel(struct lttng_consumer_channel *channel);
-enum lttcomm_return_code lttng_consumer_open_channel_packets(
- struct lttng_consumer_channel *channel);
-int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel);
-void lttng_consumer_sigbus_handle(void *addr);
-
-#endif /* LIB_CONSUMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LIB_CONSUMER_H
+#define LIB_CONSUMER_H
+
+#include <limits.h>
+#include <poll.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <urcu/list.h>
+
+#include <lttng/lttng.h>
+
+#include <common/hashtable/hashtable.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/uuid.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/pipe.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/credentials.hpp>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+
+struct lttng_consumer_local_data;
+
+/* Commands for consumer */
+enum lttng_consumer_command {
+ LTTNG_CONSUMER_ADD_CHANNEL,
+ LTTNG_CONSUMER_ADD_STREAM,
+ /* pause, delete, active depending on fd state */
+ LTTNG_CONSUMER_UPDATE_STREAM,
+ /* inform the consumer to quit when all fd has hang up */
+ LTTNG_CONSUMER_STOP, /* deprecated */
+ LTTNG_CONSUMER_ADD_RELAYD_SOCKET,
+ /* Inform the consumer to kill a specific relayd connection */
+ LTTNG_CONSUMER_DESTROY_RELAYD,
+ /* Return to the sessiond if there is data pending for a session */
+ LTTNG_CONSUMER_DATA_PENDING,
+ /* Consumer creates a channel and returns it to sessiond. */
+ LTTNG_CONSUMER_ASK_CHANNEL_CREATION,
+ LTTNG_CONSUMER_GET_CHANNEL,
+ LTTNG_CONSUMER_DESTROY_CHANNEL,
+ LTTNG_CONSUMER_PUSH_METADATA,
+ LTTNG_CONSUMER_CLOSE_METADATA,
+ LTTNG_CONSUMER_SETUP_METADATA,
+ LTTNG_CONSUMER_FLUSH_CHANNEL,
+ LTTNG_CONSUMER_SNAPSHOT_CHANNEL,
+ LTTNG_CONSUMER_SNAPSHOT_METADATA,
+ LTTNG_CONSUMER_STREAMS_SENT,
+ LTTNG_CONSUMER_DISCARDED_EVENTS,
+ LTTNG_CONSUMER_LOST_PACKETS,
+ LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL,
+ LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE,
+ LTTNG_CONSUMER_ROTATE_CHANNEL,
+ LTTNG_CONSUMER_INIT,
+ LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
+ LTTNG_CONSUMER_CLOSE_TRACE_CHUNK,
+ LTTNG_CONSUMER_TRACE_CHUNK_EXISTS,
+ LTTNG_CONSUMER_CLEAR_CHANNEL,
+ LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS,
+};
+
+enum lttng_consumer_type {
+ LTTNG_CONSUMER_UNKNOWN = 0,
+ LTTNG_CONSUMER_KERNEL,
+ LTTNG_CONSUMER64_UST,
+ LTTNG_CONSUMER32_UST,
+};
+
+enum consumer_endpoint_status {
+ CONSUMER_ENDPOINT_ACTIVE,
+ CONSUMER_ENDPOINT_INACTIVE,
+};
+
+enum consumer_channel_output {
+ CONSUMER_CHANNEL_MMAP = 0,
+ CONSUMER_CHANNEL_SPLICE = 1,
+};
+
+enum consumer_channel_type {
+ CONSUMER_CHANNEL_TYPE_METADATA = 0,
+ CONSUMER_CHANNEL_TYPE_DATA = 1,
+};
+
+enum sync_metadata_status {
+ SYNC_METADATA_STATUS_NEW_DATA,
+ SYNC_METADATA_STATUS_NO_DATA,
+ SYNC_METADATA_STATUS_ERROR,
+};
+
+extern struct lttng_consumer_global_data the_consumer_data;
+
+struct stream_list {
+ struct cds_list_head head;
+ unsigned int count;
+};
+
+/* Stub. */
+struct consumer_metadata_cache;
+
+struct lttng_consumer_channel {
+ /* Is the channel published in the channel hash tables? */
+ bool is_published;
+ /*
+ * Was the channel deleted (logically) and waiting to be reclaimed?
+ * If this flag is set, no modification that is not cleaned-up by the
+ * RCU reclamation callback should be made
+ */
+ bool is_deleted;
+ /* HT node used for consumer_data.channel_ht */
+ struct lttng_ht_node_u64 node;
+ /* HT node used for consumer_data.channels_by_session_id_ht */
+ struct lttng_ht_node_u64 channels_by_session_id_ht_node;
+ /* Indexed key. Incremented value in the consumer. */
+ uint64_t key;
+ /* Number of streams referencing this channel */
+ int refcount;
+ /* Tracing session id on the session daemon side. */
+ uint64_t session_id;
+ /* Current trace chunk of the session in which this channel exists. */
+ struct lttng_trace_chunk *trace_chunk;
+ /*
+ * Session id when requesting metadata to the session daemon for
+ * a session with per-PID buffers.
+ */
+ uint64_t session_id_per_pid;
+ /*
+ * In the case of local streams, this field contains the channel's
+ * output path; a path relative to the session's output path.
+ * e.g. ust/uid/1000/64-bit
+ *
+ * In the case of remote streams, the contents of this field depends
+ * on the version of the relay daemon peer. For 2.11+ peers, the
+ * contents are the same as in the local case. However, for legacy
+ * peers, this contains a path of the form:
+ * /hostname/session_path/ust/uid/1000/64-bit
+ */
+ char pathname[PATH_MAX];
+ /* Channel name. */
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ /* Relayd id of the channel. -1ULL if it does not apply. */
+ uint64_t relayd_id;
+ /*
+ * Number of streams NOT initialized yet. This is used in order to not
+ * delete this channel if streams are getting initialized.
+ */
+ unsigned int nb_init_stream_left;
+ /* Output type (mmap or splice). */
+ enum consumer_channel_output output;
+ /* Channel type for stream */
+ enum consumer_channel_type type;
+
+ /* For UST */
+ uid_t ust_app_uid; /* Application UID. */
+ struct lttng_ust_ctl_consumer_channel *uchan;
+ unsigned char uuid[LTTNG_UUID_STR_LEN];
+ /*
+ * Temporary stream list used to store the streams once created and waiting
+ * to be sent to the session daemon by receiving the
+ * LTTNG_CONSUMER_GET_CHANNEL.
+ */
+ struct stream_list streams;
+
+ /*
+ * Set if the channel is metadata. We keep a reference to the stream
+ * because we have to flush data once pushed by the session daemon. For a
+ * regular channel, this is always set to NULL.
+ */
+ struct lttng_consumer_stream *metadata_stream;
+
+ /* for UST */
+ int wait_fd;
+ /* Node within channel thread ht */
+ struct lttng_ht_node_u64 wait_fd_node;
+
+ /* Metadata cache is metadata channel */
+ struct consumer_metadata_cache *metadata_cache;
+
+ /* For UST metadata periodical flush */
+ int switch_timer_enabled;
+ timer_t switch_timer;
+ int switch_timer_error;
+
+ /* For the live mode */
+ int live_timer_enabled;
+ timer_t live_timer;
+ int live_timer_error;
+ /* Channel is part of a live session ? */
+ bool is_live;
+
+ /* For channel monitoring timer. */
+ int monitor_timer_enabled;
+ timer_t monitor_timer;
+
+ /* On-disk circular buffer */
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ /*
+ * Monitor or not the streams of this channel meaning this indicates if the
+ * streams should be sent to the data/metadata thread or added to the no
+ * monitor list of the channel.
+ */
+ unsigned int monitor;
+
+ /*
+ * Channel lock.
+ *
+ * This lock protects against concurrent update of channel.
+ *
+ * This is nested INSIDE the consumer data lock.
+ * This is nested OUTSIDE the channel timer lock.
+ * This is nested OUTSIDE the metadata cache lock.
+ * This is nested OUTSIDE stream lock.
+ * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+ */
+ pthread_mutex_t lock;
+
+ /*
+ * Channel teardown lock.
+ *
+ * This lock protect against teardown of channel. It is _never_
+ * taken by the timer handler.
+ *
+ * This is nested INSIDE the consumer data lock.
+ * This is nested INSIDE the channel lock.
+ * This is nested OUTSIDE the metadata cache lock.
+ * This is nested OUTSIDE stream lock.
+ * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+ */
+ pthread_mutex_t timer_lock;
+
+ /* Timer value in usec for live streaming. */
+ unsigned int live_timer_interval;
+
+ int *stream_fds;
+ int nr_stream_fds;
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+ /* Only set for UST channels. */
+ LTTNG_OPTIONAL(struct lttng_credentials) buffer_credentials;
+ /* Total number of discarded events for that channel. */
+ uint64_t discarded_events;
+ /* Total number of missed packets due to overwriting (overwrite). */
+ uint64_t lost_packets;
+
+ bool streams_sent_to_relayd;
+};
+
+struct stream_subbuffer {
+ union {
+ /*
+ * CONSUMER_CHANNEL_SPLICE
+ * No ownership assumed.
+ */
+ int fd;
+ /* CONSUMER_CHANNEL_MMAP */
+ struct lttng_buffer_view buffer;
+ } buffer;
+ union {
+ /*
+ * Common members are fine to access through either
+ * union entries (as per C11, Common Initial Sequence).
+ */
+ struct {
+ unsigned long subbuf_size;
+ unsigned long padded_subbuf_size;
+ uint64_t version;
+ /*
+ * Left unset when unsupported.
+ *
+ * Indicates that this is the last sub-buffer of
+ * a series of sub-buffer that makes-up a coherent
+ * (parseable) unit of metadata.
+ */
+ LTTNG_OPTIONAL(bool) coherent;
+ } metadata;
+ struct {
+ unsigned long subbuf_size;
+ unsigned long padded_subbuf_size;
+ uint64_t packet_size;
+ uint64_t content_size;
+ uint64_t timestamp_begin;
+ uint64_t timestamp_end;
+ uint64_t events_discarded;
+ /* Left unset when unsupported. */
+ LTTNG_OPTIONAL(uint64_t) sequence_number;
+ uint64_t stream_id;
+ /* Left unset when unsupported. */
+ LTTNG_OPTIONAL(uint64_t) stream_instance_id;
+ } data;
+ } info;
+};
+
+enum get_next_subbuffer_status {
+ GET_NEXT_SUBBUFFER_STATUS_OK,
+ GET_NEXT_SUBBUFFER_STATUS_NO_DATA,
+ GET_NEXT_SUBBUFFER_STATUS_ERROR,
+};
+
+/*
+ * Perform any operation required to acknowledge
+ * the wake-up of a consumer stream (e.g. consume a byte on a wake-up pipe).
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Perform any operation required before a consumer stream is put
+ * to sleep before awaiting a data availability notification.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*on_sleep_cb)(struct lttng_consumer_stream *,
+ struct lttng_consumer_local_data *);
+
+/*
+ * Acquire the subbuffer at the current 'consumed' position.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
+ struct lttng_consumer_stream *, struct stream_subbuffer *);
+
+/*
+ * Populate the stream_subbuffer's info member. The info to populate
+ * depends on the type (metadata/data) of the stream.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*extract_subbuffer_info_cb)(
+ struct lttng_consumer_stream *, struct stream_subbuffer *);
+
+/*
+ * Invoked after a subbuffer's info has been filled.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*pre_consume_subbuffer_cb)(struct lttng_consumer_stream *,
+ const struct stream_subbuffer *);
+
+/*
+ * Consume subbuffer contents.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
+ struct lttng_consumer_stream *,
+ const struct stream_subbuffer *);
+
+/*
+ * Release the current subbuffer and advance the 'consumed' position by
+ * one subbuffer.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*put_next_subbuffer_cb)(struct lttng_consumer_stream *,
+ struct stream_subbuffer *);
+
+/*
+ * Invoked after consuming a subbuffer.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*post_consume_cb)(struct lttng_consumer_stream *,
+ const struct stream_subbuffer *,
+ struct lttng_consumer_local_data *);
+
+/*
+ * Send a live beacon if no data is available.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef int (*send_live_beacon_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Lock the stream and channel locks and any other stream-type specific
+ * lock that need to be acquired during the processing of an
+ * availability notification.
+ */
+typedef void (*lock_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Unlock the stream and channel locks and any other stream-type specific
+ * lock before sleeping until the next availability notification.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef void (*unlock_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Assert that the stream and channel lock and any other stream type specific
+ * lock that need to be acquired during the processing of a read_subbuffer
+ * operation is acquired.
+ */
+typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Invoked when a subbuffer's metadata version does not match the last
+ * known metadata version.
+ *
+ * Stream and channel locks are acquired during this call.
+ */
+typedef void (*reset_metadata_cb)(struct lttng_consumer_stream *);
+
+/*
+ * Internal representation of the streams, sessiond_key is used to identify
+ * uniquely a stream.
+ */
+struct lttng_consumer_stream {
+ /* HT node used by the data_ht and metadata_ht */
+ struct lttng_ht_node_u64 node;
+ /* stream indexed per channel key node */
+ struct lttng_ht_node_u64 node_channel_id;
+ /* HT node used in consumer_data.stream_list_ht */
+ struct lttng_ht_node_u64 node_session_id;
+ /*
+ * List used by channels to reference streams that are not yet globally
+ * visible.
+ */
+ struct cds_list_head send_node;
+ /* Pointer to associated channel. */
+ struct lttng_consumer_channel *chan;
+ /*
+ * Current trace chunk. Holds a reference to the trace chunk.
+ * `chunk` can be NULL when a stream is not associated to a chunk, e.g.
+ * when it was created in the context of a no-output session.
+ */
+ struct lttng_trace_chunk *trace_chunk;
+
+ /* Key by which the stream is indexed for 'node'. */
+ uint64_t key;
+ /*
+ * File descriptor of the data output file. This can be either a file or a
+ * socket fd for relayd streaming.
+ */
+ int out_fd; /* output file to write the data */
+ /* Write position in the output file descriptor */
+ off_t out_fd_offset;
+ /* Amount of bytes written to the output */
+ uint64_t output_written;
+ int shm_fd_is_copy;
+ int data_read;
+ int hangup_flush_done;
+
+ /*
+ * Whether the stream is in a "complete" state (e.g. it does not have a
+ * partially written sub-buffer.
+ *
+ * Initialized to "false" on stream creation (first packet is empty).
+ *
+ * The various transitions of the quiescent state are:
+ * - On "start" tracing: set to false, since the stream is not
+ * "complete".
+ * - On "stop" tracing: if !quiescent -> flush FINAL (update
+ * timestamp_end), and set to true; the stream has entered a
+ * complete/quiescent state.
+ * - On "destroy" or stream/application hang-up: if !quiescent ->
+ * flush FINAL, and set to true.
+ *
+ * NOTE: Update and read are protected by the stream lock.
+ */
+ bool quiescent;
+
+ /*
+ * True if the sequence number is not available (lttng-modules < 2.8).
+ */
+ bool sequence_number_unavailable;
+
+ /*
+ * metadata_timer_lock protects flags waiting_on_metadata and
+ * missed_metadata_flush.
+ */
+ pthread_mutex_t metadata_timer_lock;
+ /*
+ * Flag set when awaiting metadata to be pushed. Used in the
+ * timer thread to skip waiting on the stream (and stream lock) to
+ * ensure we can proceed to flushing metadata in live mode.
+ */
+ bool waiting_on_metadata;
+ /* Raised when a timer misses a metadata flush. */
+ bool missed_metadata_flush;
+
+ enum lttng_event_output output;
+ /* Maximum subbuffer size (in bytes). */
+ unsigned long max_sb_size;
+
+ /*
+ * Still used by the kernel for MMAP output. For UST, the ustctl getter is
+ * used for the mmap base and offset.
+ */
+ void *mmap_base;
+ unsigned long mmap_len;
+
+ /* For UST */
+
+ int wait_fd;
+ /* Network sequence number. Indicating on which relayd socket it goes. */
+ uint64_t net_seq_idx;
+ /*
+ * Indicate if this stream was successfully sent to a relayd. This is set
+ * after the refcount of the relayd is incremented and is checked when the
+ * stream is closed before decrementing the refcount in order to avoid an
+ * unbalanced state.
+ */
+ unsigned int sent_to_relayd;
+
+ /* Identify if the stream is the metadata */
+ unsigned int metadata_flag;
+ /*
+ * Last known metadata version, reset the metadata file in case
+ * of change.
+ */
+ uint64_t metadata_version;
+ /* Used when the stream is set for network streaming */
+ uint64_t relayd_stream_id;
+ /*
+ * When sending a stream packet to a relayd, this number is used to track
+ * the packet sent by the consumer and seen by the relayd. When sending the
+ * data header to the relayd, this number is sent and if the transmission
+ * was successful, it is incremented.
+ *
+ * Even if the full data is not fully transmitted it won't matter since
+ * only two possible error can happen after that where either the relayd
+ * died or a read error is detected on the stream making this value useless
+ * after that.
+ *
+ * This value SHOULD be read/updated atomically or with the lock acquired.
+ */
+ uint64_t next_net_seq_num;
+ /*
+ * Lock to use the stream FDs since they are used between threads.
+ *
+ * This is nested INSIDE the consumer_data lock.
+ * This is nested INSIDE the channel lock.
+ * This is nested INSIDE the channel timer lock.
+ * This is nested OUTSIDE the metadata cache lock.
+ * This is nested OUTSIDE consumer_relayd_sock_pair lock.
+ */
+ pthread_mutex_t lock;
+ /* Tracing session id */
+ uint64_t session_id;
+ /*
+ * Indicates if the stream end point is still active or not (network
+ * streaming or local file system). The thread "owning" the stream is
+ * handling this status and can be notified of a state change through the
+ * consumer data appropriate pipe.
+ */
+ enum consumer_endpoint_status endpoint_status;
+ /* Stream name. Format is: <channel_name>_<cpu_number> */
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ /* Internal state of libustctl. */
+ struct lttng_ust_ctl_consumer_stream *ustream;
+ /* On-disk circular buffer */
+ uint64_t tracefile_size_current;
+ uint64_t tracefile_count_current;
+ /*
+ * Monitor or not the streams of this channel meaning this indicates if the
+ * streams should be sent to the data/metadata thread or added to the no
+ * monitor list of the channel.
+ */
+ unsigned int monitor;
+ /*
+ * Indicate if the stream is globally visible meaning that it has been
+ * added to the multiple hash tables. If *not* set, NO lock should be
+ * acquired in the destroy path.
+ */
+ unsigned int globally_visible;
+ /*
+ * Pipe to wake up the metadata poll thread when the UST metadata
+ * cache is updated.
+ */
+ int ust_metadata_poll_pipe[2];
+ /*
+ * How much metadata was read from the metadata cache and sent
+ * to the channel.
+ */
+ uint64_t ust_metadata_pushed;
+ /*
+ * Copy of the last discarded event value to detect the overflow of
+ * the counter.
+ */
+ uint64_t last_discarded_events;
+ /* Copy of the sequence number of the last packet extracted. */
+ uint64_t last_sequence_number;
+ /*
+ * Index file object of the index file for this stream.
+ */
+ struct lttng_index_file *index_file;
+
+ /*
+ * Local pipe to extract data when using splice.
+ */
+ int splice_pipe[2];
+
+ /*
+ * Rendez-vous point between data and metadata stream in live mode.
+ */
+ pthread_cond_t metadata_rdv;
+ pthread_mutex_t metadata_rdv_lock;
+
+ /*
+ * rotate_position represents the packet sequence number of the last
+ * packet which belongs to the current trace chunk prior to the rotation.
+ * When that position is reached, this tracefile can be closed and a
+ * new one is created in channel_read_only_attributes.path.
+ */
+ uint64_t rotate_position;
+
+ /* Whether or not a packet was opened during the current trace chunk. */
+ bool opened_packet_in_current_trace_chunk;
+
+ /*
+ * Read-only copies of channel values. We cannot safely access the
+ * channel from a stream, so we need to have a local copy of these
+ * fields in the stream object. These fields should be removed from
+ * the stream objects when we introduce refcounting.
+ */
+ struct {
+ uint64_t tracefile_size;
+ } channel_read_only_attributes;
+
+ /*
+ * Flag to inform the data or metadata thread that a stream is
+ * ready to be rotated.
+ */
+ bool rotate_ready;
+
+ /* Indicate if the stream still has some data to be read. */
+ unsigned int has_data:1;
+ /*
+ * Inform the consumer or relay to reset the metadata
+ * file before writing in it (regeneration).
+ */
+ unsigned int reset_metadata_flag:1;
+ struct {
+ /*
+ * Invoked in the order of declaration.
+ * See callback type definitions.
+ */
+ lock_cb lock;
+ on_wake_up_cb on_wake_up;
+ get_next_subbuffer_cb get_next_subbuffer;
+ extract_subbuffer_info_cb extract_subbuffer_info;
+ pre_consume_subbuffer_cb pre_consume_subbuffer;
+ reset_metadata_cb reset_metadata;
+ consume_subbuffer_cb consume_subbuffer;
+ put_next_subbuffer_cb put_next_subbuffer;
+ struct lttng_dynamic_array post_consume_cbs;
+ send_live_beacon_cb send_live_beacon;
+ on_sleep_cb on_sleep;
+ unlock_cb unlock;
+ assert_locked_cb assert_locked;
+ } read_subbuffer_ops;
+ struct metadata_bucket *metadata_bucket;
+};
+
+/*
+ * Internal representation of a relayd socket pair.
+ */
+struct consumer_relayd_sock_pair {
+ /* Network sequence number. */
+ uint64_t net_seq_idx;
+ /* Number of stream associated with this relayd */
+ int refcount;
+
+ /*
+ * This flag indicates whether or not we should destroy this object. The
+ * destruction should ONLY occurs when this flag is set and the refcount is
+ * set to zero.
+ */
+ unsigned int destroy_flag;
+
+ /*
+ * Mutex protecting the control socket to avoid out of order packets
+ * between threads sending data to the relayd. Since metadata data is sent
+ * over that socket, at least two sendmsg() are needed (header + data)
+ * creating a race for packets to overlap between threads using it.
+ *
+ * This is nested INSIDE the consumer_data lock.
+ * This is nested INSIDE the stream lock.
+ */
+ pthread_mutex_t ctrl_sock_mutex;
+
+ /* Control socket. Command and metadata are passed over it */
+ struct lttcomm_relayd_sock control_sock;
+
+ /*
+ * We don't need a mutex at this point since we only splice or write single
+ * large chunk of data with a header appended at the begining. Moreover,
+ * this socket is for now only used in a single thread.
+ */
+ struct lttcomm_relayd_sock data_sock;
+ struct lttng_ht_node_u64 node;
+
+ /* Session id on both sides for the sockets. */
+ uint64_t relayd_session_id;
+ uint64_t sessiond_session_id;
+ struct lttng_consumer_local_data *ctx;
+};
+
+/*
+ * UST consumer local data to the program. One or more instance per
+ * process.
+ */
+struct lttng_consumer_local_data {
+ /*
+ * Function to call when data is available on a buffer.
+ * Returns the number of bytes read, or negative error value.
+ */
+ ssize_t (*on_buffer_ready)(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx,
+ bool locked_by_caller);
+ /*
+ * function to call when we receive a new channel, it receives a
+ * newly allocated channel, depending on the return code of this
+ * function, the new channel will be handled by the application
+ * or the library.
+ *
+ * Returns:
+ * > 0 (success, FD is kept by application)
+ * == 0 (success, FD is left to library)
+ * < 0 (error)
+ */
+ int (*on_recv_channel)(struct lttng_consumer_channel *channel);
+ /*
+ * function to call when we receive a new stream, it receives a
+ * newly allocated stream, depending on the return code of this
+ * function, the new stream will be handled by the application
+ * or the library.
+ *
+ * Returns:
+ * > 0 (success, FD is kept by application)
+ * == 0 (success, FD is left to library)
+ * < 0 (error)
+ */
+ int (*on_recv_stream)(struct lttng_consumer_stream *stream);
+ /*
+ * function to call when a stream is getting updated by the session
+ * daemon, this function receives the sessiond key and the new
+ * state, depending on the return code of this function the
+ * update of state for the stream is handled by the application
+ * or the library.
+ *
+ * Returns:
+ * > 0 (success, FD is kept by application)
+ * == 0 (success, FD is left to library)
+ * < 0 (error)
+ */
+ int (*on_update_stream)(uint64_t sessiond_key, uint32_t state);
+ enum lttng_consumer_type type;
+ /* socket to communicate errors with sessiond */
+ int consumer_error_socket;
+ /* socket to ask metadata to sessiond. */
+ int consumer_metadata_socket;
+ /*
+ * Protect consumer_metadata_socket.
+ *
+ * This is nested OUTSIDE the metadata cache lock.
+ */
+ pthread_mutex_t metadata_socket_lock;
+ /* socket to exchange commands with sessiond */
+ char *consumer_command_sock_path;
+ /* communication with splice */
+ int consumer_channel_pipe[2];
+ /* Data stream poll thread pipe. To transfer data stream to the thread */
+ struct lttng_pipe *consumer_data_pipe;
+
+ /*
+ * Data thread use that pipe to catch wakeup from read subbuffer that
+ * detects that there is still data to be read for the stream encountered.
+ * Before doing so, the stream is flagged to indicate that there is still
+ * data to be read.
+ *
+ * Both pipes (read/write) are owned and used inside the data thread.
+ */
+ struct lttng_pipe *consumer_wakeup_pipe;
+ /* Indicate if the wakeup thread has been notified. */
+ unsigned int has_wakeup:1;
+
+ /* to let the signal handler wake up the fd receiver thread */
+ int consumer_should_quit[2];
+ /* Metadata poll thread pipe. Transfer metadata stream to it */
+ struct lttng_pipe *consumer_metadata_pipe;
+ /*
+ * Pipe used by the channel monitoring timers to provide state samples
+ * to the session daemon (write-only).
+ */
+ int channel_monitor_pipe;
+ LTTNG_OPTIONAL(lttng_uuid) sessiond_uuid;
+};
+
+/*
+ * Library-level data. One instance per process.
+ */
+struct lttng_consumer_global_data {
+ /*
+ * At this time, this lock is used to ensure coherence between the count
+ * and number of element in the hash table. It's also a protection for
+ * concurrent read/write between threads.
+ *
+ * This is nested OUTSIDE the stream lock.
+ * This is nested OUTSIDE the consumer_relayd_sock_pair lock.
+ */
+ pthread_mutex_t lock {};
+
+ /*
+ * Number of streams in the data stream hash table declared outside.
+ * Protected by consumer_data.lock.
+ */
+ int stream_count = 0;
+
+ /* Channel hash table protected by consumer_data.lock. */
+ struct lttng_ht *channel_ht = nullptr;
+ /* Channel hash table indexed by session id. */
+ struct lttng_ht *channels_by_session_id_ht = nullptr;
+ /*
+ * Flag specifying if the local array of FDs needs update in the
+ * poll function. Protected by consumer_data.lock.
+ */
+ unsigned int need_update = 1;
+ enum lttng_consumer_type type = LTTNG_CONSUMER_UNKNOWN;
+
+ /*
+ * Relayd socket(s) hashtable indexed by network sequence number. Each
+ * stream has an index which associate the right relayd socket to use.
+ */
+ struct lttng_ht *relayd_ht = nullptr;
+
+ /*
+ * This hash table contains all streams (metadata and data) indexed by
+ * session id. In other words, the ht is indexed by session id and each
+ * bucket contains the list of associated streams.
+ *
+ * This HT uses the "node_session_id" of the consumer stream.
+ */
+ struct lttng_ht *stream_list_ht = nullptr;
+
+ /*
+ * This HT uses the "node_channel_id" of the consumer stream.
+ */
+ struct lttng_ht *stream_per_chan_id_ht = nullptr;
+
+ /*
+ * Trace chunk registry indexed by (session_id, chunk_id).
+ */
+ struct lttng_trace_chunk_registry *chunk_registry = nullptr;
+};
+
+/*
+ * Set to nonzero when the consumer is exiting. Updated by signal
+ * handler and thread exit, read by threads.
+ */
+extern int consumer_quit;
+
+/*
+ * Set to nonzero when the consumer is exiting. Updated by signal
+ * handler and thread exit, read by threads.
+ */
+extern int consumer_quit;
+
+/*
+ * Flag used to temporarily pause data consumption from testpoints.
+ *
+ * This variable is dlsym-ed from a test, so needs to be exported.
+ */
+LTTNG_EXPORT extern int data_consumption_paused;
+
+/* Return a human-readable consumer type string that is suitable for logging. */
+static inline
+const char *lttng_consumer_type_str(enum lttng_consumer_type type)
+{
+ switch (type) {
+ case LTTNG_CONSUMER_UNKNOWN:
+ return "unknown";
+ case LTTNG_CONSUMER_KERNEL:
+ return "kernel";
+ case LTTNG_CONSUMER32_UST:
+ return "32-bit user space";
+ case LTTNG_CONSUMER64_UST:
+ return "64-bit user space";
+ default:
+ abort();
+ }
+}
+
+/*
+ * Init consumer data structures.
+ */
+int lttng_consumer_init(void);
+
+/*
+ * Set the error socket for communication with a session daemon.
+ */
+void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx,
+ int sock);
+
+/*
+ * Set the command socket path for communication with a session daemon.
+ */
+void lttng_consumer_set_command_sock_path(
+ struct lttng_consumer_local_data *ctx, char *sock);
+
+/*
+ * Send return code to session daemon.
+ *
+ * Returns the return code of sendmsg : the number of bytes transmitted or -1
+ * on error.
+ */
+int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd);
+
+/*
+ * Called from signal handler to ensure a clean exit.
+ */
+void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx);
+
+/*
+ * Cleanup the daemon's socket on exit.
+ */
+void lttng_consumer_cleanup(void);
+
+/*
+ * Poll on the should_quit pipe and the command socket return -1 on error and
+ * should exit, 0 if data is available on the command socket
+ */
+int lttng_consumer_poll_socket(struct pollfd *kconsumer_sockpoll);
+
+/*
+ * Copy the fields from the channel that need to be accessed (read-only)
+ * directly from the stream.
+ */
+void consumer_stream_update_channel_attributes(
+ struct lttng_consumer_stream *stream,
+ struct lttng_consumer_channel *channel);
+
+struct lttng_consumer_stream *consumer_allocate_stream(
+ struct lttng_consumer_channel *channel,
+ uint64_t channel_key,
+ uint64_t stream_key,
+ const char *channel_name,
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *trace_chunk,
+ int cpu,
+ int *alloc_ret,
+ enum consumer_channel_type type,
+ unsigned int monitor);
+struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
+ uint64_t session_id,
+ const uint64_t *chunk_id,
+ const char *pathname,
+ const char *name,
+ uint64_t relayd_id,
+ enum lttng_event_output output,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ uint64_t session_id_per_pid,
+ unsigned int monitor,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ const char *root_shm_path,
+ const char *shm_path);
+void consumer_del_stream(struct lttng_consumer_stream *stream,
+ struct lttng_ht *ht);
+void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
+ struct lttng_ht *ht);
+int consumer_add_channel(struct lttng_consumer_channel *channel,
+ struct lttng_consumer_local_data *ctx);
+void consumer_del_channel(struct lttng_consumer_channel *channel);
+
+/* lttng-relayd consumer command */
+struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
+int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
+int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
+void close_relayd_stream(struct lttng_consumer_stream *stream);
+struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
+int consumer_handle_stream_before_relayd(struct lttng_consumer_stream *stream,
+ size_t data_size);
+void consumer_steal_stream_key(int key, struct lttng_ht *ht);
+
+struct lttng_consumer_local_data *lttng_consumer_create(
+ enum lttng_consumer_type type,
+ ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx,
+ bool locked_by_caller),
+ int (*recv_channel)(struct lttng_consumer_channel *channel),
+ int (*recv_stream)(struct lttng_consumer_stream *stream),
+ int (*update_stream)(uint64_t sessiond_key, uint32_t state));
+void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx);
+ssize_t lttng_consumer_on_read_subbuffer_mmap(
+ struct lttng_consumer_stream *stream,
+ const struct lttng_buffer_view *buffer,
+ unsigned long padding);
+ssize_t lttng_consumer_on_read_subbuffer_splice(
+ struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_stream *stream, unsigned long len,
+ unsigned long padding);
+int lttng_consumer_sample_snapshot_positions(struct lttng_consumer_stream *stream);
+int lttng_consumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_ustconsumer_get_wakeup_fd(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_close_wakeup_fd(struct lttng_consumer_stream *stream);
+void *consumer_thread_metadata_poll(void *data);
+void *consumer_thread_data_poll(void *data);
+void *consumer_thread_sessiond_poll(void *data);
+void *consumer_thread_channel_poll(void *data);
+int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+ int sock, struct pollfd *consumer_sockpoll);
+
+ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx,
+ bool locked_by_caller);
+int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream);
+void consumer_add_relayd_socket(uint64_t net_seq_idx,
+ int sock_type,
+ struct lttng_consumer_local_data *ctx,
+ int sock,
+ struct pollfd *consumer_sockpoll,
+ uint64_t sessiond_id,
+ uint64_t relayd_session_id,
+ uint32_t relayd_version_major,
+ uint32_t relayd_version_minor,
+ enum lttcomm_sock_proto relayd_socket_protocol);
+void consumer_flag_relayd_for_destroy(
+ struct consumer_relayd_sock_pair *relayd);
+int consumer_data_pending(uint64_t id);
+int consumer_send_status_msg(int sock, int ret_code);
+int consumer_send_status_channel(int sock,
+ struct lttng_consumer_channel *channel);
+void notify_thread_del_channel(struct lttng_consumer_local_data *ctx,
+ uint64_t key);
+void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd);
+unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
+ unsigned long produced_pos, uint64_t nb_packets_per_stream,
+ uint64_t max_sb_size);
+void consumer_add_data_stream(struct lttng_consumer_stream *stream);
+void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
+void consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
+void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
+int consumer_create_index_file(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
+ uint64_t key, uint64_t relayd_id);
+int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_stream(struct lttng_consumer_stream *stream);
+int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel,
+ uint64_t key);
+void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream);
+enum lttcomm_return_code lttng_consumer_create_trace_chunk(
+ const uint64_t *relayd_id, uint64_t session_id,
+ uint64_t chunk_id,
+ time_t chunk_creation_timestamp,
+ const char *chunk_override_name,
+ const struct lttng_credentials *credentials,
+ struct lttng_directory_handle *chunk_directory_handle);
+enum lttcomm_return_code lttng_consumer_close_trace_chunk(
+ const uint64_t *relayd_id, uint64_t session_id,
+ uint64_t chunk_id, time_t chunk_close_timestamp,
+ const enum lttng_trace_chunk_command_type *close_command,
+ char *path);
+enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
+ const uint64_t *relayd_id, uint64_t session_id,
+ uint64_t chunk_id);
+void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
+enum lttcomm_return_code lttng_consumer_init_command(
+ struct lttng_consumer_local_data *ctx,
+ const lttng_uuid sessiond_uuid);
+int lttng_consumer_clear_channel(struct lttng_consumer_channel *channel);
+enum lttcomm_return_code lttng_consumer_open_channel_packets(
+ struct lttng_consumer_channel *channel);
+int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel);
+void lttng_consumer_sigbus_handle(void *addr);
+
+#endif /* LIB_CONSUMER_H */
*
*/
-#include "metadata-bucket.h"
+#include "metadata-bucket.hpp"
-#include <common/buffer-view.h>
-#include <common/consumer/consumer.h>
-#include <common/dynamic-buffer.h>
-#include <common/macros.h>
-#include <common/error.h>
+#include <common/buffer-view.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
struct metadata_bucket {
struct lttng_dynamic_buffer content;
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef METADATA_BUCKET_H
-#define METADATA_BUCKET_H
-
-#include <common/consumer/consumer.h>
-
-struct metadata_bucket;
-
-typedef ssize_t (*metadata_bucket_flush_cb)(
- const struct stream_subbuffer *buffer, void *data);
-
-enum metadata_bucket_status {
- METADATA_BUCKET_STATUS_OK,
- METADATA_BUCKET_STATUS_ERROR,
-};
-
-struct metadata_bucket *metadata_bucket_create(
- metadata_bucket_flush_cb flush, void *data);
-
-void metadata_bucket_destroy(struct metadata_bucket *bucket);
-
-enum metadata_bucket_status metadata_bucket_fill(struct metadata_bucket *bucket,
- const struct stream_subbuffer *buffer);
-
-void metadata_bucket_reset(struct metadata_bucket *bucket);
-
-#endif /* METADATA_BUCKET_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef METADATA_BUCKET_H
+#define METADATA_BUCKET_H
+
+#include <common/consumer/consumer.hpp>
+
+struct metadata_bucket;
+
+typedef ssize_t (*metadata_bucket_flush_cb)(
+ const struct stream_subbuffer *buffer, void *data);
+
+enum metadata_bucket_status {
+ METADATA_BUCKET_STATUS_OK,
+ METADATA_BUCKET_STATUS_ERROR,
+};
+
+struct metadata_bucket *metadata_bucket_create(
+ metadata_bucket_flush_cb flush, void *data);
+
+void metadata_bucket_destroy(struct metadata_bucket *bucket);
+
+enum metadata_bucket_status metadata_bucket_fill(struct metadata_bucket *bucket,
+ const struct stream_subbuffer *buffer);
+
+void metadata_bucket_reset(struct metadata_bucket *bucket);
+
+#endif /* METADATA_BUCKET_H */
*
*/
-#include "context.h"
+#include "context.hpp"
#include <stddef.h>
#include <string.h>
-#include <common/error.h>
-#include <common/macros.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
int parse_application_context(const char *str, char **out_provider_name,
char **out_ctx_name)
+++ /dev/null
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_COMMON_CONTEXT_H
-#define LTTNG_COMMON_CONTEXT_H
-
-#include <common/macros.h>
-
-/*
- * Parse string as an application context of the form
- * "$app.provider_name:context_name" and return the provider name and context
- * name separately.
- *
- * provider_name and ctx_name are returned only if an application context name
- * was successfully parsed and must be freed by the caller.
- *
- * Returns 0 if the string is a valid application context, else a negative
- * value on error.
- */
-int parse_application_context(const char *str, char **provider_name,
- char **ctx_name);
-
-#endif /* LTTNG_COMMON_CONTEXT_H */
--- /dev/null
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_CONTEXT_H
+#define LTTNG_COMMON_CONTEXT_H
+
+#include <common/macros.hpp>
+
+/*
+ * Parse string as an application context of the form
+ * "$app.provider_name:context_name" and return the provider name and context
+ * name separately.
+ *
+ * provider_name and ctx_name are returned only if an application context name
+ * was successfully parsed and must be freed by the caller.
+ *
+ * Returns 0 if the string is a valid application context, else a negative
+ * value on error.
+ */
+int parse_application_context(const char *str, char **provider_name,
+ char **ctx_name);
+
+#endif /* LTTNG_COMMON_CONTEXT_H */
*/
#include <stdbool.h>
-#include "credentials.h"
+#include "credentials.hpp"
uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds)
{
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CREDENTIALS_H
-#define LTTNG_CREDENTIALS_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include "macros.h"
-
-#include "optional.h"
-
-struct lttng_credentials {
- LTTNG_OPTIONAL(uid_t) uid;
- LTTNG_OPTIONAL(gid_t) gid;
-};
-
-uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds);
-
-gid_t lttng_credentials_get_gid(const struct lttng_credentials *creds);
-
-bool lttng_credentials_is_equal_uid(const struct lttng_credentials *a,
- const struct lttng_credentials *b);
-
-bool lttng_credentials_is_equal_gid(const struct lttng_credentials *a,
- const struct lttng_credentials *b);
-
-bool lttng_credentials_is_equal(const struct lttng_credentials *a,
- const struct lttng_credentials *b);
-
-#endif /* LTTNG_CREDENTIALS_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CREDENTIALS_H
+#define LTTNG_CREDENTIALS_H
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include "macros.hpp"
+
+#include "optional.hpp"
+
+struct lttng_credentials {
+ LTTNG_OPTIONAL(uid_t) uid;
+ LTTNG_OPTIONAL(gid_t) gid;
+};
+
+uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds);
+
+gid_t lttng_credentials_get_gid(const struct lttng_credentials *creds);
+
+bool lttng_credentials_is_equal_uid(const struct lttng_credentials *a,
+ const struct lttng_credentials *b);
+
+bool lttng_credentials_is_equal_gid(const struct lttng_credentials *a,
+ const struct lttng_credentials *b);
+
+bool lttng_credentials_is_equal(const struct lttng_credentials *a,
+ const struct lttng_credentials *b);
+
+#endif /* LTTNG_CREDENTIALS_H */
#define _LGPL_SOURCE
#include <unistd.h>
-#include <common/compat/paths.h>
+#include <common/compat/paths.hpp>
#include <fcntl.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <urcu/system.h>
-#include <common/daemonize.h>
-#include <common/error.h>
+#include <common/daemonize.hpp>
+#include <common/error.hpp>
int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
int close_fds)
+++ /dev/null
-#ifndef LTTNG_DAEMONIZE_H
-#define LTTNG_DAEMONIZE_H
-
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#include <unistd.h>
-#include <common/macros.h>
-
-/*
- * Daemonize this process by forking and making the parent wait for the child
- * to signal it indicating readiness. Once received, the parent successfully
- * quits.
- *
- * The child process undergoes the same action that daemon(3) does meaning
- * setsid, chdir, and dup /dev/null into 0, 1 and 2.
- *
- * Return 0 on success else -1 on error.
- */
-int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
- int close_fds);
-
-#endif /* LTTNG_DAEMONIZE_H */
--- /dev/null
+#ifndef LTTNG_DAEMONIZE_H
+#define LTTNG_DAEMONIZE_H
+
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <unistd.h>
+#include <common/macros.hpp>
+
+/*
+ * Daemonize this process by forking and making the parent wait for the child
+ * to signal it indicating readiness. Once received, the parent successfully
+ * quits.
+ *
+ * The child process undergoes the same action that daemon(3) does meaning
+ * setsid, chdir, and dup /dev/null into 0, 1 and 2.
+ *
+ * Return 0 on success else -1 on error.
+ */
+int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
+ int close_fds);
+
+#endif /* LTTNG_DAEMONIZE_H */
#include <pthread.h>
#include <algorithm>
-#include "defaults.h"
-#include "macros.h"
-#include "error.h"
+#include "defaults.hpp"
+#include "macros.hpp"
+#include "error.hpp"
static int pthread_attr_init_done;
static pthread_attr_t tattr;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _DEFAULTS_H
-#define _DEFAULTS_H
-
-#include <pthread.h>
-#include <common/macros.h>
-
-/* Default unix group name for tracing. */
-#define DEFAULT_TRACING_GROUP "tracing"
-
-/*
- * This value is defined in the CTF specification (see
- * git://git.efficios.com/ctf.git in the file
- * common-trace-format-specification.txt.
- */
-#define DEFAULT_METADATA_NAME "metadata"
-
-/* Environment variable to set session daemon binary path. */
-#define DEFAULT_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
-
-/* Environment variable to set man pager binary path. */
-#define DEFAULT_MAN_BIN_PATH_ENV "LTTNG_MAN_BIN_PATH"
-
-/* Default man pager binary path. */
-#define DEFAULT_MAN_BIN_PATH "/usr/bin/man"
-
-/* Default trace output directory name */
-#define DEFAULT_TRACE_DIR_NAME "lttng-traces"
-
-/* Default size of a hash table */
-#define DEFAULT_HT_SIZE 4
-
-/* Default session daemon paths */
-#define DEFAULT_HOME_DIR "/tmp"
-#define DEFAULT_UST_SOCK_DIR DEFAULT_HOME_DIR "/ust-app-socks"
-#define DEFAULT_GLOBAL_APPS_PIPE DEFAULT_UST_SOCK_DIR "/global"
-#define DEFAULT_TRACE_OUTPUT DEFAULT_HOME_DIR "/lttng"
-
-/* Default directory where the trace are written in per domain */
-#define DEFAULT_KERNEL_TRACE_DIR "kernel"
-#define DEFAULT_UST_TRACE_DIR "ust"
-
-/* Subpath for per PID or UID sessions. */
-#define DEFAULT_UST_TRACE_PID_PATH "pid"
-#define DEFAULT_UST_TRACE_UID_PATH "uid/%d/%u-bit"
-
-/*
- * Default session name for the lttng command line. This default value will
- * get the date and time appended (%Y%m%d-%H%M%S) to it.
- */
-#define DEFAULT_SESSION_NAME "auto"
-
-/* Default consumer paths */
-#define DEFAULT_CONSUMERD_FILE "lttng-consumerd"
-
-/* Default consumer paths */
-#define DEFAULT_CONSUMERD_RUNDIR "%s"
-
-/* Kernel consumer path */
-#define DEFAULT_KCONSUMERD_PATH DEFAULT_CONSUMERD_RUNDIR "/kconsumerd"
-#define DEFAULT_KCONSUMERD_CMD_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/command"
-#define DEFAULT_KCONSUMERD_ERR_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/error"
-
-/* UST 64-bit consumer path */
-#define DEFAULT_USTCONSUMERD64_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64"
-#define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/command"
-#define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/error"
-
-/* UST 32-bit consumer path */
-#define DEFAULT_USTCONSUMERD32_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32"
-#define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command"
-#define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error"
-
-/* Relayd path */
-#define DEFAULT_RELAYD_RUNDIR "%s"
-#define DEFAULT_RELAYD_PATH DEFAULT_RELAYD_RUNDIR "/relayd"
-
-#define DEFAULT_RELAYD_MIN_FD_POOL_SIZE 100
-/*
- * The file descriptor pool size needs a reserve buffer to accommodates the
- * indirect use of short-lived file descriptors. For instance, glibc will
- * create a socket (and thus, use an fd) during calls to gethostname() or
- * when querying the user's group. Other calls also probably make use of
- * short-lived FDs.
- *
- * The theoritical maximal reserve corresponds to the number of threads as,
- * in the worst case, they could all be making such calls.
- *
- * This value must be less than DEFAULT_RELAYD_MIN_FD_POOL_SIZE.
- */
-#define DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE 10
-
-/* Default lttng run directory */
-#define DEFAULT_LTTNG_HOME_ENV_VAR "LTTNG_HOME"
-#define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR "HOME"
-#define DEFAULT_LTTNG_RUNDIR CONFIG_LTTNG_SYSTEM_RUNDIR
-#define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng"
-#define DEFAULT_LTTNG_SESSIOND_PIDFILE "lttng-sessiond.pid"
-#define DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE "agent.port"
-#define DEFAULT_LTTNG_SESSIOND_LOCKFILE "lttng-sessiond.lck"
-
-/* Default probes list */
-#define DEFAULT_LTTNG_KMOD_PROBES "LTTNG_KMOD_PROBES"
-
-/* Default extra probes list */
-#define DEFAULT_LTTNG_EXTRA_KMOD_PROBES "LTTNG_EXTRA_KMOD_PROBES"
-
-/* Default unix socket path */
-#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
-#define DEFAULT_HOME_CLIENT_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
-#define DEFAULT_GLOBAL_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/sessiond-health"
-#define DEFAULT_HOME_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-health"
-#define DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/sessiond-notification"
-#define DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-notification"
-
-/* Default consumer health unix socket path */
-#define DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd32/health"
-#define DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd32/health"
-#define DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd64/health"
-#define DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd64/health"
-#define DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/kconsumerd/health"
-#define DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/kconsumerd/health"
-
-/* Default relay health unix socket path */
-#define DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/relayd/health-%d"
-#define DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/relayd/health-%d"
-
-/* Default daemon configuration file path */
-#define DEFAULT_SYSTEM_CONFIGPATH CONFIG_LTTNG_SYSTEM_CONFIGDIR \
- "/lttng"
-
-#define DEFAULT_DAEMON_CONFIG_FILE "lttng.conf"
-#define DEFAULT_DAEMON_HOME_CONFIGPATH DEFAULT_LTTNG_HOME_RUNDIR "/" \
- DEFAULT_DAEMON_CONFIG_FILE
-#define DEFAULT_DAEMON_SYSTEM_CONFIGPATH DEFAULT_SYSTEM_CONFIGPATH "/" \
- DEFAULT_DAEMON_CONFIG_FILE
-
-/* Default session configuration file path */
-#define DEFAULT_SESSION_PATH "sessions"
-/* Auto load session in that directory. */
-#define DEFAULT_SESSION_CONFIG_AUTOLOAD "auto"
-#define DEFAULT_SESSION_HOME_CONFIGPATH DEFAULT_LTTNG_HOME_RUNDIR "/" \
- DEFAULT_SESSION_PATH
-#define DEFAULT_SESSION_SYSTEM_CONFIGPATH DEFAULT_SYSTEM_CONFIGPATH "/" \
- DEFAULT_SESSION_PATH
-#define DEFAULT_SESSION_CONFIG_FILE_EXTENSION ".lttng"
-#define DEFAULT_SESSION_CONFIG_XSD_FILENAME "session.xsd"
-#define DEFAULT_SESSION_CONFIG_XSD_PATH CONFIG_LTTNG_SYSTEM_DATADIR "/xml/lttng/"
-#define DEFAULT_SESSION_CONFIG_XSD_PATH_ENV "LTTNG_SESSION_CONFIG_XSD_PATH"
-
-#define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
- DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
-#define DEFAULT_HOME_APPS_UNIX_SOCK \
- DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
-#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \
- "/" LTTNG_UST_WAIT_FILENAME
-#define DEFAULT_HOME_APPS_WAIT_SHM_PATH \
- DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d"
-
-/*
- * Value taken from the hard limit allowed by the kernel when using setrlimit
- * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
- */
-#define DEFAULT_POLL_SIZE 65535
-
-/*
- * Format is %s_%d respectively channel name and CPU number. Eigth bytes
- * are added here to add space for the CPU number. I guess 2^8 CPUs is more
- * than enough. We might end up with quantum computing in a cell phone when
- * reaching this limit.
- */
-#define DEFAULT_STREAM_NAME_LEN LTTNG_SYMBOL_NAME_LEN + 8
-
-/* Default channel attributes */
-#define DEFAULT_CHANNEL_NAME "channel0"
-/* Default JUL domain channel name. */
-#define DEFAULT_JUL_CHANNEL_NAME "lttng_jul_channel"
-/* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
-#define DEFAULT_JUL_EVENT_COMPONENT "lttng_jul"
-#define DEFAULT_JUL_EVENT_NAME DEFAULT_JUL_EVENT_COMPONENT ":*"
-
-/* Default log4j domain channel name. */
-#define DEFAULT_LOG4J_CHANNEL_NAME "lttng_log4j_channel"
-/* Default log4j tracepoint name. This is a wildcard for the log4j domain. */
-#define DEFAULT_LOG4J_EVENT_COMPONENT "lttng_log4j"
-#define DEFAULT_LOG4J_EVENT_NAME DEFAULT_LOG4J_EVENT_COMPONENT ":*"
-
-/* Default Python domain channel name. */
-#define DEFAULT_PYTHON_CHANNEL_NAME "lttng_python_channel"
-/* Default Python tracepoint name. This is a wildcard for the python domain. */
-#define DEFAULT_PYTHON_EVENT_COMPONENT "lttng_python"
-#define DEFAULT_PYTHON_EVENT_NAME DEFAULT_PYTHON_EVENT_COMPONENT ":*"
-
-#define DEFAULT_CHANNEL_OVERWRITE -1
-#define DEFAULT_CHANNEL_TRACEFILE_SIZE CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE
-#define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT
-
-#define _DEFAULT_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_CHANNEL_SUBBUF_SIZE
-#define _DEFAULT_CHANNEL_OUTPUT LTTNG_EVENT_MMAP
-
-/* Metadata channel defaults. */
-#define DEFAULT_METADATA_SUBBUF_SIZE CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
-#define DEFAULT_METADATA_SUBBUF_NUM CONFIG_DEFAULT_METADATA_SUBBUF_NUM
-#define DEFAULT_METADATA_CACHE_SIZE CONFIG_DEFAULT_METADATA_CACHE_SIZE
-#define DEFAULT_METADATA_SWITCH_TIMER 0
-#define DEFAULT_METADATA_READ_TIMER 0
-#define DEFAULT_METADATA_OVERWRITE 0
-#define DEFAULT_METADATA_OUTPUT LTTNG_EVENT_MMAP
-
-/* Kernel has different defaults */
-
-/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE
-/*
- * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2.
- * Update help manually if override.
- */
-#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM
-/* See lttng-kernel.h enum lttng_kernel_output for channel output */
-#define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE
-#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER
-#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER
-#define DEFAULT_KERNEL_CHANNEL_READ_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER
-#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER
-#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT
-
-/* User space defaults */
-
-/* Must be a power of 2 */
-#define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE
-#define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE
-/* Must be a power of 2. Update help manuall if override. */
-#define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM
-#define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM
-/* See lttng-ust.h enum lttng_ust_output */
-#define DEFAULT_UST_PID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
-#define DEFAULT_UST_UID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
-/* Timers in usec. */
-#define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER
-#define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER
-#define DEFAULT_UST_PID_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_LIVE_TIMER
-#define DEFAULT_UST_UID_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_LIVE_TIMER
-#define DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER
-#define DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER
-
-#define DEFAULT_UST_PID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER
-#define DEFAULT_UST_UID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER
-
-#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT
-#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT
-
-/*
- * Default timeout value for the sem_timedwait() call. Blocking forever is not
- * wanted so a timeout is used to control the data flow and not freeze the
- * session daemon.
- */
-#define DEFAULT_SEM_WAIT_TIMEOUT 30 /* in seconds */
-
-/* Default bind addresses for network services. */
-#define DEFAULT_NETWORK_CONTROL_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_CONTROL_BIND_ADDRESS
-#define DEFAULT_NETWORK_DATA_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_DATA_BIND_ADDRESS
-#define DEFAULT_NETWORK_VIEWER_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_VIEWER_BIND_ADDRESS
-#define DEFAULT_AGENT_BIND_ADDRESS CONFIG_DEFAULT_AGENT_BIND_ADDRESS
-
-/* Default network ports for trace streaming support. */
-#define DEFAULT_NETWORK_CONTROL_PORT CONFIG_DEFAULT_NETWORK_CONTROL_PORT
-#define DEFAULT_NETWORK_DATA_PORT CONFIG_DEFAULT_NETWORK_DATA_PORT
-#define DEFAULT_NETWORK_VIEWER_PORT CONFIG_DEFAULT_NETWORK_VIEWER_PORT
-
-/* Agent registration TCP port range. */
-#define DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN
-#define DEFAULT_AGENT_TCP_PORT_RANGE_END CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_END
-
-/* Number of buckets in the event notifier error count map. */
-#define DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE CONFIG_DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE
-
-/*
- * If a thread stalls for this amount of time, it will be considered bogus (bad
- * health).
- */
-#define DEFAULT_HEALTH_CHECK_DELTA_S 20
-#define DEFAULT_HEALTH_CHECK_DELTA_NS 0
-
-/*
- * Wait period before retrying the lttng_data_pending command in the lttng
- * stop command of liblttng-ctl.
- */
-#define DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US 200000 /* usec */
-
-/*
- * Wait period before retrying the lttng_consumer_flushed_cache when
- * the consumer receives metadata.
- */
-#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */
-
-/*
- * The usual value for the maximum TCP SYN retries time and TCP FIN timeout is
- * 180 and 60 seconds on most Linux system and the default value since kernel
- * 2.2 thus using the highest value. See tcp(7) for more details.
- */
-#define DEFAULT_INET_TCP_TIMEOUT 180 /* sec */
-
-/* Maximum payload size for a control connection */
-
-#define DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE CONFIG_DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE
-
-/*
- * Default receiving and sending timeout for an application socket.
- */
-#define DEFAULT_APP_SOCKET_RW_TIMEOUT CONFIG_DEFAULT_APP_SOCKET_RW_TIMEOUT
-#define DEFAULT_APP_SOCKET_TIMEOUT_ENV "LTTNG_APP_SOCKET_TIMEOUT"
-
-#define DEFAULT_UST_STREAM_FD_NUM 2 /* Number of fd per UST stream. */
-
-#define DEFAULT_SNAPSHOT_NAME "snapshot"
-#define DEFAULT_SNAPSHOT_MAX_SIZE 0 /* Unlimited. */
-
-/* Suffix of an index file. */
-#define DEFAULT_INDEX_FILE_SUFFIX ".idx"
-#define DEFAULT_INDEX_DIR "index"
-
-/* Default lttng command live timer value in usec. */
-#define DEFAULT_LTTNG_LIVE_TIMER CONFIG_DEFAULT_LTTNG_LIVE_TIMER
-
-/* Default runas worker name */
-#define DEFAULT_RUN_AS_WORKER_NAME "lttng-runas"
-
-/* Default LTTng MI XML namespace. */
-#define DEFAULT_LTTNG_MI_NAMESPACE "https://lttng.org/xml/ns/lttng-mi"
-
-/* Default thread stack size; the default mandated by pthread_create(3) */
-#define DEFAULT_LTTNG_THREAD_STACK_SIZE 2097152
-
-/* Default maximal size of message notification channel message payloads. */
-#define DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE 65536
-
-/* Default maximal size of trace archive location. */
-#define DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE 65536
-
-/* Default maximal size of message notification channel message payloads. */
-#define DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT 100
-
-
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL"
-#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD"
-#define DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV "LTTNG_RELAYD_DISALLOW_CLEAR"
-
-#define DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV "LTTNG_RELAYD_WORKING_DIRECTORY"
-
-/*
- * Name of the intermediate directory used to rename the trace chunk of a
- * session's first rotation.
- */
-#define DEFAULT_CHUNK_TMP_OLD_DIRECTORY ".tmp_old_chunk"
-#define DEFAULT_CHUNK_TMP_NEW_DIRECTORY ".tmp_new_chunk"
-#define DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "archives"
-#define DEFAULT_UNLINKED_FILES_DIRECTORY ".unlinked"
-
-/*
- * Default timer value in usec for the rotate pending polling check on the
- * relay when a rotation has completed on the consumer.
- */
-#define DEFAULT_ROTATE_PENDING_TIMER CONFIG_DEFAULT_ROTATE_PENDING_TIMER
-
-/*
- * Returns the default subbuf size.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_channel_subbuf_size(void);
-
-/*
- * Returns the default metadata subbuf size.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_metadata_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the kernel domain.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_kernel_channel_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the UST domain per PID.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_ust_pid_channel_subbuf_size(void);
-
-/*
- * Returns the default subbuf size for the UST domain per UID.
- *
- * This function depends on a value that is set at constructor time, so it is
- * unsafe to call it from another constructor.
- */
-size_t default_get_ust_uid_channel_subbuf_size(void);
-
-/*
- * Get the default pthread_attr to use on thread creation.
- *
- * Some libc, such as musl, don't honor the limit set for the stack size and use
- * their own empirically chosen static value. This function checks if the
- * current stack size is smaller than the stack size limit and if so returns a
- * pthread_attr_t pointer where the thread stack size is set to the soft stack
- * size limit.
- */
-pthread_attr_t *default_pthread_attr(void);
-
-#endif /* _DEFAULTS_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _DEFAULTS_H
+#define _DEFAULTS_H
+
+#include <pthread.h>
+#include <common/macros.hpp>
+
+/* Default unix group name for tracing. */
+#define DEFAULT_TRACING_GROUP "tracing"
+
+/*
+ * This value is defined in the CTF specification (see
+ * git://git.efficios.com/ctf.git in the file
+ * common-trace-format-specification.txt.
+ */
+#define DEFAULT_METADATA_NAME "metadata"
+
+/* Environment variable to set session daemon binary path. */
+#define DEFAULT_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
+
+/* Environment variable to set man pager binary path. */
+#define DEFAULT_MAN_BIN_PATH_ENV "LTTNG_MAN_BIN_PATH"
+
+/* Default man pager binary path. */
+#define DEFAULT_MAN_BIN_PATH "/usr/bin/man"
+
+/* Default trace output directory name */
+#define DEFAULT_TRACE_DIR_NAME "lttng-traces"
+
+/* Default size of a hash table */
+#define DEFAULT_HT_SIZE 4
+
+/* Default session daemon paths */
+#define DEFAULT_HOME_DIR "/tmp"
+#define DEFAULT_UST_SOCK_DIR DEFAULT_HOME_DIR "/ust-app-socks"
+#define DEFAULT_GLOBAL_APPS_PIPE DEFAULT_UST_SOCK_DIR "/global"
+#define DEFAULT_TRACE_OUTPUT DEFAULT_HOME_DIR "/lttng"
+
+/* Default directory where the trace are written in per domain */
+#define DEFAULT_KERNEL_TRACE_DIR "kernel"
+#define DEFAULT_UST_TRACE_DIR "ust"
+
+/* Subpath for per PID or UID sessions. */
+#define DEFAULT_UST_TRACE_PID_PATH "pid"
+#define DEFAULT_UST_TRACE_UID_PATH "uid/%d/%u-bit"
+
+/*
+ * Default session name for the lttng command line. This default value will
+ * get the date and time appended (%Y%m%d-%H%M%S) to it.
+ */
+#define DEFAULT_SESSION_NAME "auto"
+
+/* Default consumer paths */
+#define DEFAULT_CONSUMERD_FILE "lttng-consumerd"
+
+/* Default consumer paths */
+#define DEFAULT_CONSUMERD_RUNDIR "%s"
+
+/* Kernel consumer path */
+#define DEFAULT_KCONSUMERD_PATH DEFAULT_CONSUMERD_RUNDIR "/kconsumerd"
+#define DEFAULT_KCONSUMERD_CMD_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/command"
+#define DEFAULT_KCONSUMERD_ERR_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/error"
+
+/* UST 64-bit consumer path */
+#define DEFAULT_USTCONSUMERD64_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64"
+#define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/command"
+#define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/error"
+
+/* UST 32-bit consumer path */
+#define DEFAULT_USTCONSUMERD32_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32"
+#define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command"
+#define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error"
+
+/* Relayd path */
+#define DEFAULT_RELAYD_RUNDIR "%s"
+#define DEFAULT_RELAYD_PATH DEFAULT_RELAYD_RUNDIR "/relayd"
+
+#define DEFAULT_RELAYD_MIN_FD_POOL_SIZE 100
+/*
+ * The file descriptor pool size needs a reserve buffer to accommodates the
+ * indirect use of short-lived file descriptors. For instance, glibc will
+ * create a socket (and thus, use an fd) during calls to gethostname() or
+ * when querying the user's group. Other calls also probably make use of
+ * short-lived FDs.
+ *
+ * The theoritical maximal reserve corresponds to the number of threads as,
+ * in the worst case, they could all be making such calls.
+ *
+ * This value must be less than DEFAULT_RELAYD_MIN_FD_POOL_SIZE.
+ */
+#define DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE 10
+
+/* Default lttng run directory */
+#define DEFAULT_LTTNG_HOME_ENV_VAR "LTTNG_HOME"
+#define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR "HOME"
+#define DEFAULT_LTTNG_RUNDIR CONFIG_LTTNG_SYSTEM_RUNDIR
+#define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng"
+#define DEFAULT_LTTNG_SESSIOND_PIDFILE "lttng-sessiond.pid"
+#define DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE "agent.port"
+#define DEFAULT_LTTNG_SESSIOND_LOCKFILE "lttng-sessiond.lck"
+
+/* Default probes list */
+#define DEFAULT_LTTNG_KMOD_PROBES "LTTNG_KMOD_PROBES"
+
+/* Default extra probes list */
+#define DEFAULT_LTTNG_EXTRA_KMOD_PROBES "LTTNG_EXTRA_KMOD_PROBES"
+
+/* Default unix socket path */
+#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
+#define DEFAULT_HOME_CLIENT_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
+#define DEFAULT_GLOBAL_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/sessiond-health"
+#define DEFAULT_HOME_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-health"
+#define DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/sessiond-notification"
+#define DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-notification"
+
+/* Default consumer health unix socket path */
+#define DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd32/health"
+#define DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd32/health"
+#define DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd64/health"
+#define DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd64/health"
+#define DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/kconsumerd/health"
+#define DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/kconsumerd/health"
+
+/* Default relay health unix socket path */
+#define DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/relayd/health-%d"
+#define DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/relayd/health-%d"
+
+/* Default daemon configuration file path */
+#define DEFAULT_SYSTEM_CONFIGPATH CONFIG_LTTNG_SYSTEM_CONFIGDIR \
+ "/lttng"
+
+#define DEFAULT_DAEMON_CONFIG_FILE "lttng.conf"
+#define DEFAULT_DAEMON_HOME_CONFIGPATH DEFAULT_LTTNG_HOME_RUNDIR "/" \
+ DEFAULT_DAEMON_CONFIG_FILE
+#define DEFAULT_DAEMON_SYSTEM_CONFIGPATH DEFAULT_SYSTEM_CONFIGPATH "/" \
+ DEFAULT_DAEMON_CONFIG_FILE
+
+/* Default session configuration file path */
+#define DEFAULT_SESSION_PATH "sessions"
+/* Auto load session in that directory. */
+#define DEFAULT_SESSION_CONFIG_AUTOLOAD "auto"
+#define DEFAULT_SESSION_HOME_CONFIGPATH DEFAULT_LTTNG_HOME_RUNDIR "/" \
+ DEFAULT_SESSION_PATH
+#define DEFAULT_SESSION_SYSTEM_CONFIGPATH DEFAULT_SYSTEM_CONFIGPATH "/" \
+ DEFAULT_SESSION_PATH
+#define DEFAULT_SESSION_CONFIG_FILE_EXTENSION ".lttng"
+#define DEFAULT_SESSION_CONFIG_XSD_FILENAME "session.xsd"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH CONFIG_LTTNG_SYSTEM_DATADIR "/xml/lttng/"
+#define DEFAULT_SESSION_CONFIG_XSD_PATH_ENV "LTTNG_SESSION_CONFIG_XSD_PATH"
+
+#define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
+ DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
+#define DEFAULT_HOME_APPS_UNIX_SOCK \
+ DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
+#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \
+ "/" LTTNG_UST_WAIT_FILENAME
+#define DEFAULT_HOME_APPS_WAIT_SHM_PATH \
+ DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d"
+
+/*
+ * Value taken from the hard limit allowed by the kernel when using setrlimit
+ * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
+ */
+#define DEFAULT_POLL_SIZE 65535
+
+/*
+ * Format is %s_%d respectively channel name and CPU number. Eigth bytes
+ * are added here to add space for the CPU number. I guess 2^8 CPUs is more
+ * than enough. We might end up with quantum computing in a cell phone when
+ * reaching this limit.
+ */
+#define DEFAULT_STREAM_NAME_LEN LTTNG_SYMBOL_NAME_LEN + 8
+
+/* Default channel attributes */
+#define DEFAULT_CHANNEL_NAME "channel0"
+/* Default JUL domain channel name. */
+#define DEFAULT_JUL_CHANNEL_NAME "lttng_jul_channel"
+/* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
+#define DEFAULT_JUL_EVENT_COMPONENT "lttng_jul"
+#define DEFAULT_JUL_EVENT_NAME DEFAULT_JUL_EVENT_COMPONENT ":*"
+
+/* Default log4j domain channel name. */
+#define DEFAULT_LOG4J_CHANNEL_NAME "lttng_log4j_channel"
+/* Default log4j tracepoint name. This is a wildcard for the log4j domain. */
+#define DEFAULT_LOG4J_EVENT_COMPONENT "lttng_log4j"
+#define DEFAULT_LOG4J_EVENT_NAME DEFAULT_LOG4J_EVENT_COMPONENT ":*"
+
+/* Default Python domain channel name. */
+#define DEFAULT_PYTHON_CHANNEL_NAME "lttng_python_channel"
+/* Default Python tracepoint name. This is a wildcard for the python domain. */
+#define DEFAULT_PYTHON_EVENT_COMPONENT "lttng_python"
+#define DEFAULT_PYTHON_EVENT_NAME DEFAULT_PYTHON_EVENT_COMPONENT ":*"
+
+#define DEFAULT_CHANNEL_OVERWRITE -1
+#define DEFAULT_CHANNEL_TRACEFILE_SIZE CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE
+#define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT
+
+#define _DEFAULT_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_CHANNEL_SUBBUF_SIZE
+#define _DEFAULT_CHANNEL_OUTPUT LTTNG_EVENT_MMAP
+
+/* Metadata channel defaults. */
+#define DEFAULT_METADATA_SUBBUF_SIZE CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
+#define DEFAULT_METADATA_SUBBUF_NUM CONFIG_DEFAULT_METADATA_SUBBUF_NUM
+#define DEFAULT_METADATA_CACHE_SIZE CONFIG_DEFAULT_METADATA_CACHE_SIZE
+#define DEFAULT_METADATA_SWITCH_TIMER 0
+#define DEFAULT_METADATA_READ_TIMER 0
+#define DEFAULT_METADATA_OVERWRITE 0
+#define DEFAULT_METADATA_OUTPUT LTTNG_EVENT_MMAP
+
+/* Kernel has different defaults */
+
+/* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE
+/*
+ * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2.
+ * Update help manually if override.
+ */
+#define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM
+/* See lttng-kernel.h enum lttng_kernel_output for channel output */
+#define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE
+#define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER
+#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER
+#define DEFAULT_KERNEL_CHANNEL_READ_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER
+#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER
+#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT
+
+/* User space defaults */
+
+/* Must be a power of 2 */
+#define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE
+#define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE
+/* Must be a power of 2. Update help manuall if override. */
+#define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM
+#define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM CONFIG_DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM
+/* See lttng-ust.h enum lttng_ust_output */
+#define DEFAULT_UST_PID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
+#define DEFAULT_UST_UID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
+/* Timers in usec. */
+#define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER
+#define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER
+#define DEFAULT_UST_PID_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_LIVE_TIMER
+#define DEFAULT_UST_UID_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_LIVE_TIMER
+#define DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER
+#define DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER
+
+#define DEFAULT_UST_PID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER
+#define DEFAULT_UST_UID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER
+
+#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT
+#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT
+
+/*
+ * Default timeout value for the sem_timedwait() call. Blocking forever is not
+ * wanted so a timeout is used to control the data flow and not freeze the
+ * session daemon.
+ */
+#define DEFAULT_SEM_WAIT_TIMEOUT 30 /* in seconds */
+
+/* Default bind addresses for network services. */
+#define DEFAULT_NETWORK_CONTROL_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_CONTROL_BIND_ADDRESS
+#define DEFAULT_NETWORK_DATA_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_DATA_BIND_ADDRESS
+#define DEFAULT_NETWORK_VIEWER_BIND_ADDRESS CONFIG_DEFAULT_NETWORK_VIEWER_BIND_ADDRESS
+#define DEFAULT_AGENT_BIND_ADDRESS CONFIG_DEFAULT_AGENT_BIND_ADDRESS
+
+/* Default network ports for trace streaming support. */
+#define DEFAULT_NETWORK_CONTROL_PORT CONFIG_DEFAULT_NETWORK_CONTROL_PORT
+#define DEFAULT_NETWORK_DATA_PORT CONFIG_DEFAULT_NETWORK_DATA_PORT
+#define DEFAULT_NETWORK_VIEWER_PORT CONFIG_DEFAULT_NETWORK_VIEWER_PORT
+
+/* Agent registration TCP port range. */
+#define DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN
+#define DEFAULT_AGENT_TCP_PORT_RANGE_END CONFIG_DEFAULT_AGENT_TCP_PORT_RANGE_END
+
+/* Number of buckets in the event notifier error count map. */
+#define DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE CONFIG_DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE
+
+/*
+ * If a thread stalls for this amount of time, it will be considered bogus (bad
+ * health).
+ */
+#define DEFAULT_HEALTH_CHECK_DELTA_S 20
+#define DEFAULT_HEALTH_CHECK_DELTA_NS 0
+
+/*
+ * Wait period before retrying the lttng_data_pending command in the lttng
+ * stop command of liblttng-ctl.
+ */
+#define DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US 200000 /* usec */
+
+/*
+ * Wait period before retrying the lttng_consumer_flushed_cache when
+ * the consumer receives metadata.
+ */
+#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */
+
+/*
+ * The usual value for the maximum TCP SYN retries time and TCP FIN timeout is
+ * 180 and 60 seconds on most Linux system and the default value since kernel
+ * 2.2 thus using the highest value. See tcp(7) for more details.
+ */
+#define DEFAULT_INET_TCP_TIMEOUT 180 /* sec */
+
+/* Maximum payload size for a control connection */
+
+#define DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE CONFIG_DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE
+
+/*
+ * Default receiving and sending timeout for an application socket.
+ */
+#define DEFAULT_APP_SOCKET_RW_TIMEOUT CONFIG_DEFAULT_APP_SOCKET_RW_TIMEOUT
+#define DEFAULT_APP_SOCKET_TIMEOUT_ENV "LTTNG_APP_SOCKET_TIMEOUT"
+
+#define DEFAULT_UST_STREAM_FD_NUM 2 /* Number of fd per UST stream. */
+
+#define DEFAULT_SNAPSHOT_NAME "snapshot"
+#define DEFAULT_SNAPSHOT_MAX_SIZE 0 /* Unlimited. */
+
+/* Suffix of an index file. */
+#define DEFAULT_INDEX_FILE_SUFFIX ".idx"
+#define DEFAULT_INDEX_DIR "index"
+
+/* Default lttng command live timer value in usec. */
+#define DEFAULT_LTTNG_LIVE_TIMER CONFIG_DEFAULT_LTTNG_LIVE_TIMER
+
+/* Default runas worker name */
+#define DEFAULT_RUN_AS_WORKER_NAME "lttng-runas"
+
+/* Default LTTng MI XML namespace. */
+#define DEFAULT_LTTNG_MI_NAMESPACE "https://lttng.org/xml/ns/lttng-mi"
+
+/* Default thread stack size; the default mandated by pthread_create(3) */
+#define DEFAULT_LTTNG_THREAD_STACK_SIZE 2097152
+
+/* Default maximal size of message notification channel message payloads. */
+#define DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE 65536
+
+/* Default maximal size of trace archive location. */
+#define DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE 65536
+
+/* Default maximal size of message notification channel message payloads. */
+#define DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT 100
+
+
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL"
+#define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD"
+#define DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV "LTTNG_RELAYD_DISALLOW_CLEAR"
+
+#define DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV "LTTNG_RELAYD_WORKING_DIRECTORY"
+
+/*
+ * Name of the intermediate directory used to rename the trace chunk of a
+ * session's first rotation.
+ */
+#define DEFAULT_CHUNK_TMP_OLD_DIRECTORY ".tmp_old_chunk"
+#define DEFAULT_CHUNK_TMP_NEW_DIRECTORY ".tmp_new_chunk"
+#define DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "archives"
+#define DEFAULT_UNLINKED_FILES_DIRECTORY ".unlinked"
+
+/*
+ * Default timer value in usec for the rotate pending polling check on the
+ * relay when a rotation has completed on the consumer.
+ */
+#define DEFAULT_ROTATE_PENDING_TIMER CONFIG_DEFAULT_ROTATE_PENDING_TIMER
+
+/*
+ * Returns the default subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_channel_subbuf_size(void);
+
+/*
+ * Returns the default metadata subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_metadata_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the kernel domain.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_kernel_channel_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the UST domain per PID.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_ust_pid_channel_subbuf_size(void);
+
+/*
+ * Returns the default subbuf size for the UST domain per UID.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+size_t default_get_ust_uid_channel_subbuf_size(void);
+
+/*
+ * Get the default pthread_attr to use on thread creation.
+ *
+ * Some libc, such as musl, don't honor the limit set for the stack size and use
+ * their own empirically chosen static value. This function checks if the
+ * current stack size is smaller than the stack size limit and if so returns a
+ * pthread_attr_t pointer where the thread stack size is set to the soft stack
+ * size limit.
+ */
+pthread_attr_t *default_pthread_attr(void);
+
+#endif /* _DEFAULTS_H */
*
*/
-#include "lttng/domain-internal.h"
-#include "common/macros.h"
+#include "lttng/domain-internal.hpp"
+#include "common/macros.hpp"
const char *lttng_domain_type_str(enum lttng_domain_type domain_type)
{
*
*/
-#include <common/dynamic-array.h>
+#include <common/dynamic-array.hpp>
void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
size_t element_size,
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DYNAMIC_ARRAY_H
-#define LTTNG_DYNAMIC_ARRAY_H
-
-#include <common/dynamic-buffer.h>
-
-typedef void (*lttng_dynamic_array_element_destructor)(void *element);
-typedef void (*lttng_dynamic_pointer_array_destructor)(void *ptr);
-
-struct lttng_dynamic_array {
- struct lttng_dynamic_buffer buffer;
- size_t element_size;
- size_t size;
- lttng_dynamic_array_element_destructor destructor;
-};
-
-struct lttng_dynamic_pointer_array {
- struct lttng_dynamic_array array;
-};
-
-/*
- * Initialize a resizable array of fixed-size elements. This performs no
- * allocation and can't fail.
- */
-void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
- size_t element_size,
- lttng_dynamic_array_element_destructor destructor);
-
-/*
- * Returns the number of elements in the dynamic array.
- */
-static inline
-size_t lttng_dynamic_array_get_count(
- const struct lttng_dynamic_array *array)
-{
- return array->size;
-}
-
-/*
- * Returns a pointer to the element. Mutating operations on the array invalidate
- * the returned pointer.
- */
-static inline
-void *lttng_dynamic_array_get_element(const struct lttng_dynamic_array *array,
- size_t element_index)
-{
- LTTNG_ASSERT(element_index < array->size);
- return array->buffer.data + (element_index * array->element_size);
-}
-
-/*
- * Set the array's element count to new_element_count. Any added element will
- * be zeroed.
- *
- * Be careful to expand the array's element count _before_ calling out external
- * APIs (e.g. read(3)) which may populate the buffer as setting the element
- * count after will zero-out the result of the operation.
- *
- * Shrinking an array does not zero the old content. If the buffer may contain
- * sensititve information, it must be cleared manually _before_ changing the
- * size.
- *
- * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
- * of prior calls to set_capacity().
- */
-int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array,
- size_t new_element_count);
-
-/*
- * Add an element to the end of a dynamic array. The array's element count is
- * increased by one and its underlying capacity is adjusted automatically.
- *
- * element is a pointer to the element to add (copy) to the array.
- */
-int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array,
- const void *element);
-
-/*
- * Remove an element from the dynamic array. The array's element count is
- * decreased by one and the following elements are shifted to take its place
- * (when applicable).
- */
-int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array,
- size_t element_index);
-
-/* Release any memory used by the dynamic array. */
-void lttng_dynamic_array_reset(struct lttng_dynamic_array *array);
-
-/* Remove all elements from the dynamic array. */
-void lttng_dynamic_array_clear(struct lttng_dynamic_array *array);
-
-/*
- * Specialization of lttng_dynamic_array for pointers. This utility
- * is built under the assumption that pointer sizes are equal
- * for all data types on supported architectures. Revisit this in the event
- * of a port to an Harvard architecture.
- */
-
-/*
- * Initialize a resizable array of fixed-size elements. This performs no
- * allocation and can't fail.
- */
-void lttng_dynamic_pointer_array_init(
- struct lttng_dynamic_pointer_array *array,
- lttng_dynamic_pointer_array_destructor destructor);
-
-/*
- * Returns the number of pointers in the dynamic pointer array.
- */
-static inline
-size_t lttng_dynamic_pointer_array_get_count(
- const struct lttng_dynamic_pointer_array *array)
-{
- return lttng_dynamic_array_get_count(&array->array);
-}
-
-/*
- * Returns the pointer at index `index`.
- */
-static inline
-void *lttng_dynamic_pointer_array_get_pointer(
- const struct lttng_dynamic_pointer_array *array, size_t index)
-{
- void **element = (void **) lttng_dynamic_array_get_element(&array->array, index);
-
- return *element;
-}
-
-/*
- * Returns the pointer at index `index`, sets the array slot to NULL. Does not
- * run the destructor.
- */
-
-static inline
-void *lttng_dynamic_pointer_array_steal_pointer(
- struct lttng_dynamic_pointer_array *array, size_t index)
-{
- void **p_element = (void **) lttng_dynamic_array_get_element(&array->array, index);
- void *element = *p_element;
-
- *p_element = NULL;
-
- return element;
-}
-
-/*
- * Add a pointer to the end of a dynamic pointer array. The array's element
- * count is increased by one and its underlying capacity is adjusted
- * automatically.
- */
-static inline
-int lttng_dynamic_pointer_array_add_pointer(
- struct lttng_dynamic_pointer_array *array, void *pointer)
-{
- return lttng_dynamic_array_add_element(&array->array, &pointer);
-}
-
-/*
- * Remove a pointer from a dynamic pointer array. The array's element
- * count is decreased by one and the following pointers are shifted to
- * take the place of the removed pointer (if applicable).
- */
-int lttng_dynamic_pointer_array_remove_pointer(
- struct lttng_dynamic_pointer_array *array, size_t index);
-
-/* Release any memory used by the dynamic array. */
-void lttng_dynamic_pointer_array_reset(
- struct lttng_dynamic_pointer_array *array);
-
-/* Remove all elements from the dynamic pointer array. */
-void lttng_dynamic_pointer_array_clear(
- struct lttng_dynamic_pointer_array *array);
-
-#endif /* LTTNG_DYNAMIC_ARRAY_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DYNAMIC_ARRAY_H
+#define LTTNG_DYNAMIC_ARRAY_H
+
+#include <common/dynamic-buffer.hpp>
+
+typedef void (*lttng_dynamic_array_element_destructor)(void *element);
+typedef void (*lttng_dynamic_pointer_array_destructor)(void *ptr);
+
+struct lttng_dynamic_array {
+ struct lttng_dynamic_buffer buffer;
+ size_t element_size;
+ size_t size;
+ lttng_dynamic_array_element_destructor destructor;
+};
+
+struct lttng_dynamic_pointer_array {
+ struct lttng_dynamic_array array;
+};
+
+/*
+ * Initialize a resizable array of fixed-size elements. This performs no
+ * allocation and can't fail.
+ */
+void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
+ size_t element_size,
+ lttng_dynamic_array_element_destructor destructor);
+
+/*
+ * Returns the number of elements in the dynamic array.
+ */
+static inline
+size_t lttng_dynamic_array_get_count(
+ const struct lttng_dynamic_array *array)
+{
+ return array->size;
+}
+
+/*
+ * Returns a pointer to the element. Mutating operations on the array invalidate
+ * the returned pointer.
+ */
+static inline
+void *lttng_dynamic_array_get_element(const struct lttng_dynamic_array *array,
+ size_t element_index)
+{
+ LTTNG_ASSERT(element_index < array->size);
+ return array->buffer.data + (element_index * array->element_size);
+}
+
+/*
+ * Set the array's element count to new_element_count. Any added element will
+ * be zeroed.
+ *
+ * Be careful to expand the array's element count _before_ calling out external
+ * APIs (e.g. read(3)) which may populate the buffer as setting the element
+ * count after will zero-out the result of the operation.
+ *
+ * Shrinking an array does not zero the old content. If the buffer may contain
+ * sensititve information, it must be cleared manually _before_ changing the
+ * size.
+ *
+ * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
+ * of prior calls to set_capacity().
+ */
+int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array,
+ size_t new_element_count);
+
+/*
+ * Add an element to the end of a dynamic array. The array's element count is
+ * increased by one and its underlying capacity is adjusted automatically.
+ *
+ * element is a pointer to the element to add (copy) to the array.
+ */
+int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array,
+ const void *element);
+
+/*
+ * Remove an element from the dynamic array. The array's element count is
+ * decreased by one and the following elements are shifted to take its place
+ * (when applicable).
+ */
+int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array,
+ size_t element_index);
+
+/* Release any memory used by the dynamic array. */
+void lttng_dynamic_array_reset(struct lttng_dynamic_array *array);
+
+/* Remove all elements from the dynamic array. */
+void lttng_dynamic_array_clear(struct lttng_dynamic_array *array);
+
+/*
+ * Specialization of lttng_dynamic_array for pointers. This utility
+ * is built under the assumption that pointer sizes are equal
+ * for all data types on supported architectures. Revisit this in the event
+ * of a port to an Harvard architecture.
+ */
+
+/*
+ * Initialize a resizable array of fixed-size elements. This performs no
+ * allocation and can't fail.
+ */
+void lttng_dynamic_pointer_array_init(
+ struct lttng_dynamic_pointer_array *array,
+ lttng_dynamic_pointer_array_destructor destructor);
+
+/*
+ * Returns the number of pointers in the dynamic pointer array.
+ */
+static inline
+size_t lttng_dynamic_pointer_array_get_count(
+ const struct lttng_dynamic_pointer_array *array)
+{
+ return lttng_dynamic_array_get_count(&array->array);
+}
+
+/*
+ * Returns the pointer at index `index`.
+ */
+static inline
+void *lttng_dynamic_pointer_array_get_pointer(
+ const struct lttng_dynamic_pointer_array *array, size_t index)
+{
+ void **element = (void **) lttng_dynamic_array_get_element(&array->array, index);
+
+ return *element;
+}
+
+/*
+ * Returns the pointer at index `index`, sets the array slot to NULL. Does not
+ * run the destructor.
+ */
+
+static inline
+void *lttng_dynamic_pointer_array_steal_pointer(
+ struct lttng_dynamic_pointer_array *array, size_t index)
+{
+ void **p_element = (void **) lttng_dynamic_array_get_element(&array->array, index);
+ void *element = *p_element;
+
+ *p_element = NULL;
+
+ return element;
+}
+
+/*
+ * Add a pointer to the end of a dynamic pointer array. The array's element
+ * count is increased by one and its underlying capacity is adjusted
+ * automatically.
+ */
+static inline
+int lttng_dynamic_pointer_array_add_pointer(
+ struct lttng_dynamic_pointer_array *array, void *pointer)
+{
+ return lttng_dynamic_array_add_element(&array->array, &pointer);
+}
+
+/*
+ * Remove a pointer from a dynamic pointer array. The array's element
+ * count is decreased by one and the following pointers are shifted to
+ * take the place of the removed pointer (if applicable).
+ */
+int lttng_dynamic_pointer_array_remove_pointer(
+ struct lttng_dynamic_pointer_array *array, size_t index);
+
+/* Release any memory used by the dynamic array. */
+void lttng_dynamic_pointer_array_reset(
+ struct lttng_dynamic_pointer_array *array);
+
+/* Remove all elements from the dynamic pointer array. */
+void lttng_dynamic_pointer_array_clear(
+ struct lttng_dynamic_pointer_array *array);
+
+#endif /* LTTNG_DYNAMIC_ARRAY_H */
*
*/
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/utils.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/utils.hpp>
/*
* Round to (upper) power of two, val is returned if it already is a power of
+++ /dev/null
-/*
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_DYNAMIC_BUFFER_H
-#define LTTNG_DYNAMIC_BUFFER_H
-
-#include <stddef.h>
-#include <stdint.h>
-#include <common/macros.h>
-
-struct lttng_buffer_view;
-
-struct lttng_dynamic_buffer {
- char *data;
- /* size is the buffer's currently used capacity. */
- size_t size;
- /*
- * capacity shall not be accessed by users directly, it is meant for
- * internal use only.
- */
- size_t _capacity;
-};
-
-/*
- * Initialize a dynamic buffer. This performs no allocation and is meant
- * to be used instead of memset or explicit initialization of the buffer.
- */
-void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer);
-
-/*
- * Append the content of a raw memory buffer to the end of a dynamic buffer
- * (after its current "size"). The dynamic buffer's size is increased by
- * "len", and its capacity is adjusted automatically.
- */
-int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
- const void *buf, size_t len);
-
-/*
- * Performs the same action as lttng_dynamic_buffer_append(), but using another
- * dynamic buffer as the source buffer. The source buffer's size is used in lieu
- * of "len".
- */
-int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
- const struct lttng_dynamic_buffer *src_buffer);
-
-/*
- * Performs the same action as lttng_dynamic_buffer_append(), but using a
- * buffer view as the source buffer. The source buffer's size is used in lieu
- * of "len".
- */
-int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
- const struct lttng_buffer_view *view);
-
-/*
- * Set the buffer's size to new_size. The capacity of the buffer will
- * be expanded (if necessary) to accommodates new_size. Areas acquired by
- * a size increase will be zeroed.
- *
- * Be careful to expand the buffer's size _before_ calling out external
- * APIs (e.g. read(3)) which may populate the buffer as setting the size
- * after will zero-out the result of the operation.
- *
- * Shrinking a buffer does not zero the old content. If the buffer may contain
- * sensititve information, it must be cleared manually _before_ changing the
- * size.
- *
- * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
- * of prior calls to set_capacity().
- */
-int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
- size_t new_size);
-
-/*
- * Set the buffer's capacity to accommodates the new_capacity, allocating memory
- * as necessary. The buffer's content is preserved. Setting a buffer's capacity
- * is meant as a _hint_ to the underlying buffer and is only optimization; no
- * guarantee is offered that subsequent calls to append or set_size will succeed.
- *
- * If the current size > new_capacity, the operation will fail.
- */
-int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
- size_t new_capacity);
-
-/* Release any memory used by the dynamic buffer. */
-void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer);
-
-/* Get the space left in the buffer before a new resize is needed. */
-size_t lttng_dynamic_buffer_get_capacity_left(
- struct lttng_dynamic_buffer *buffer);
-
-#endif /* LTTNG_DYNAMIC_BUFFER_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_DYNAMIC_BUFFER_H
+#define LTTNG_DYNAMIC_BUFFER_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <common/macros.hpp>
+
+struct lttng_buffer_view;
+
+struct lttng_dynamic_buffer {
+ char *data;
+ /* size is the buffer's currently used capacity. */
+ size_t size;
+ /*
+ * capacity shall not be accessed by users directly, it is meant for
+ * internal use only.
+ */
+ size_t _capacity;
+};
+
+/*
+ * Initialize a dynamic buffer. This performs no allocation and is meant
+ * to be used instead of memset or explicit initialization of the buffer.
+ */
+void lttng_dynamic_buffer_init(struct lttng_dynamic_buffer *buffer);
+
+/*
+ * Append the content of a raw memory buffer to the end of a dynamic buffer
+ * (after its current "size"). The dynamic buffer's size is increased by
+ * "len", and its capacity is adjusted automatically.
+ */
+int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
+ const void *buf, size_t len);
+
+/*
+ * Performs the same action as lttng_dynamic_buffer_append(), but using another
+ * dynamic buffer as the source buffer. The source buffer's size is used in lieu
+ * of "len".
+ */
+int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
+ const struct lttng_dynamic_buffer *src_buffer);
+
+/*
+ * Performs the same action as lttng_dynamic_buffer_append(), but using a
+ * buffer view as the source buffer. The source buffer's size is used in lieu
+ * of "len".
+ */
+int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
+ const struct lttng_buffer_view *view);
+
+/*
+ * Set the buffer's size to new_size. The capacity of the buffer will
+ * be expanded (if necessary) to accommodates new_size. Areas acquired by
+ * a size increase will be zeroed.
+ *
+ * Be careful to expand the buffer's size _before_ calling out external
+ * APIs (e.g. read(3)) which may populate the buffer as setting the size
+ * after will zero-out the result of the operation.
+ *
+ * Shrinking a buffer does not zero the old content. If the buffer may contain
+ * sensititve information, it must be cleared manually _before_ changing the
+ * size.
+ *
+ * NOTE: It is striclty _invalid_ to access memory after _size_, regardless
+ * of prior calls to set_capacity().
+ */
+int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
+ size_t new_size);
+
+/*
+ * Set the buffer's capacity to accommodates the new_capacity, allocating memory
+ * as necessary. The buffer's content is preserved. Setting a buffer's capacity
+ * is meant as a _hint_ to the underlying buffer and is only optimization; no
+ * guarantee is offered that subsequent calls to append or set_size will succeed.
+ *
+ * If the current size > new_capacity, the operation will fail.
+ */
+int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
+ size_t new_capacity);
+
+/* Release any memory used by the dynamic buffer. */
+void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer);
+
+/* Get the space left in the buffer before a new resize is needed. */
+size_t lttng_dynamic_buffer_get_capacity_left(
+ struct lttng_dynamic_buffer *buffer);
+
+#endif /* LTTNG_DYNAMIC_BUFFER_H */
*
*/
-#include <lttng/endpoint-internal.h>
+#include <lttng/endpoint-internal.hpp>
static
struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
*
*/
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
-#include <lttng/action/path-internal.h>
-#include <lttng/error-query-internal.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
+#include <lttng/action/path-internal.hpp>
+#include <lttng/error-query-internal.hpp>
#include <lttng/error-query.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
#include <stddef.h>
struct lttng_error_query {
#include <stdlib.h>
#include <string.h>
-#include <common/common.h>
-#include <common/thread.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
+#include <common/common.hpp>
+#include <common/thread.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
#include <lttng/lttng-error.h>
-#include "error.h"
+#include "error.hpp"
/*
* lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _ERROR_H
-#define _ERROR_H
-
-#include <common/compat/errno.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdbool.h>
-#include <urcu/tls-compat.h>
-#include <common/compat/time.h>
-#include <common/string-utils/format.h>
-#include <common/macros.h>
-
-#ifndef _GNU_SOURCE
-#error "lttng-tools error.h needs _GNU_SOURCE"
-#endif
-
-#include <lttng/lttng-error.h>
-#include <common/compat/tid.h>
-
-/* Avoid conflict with Solaris <sys/regset.h> */
-#if defined(ERR) && defined(__sun__)
-#undef ERR
-#endif
-
-/* Stringify the expansion of a define */
-#define XSTR(d) STR(d)
-#define STR(s) #s
-
-/*
- * Contains the string of the log entry time. This is used as a thread local
- * storage so we don't race between thread and also avoid memory allocation
- * every time a log is fired.
- */
-struct log_time {
- /* Format: 00:00:00.000000000 plus NULL byte. */
- char str[19];
-};
-extern LTTNG_EXPORT DECLARE_URCU_TLS(struct log_time, error_log_time);
-extern DECLARE_URCU_TLS(const char *, logger_thread_name);
-
-extern int lttng_opt_quiet;
-extern int lttng_opt_verbose;
-extern int lttng_opt_mi;
-
-/* Error type. */
-enum lttng_error_level {
- PRINT_ERR = 0,
- PRINT_BUG = 1,
- PRINT_WARN = 2,
- PRINT_MSG = 3,
- PRINT_DBG = 4,
- PRINT_DBG2 = 5,
- PRINT_DBG3 = 6,
-};
-
-static inline bool __lttng_print_check_opt(enum lttng_error_level type)
-{
- /* lttng_opt_mi and lttng_opt_quiet. */
- switch (type) {
- case PRINT_DBG3:
- case PRINT_DBG2:
- case PRINT_DBG:
- case PRINT_MSG:
- if (lttng_opt_mi) {
- return false;
- }
- /* Fall-through. */
- case PRINT_WARN:
- case PRINT_BUG:
- case PRINT_ERR:
- if (lttng_opt_quiet) {
- return false;
- }
- }
-
- /* lttng_opt_verbose */
- switch (type) {
- case PRINT_DBG3:
- if (lttng_opt_verbose < 3) {
- return false;
- }
- break;
- case PRINT_DBG2:
- if (lttng_opt_verbose < 2) {
- return false;
- }
- break;
- case PRINT_DBG:
- if (lttng_opt_verbose < 1) {
- return false;
- }
- break;
- case PRINT_MSG:
- case PRINT_WARN:
- case PRINT_BUG:
- case PRINT_ERR:
- break;
- }
-
- return true;
-}
-
-C_LINKAGE void lttng_abort_on_error(void);
-
-static inline void __lttng_print_check_abort(enum lttng_error_level type)
-{
- switch (type) {
- case PRINT_DBG3:
- case PRINT_DBG2:
- case PRINT_DBG:
- case PRINT_MSG:
- case PRINT_WARN:
- break;
- case PRINT_BUG:
- case PRINT_ERR:
- lttng_abort_on_error();
- }
-}
-
-/*
- * Macro for printing message depending on command line option and verbosity.
- *
- * Machine interface:
- * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
- * want any nested msg to show up when printing mi to stdout(if it's the case).
- * All warnings and errors should be printed to stderr as normal.
- */
-#define __lttng_print(type, fmt, args...) \
- do { \
- if (__lttng_print_check_opt(type)) { \
- fprintf((type) == PRINT_MSG ? stdout : stderr, fmt, ## args); \
- } \
- __lttng_print_check_abort(type); \
- } while (0)
-
-/* Three level of debug. Use -v, -vv or -vvv for the levels */
-#define _ERRMSG(msg, type, fmt, args...) \
- do { \
- if (caa_unlikely(__lttng_print_check_opt(type))) { \
- char generic_name[MAX_INT_DEC_LEN(long) + \
- MAX_INT_DEC_LEN(long)]; \
- \
- snprintf(generic_name, sizeof(generic_name), \
- "%ld/%ld", (long) getpid(), \
- (long) lttng_gettid()); \
- \
- __lttng_print(type, \
- msg " - %s [%s]: " fmt \
- " (in %s() at " __FILE__ \
- ":" XSTR(__LINE__) ")\n", \
- log_add_time(), \
- URCU_TLS(logger_thread_name) ?: \
- generic_name, \
- ##args, __func__); \
- } \
- } while (0)
-
-#define _ERRMSG_NO_LOC(msg, type, fmt, args...) \
- do { \
- if (caa_unlikely(__lttng_print_check_opt(type))) { \
- char generic_name[MAX_INT_DEC_LEN(long) + \
- MAX_INT_DEC_LEN(long)]; \
- \
- snprintf(generic_name, sizeof(generic_name), \
- "%ld/%ld", (long) getpid(), \
- (long) lttng_gettid()); \
- \
- __lttng_print(type, msg " - %s [%s]: " fmt "\n", \
- log_add_time(), \
- URCU_TLS(logger_thread_name) ?: \
- generic_name, \
- ##args); \
- } \
- } while (0)
-
-#define MSG(fmt, args...) \
- __lttng_print(PRINT_MSG, fmt "\n", ## args)
-#define _MSG(fmt, args...) \
- __lttng_print(PRINT_MSG, fmt, ## args)
-#define ERR(fmt, args...) \
- __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
-#define WARN(fmt, args...) \
- __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
-
-#define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
-
-#define DBG(fmt, args...) _ERRMSG("DBG1", PRINT_DBG, fmt, ## args)
-#define DBG_NO_LOC(fmt, args...) _ERRMSG_NO_LOC("DBG1", PRINT_DBG, fmt, ## args)
-#define DBG2(fmt, args...) _ERRMSG("DBG2", PRINT_DBG2, fmt, ## args)
-#define DBG3(fmt, args...) _ERRMSG("DBG3", PRINT_DBG3, fmt, ## args)
-#define LOG(type, fmt, args...) \
- do { \
- switch (type) { \
- case PRINT_ERR: \
- ERR(fmt, ## args); \
- break; \
- case PRINT_WARN: \
- WARN(fmt, ## args); \
- break; \
- case PRINT_BUG: \
- BUG(fmt, ## args); \
- break; \
- case PRINT_MSG: \
- MSG(fmt, ## args); \
- break; \
- case PRINT_DBG: \
- DBG(fmt, ## args); \
- break; \
- case PRINT_DBG2: \
- DBG2(fmt, ## args); \
- break; \
- case PRINT_DBG3: \
- DBG3(fmt, ## args); \
- break; \
- default: \
- abort(); \
- } \
- } while(0);
-
-#define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args)
-
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-
-/*
- * Version using XSI strerror_r.
- */
-#define PERROR(call, args...) \
- do { \
- char _perror_buf[200]; \
- strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \
- _PERROR(call ": %s", ##args, _perror_buf); \
- } while (0);
-#else
-/*
- * Version using GNU strerror_r, for linux with appropriate defines.
- */
-#define PERROR(call, args...) \
- do { \
- char *_perror_buf; \
- char _perror_tmp[200]; \
- _perror_buf = strerror_r( \
- errno, _perror_tmp, sizeof(_perror_tmp)); \
- _PERROR(call ": %s", ##args, _perror_buf); \
- } while (0);
-#endif
-
-const char *error_get_str(int32_t code);
-
-/*
- * Function that format the time and return the reference of log_time.str to
- * the caller. On error, an empty string is returned thus no time will be
- * printed in the log.
- */
-const char *log_add_time(void);
-
-/* Name must be a statically-allocated string. */
-void logger_set_thread_name(const char *name, bool set_pthread_name);
-
-#endif /* _ERROR_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _ERROR_H
+#define _ERROR_H
+
+#include <common/compat/errno.hpp>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <urcu/tls-compat.h>
+#include <common/compat/time.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/macros.hpp>
+
+#ifndef _GNU_SOURCE
+#error "lttng-tools error.h needs _GNU_SOURCE"
+#endif
+
+#include <lttng/lttng-error.h>
+#include <common/compat/tid.hpp>
+
+/* Avoid conflict with Solaris <sys/regset.h> */
+#if defined(ERR) && defined(__sun__)
+#undef ERR
+#endif
+
+/* Stringify the expansion of a define */
+#define XSTR(d) STR(d)
+#define STR(s) #s
+
+/*
+ * Contains the string of the log entry time. This is used as a thread local
+ * storage so we don't race between thread and also avoid memory allocation
+ * every time a log is fired.
+ */
+struct log_time {
+ /* Format: 00:00:00.000000000 plus NULL byte. */
+ char str[19];
+};
+extern LTTNG_EXPORT DECLARE_URCU_TLS(struct log_time, error_log_time);
+extern DECLARE_URCU_TLS(const char *, logger_thread_name);
+
+extern int lttng_opt_quiet;
+extern int lttng_opt_verbose;
+extern int lttng_opt_mi;
+
+/* Error type. */
+enum lttng_error_level {
+ PRINT_ERR = 0,
+ PRINT_BUG = 1,
+ PRINT_WARN = 2,
+ PRINT_MSG = 3,
+ PRINT_DBG = 4,
+ PRINT_DBG2 = 5,
+ PRINT_DBG3 = 6,
+};
+
+static inline bool __lttng_print_check_opt(enum lttng_error_level type)
+{
+ /* lttng_opt_mi and lttng_opt_quiet. */
+ switch (type) {
+ case PRINT_DBG3:
+ case PRINT_DBG2:
+ case PRINT_DBG:
+ case PRINT_MSG:
+ if (lttng_opt_mi) {
+ return false;
+ }
+ /* Fall-through. */
+ case PRINT_WARN:
+ case PRINT_BUG:
+ case PRINT_ERR:
+ if (lttng_opt_quiet) {
+ return false;
+ }
+ }
+
+ /* lttng_opt_verbose */
+ switch (type) {
+ case PRINT_DBG3:
+ if (lttng_opt_verbose < 3) {
+ return false;
+ }
+ break;
+ case PRINT_DBG2:
+ if (lttng_opt_verbose < 2) {
+ return false;
+ }
+ break;
+ case PRINT_DBG:
+ if (lttng_opt_verbose < 1) {
+ return false;
+ }
+ break;
+ case PRINT_MSG:
+ case PRINT_WARN:
+ case PRINT_BUG:
+ case PRINT_ERR:
+ break;
+ }
+
+ return true;
+}
+
+C_LINKAGE void lttng_abort_on_error(void);
+
+static inline void __lttng_print_check_abort(enum lttng_error_level type)
+{
+ switch (type) {
+ case PRINT_DBG3:
+ case PRINT_DBG2:
+ case PRINT_DBG:
+ case PRINT_MSG:
+ case PRINT_WARN:
+ break;
+ case PRINT_BUG:
+ case PRINT_ERR:
+ lttng_abort_on_error();
+ }
+}
+
+/*
+ * Macro for printing message depending on command line option and verbosity.
+ *
+ * Machine interface:
+ * We use lttng_opt_mi to suppress all normal msg to stdout. We don't
+ * want any nested msg to show up when printing mi to stdout(if it's the case).
+ * All warnings and errors should be printed to stderr as normal.
+ */
+#define __lttng_print(type, fmt, args...) \
+ do { \
+ if (__lttng_print_check_opt(type)) { \
+ fprintf((type) == PRINT_MSG ? stdout : stderr, fmt, ## args); \
+ } \
+ __lttng_print_check_abort(type); \
+ } while (0)
+
+/* Three level of debug. Use -v, -vv or -vvv for the levels */
+#define _ERRMSG(msg, type, fmt, args...) \
+ do { \
+ if (caa_unlikely(__lttng_print_check_opt(type))) { \
+ char generic_name[MAX_INT_DEC_LEN(long) + \
+ MAX_INT_DEC_LEN(long)]; \
+ \
+ snprintf(generic_name, sizeof(generic_name), \
+ "%ld/%ld", (long) getpid(), \
+ (long) lttng_gettid()); \
+ \
+ __lttng_print(type, \
+ msg " - %s [%s]: " fmt \
+ " (in %s() at " __FILE__ \
+ ":" XSTR(__LINE__) ")\n", \
+ log_add_time(), \
+ URCU_TLS(logger_thread_name) ?: \
+ generic_name, \
+ ##args, __func__); \
+ } \
+ } while (0)
+
+#define _ERRMSG_NO_LOC(msg, type, fmt, args...) \
+ do { \
+ if (caa_unlikely(__lttng_print_check_opt(type))) { \
+ char generic_name[MAX_INT_DEC_LEN(long) + \
+ MAX_INT_DEC_LEN(long)]; \
+ \
+ snprintf(generic_name, sizeof(generic_name), \
+ "%ld/%ld", (long) getpid(), \
+ (long) lttng_gettid()); \
+ \
+ __lttng_print(type, msg " - %s [%s]: " fmt "\n", \
+ log_add_time(), \
+ URCU_TLS(logger_thread_name) ?: \
+ generic_name, \
+ ##args); \
+ } \
+ } while (0)
+
+#define MSG(fmt, args...) \
+ __lttng_print(PRINT_MSG, fmt "\n", ## args)
+#define _MSG(fmt, args...) \
+ __lttng_print(PRINT_MSG, fmt, ## args)
+#define ERR(fmt, args...) \
+ __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
+#define WARN(fmt, args...) \
+ __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
+
+#define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
+
+#define DBG(fmt, args...) _ERRMSG("DBG1", PRINT_DBG, fmt, ## args)
+#define DBG_NO_LOC(fmt, args...) _ERRMSG_NO_LOC("DBG1", PRINT_DBG, fmt, ## args)
+#define DBG2(fmt, args...) _ERRMSG("DBG2", PRINT_DBG2, fmt, ## args)
+#define DBG3(fmt, args...) _ERRMSG("DBG3", PRINT_DBG3, fmt, ## args)
+#define LOG(type, fmt, args...) \
+ do { \
+ switch (type) { \
+ case PRINT_ERR: \
+ ERR(fmt, ## args); \
+ break; \
+ case PRINT_WARN: \
+ WARN(fmt, ## args); \
+ break; \
+ case PRINT_BUG: \
+ BUG(fmt, ## args); \
+ break; \
+ case PRINT_MSG: \
+ MSG(fmt, ## args); \
+ break; \
+ case PRINT_DBG: \
+ DBG(fmt, ## args); \
+ break; \
+ case PRINT_DBG2: \
+ DBG2(fmt, ## args); \
+ break; \
+ case PRINT_DBG3: \
+ DBG3(fmt, ## args); \
+ break; \
+ default: \
+ abort(); \
+ } \
+ } while(0);
+
+#define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args)
+
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+
+/*
+ * Version using XSI strerror_r.
+ */
+#define PERROR(call, args...) \
+ do { \
+ char _perror_buf[200]; \
+ strerror_r(errno, _perror_buf, sizeof(_perror_buf)); \
+ _PERROR(call ": %s", ##args, _perror_buf); \
+ } while (0);
+#else
+/*
+ * Version using GNU strerror_r, for linux with appropriate defines.
+ */
+#define PERROR(call, args...) \
+ do { \
+ char *_perror_buf; \
+ char _perror_tmp[200]; \
+ _perror_buf = strerror_r( \
+ errno, _perror_tmp, sizeof(_perror_tmp)); \
+ _PERROR(call ": %s", ##args, _perror_buf); \
+ } while (0);
+#endif
+
+const char *error_get_str(int32_t code);
+
+/*
+ * Function that format the time and return the reference of log_time.str to
+ * the caller. On error, an empty string is returned thus no time will be
+ * printed in the log.
+ */
+const char *log_add_time(void);
+
+/* Name must be a statically-allocated string. */
+void logger_set_thread_name(const char *name, bool set_pthread_name);
+
+#endif /* _ERROR_H */
*
*/
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <lttng/condition/session-consumed-size-internal.h>
-#include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
-#include <common/macros.h>
-#include <common/error.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
#include <stdbool.h>
void lttng_evaluation_init(struct lttng_evaluation *evaluation,
#define _LGPL_SOURCE
#include <stddef.h>
-#include <common/bytecode/bytecode.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/event-expr-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <lttng/event-field-value-internal.h>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <lttng/event-field-value-internal.hpp>
static
struct lttng_event_field_value *create_empty_field_val(
*
*/
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging-internal.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <lttng/event-rule/log4j-logging-internal.h>
-#include <lttng/event-rule/python-logging-internal.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging-internal.hpp>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <lttng/event-rule/log4j-logging-internal.hpp>
+#include <lttng/event-rule/python-logging-internal.hpp>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
#include <stdbool.h>
enum lttng_event_rule_type lttng_event_rule_get_type(
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/jul-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/jul-logging-internal.hpp>
#include <lttng/event.h>
#include <lttng/log-level-rule.h>
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
#include <ctype.h>
#include <lttng/constant.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
+#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
#include <stdio.h>
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
#define IS_SYSCALL_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL)
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
#include <lttng/event.h>
#define IS_KERNEL_TRACEPOINT_EVENT_RULE(rule) \
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
#define IS_UPROBE_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE)
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/log4j-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/log4j-logging-internal.hpp>
#include <lttng/event.h>
#include <lttng/log-level-rule.h>
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/python-logging-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/python-logging-internal.hpp>
#include <lttng/event.h>
#include <lttng/log-level-rule.h>
*
*/
-#include <common/credentials.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/runas.h>
-#include <common/string-utils/string-utils.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <common/credentials.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
#include <lttng/event.h>
#include <lttng/log-level-rule.h>
*
*/
-#include "common/compat/string.h"
-#include "common/macros.h"
-#include "lttng/lttng-error.h"
-#include <assert.h>
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/align.h>
+#include <common/align.hpp>
+#include <common/buffer-view.hpp>
+#include <common/compat/string.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <lttng/constant.h>
-#include <lttng/event-internal.h>
+#include <lttng/event-internal.hpp>
#include <lttng/event.h>
-#include <lttng/userspace-probe-internal.h>
-#include <stdint.h>
-#include <string.h>
+#include <lttng/lttng-error.h>
+#include <lttng/userspace-probe-internal.hpp>
struct event_list_element {
struct lttng_event *event;
#include <unistd.h>
#include <urcu/ref.h>
-#include "fd-handle.h"
-#include <common/error.h>
+#include "fd-handle.hpp"
+#include <common/error.hpp>
struct fd_handle {
struct urcu_ref ref;
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FD_HANDLE_H
-#define FD_HANDLE_H
-
-#include <common/macros.h>
-
-/*
- * Wrapper around a file descriptor providing reference counting semantics.
- *
- * An fd_handle will close() the underlying file descriptor when its reference
- * count reaches zero.
- */
-struct fd_handle;
-
-/* Create a file descriptor handle. */
-struct fd_handle *fd_handle_create(int fd);
-
-/* Acquire reference to a file descriptor handle. */
-void fd_handle_get(struct fd_handle *handle);
-
-/* Release reference to a file descriptor handle. */
-void fd_handle_put(struct fd_handle *handle);
-
-/*
- * Return the underlying file descriptor of a file descriptor handle.
- *
- * This function can't fail.
- */
-int fd_handle_get_fd(struct fd_handle *handle);
-
-/*
- * Obtain a copy of a file descriptor handle.
- *
- * On success, the caller becomes the sole owner of the returned file descriptor
- * handle. The underlying file descriptor is duplicated using dup(). Refer to
- * the system documentation for the semantics of dup() for this particular file
- * descriptor type.
- */
-struct fd_handle *fd_handle_copy(const struct fd_handle *handle);
-
-#endif /* FS_HANDLE_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FD_HANDLE_H
+#define FD_HANDLE_H
+
+#include <common/macros.hpp>
+
+/*
+ * Wrapper around a file descriptor providing reference counting semantics.
+ *
+ * An fd_handle will close() the underlying file descriptor when its reference
+ * count reaches zero.
+ */
+struct fd_handle;
+
+/* Create a file descriptor handle. */
+struct fd_handle *fd_handle_create(int fd);
+
+/* Acquire reference to a file descriptor handle. */
+void fd_handle_get(struct fd_handle *handle);
+
+/* Release reference to a file descriptor handle. */
+void fd_handle_put(struct fd_handle *handle);
+
+/*
+ * Return the underlying file descriptor of a file descriptor handle.
+ *
+ * This function can't fail.
+ */
+int fd_handle_get_fd(struct fd_handle *handle);
+
+/*
+ * Obtain a copy of a file descriptor handle.
+ *
+ * On success, the caller becomes the sole owner of the returned file descriptor
+ * handle. The underlying file descriptor is duplicated using dup(). Refer to
+ * the system documentation for the semantics of dup() for this particular file
+ * descriptor type.
+ */
+struct fd_handle *fd_handle_copy(const struct fd_handle *handle);
+
+#endif /* FS_HANDLE_H */
#include <sys/stat.h>
#include <sys/types.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/fs-handle-internal.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
-
-#include "fd-tracker.h"
-#include "inode.h"
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/fs-handle-internal.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+
+#include "fd-tracker.hpp"
+#include "inode.hpp"
/* Tracker lock must be taken by the user. */
#define TRACKED_COUNT(tracker) \
+++ /dev/null
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef FD_TRACKER_H
-#define FD_TRACKER_H
-
-#include <common/compat/directory-handle.h>
-#include <common/macros.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-struct fs_handle;
-struct fd_tracker;
-
-/*
- * Callback which returns a file descriptor to track through the fd
- * tracker. This callback must not make use of the fd_tracker as a deadlock
- * may occur.
- *
- * The int pointer argument is an output parameter that should be used to return
- * the advertised number of file descriptors.
- *
- * Must return zero on success. Negative values should map to a UNIX error code.
- */
-typedef int (*fd_open_cb)(void *, int *out_fds);
-
-/*
- * Callback to allow the user to close a now-untracked file descriptor. This
- * callback must not make use of the fd_tracker as a deadlock may occur.
- *
- * The callback can freely modify the in_fds argument as it is copied by the
- * fd_tracker before being used. The fd tracker assumes in_fds to be closed by
- * the time the callback returns.
- *
- * Must return zero on success. Negative values should map to a UNIX error code.
- */
-typedef int (*fd_close_cb)(void *, int *in_fds);
-
-/*
- * Set the maximal number of fds that the process should be allowed to open at
- * any given time. This function must be called before any other of this
- * interface.
- *
- * The unlinked_file_path is an absolute path (which does not need to exist)
- * under which unlinked files will be stored for as long as a reference to them
- * is held.
- */
-struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
- unsigned int capacity);
-
-/* Returns an error if file descriptors are leaked. */
-int fd_tracker_destroy(struct fd_tracker *tracker);
-
-/*
- * Open a handle to a suspendable filesystem file descriptor.
- *
- * See OPEN(3) for an explanation of flags and mode. NULL is returned in case of
- * error and errno is left untouched. Note that passing NULL as mode will result
- * in open()'s default behaviour being used (using the process' umask).
- *
- * A fs_handle wraps a file descriptor created by OPEN(3). It is suspendable
- * meaning that the underlying file may be closed at any time unless the
- * handle is marked as being in-use (see fs_handle_get_fd() and
- * fs_handle_put_fd()).
- *
- * If the tracker opted to close the underlying file descriptor, it will
- * be restored to its last known state when it is obtained through
- * the fs_handle's fs_handle_get_fd() method.
- *
- * Note that a suspendable file descriptor can be closed by the fd tracker at
- * anytime when it is not in use. This means that the user should not rely on it
- * being safe to unlink the file. Moreover, concurent modifications to the file
- * (e.g. truncation) may react differently than if the file descriptor was kept
- * open.
- */
-struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
- struct lttng_directory_handle *directory,
- const char *path,
- int flags,
- mode_t *mode);
-
-/*
- * Open a tracked unsuspendable file descriptor.
- *
- * This function allows the fd tracker to keep track of unsuspendable
- * file descriptors. A callback, open, is passed to allow the tracker
- * to atomically reserve an entry for a given count of new file descriptors,
- * suspending file descriptors as needed, and invoke the provided callback
- * without ever exceeding the tracker's capacity.
- *
- * fd_count indicates the count of file descriptors that will be opened and
- * returned by the open callback. The storage location at out_fds is assumed
- * to be large enough to hold 'fd_count * sizeof(int)'.
- *
- * Names may be provided to allow easier debugging of file descriptor
- * exhaustions.
- *
- * The callback's return value is returned to the user. Additionally, two
- * negative tracker-specific codes may be returned:
- * - ENOMEM: allocation of a new entry failed,
- * - EMFILE: too many unsuspendable fds are opened and the tracker can't
- * accommodates the request for a new unsuspendable entry.
- */
-int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
- int *out_fds,
- const char **names,
- unsigned int fd_count,
- fd_open_cb open,
- void *data);
-
-/*
- * Close a tracked unsuspendable file descriptor.
- *
- * This function allows the fd tracker to keep track of unsuspendable
- * file descriptors. A callback, close, is passed to allow the tracker
- * to atomically release a file descriptor entry.
- *
- * Returns 0 if the close callback returned success. Returns the value returned
- * by the close callback if it is negative. Additionally, a tracker-specific
- * code may be returned:
- * - EINVAL: a file descriptor was unknown to the tracker
- *
- * Closed fds are set to -1 in the fds array which, in the event of an error,
- * allows the user to know which file descriptors are no longer being tracked.
- */
-int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
- int *fds,
- unsigned int fd_count,
- fd_close_cb close,
- void *data);
-
-/*
- * Log the contents of the fd_tracker.
- */
-void fd_tracker_log(struct fd_tracker *tracker);
-
-#endif /* FD_TRACKER_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef FD_TRACKER_H
+#define FD_TRACKER_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/macros.hpp>
+#include <stdint.h>
+#include <sys/types.h>
+
+struct fs_handle;
+struct fd_tracker;
+
+/*
+ * Callback which returns a file descriptor to track through the fd
+ * tracker. This callback must not make use of the fd_tracker as a deadlock
+ * may occur.
+ *
+ * The int pointer argument is an output parameter that should be used to return
+ * the advertised number of file descriptors.
+ *
+ * Must return zero on success. Negative values should map to a UNIX error code.
+ */
+typedef int (*fd_open_cb)(void *, int *out_fds);
+
+/*
+ * Callback to allow the user to close a now-untracked file descriptor. This
+ * callback must not make use of the fd_tracker as a deadlock may occur.
+ *
+ * The callback can freely modify the in_fds argument as it is copied by the
+ * fd_tracker before being used. The fd tracker assumes in_fds to be closed by
+ * the time the callback returns.
+ *
+ * Must return zero on success. Negative values should map to a UNIX error code.
+ */
+typedef int (*fd_close_cb)(void *, int *in_fds);
+
+/*
+ * Set the maximal number of fds that the process should be allowed to open at
+ * any given time. This function must be called before any other of this
+ * interface.
+ *
+ * The unlinked_file_path is an absolute path (which does not need to exist)
+ * under which unlinked files will be stored for as long as a reference to them
+ * is held.
+ */
+struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
+ unsigned int capacity);
+
+/* Returns an error if file descriptors are leaked. */
+int fd_tracker_destroy(struct fd_tracker *tracker);
+
+/*
+ * Open a handle to a suspendable filesystem file descriptor.
+ *
+ * See OPEN(3) for an explanation of flags and mode. NULL is returned in case of
+ * error and errno is left untouched. Note that passing NULL as mode will result
+ * in open()'s default behaviour being used (using the process' umask).
+ *
+ * A fs_handle wraps a file descriptor created by OPEN(3). It is suspendable
+ * meaning that the underlying file may be closed at any time unless the
+ * handle is marked as being in-use (see fs_handle_get_fd() and
+ * fs_handle_put_fd()).
+ *
+ * If the tracker opted to close the underlying file descriptor, it will
+ * be restored to its last known state when it is obtained through
+ * the fs_handle's fs_handle_get_fd() method.
+ *
+ * Note that a suspendable file descriptor can be closed by the fd tracker at
+ * anytime when it is not in use. This means that the user should not rely on it
+ * being safe to unlink the file. Moreover, concurent modifications to the file
+ * (e.g. truncation) may react differently than if the file descriptor was kept
+ * open.
+ */
+struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
+ struct lttng_directory_handle *directory,
+ const char *path,
+ int flags,
+ mode_t *mode);
+
+/*
+ * Open a tracked unsuspendable file descriptor.
+ *
+ * This function allows the fd tracker to keep track of unsuspendable
+ * file descriptors. A callback, open, is passed to allow the tracker
+ * to atomically reserve an entry for a given count of new file descriptors,
+ * suspending file descriptors as needed, and invoke the provided callback
+ * without ever exceeding the tracker's capacity.
+ *
+ * fd_count indicates the count of file descriptors that will be opened and
+ * returned by the open callback. The storage location at out_fds is assumed
+ * to be large enough to hold 'fd_count * sizeof(int)'.
+ *
+ * Names may be provided to allow easier debugging of file descriptor
+ * exhaustions.
+ *
+ * The callback's return value is returned to the user. Additionally, two
+ * negative tracker-specific codes may be returned:
+ * - ENOMEM: allocation of a new entry failed,
+ * - EMFILE: too many unsuspendable fds are opened and the tracker can't
+ * accommodates the request for a new unsuspendable entry.
+ */
+int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
+ int *out_fds,
+ const char **names,
+ unsigned int fd_count,
+ fd_open_cb open,
+ void *data);
+
+/*
+ * Close a tracked unsuspendable file descriptor.
+ *
+ * This function allows the fd tracker to keep track of unsuspendable
+ * file descriptors. A callback, close, is passed to allow the tracker
+ * to atomically release a file descriptor entry.
+ *
+ * Returns 0 if the close callback returned success. Returns the value returned
+ * by the close callback if it is negative. Additionally, a tracker-specific
+ * code may be returned:
+ * - EINVAL: a file descriptor was unknown to the tracker
+ *
+ * Closed fds are set to -1 in the fds array which, in the event of an error,
+ * allows the user to know which file descriptors are no longer being tracked.
+ */
+int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
+ int *fds,
+ unsigned int fd_count,
+ fd_close_cb close,
+ void *data);
+
+/*
+ * Log the contents of the fd_tracker.
+ */
+void fd_tracker_log(struct fd_tracker *tracker);
+
+#endif /* FD_TRACKER_H */
*
*/
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <common/string-utils/format.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/utils.hpp>
#include <inttypes.h>
#include <lttng/constant.h>
#include <sys/stat.h>
#include <urcu/rculfhash.h>
#include <urcu/ref.h>
-#include "inode.h"
+#include "inode.hpp"
struct inode_id {
dev_t device;
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef FD_TRACKER_INODE_H
-#define FD_TRACKER_INODE_H
-
-#include <common/compat/directory-handle.h>
-#include <stdbool.h>
-
-struct lttng_inode;
-struct lttng_inode_registry;
-struct lttng_unlinked_file_directory;
-struct lttng_directory_handle;
-
-/*
- * The unlinked file pool is protected by the fd-tracker's lock.
- *
- * NOTE: the unlinked file pool can use a single file desriptor when unlinked
- * files are present in the pool. This file descriptor is not accounted-for
- * by the fd-tracker. Users of the fd-tracker should account for this extra
- * file descriptor.
- */
-struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
- const char *path);
-
-void lttng_unlinked_file_pool_destroy(
- struct lttng_unlinked_file_pool *pool);
-
-/* The inode registry is protected by the fd-tracker's lock. */
-struct lttng_inode_registry *lttng_inode_registry_create(void);
-
-struct lttng_inode *lttng_inode_registry_get_inode(
- struct lttng_inode_registry *registry,
- struct lttng_directory_handle *handle,
- const char *path,
- int fd,
- struct lttng_unlinked_file_pool *pool);
-
-void lttng_inode_registry_destroy(struct lttng_inode_registry *registry);
-
-void lttng_inode_borrow_location(struct lttng_inode *inode,
- const struct lttng_directory_handle **out_directory_handle,
- const char **out_path);
-
-/* Returns a new reference to the inode's location directory handle. */
-struct lttng_directory_handle *lttng_inode_get_location_directory_handle(
- struct lttng_inode *inode);
-
-int lttng_inode_rename(struct lttng_inode *inode,
- struct lttng_directory_handle *old_directory_handle,
- const char *old_path,
- struct lttng_directory_handle *new_directory_handle,
- const char *new_path,
- bool overwrite);
-
-int lttng_inode_unlink(struct lttng_inode *inode);
-
-void lttng_inode_put(struct lttng_inode *inode);
-
-#endif /* FD_TRACKER_INODE_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef FD_TRACKER_INODE_H
+#define FD_TRACKER_INODE_H
+
+#include <common/compat/directory-handle.hpp>
+#include <stdbool.h>
+
+struct lttng_inode;
+struct lttng_inode_registry;
+struct lttng_unlinked_file_directory;
+struct lttng_directory_handle;
+
+/*
+ * The unlinked file pool is protected by the fd-tracker's lock.
+ *
+ * NOTE: the unlinked file pool can use a single file desriptor when unlinked
+ * files are present in the pool. This file descriptor is not accounted-for
+ * by the fd-tracker. Users of the fd-tracker should account for this extra
+ * file descriptor.
+ */
+struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
+ const char *path);
+
+void lttng_unlinked_file_pool_destroy(
+ struct lttng_unlinked_file_pool *pool);
+
+/* The inode registry is protected by the fd-tracker's lock. */
+struct lttng_inode_registry *lttng_inode_registry_create(void);
+
+struct lttng_inode *lttng_inode_registry_get_inode(
+ struct lttng_inode_registry *registry,
+ struct lttng_directory_handle *handle,
+ const char *path,
+ int fd,
+ struct lttng_unlinked_file_pool *pool);
+
+void lttng_inode_registry_destroy(struct lttng_inode_registry *registry);
+
+void lttng_inode_borrow_location(struct lttng_inode *inode,
+ const struct lttng_directory_handle **out_directory_handle,
+ const char **out_path);
+
+/* Returns a new reference to the inode's location directory handle. */
+struct lttng_directory_handle *lttng_inode_get_location_directory_handle(
+ struct lttng_inode *inode);
+
+int lttng_inode_rename(struct lttng_inode *inode,
+ struct lttng_directory_handle *old_directory_handle,
+ const char *old_path,
+ struct lttng_directory_handle *new_directory_handle,
+ const char *new_path,
+ bool overwrite);
+
+int lttng_inode_unlink(struct lttng_inode *inode);
+
+void lttng_inode_put(struct lttng_inode *inode);
+
+#endif /* FD_TRACKER_INODE_H */
*
*/
-#include <common/compat/poll.h>
+#include <common/compat/poll.hpp>
-#include "utils.h"
+#include "utils.hpp"
#ifdef HAVE_EPOLL
*
*/
-#include <common/error.h>
-#include <common/fd-tracker/utils.h>
-#include <common/utils.h>
+#include <common/error.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/utils.hpp>
#include <lttng/constant.h>
#include <stdio.h>
#include <stdlib.h>
+++ /dev/null
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FD_TRACKER_UTILS_H
-#define FD_TRACKER_UTILS_H
-
-#include <common/compat/directory-handle.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/macros.h>
-
-struct lttng_poll_event;
-
-/*
- * Utility implementing a close_fd callback which receives one file descriptor
- * and closes it, returning close()'s return value.
- */
-int fd_tracker_util_close_fd(void *, int *fd);
-
-/*
- * Create a pipe and track its underlying fds.
- */
-int fd_tracker_util_pipe_open_cloexec(
- struct fd_tracker *tracker, const char *name, int *pipe);
-int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe);
-
-/*
- * Create a poll event and track its underlying fd, if applicable.
- */
-int fd_tracker_util_poll_create(struct fd_tracker *tracker,
- const char *name,
- struct lttng_poll_event *events,
- int size,
- int flags);
-int fd_tracker_util_poll_clean(
- struct fd_tracker *tracker, struct lttng_poll_event *events);
-
-struct lttng_directory_handle *fd_tracker_create_directory_handle(
- struct fd_tracker *tracker, const char *path);
-
-struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
- struct fd_tracker *tracker,
- struct lttng_directory_handle *handle,
- const char *path);
-
-#endif /* FD_TRACKER_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FD_TRACKER_UTILS_H
+#define FD_TRACKER_UTILS_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/macros.hpp>
+
+struct lttng_poll_event;
+
+/*
+ * Utility implementing a close_fd callback which receives one file descriptor
+ * and closes it, returning close()'s return value.
+ */
+int fd_tracker_util_close_fd(void *, int *fd);
+
+/*
+ * Create a pipe and track its underlying fds.
+ */
+int fd_tracker_util_pipe_open_cloexec(
+ struct fd_tracker *tracker, const char *name, int *pipe);
+int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe);
+
+/*
+ * Create a poll event and track its underlying fd, if applicable.
+ */
+int fd_tracker_util_poll_create(struct fd_tracker *tracker,
+ const char *name,
+ struct lttng_poll_event *events,
+ int size,
+ int flags);
+int fd_tracker_util_poll_clean(
+ struct fd_tracker *tracker, struct lttng_poll_event *events);
+
+struct lttng_directory_handle *fd_tracker_create_directory_handle(
+ struct fd_tracker *tracker, const char *path);
+
+struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
+ struct fd_tracker *tracker,
+ struct lttng_directory_handle *handle,
+ const char *path);
+
+#endif /* FD_TRACKER_UTILS_H */
#include <stdlib.h>
#include <inttypes.h>
-#include <common/compat/errno.h>
-#include <common/bytecode/bytecode.h>
-#include <common/filter/filter-ast.h>
+#include <common/compat/errno.hpp>
+#include <common/bytecode/bytecode.hpp>
+#include <common/filter/filter-ast.hpp>
#include <common/filter/filter-parser.hpp>
/* For error.h */
*
*/
-#include "filter.h"
+#include "filter.hpp"
#include <stddef.h>
struct bytecode_symbol_iterator {
+++ /dev/null
-/*
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_COMMON_FILTER_H
-#define LTTNG_COMMON_FILTER_H
-
-#include <common/sessiond-comm/sessiond-comm.h>
-
-struct bytecode_symbol_iterator;
-
-/*
- * Create an iterator on a bytecode's symbols. The iterator points to the
- * first element after creation.
- */
-struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(
- struct lttng_bytecode *bytecode);
-
-/*
- * Advance iterator of one element.
- *
- * Returns 0 if a next element exists or a negative value at the end.
- */
-int bytecode_symbol_iterator_next(struct bytecode_symbol_iterator *it);
-
-int bytecode_symbol_iterator_get_type(struct bytecode_symbol_iterator *it);
-
-const char *bytecode_symbol_iterator_get_name(
- struct bytecode_symbol_iterator *it);
-
-void bytecode_symbol_iterator_destroy(struct bytecode_symbol_iterator *it);
-
-#endif /* LTTNG_COMMON_FILTER_H */
--- /dev/null
+/*
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_FILTER_H
+#define LTTNG_COMMON_FILTER_H
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+struct bytecode_symbol_iterator;
+
+/*
+ * Create an iterator on a bytecode's symbols. The iterator points to the
+ * first element after creation.
+ */
+struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(
+ struct lttng_bytecode *bytecode);
+
+/*
+ * Advance iterator of one element.
+ *
+ * Returns 0 if a next element exists or a negative value at the end.
+ */
+int bytecode_symbol_iterator_next(struct bytecode_symbol_iterator *it);
+
+int bytecode_symbol_iterator_get_type(struct bytecode_symbol_iterator *it);
+
+const char *bytecode_symbol_iterator_get_name(
+ struct bytecode_symbol_iterator *it);
+
+void bytecode_symbol_iterator_destroy(struct bytecode_symbol_iterator *it);
+
+#endif /* LTTNG_COMMON_FILTER_H */
+++ /dev/null
-#ifndef _FILTER_AST_H
-#define _FILTER_AST_H
-
-/*
- * filter-ast.h
- *
- * LTTng filter AST
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-/*
- * Note: filter-ast.h should be included before filter-parser.h.
- */
-
-#include <urcu/list.h>
-#include <stdio.h>
-#include <stdint.h>
-
-#define printf_debug(fmt, args...) \
- do { \
- if (filter_parser_debug) \
- fprintf(stdout, "[debug] " fmt, ## args); \
- } while (0)
-
-// the parameter name (of the reentrant 'yyparse' function)
-// data is a pointer to a 'SParserParam' structure
-//#define YYPARSE_PARAM parser_ctx
-
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
-typedef void* yyscan_t;
-#endif
-
-extern int filter_parser_debug;
-
-struct filter_node;
-struct filter_parser;
-
-enum node_type {
- NODE_UNKNOWN = 0,
- NODE_ROOT,
-
- NODE_EXPRESSION,
- NODE_OP,
- NODE_UNARY_OP,
-
- NR_NODE_TYPES,
-};
-
-enum op_type {
- AST_OP_UNKNOWN = 0,
- AST_OP_MUL,
- AST_OP_DIV,
- AST_OP_MOD,
- AST_OP_PLUS,
- AST_OP_MINUS,
- AST_OP_BIT_RSHIFT,
- AST_OP_BIT_LSHIFT,
- AST_OP_AND,
- AST_OP_OR,
- AST_OP_BIT_AND,
- AST_OP_BIT_OR,
- AST_OP_BIT_XOR,
-
- AST_OP_EQ,
- AST_OP_NE,
- AST_OP_GT,
- AST_OP_LT,
- AST_OP_GE,
- AST_OP_LE,
-};
-
-enum unary_op_type {
- AST_UNARY_UNKNOWN = 0,
- AST_UNARY_PLUS,
- AST_UNARY_MINUS,
- AST_UNARY_NOT,
- AST_UNARY_BIT_NOT,
-};
-
-enum ast_link_type {
- AST_LINK_UNKNOWN = 0,
- AST_LINK_DOT,
- AST_LINK_RARROW,
- AST_LINK_BRACKET,
-};
-
-enum ast_expt_type {
- AST_EXP_UNKNOWN = 0,
- AST_EXP_STRING,
- AST_EXP_CONSTANT,
- AST_EXP_FLOAT_CONSTANT,
- AST_EXP_IDENTIFIER,
- AST_EXP_GLOBAL_IDENTIFIER,
- AST_EXP_NESTED,
-};
-
-struct filter_node {
- /*
- * Parent node is only set on demand by specific visitor.
- */
- struct filter_node *parent;
- struct cds_list_head gc;
-
- enum node_type type;
- union {
- struct {
- /* Avoid -Wextern-c-compat warning with clang++. */
- char unused;
- } unknown;
- struct {
- struct filter_node *child;
- } root;
- struct {
- enum ast_expt_type type;
- enum ast_link_type post_op; /* reverse */
- enum ast_link_type pre_op; /* forward */
- union {
- const char *string;
- uint64_t constant;
- double float_constant;
- const char *identifier;
- /*
- * child can be nested.
- */
- struct filter_node *child;
- } u;
- /* prev: backward dot/arrow chain (postfix expression) */
- struct filter_node *prev;
- /* next: forward dot/arrow chain, generated by a visitor. */
- struct filter_node *next;
- /* next_bracket: linked bracket chain (prefix expression) */
- struct filter_node *next_bracket;
- } expression;
- struct {
- enum op_type type;
- struct filter_node *lchild;
- struct filter_node *rchild;
- } op;
- struct {
- enum unary_op_type type;
- struct filter_node *child;
- } unary_op;
- } u;
-};
-
-struct filter_ast {
- struct filter_node root;
- struct cds_list_head allocated_nodes;
-};
-
-const char *node_type(struct filter_node *node);
-
-struct ir_op;
-
-struct filter_parser_ctx {
- yyscan_t scanner;
- struct filter_ast *ast;
- struct cds_list_head allocated_strings;
- struct ir_op *ir_root;
- struct lttng_bytecode_alloc *bytecode;
- struct lttng_bytecode_alloc *bytecode_reloc;
-};
-
-struct filter_parser_ctx *filter_parser_ctx_alloc(FILE *input);
-void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx);
-int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx);
-int filter_parser_ctx_create_from_filter_expression(
- const char *filter_expression, struct filter_parser_ctx **ctxp);
-
-static inline
-struct filter_ast *filter_parser_get_ast(struct filter_parser_ctx *parser_ctx)
-{
- return parser_ctx->ast;
-}
-
-int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream,
- int indent);
-int filter_visitor_ir_generate(struct filter_parser_ctx *ctx);
-void filter_ir_free(struct filter_parser_ctx *ctx);
-int filter_visitor_bytecode_generate(struct filter_parser_ctx *ctx);
-void filter_bytecode_free(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_check_binary_comparator(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_validate_string(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx *ctx);
-int filter_visitor_ir_validate_globbing(struct filter_parser_ctx *ctx);
-
-#endif /* _FILTER_AST_H */
--- /dev/null
+#ifndef _FILTER_AST_H
+#define _FILTER_AST_H
+
+/*
+ * filter-ast.h
+ *
+ * LTTng filter AST
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+/*
+ * Note: filter-ast.h should be included before filter-parser.h.
+ */
+
+#include <urcu/list.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#define printf_debug(fmt, args...) \
+ do { \
+ if (filter_parser_debug) \
+ fprintf(stdout, "[debug] " fmt, ## args); \
+ } while (0)
+
+// the parameter name (of the reentrant 'yyparse' function)
+// data is a pointer to a 'SParserParam' structure
+//#define YYPARSE_PARAM parser_ctx
+
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+extern int filter_parser_debug;
+
+struct filter_node;
+struct filter_parser;
+
+enum node_type {
+ NODE_UNKNOWN = 0,
+ NODE_ROOT,
+
+ NODE_EXPRESSION,
+ NODE_OP,
+ NODE_UNARY_OP,
+
+ NR_NODE_TYPES,
+};
+
+enum op_type {
+ AST_OP_UNKNOWN = 0,
+ AST_OP_MUL,
+ AST_OP_DIV,
+ AST_OP_MOD,
+ AST_OP_PLUS,
+ AST_OP_MINUS,
+ AST_OP_BIT_RSHIFT,
+ AST_OP_BIT_LSHIFT,
+ AST_OP_AND,
+ AST_OP_OR,
+ AST_OP_BIT_AND,
+ AST_OP_BIT_OR,
+ AST_OP_BIT_XOR,
+
+ AST_OP_EQ,
+ AST_OP_NE,
+ AST_OP_GT,
+ AST_OP_LT,
+ AST_OP_GE,
+ AST_OP_LE,
+};
+
+enum unary_op_type {
+ AST_UNARY_UNKNOWN = 0,
+ AST_UNARY_PLUS,
+ AST_UNARY_MINUS,
+ AST_UNARY_NOT,
+ AST_UNARY_BIT_NOT,
+};
+
+enum ast_link_type {
+ AST_LINK_UNKNOWN = 0,
+ AST_LINK_DOT,
+ AST_LINK_RARROW,
+ AST_LINK_BRACKET,
+};
+
+enum ast_expt_type {
+ AST_EXP_UNKNOWN = 0,
+ AST_EXP_STRING,
+ AST_EXP_CONSTANT,
+ AST_EXP_FLOAT_CONSTANT,
+ AST_EXP_IDENTIFIER,
+ AST_EXP_GLOBAL_IDENTIFIER,
+ AST_EXP_NESTED,
+};
+
+struct filter_node {
+ /*
+ * Parent node is only set on demand by specific visitor.
+ */
+ struct filter_node *parent;
+ struct cds_list_head gc;
+
+ enum node_type type;
+ union {
+ struct {
+ /* Avoid -Wextern-c-compat warning with clang++. */
+ char unused;
+ } unknown;
+ struct {
+ struct filter_node *child;
+ } root;
+ struct {
+ enum ast_expt_type type;
+ enum ast_link_type post_op; /* reverse */
+ enum ast_link_type pre_op; /* forward */
+ union {
+ const char *string;
+ uint64_t constant;
+ double float_constant;
+ const char *identifier;
+ /*
+ * child can be nested.
+ */
+ struct filter_node *child;
+ } u;
+ /* prev: backward dot/arrow chain (postfix expression) */
+ struct filter_node *prev;
+ /* next: forward dot/arrow chain, generated by a visitor. */
+ struct filter_node *next;
+ /* next_bracket: linked bracket chain (prefix expression) */
+ struct filter_node *next_bracket;
+ } expression;
+ struct {
+ enum op_type type;
+ struct filter_node *lchild;
+ struct filter_node *rchild;
+ } op;
+ struct {
+ enum unary_op_type type;
+ struct filter_node *child;
+ } unary_op;
+ } u;
+};
+
+struct filter_ast {
+ struct filter_node root;
+ struct cds_list_head allocated_nodes;
+};
+
+const char *node_type(struct filter_node *node);
+
+struct ir_op;
+
+struct filter_parser_ctx {
+ yyscan_t scanner;
+ struct filter_ast *ast;
+ struct cds_list_head allocated_strings;
+ struct ir_op *ir_root;
+ struct lttng_bytecode_alloc *bytecode;
+ struct lttng_bytecode_alloc *bytecode_reloc;
+};
+
+struct filter_parser_ctx *filter_parser_ctx_alloc(FILE *input);
+void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx);
+int filter_parser_ctx_append_ast(struct filter_parser_ctx *parser_ctx);
+int filter_parser_ctx_create_from_filter_expression(
+ const char *filter_expression, struct filter_parser_ctx **ctxp);
+
+static inline
+struct filter_ast *filter_parser_get_ast(struct filter_parser_ctx *parser_ctx)
+{
+ return parser_ctx->ast;
+}
+
+int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream,
+ int indent);
+int filter_visitor_ir_generate(struct filter_parser_ctx *ctx);
+void filter_ir_free(struct filter_parser_ctx *ctx);
+int filter_visitor_bytecode_generate(struct filter_parser_ctx *ctx);
+void filter_bytecode_free(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_check_binary_comparator(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_validate_string(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx *ctx);
+int filter_visitor_ir_validate_globbing(struct filter_parser_ctx *ctx);
+
+#endif /* _FILTER_AST_H */
+++ /dev/null
-#ifndef _FILTER_IR_H
-#define _FILTER_IR_H
-
-/*
- * filter-ir.h
- *
- * LTTng filter ir
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include "filter-ast.h"
-
-enum ir_op_signedness {
- IR_SIGN_UNKNOWN = 0,
- IR_SIGNED,
- IR_UNSIGNED,
- IR_SIGN_DYN, /* signedness determined dynamically */
-};
-
-enum ir_data_type {
- IR_DATA_UNKNOWN = 0,
- IR_DATA_STRING,
- IR_DATA_NUMERIC, /* numeric and boolean */
- IR_DATA_FLOAT,
- IR_DATA_FIELD_REF,
- IR_DATA_GET_CONTEXT_REF,
- IR_DATA_EXPRESSION,
-};
-
-static inline
-const char *ir_data_type_str(enum ir_data_type type)
-{
- switch (type) {
- case IR_DATA_UNKNOWN:
- return "IR_DATA_UNKNOWN";
- case IR_DATA_STRING:
- return "IR_DATA_STRING";
- case IR_DATA_NUMERIC:
- return "IR_DATA_NUMERIC";
- case IR_DATA_FLOAT:
- return "IR_DATA_FLOAT";
- case IR_DATA_FIELD_REF:
- return "IR_DATA_FIELD_REF";
- case IR_DATA_GET_CONTEXT_REF:
- return "IR_DATA_GET_CONTEXT_REF";
- case IR_DATA_EXPRESSION:
- return "IR_DATA_EXPRESSION";
- default:
- abort();
- }
-}
-
-enum ir_op_type {
- IR_OP_UNKNOWN = 0,
- IR_OP_ROOT,
- IR_OP_LOAD,
- IR_OP_UNARY,
- IR_OP_BINARY,
- IR_OP_LOGICAL,
-};
-
-static inline
-const char *ir_op_type_str(enum ir_op_type type)
-{
- switch (type) {
- case IR_OP_UNKNOWN:
- return "IR_OP_UNKNOWN";
- case IR_OP_ROOT:
- return "IR_OP_ROOT";
- case IR_OP_LOAD:
- return "IR_OP_LOAD";
- case IR_OP_UNARY:
- return "IR_OP_UNARY";
- case IR_OP_BINARY:
- return "IR_OP_BINARY";
- case IR_OP_LOGICAL:
- return "IR_OP_LOGICAL";
- default:
- abort();
- }
-}
-
-/* left or right child */
-enum ir_side {
- IR_SIDE_UNKNOWN = 0,
- IR_LEFT,
- IR_RIGHT,
-};
-
-enum ir_load_string_type {
- /* Plain, no globbing at all: `hello world`. */
- IR_LOAD_STRING_TYPE_PLAIN = 0,
-
- /* Star at the end only: `hello *`. */
- IR_LOAD_STRING_TYPE_GLOB_STAR_END,
-
- /* At least one star, anywhere, but not at the end only: `he*wor*`. */
- IR_LOAD_STRING_TYPE_GLOB_STAR,
-};
-
-struct ir_op_root {
- struct ir_op *child;
-};
-
-enum ir_load_expression_type {
- IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
- IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
- IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
- IR_LOAD_EXPRESSION_GET_SYMBOL,
- IR_LOAD_EXPRESSION_GET_INDEX,
- IR_LOAD_EXPRESSION_LOAD_FIELD,
-};
-
-static inline
-const char *ir_load_expression_type_str(enum ir_load_expression_type type)
-{
- switch (type) {
- case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
- return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
- case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
- return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
- case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
- return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
- case IR_LOAD_EXPRESSION_GET_SYMBOL:
- return "IR_LOAD_EXPRESSION_GET_SYMBOL";
- case IR_LOAD_EXPRESSION_GET_INDEX:
- return "IR_LOAD_EXPRESSION_GET_INDEX";
- case IR_LOAD_EXPRESSION_LOAD_FIELD:
- return "IR_LOAD_EXPRESSION_LOAD_FIELD";
- default:
- abort();
- }
-}
-
-struct ir_load_expression_op {
- struct ir_load_expression_op *next;
- enum ir_load_expression_type type;
- union {
- char *symbol;
- uint64_t index;
- } u;
-};
-
-struct ir_load_expression {
- struct ir_load_expression_op *child;
-};
-
-struct ir_op_load {
- union {
- struct {
- enum ir_load_string_type type;
- char *value;
- } string;
- int64_t num;
- double flt;
- char *ref;
- struct ir_load_expression *expression;
- } u;
-};
-
-struct ir_op_unary {
- enum unary_op_type type;
- struct ir_op *child;
-};
-
-struct ir_op_binary {
- enum op_type type;
- struct ir_op *left;
- struct ir_op *right;
-};
-
-struct ir_op_logical {
- enum op_type type;
- struct ir_op *left;
- struct ir_op *right;
-};
-
-struct ir_op {
- /* common to all ops */
- enum ir_op_type op;
- enum ir_data_type data_type;
- enum ir_op_signedness signedness;
- enum ir_side side;
-
- union {
- struct ir_op_root root;
- struct ir_op_load load;
- struct ir_op_unary unary;
- struct ir_op_binary binary;
- struct ir_op_logical logical;
- } u;
-};
-
-#endif /* _FILTER_IR_H */
--- /dev/null
+#ifndef _FILTER_IR_H
+#define _FILTER_IR_H
+
+/*
+ * filter-ir.h
+ *
+ * LTTng filter ir
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include "filter-ast.hpp"
+
+enum ir_op_signedness {
+ IR_SIGN_UNKNOWN = 0,
+ IR_SIGNED,
+ IR_UNSIGNED,
+ IR_SIGN_DYN, /* signedness determined dynamically */
+};
+
+enum ir_data_type {
+ IR_DATA_UNKNOWN = 0,
+ IR_DATA_STRING,
+ IR_DATA_NUMERIC, /* numeric and boolean */
+ IR_DATA_FLOAT,
+ IR_DATA_FIELD_REF,
+ IR_DATA_GET_CONTEXT_REF,
+ IR_DATA_EXPRESSION,
+};
+
+static inline
+const char *ir_data_type_str(enum ir_data_type type)
+{
+ switch (type) {
+ case IR_DATA_UNKNOWN:
+ return "IR_DATA_UNKNOWN";
+ case IR_DATA_STRING:
+ return "IR_DATA_STRING";
+ case IR_DATA_NUMERIC:
+ return "IR_DATA_NUMERIC";
+ case IR_DATA_FLOAT:
+ return "IR_DATA_FLOAT";
+ case IR_DATA_FIELD_REF:
+ return "IR_DATA_FIELD_REF";
+ case IR_DATA_GET_CONTEXT_REF:
+ return "IR_DATA_GET_CONTEXT_REF";
+ case IR_DATA_EXPRESSION:
+ return "IR_DATA_EXPRESSION";
+ default:
+ abort();
+ }
+}
+
+enum ir_op_type {
+ IR_OP_UNKNOWN = 0,
+ IR_OP_ROOT,
+ IR_OP_LOAD,
+ IR_OP_UNARY,
+ IR_OP_BINARY,
+ IR_OP_LOGICAL,
+};
+
+static inline
+const char *ir_op_type_str(enum ir_op_type type)
+{
+ switch (type) {
+ case IR_OP_UNKNOWN:
+ return "IR_OP_UNKNOWN";
+ case IR_OP_ROOT:
+ return "IR_OP_ROOT";
+ case IR_OP_LOAD:
+ return "IR_OP_LOAD";
+ case IR_OP_UNARY:
+ return "IR_OP_UNARY";
+ case IR_OP_BINARY:
+ return "IR_OP_BINARY";
+ case IR_OP_LOGICAL:
+ return "IR_OP_LOGICAL";
+ default:
+ abort();
+ }
+}
+
+/* left or right child */
+enum ir_side {
+ IR_SIDE_UNKNOWN = 0,
+ IR_LEFT,
+ IR_RIGHT,
+};
+
+enum ir_load_string_type {
+ /* Plain, no globbing at all: `hello world`. */
+ IR_LOAD_STRING_TYPE_PLAIN = 0,
+
+ /* Star at the end only: `hello *`. */
+ IR_LOAD_STRING_TYPE_GLOB_STAR_END,
+
+ /* At least one star, anywhere, but not at the end only: `he*wor*`. */
+ IR_LOAD_STRING_TYPE_GLOB_STAR,
+};
+
+struct ir_op_root {
+ struct ir_op *child;
+};
+
+enum ir_load_expression_type {
+ IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
+ IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
+ IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
+ IR_LOAD_EXPRESSION_GET_SYMBOL,
+ IR_LOAD_EXPRESSION_GET_INDEX,
+ IR_LOAD_EXPRESSION_LOAD_FIELD,
+};
+
+static inline
+const char *ir_load_expression_type_str(enum ir_load_expression_type type)
+{
+ switch (type) {
+ case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
+ return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
+ case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
+ return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
+ case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
+ return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
+ case IR_LOAD_EXPRESSION_GET_SYMBOL:
+ return "IR_LOAD_EXPRESSION_GET_SYMBOL";
+ case IR_LOAD_EXPRESSION_GET_INDEX:
+ return "IR_LOAD_EXPRESSION_GET_INDEX";
+ case IR_LOAD_EXPRESSION_LOAD_FIELD:
+ return "IR_LOAD_EXPRESSION_LOAD_FIELD";
+ default:
+ abort();
+ }
+}
+
+struct ir_load_expression_op {
+ struct ir_load_expression_op *next;
+ enum ir_load_expression_type type;
+ union {
+ char *symbol;
+ uint64_t index;
+ } u;
+};
+
+struct ir_load_expression {
+ struct ir_load_expression_op *child;
+};
+
+struct ir_op_load {
+ union {
+ struct {
+ enum ir_load_string_type type;
+ char *value;
+ } string;
+ int64_t num;
+ double flt;
+ char *ref;
+ struct ir_load_expression *expression;
+ } u;
+};
+
+struct ir_op_unary {
+ enum unary_op_type type;
+ struct ir_op *child;
+};
+
+struct ir_op_binary {
+ enum op_type type;
+ struct ir_op *left;
+ struct ir_op *right;
+};
+
+struct ir_op_logical {
+ enum op_type type;
+ struct ir_op *left;
+ struct ir_op *right;
+};
+
+struct ir_op {
+ /* common to all ops */
+ enum ir_op_type op;
+ enum ir_data_type data_type;
+ enum ir_op_signedness signedness;
+ enum ir_side side;
+
+ union {
+ struct ir_op_root root;
+ struct ir_op_load load;
+ struct ir_op_unary unary;
+ struct ir_op_binary binary;
+ struct ir_op_logical logical;
+ } u;
+};
+
+#endif /* _FILTER_IR_H */
*/
#include <stdio.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
#include <lttng/lttng-export.h>
%}
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
-#include "common/bytecode/bytecode.h"
-#include "filter-ast.h"
+#include "common/bytecode/bytecode.hpp"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "memstream.h"
+#include "memstream.hpp"
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
#define WIDTH_u64_SCANF_IS_A_BROKEN_API "20"
#define WIDTH_o64_SCANF_IS_A_BROKEN_API "22"
%code provides
{
-#include "common/macros.h"
+#include "common/macros.hpp"
void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
}
+++ /dev/null
-#ifndef _FILTER_SYMBOLS_H
-#define _FILTER_SYMBOLS_H
-
-/*
- * filter-symbols.h
- *
- * LTTng filter flex/bison symbol prefixes
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#define yy_create_buffer lttng_filter_yy_create_buffer
-#define yy_delete_buffer lttng_filter_yy_delete_buffer
-#define yy_flush_buffer lttng_filter_yy_flush_buffer
-#define yy_scan_buffer lttng_filter_yy_scan_buffer
-#define yy_scan_bytes lttng_filter_yy_scan_bytes
-#define yy_scan_string lttng_filter_yy_scan_string
-#define yy_switch_to_buffer lttng_filter_yy_switch_to_buffer
-#define yyalloc lttng_filter_yyalloc
-#define yyfree lttng_filter_yyfree
-#define yyget_column lttng_filter_yyget_column
-#define yyget_debug lttng_filter_yyget_debug
-#define yyget_extra lttng_filter_yyget_extra
-#define yyget_in lttng_filter_yyget_in
-#define yyget_leng lttng_filter_yyget_leng
-#define yyget_lineno lttng_filter_yyget_lineno
-#define yyget_lval lttng_filter_yyget_lval
-#define yyget_out lttng_filter_yyget_out
-#define yyget_text lttng_filter_yyget_text
-#define yylex_init lttng_filter_yylex_init
-#define yypop_buffer_state lttng_filter_yypop_buffer_state
-#define yypush_buffer_state lttng_filter_yypush_buffer_state
-#define yyrealloc lttng_filter_yyrealloc
-#define yyset_column lttng_filter_yyset_column
-#define yyset_debug lttng_filter_yyset_debug
-#define yyset_extra lttng_filter_yyset_extra
-#define yyset_in lttng_filter_yyset_in
-#define yyset_lineno lttng_filter_yyset_lineno
-#define yyset_lval lttng_filter_yyset_lval
-#define yyset_out lttng_filter_yyset_out
-
-#endif /* _FILTER_SYMBOLS_H */
--- /dev/null
+#ifndef _FILTER_SYMBOLS_H
+#define _FILTER_SYMBOLS_H
+
+/*
+ * filter-symbols.h
+ *
+ * LTTng filter flex/bison symbol prefixes
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#define yy_create_buffer lttng_filter_yy_create_buffer
+#define yy_delete_buffer lttng_filter_yy_delete_buffer
+#define yy_flush_buffer lttng_filter_yy_flush_buffer
+#define yy_scan_buffer lttng_filter_yy_scan_buffer
+#define yy_scan_bytes lttng_filter_yy_scan_bytes
+#define yy_scan_string lttng_filter_yy_scan_string
+#define yy_switch_to_buffer lttng_filter_yy_switch_to_buffer
+#define yyalloc lttng_filter_yyalloc
+#define yyfree lttng_filter_yyfree
+#define yyget_column lttng_filter_yyget_column
+#define yyget_debug lttng_filter_yyget_debug
+#define yyget_extra lttng_filter_yyget_extra
+#define yyget_in lttng_filter_yyget_in
+#define yyget_leng lttng_filter_yyget_leng
+#define yyget_lineno lttng_filter_yyget_lineno
+#define yyget_lval lttng_filter_yyget_lval
+#define yyget_out lttng_filter_yyget_out
+#define yyget_text lttng_filter_yyget_text
+#define yylex_init lttng_filter_yylex_init
+#define yypop_buffer_state lttng_filter_yypop_buffer_state
+#define yypush_buffer_state lttng_filter_yypush_buffer_state
+#define yyrealloc lttng_filter_yyrealloc
+#define yyset_column lttng_filter_yyset_column
+#define yyset_debug lttng_filter_yyset_debug
+#define yyset_extra lttng_filter_yyset_extra
+#define yyset_in lttng_filter_yyset_in
+#define yyset_lineno lttng_filter_yyset_lineno
+#define yyset_lval lttng_filter_yyset_lval
+#define yyset_out lttng_filter_yyset_out
+
+#endif /* _FILTER_SYMBOLS_H */
#include <stdlib.h>
#include <string.h>
-#include <common/align.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-
-#include "common/align.h"
-#include "common/bytecode/bytecode.h"
-#include "common/compat/string.h"
-#include "common/macros.h"
-#include "common/string-utils/string-utils.h"
-#include "filter-ast.h"
-#include "filter-ir.h"
+#include <common/align.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+
+#include "common/align.hpp"
+#include "common/bytecode/bytecode.hpp"
+#include "common/compat/string.hpp"
+#include "common/macros.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
#ifndef max_t
#define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b)))
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
-#include <common/compat/errno.h>
-#include <common/macros.h>
-#include <common/string-utils/string-utils.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
+#include <common/string-utils/string-utils.hpp>
static
struct ir_op *generate_ir_recursive(struct filter_parser_ctx *ctx,
#include <stdlib.h>
#include <inttypes.h>
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
static
int check_bin_comparator(struct ir_op *node)
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
static
int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
#include <stdlib.h>
#include <inttypes.h>
-#include <common/compat/errno.h>
-#include <common/macros.h>
-#include <common/string-utils/string-utils.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
+#include <common/string-utils/string-utils.hpp>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
static
int normalize_glob_patterns(struct ir_op *node)
#include <stdlib.h>
#include <inttypes.h>
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
static
int validate_globbing(struct ir_op *node)
#include <stdlib.h>
#include <inttypes.h>
-#include <common/macros.h>
-#include <common/compat/errno.h>
+#include <common/macros.hpp>
+#include <common/compat/errno.hpp>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include "filter-ir.h"
+#include "filter-ir.hpp"
enum parse_char_result {
PARSE_CHAR_UNKNOWN = -2,
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
-#include "filter-ast.h"
+#include "filter-ast.hpp"
#include "filter-parser.hpp"
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args)
+++ /dev/null
-/*
- * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef _LTTNG_CTL_MEMSTREAM_H
-#define _LTTNG_CTL_MEMSTREAM_H
-
-#ifdef LTTNG_HAVE_FMEMOPEN
-#include <stdio.h>
-
-static inline
-FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
-{
- return fmemopen(buf, size, mode);
-}
-
-#else /* LTTNG_HAVE_FMEMOPEN */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common/error.h>
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
-{
- char tmpname[PATH_MAX];
- size_t len;
- FILE *fp;
- int ret;
-
- /*
- * Support reading only.
- */
- if (strcmp(mode, "rb") != 0) {
- return NULL;
- }
- strncpy(tmpname, "/tmp/lttng-tmp-XXXXXX", PATH_MAX);
- ret = mkstemp(tmpname);
- if (ret < 0) {
- return NULL;
- }
- /*
- * We need to write to the file.
- */
- fp = fdopen(ret, "w+");
- if (!fp) {
- goto error_unlink;
- }
- /* Copy the entire buffer to the file */
- len = fwrite(buf, sizeof(char), size, fp);
- if (len != size) {
- goto error_close;
- }
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- PERROR("fseek");
- goto error_close;
- }
- /* We keep the handle open, but can unlink the file on the VFS. */
- ret = unlink(tmpname);
- if (ret < 0) {
- PERROR("unlink");
- }
- return fp;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- PERROR("close");
- }
-error_unlink:
- ret = unlink(tmpname);
- if (ret < 0) {
- PERROR("unlink");
- }
- return NULL;
-}
-
-#endif /* LTTNG_HAVE_FMEMOPEN */
-
-#endif /* _LTTNG_CTL_MEMSTREAM_H */
--- /dev/null
+/*
+ * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef _LTTNG_CTL_MEMSTREAM_H
+#define _LTTNG_CTL_MEMSTREAM_H
+
+#ifdef LTTNG_HAVE_FMEMOPEN
+#include <stdio.h>
+
+static inline
+FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
+{
+ return fmemopen(buf, size, mode);
+}
+
+#else /* LTTNG_HAVE_FMEMOPEN */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <common/error.hpp>
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *lttng_fmemopen(void *buf, size_t size, const char *mode)
+{
+ char tmpname[PATH_MAX];
+ size_t len;
+ FILE *fp;
+ int ret;
+
+ /*
+ * Support reading only.
+ */
+ if (strcmp(mode, "rb") != 0) {
+ return NULL;
+ }
+ strncpy(tmpname, "/tmp/lttng-tmp-XXXXXX", PATH_MAX);
+ ret = mkstemp(tmpname);
+ if (ret < 0) {
+ return NULL;
+ }
+ /*
+ * We need to write to the file.
+ */
+ fp = fdopen(ret, "w+");
+ if (!fp) {
+ goto error_unlink;
+ }
+ /* Copy the entire buffer to the file */
+ len = fwrite(buf, sizeof(char), size, fp);
+ if (len != size) {
+ goto error_close;
+ }
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ PERROR("fseek");
+ goto error_close;
+ }
+ /* We keep the handle open, but can unlink the file on the VFS. */
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ PERROR("unlink");
+ }
+ return fp;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ PERROR("close");
+ }
+error_unlink:
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ PERROR("unlink");
+ }
+ return NULL;
+}
+
+#endif /* LTTNG_HAVE_FMEMOPEN */
+
+#endif /* _LTTNG_CTL_MEMSTREAM_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FS_HANDLE_INTERNAL_H
-#define FS_HANDLE_INTERNAL_H
-
-struct fs_handle;
-
-/*
- * Multiple internal APIs return fs_handles. For the moment, this internal
- * interface allows the use of different fs_handle implementations in different
- * daemons. For instance, the trace chunk interface returns fs_handles that
- * behave diffently depending on whether or not the trace chunk was configured
- * to use an fd-tracker.
- */
-
-typedef int (*fs_handle_get_fd_cb)(struct fs_handle *);
-typedef void (*fs_handle_put_fd_cb)(struct fs_handle *);
-typedef int (*fs_handle_unlink_cb)(struct fs_handle *);
-typedef int (*fs_handle_close_cb)(struct fs_handle *);
-
-struct fs_handle {
- fs_handle_get_fd_cb get_fd;
- fs_handle_put_fd_cb put_fd;
- fs_handle_unlink_cb unlink;
- fs_handle_close_cb close;
-};
-
-#endif /* FS_HANDLE_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FS_HANDLE_INTERNAL_H
+#define FS_HANDLE_INTERNAL_H
+
+struct fs_handle;
+
+/*
+ * Multiple internal APIs return fs_handles. For the moment, this internal
+ * interface allows the use of different fs_handle implementations in different
+ * daemons. For instance, the trace chunk interface returns fs_handles that
+ * behave diffently depending on whether or not the trace chunk was configured
+ * to use an fd-tracker.
+ */
+
+typedef int (*fs_handle_get_fd_cb)(struct fs_handle *);
+typedef void (*fs_handle_put_fd_cb)(struct fs_handle *);
+typedef int (*fs_handle_unlink_cb)(struct fs_handle *);
+typedef int (*fs_handle_close_cb)(struct fs_handle *);
+
+struct fs_handle {
+ fs_handle_get_fd_cb get_fd;
+ fs_handle_put_fd_cb put_fd;
+ fs_handle_unlink_cb unlink;
+ fs_handle_close_cb close;
+};
+
+#endif /* FS_HANDLE_INTERNAL_H */
*
*/
-#include <common/fs-handle-internal.h>
-#include <common/fs-handle.h>
-#include <common/readwrite.h>
+#include <common/fs-handle-internal.hpp>
+#include <common/fs-handle.hpp>
+#include <common/readwrite.hpp>
int fs_handle_get_fd(struct fs_handle *handle)
{
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef FS_HANDLE_H
-#define FS_HANDLE_H
-
-#include <common/macros.h>
-#include <stdio.h>
-
-struct fs_handle;
-
-/*
- * Marks the handle as the most recently used and marks the 'fd' as
- * "in-use". This prevents the tracker from recycling the underlying
- * file descriptor while it is actively being used by a thread.
- *
- * Don't forget that the tracker may be initiating an fd 'suspension'
- * from another thread as the need to free an fd slot may arise from any
- * thread within the daemon.
- *
- * Note that a restorable fd should never be held for longer than
- * strictly necessary (e.g. the duration of a syscall()).
- *
- * Returns the fd on success, otherwise a negative value may be returned
- * if the restoration of the fd failed.
- */
-int fs_handle_get_fd(struct fs_handle *handle);
-
-/*
- * Used by the caller to signal that it is no longer using the underlying fd and
- * that it may be safely suspended.
- */
-void fs_handle_put_fd(struct fs_handle *handle);
-
-/*
- * Unlink the file associated to an fs_handle. Note that the unlink
- * operation will not be performed immediately. It will only be performed
- * once all references to the underlying file (through other fs_handle objects)
- * have been released.
- *
- * However, note that the file will be renamed so as to provide the observable
- * effect of an unlink(), that is removing a name from the filesystem.
- *
- * Returns 0 on success, otherwise a negative value will be returned
- * if the operation failed.
- */
-int fs_handle_unlink(struct fs_handle *handle);
-
-/*
- * Frees the handle and discards the underlying fd.
- */
-int fs_handle_close(struct fs_handle *handle);
-
-ssize_t fs_handle_read(struct fs_handle *handle, void *buf, size_t count);
-
-ssize_t fs_handle_write(struct fs_handle *handle, const void *buf, size_t count);
-
-int fs_handle_truncate(struct fs_handle *handle, off_t offset);
-
-off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence);
-
-#endif /* FS_HANDLE_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef FS_HANDLE_H
+#define FS_HANDLE_H
+
+#include <common/macros.hpp>
+#include <stdio.h>
+
+struct fs_handle;
+
+/*
+ * Marks the handle as the most recently used and marks the 'fd' as
+ * "in-use". This prevents the tracker from recycling the underlying
+ * file descriptor while it is actively being used by a thread.
+ *
+ * Don't forget that the tracker may be initiating an fd 'suspension'
+ * from another thread as the need to free an fd slot may arise from any
+ * thread within the daemon.
+ *
+ * Note that a restorable fd should never be held for longer than
+ * strictly necessary (e.g. the duration of a syscall()).
+ *
+ * Returns the fd on success, otherwise a negative value may be returned
+ * if the restoration of the fd failed.
+ */
+int fs_handle_get_fd(struct fs_handle *handle);
+
+/*
+ * Used by the caller to signal that it is no longer using the underlying fd and
+ * that it may be safely suspended.
+ */
+void fs_handle_put_fd(struct fs_handle *handle);
+
+/*
+ * Unlink the file associated to an fs_handle. Note that the unlink
+ * operation will not be performed immediately. It will only be performed
+ * once all references to the underlying file (through other fs_handle objects)
+ * have been released.
+ *
+ * However, note that the file will be renamed so as to provide the observable
+ * effect of an unlink(), that is removing a name from the filesystem.
+ *
+ * Returns 0 on success, otherwise a negative value will be returned
+ * if the operation failed.
+ */
+int fs_handle_unlink(struct fs_handle *handle);
+
+/*
+ * Frees the handle and discards the underlying fd.
+ */
+int fs_handle_close(struct fs_handle *handle);
+
+ssize_t fs_handle_read(struct fs_handle *handle, void *buf, size_t count);
+
+ssize_t fs_handle_write(struct fs_handle *handle, const void *buf, size_t count);
+
+int fs_handle_truncate(struct fs_handle *handle, off_t offset);
+
+off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence);
+
+#endif /* FS_HANDLE_H */
#include <urcu.h>
#include <urcu/futex.h>
-#include <common/common.h>
+#include <common/common.hpp>
-#include "futex.h"
+#include "futex.hpp"
/*
* This futex wait/wake scheme only works for N wakers / 1 waiters. Hence the
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_FUTEX_H
-#define _LTT_FUTEX_H
-
-void futex_wait_update(int32_t *futex, int active);
-void futex_nto1_prepare(int32_t *futex);
-void futex_nto1_wait(int32_t *futex);
-void futex_nto1_wake(int32_t *futex);
-
-#endif /* _LTT_FUTEX_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_FUTEX_H
+#define _LTT_FUTEX_H
+
+void futex_wait_update(int32_t *futex, int active);
+void futex_nto1_prepare(int32_t *futex);
+void futex_nto1_wait(int32_t *futex);
+void futex_nto1_wake(int32_t *futex);
+
+#endif /* _LTT_FUTEX_H */
+++ /dev/null
-#ifndef _HASHTABLE_SYMBOLS_H
-#define _HASHTABLE_SYMBOLS_H
-
-/*
- * hashtable-symbols.h
- *
- * LTTng hash table symbol prefixing
- *
- * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#define _cds_lfht_new lttng__cds_lfht_new
-#define cds_lfht_add lttng_cds_lfht_add
-#define cds_lfht_add_replace lttng_cds_lfht_add_replace
-#define cds_lfht_add_unique lttng_cds_lfht_add_unique
-#define cds_lfht_count_nodes lttng_cds_lfht_count_nodes
-#define cds_lfht_del lttng_cds_lfht_del
-#define cds_lfht_destroy lttng_cds_lfht_destroy
-#define cds_lfht_first lttng_cds_lfht_first
-#define cds_lfht_fls_ulong lttng_cds_lfht_fls_ulong
-#define cds_lfht_get_count_order_u32 lttng_cds_lfht_get_count_order_u32
-#define cds_lfht_get_count_order_ulong lttng_cds_lfht_get_count_order_ulong
-#define cds_lfht_is_node_deleted lttng_cds_lfht_is_node_deleted
-#define cds_lfht_lookup lttng_cds_lfht_lookup
-#define cds_lfht_next lttng_cds_lfht_next
-#define cds_lfht_next_duplicate lttng_cds_lfht_next_duplicate
-#define cds_lfht_replace lttng_cds_lfht_replace
-#define cds_lfht_resize lttng_cds_lfht_resize
-
-#endif /* _HASHTABLE_SYMBOLS_H */
--- /dev/null
+#ifndef _HASHTABLE_SYMBOLS_H
+#define _HASHTABLE_SYMBOLS_H
+
+/*
+ * hashtable-symbols.h
+ *
+ * LTTng hash table symbol prefixing
+ *
+ * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#define _cds_lfht_new lttng__cds_lfht_new
+#define cds_lfht_add lttng_cds_lfht_add
+#define cds_lfht_add_replace lttng_cds_lfht_add_replace
+#define cds_lfht_add_unique lttng_cds_lfht_add_unique
+#define cds_lfht_count_nodes lttng_cds_lfht_count_nodes
+#define cds_lfht_del lttng_cds_lfht_del
+#define cds_lfht_destroy lttng_cds_lfht_destroy
+#define cds_lfht_first lttng_cds_lfht_first
+#define cds_lfht_fls_ulong lttng_cds_lfht_fls_ulong
+#define cds_lfht_get_count_order_u32 lttng_cds_lfht_get_count_order_u32
+#define cds_lfht_get_count_order_ulong lttng_cds_lfht_get_count_order_ulong
+#define cds_lfht_is_node_deleted lttng_cds_lfht_is_node_deleted
+#define cds_lfht_lookup lttng_cds_lfht_lookup
+#define cds_lfht_next lttng_cds_lfht_next
+#define cds_lfht_next_duplicate lttng_cds_lfht_next_duplicate
+#define cds_lfht_replace lttng_cds_lfht_replace
+#define cds_lfht_resize lttng_cds_lfht_resize
+
+#endif /* _HASHTABLE_SYMBOLS_H */
#include <urcu.h>
#include <urcu/compiler.h>
-#include <common/common.h>
-#include <common/defaults.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
-#include "hashtable.h"
-#include "utils.h"
+#include "hashtable.hpp"
+#include "utils.hpp"
/* seed_lock protects both seed_init and lttng_ht_seed. */
static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_HT_H
-#define _LTT_HT_H
-
-#include <urcu.h>
-#include <stdint.h>
-
-#include <common/macros.h>
-#include <lttng/lttng-export.h>
-#include <urcu/rculfhash.h>
-
-LTTNG_EXPORT extern unsigned long lttng_ht_seed;
-
-typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed);
-typedef cds_lfht_match_fct hash_match_fct;
-
-enum lttng_ht_type {
- LTTNG_HT_TYPE_STRING,
- LTTNG_HT_TYPE_ULONG,
- LTTNG_HT_TYPE_U64,
- LTTNG_HT_TYPE_TWO_U64,
-};
-
-struct lttng_ht {
- struct cds_lfht *ht;
- cds_lfht_match_fct match_fct;
- hash_fct_type hash_fct;
-};
-
-struct lttng_ht_iter {
- struct cds_lfht_iter iter;
-};
-
-struct lttng_ht_node_str {
- char *key;
- struct cds_lfht_node node;
- struct rcu_head head;
-};
-
-struct lttng_ht_node_ulong {
- unsigned long key;
- struct cds_lfht_node node;
- struct rcu_head head;
-};
-
-struct lttng_ht_node_u64 {
- uint64_t key;
- struct cds_lfht_node node;
- struct rcu_head head;
-};
-
-struct lttng_ht_two_u64 {
- uint64_t key1;
- uint64_t key2;
-};
-
-struct lttng_ht_node_two_u64 {
- struct lttng_ht_two_u64 key;
- struct cds_lfht_node node;
- struct rcu_head head;
-};
-
-/* Hashtable new and destroy */
-struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type);
-void lttng_ht_destroy(struct lttng_ht *ht);
-
-/* Specialized node init and free functions */
-void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
-void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
- unsigned long key);
-void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node,
- uint64_t key);
-void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node,
- uint64_t key1, uint64_t key2);
-void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
-void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
-void lttng_ht_node_free_u64(struct lttng_ht_node_u64 *node);
-void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64 *node);
-
-void lttng_ht_lookup(struct lttng_ht *ht, const void *key,
- struct lttng_ht_iter *iter);
-
-/* Specialized add unique functions */
-void lttng_ht_add_unique_str(struct lttng_ht *ht,
- struct lttng_ht_node_str *node);
-void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
- struct lttng_ht_node_ulong *node);
-void lttng_ht_add_unique_u64(struct lttng_ht *ht,
- struct lttng_ht_node_u64 *node);
-void lttng_ht_add_unique_two_u64(struct lttng_ht *ht,
- struct lttng_ht_node_two_u64 *node);
-struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
- struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
-struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(
- struct lttng_ht *ht, struct lttng_ht_node_u64 *node);
-void lttng_ht_add_str(struct lttng_ht *ht,
- struct lttng_ht_node_str *node);
-void lttng_ht_add_ulong(struct lttng_ht *ht,
- struct lttng_ht_node_ulong *node);
-void lttng_ht_add_u64(struct lttng_ht *ht,
- struct lttng_ht_node_u64 *node);
-
-int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
-
-void lttng_ht_get_first(struct lttng_ht *ht,
- struct lttng_ht_iter *iter);
-void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
-
-unsigned long lttng_ht_get_count(struct lttng_ht *ht);
-
-struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
- struct lttng_ht_iter *iter);
-struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
- struct lttng_ht_iter *iter);
-struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
- struct lttng_ht_iter *iter);
-struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
- struct lttng_ht_iter *iter);
-
-#endif /* _LTT_HT_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_HT_H
+#define _LTT_HT_H
+
+#include <urcu.h>
+#include <stdint.h>
+
+#include <common/macros.hpp>
+#include <lttng/lttng-export.h>
+#include <urcu/rculfhash.h>
+
+LTTNG_EXPORT extern unsigned long lttng_ht_seed;
+
+typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed);
+typedef cds_lfht_match_fct hash_match_fct;
+
+enum lttng_ht_type {
+ LTTNG_HT_TYPE_STRING,
+ LTTNG_HT_TYPE_ULONG,
+ LTTNG_HT_TYPE_U64,
+ LTTNG_HT_TYPE_TWO_U64,
+};
+
+struct lttng_ht {
+ struct cds_lfht *ht;
+ cds_lfht_match_fct match_fct;
+ hash_fct_type hash_fct;
+};
+
+struct lttng_ht_iter {
+ struct cds_lfht_iter iter;
+};
+
+struct lttng_ht_node_str {
+ char *key;
+ struct cds_lfht_node node;
+ struct rcu_head head;
+};
+
+struct lttng_ht_node_ulong {
+ unsigned long key;
+ struct cds_lfht_node node;
+ struct rcu_head head;
+};
+
+struct lttng_ht_node_u64 {
+ uint64_t key;
+ struct cds_lfht_node node;
+ struct rcu_head head;
+};
+
+struct lttng_ht_two_u64 {
+ uint64_t key1;
+ uint64_t key2;
+};
+
+struct lttng_ht_node_two_u64 {
+ struct lttng_ht_two_u64 key;
+ struct cds_lfht_node node;
+ struct rcu_head head;
+};
+
+/* Hashtable new and destroy */
+struct lttng_ht *lttng_ht_new(unsigned long size, enum lttng_ht_type type);
+void lttng_ht_destroy(struct lttng_ht *ht);
+
+/* Specialized node init and free functions */
+void lttng_ht_node_init_str(struct lttng_ht_node_str *node, char *key);
+void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
+ unsigned long key);
+void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node,
+ uint64_t key);
+void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node,
+ uint64_t key1, uint64_t key2);
+void lttng_ht_node_free_str(struct lttng_ht_node_str *node);
+void lttng_ht_node_free_ulong(struct lttng_ht_node_ulong *node);
+void lttng_ht_node_free_u64(struct lttng_ht_node_u64 *node);
+void lttng_ht_node_free_two_u64(struct lttng_ht_node_two_u64 *node);
+
+void lttng_ht_lookup(struct lttng_ht *ht, const void *key,
+ struct lttng_ht_iter *iter);
+
+/* Specialized add unique functions */
+void lttng_ht_add_unique_str(struct lttng_ht *ht,
+ struct lttng_ht_node_str *node);
+void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
+ struct lttng_ht_node_ulong *node);
+void lttng_ht_add_unique_u64(struct lttng_ht *ht,
+ struct lttng_ht_node_u64 *node);
+void lttng_ht_add_unique_two_u64(struct lttng_ht *ht,
+ struct lttng_ht_node_two_u64 *node);
+struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
+ struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
+struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(
+ struct lttng_ht *ht, struct lttng_ht_node_u64 *node);
+void lttng_ht_add_str(struct lttng_ht *ht,
+ struct lttng_ht_node_str *node);
+void lttng_ht_add_ulong(struct lttng_ht *ht,
+ struct lttng_ht_node_ulong *node);
+void lttng_ht_add_u64(struct lttng_ht *ht,
+ struct lttng_ht_node_u64 *node);
+
+int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
+
+void lttng_ht_get_first(struct lttng_ht *ht,
+ struct lttng_ht_iter *iter);
+void lttng_ht_get_next(struct lttng_ht *ht, struct lttng_ht_iter *iter);
+
+unsigned long lttng_ht_get_count(struct lttng_ht *ht);
+
+struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
+ struct lttng_ht_iter *iter);
+struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
+ struct lttng_ht_iter *iter);
+struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
+ struct lttng_ht_iter *iter);
+struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
+ struct lttng_ht_iter *iter);
+
+#endif /* _LTT_HT_H */
*/
#define _LGPL_SOURCE
-#include "hashtable.h"
-#include "utils.h"
+#include "hashtable.hpp"
+#include "utils.hpp"
unsigned long lttng_ht_seed;
#include <time.h> /* defines time_t for timings in the test */
#include <urcu/compiler.h>
-#include "utils.h"
-#include <common/compat/endian.h> /* attempt to define endianness */
-#include <common/common.h>
-#include <common/hashtable/hashtable.h>
+#include "utils.hpp"
+#include <common/compat/endian.hpp> /* attempt to define endianness */
+#include <common/common.hpp>
+#include <common/hashtable/hashtable.hpp>
/*
* My best guess at if you are big-endian or little-endian. This may
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTT_HT_UTILS_H
-#define _LTT_HT_UTILS_H
-
-#include <stdint.h>
-
-unsigned long hash_key_ulong(const void *_key, unsigned long seed);
-unsigned long hash_key_u64(const void *_key, unsigned long seed);
-unsigned long hash_key_str(const void *key, unsigned long seed);
-unsigned long hash_key_two_u64(const void *key, unsigned long seed);
-int hash_match_key_ulong(const void *key1, const void *key2);
-int hash_match_key_u64(const void *key1, const void *key2);
-int hash_match_key_str(const void *key1, const void *key2);
-int hash_match_key_two_u64(const void *key1, const void *key2);
-
-#endif /* _LTT_HT_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTT_HT_UTILS_H
+#define _LTT_HT_UTILS_H
+
+#include <stdint.h>
+
+unsigned long hash_key_ulong(const void *_key, unsigned long seed);
+unsigned long hash_key_u64(const void *_key, unsigned long seed);
+unsigned long hash_key_str(const void *key, unsigned long seed);
+unsigned long hash_key_two_u64(const void *key, unsigned long seed);
+int hash_match_key_ulong(const void *key1, const void *key2);
+int hash_match_key_u64(const void *key1, const void *key2);
+int hash_match_key_str(const void *key1, const void *key2);
+int hash_match_key_two_u64(const void *key1, const void *key2);
+
+#endif /* _LTT_HT_UTILS_H */
#include <stdlib.h>
#include <time.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/sessiond-comm/inet.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/inet.hpp>
-#include <lttng/health-internal.h>
+#include <lttng/health-internal.hpp>
/*
* An application-specific error state for unregistered thread keeps
#include <urcu.h>
#include <urcu/list.h>
-#include "macros.h"
-#include "error.h"
+#include "macros.hpp"
+#include "error.hpp"
-#include "index-allocator.h"
+#include "index-allocator.hpp"
struct lttng_index_allocator {
struct cds_list_head unused_list;
+++ /dev/null
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _COMMON_INDEX_ALLOCATOR_H
-#define _COMMON_INDEX_ALLOCATOR_H
-
-#include <inttypes.h>
-#include <lttng/lttng-export.h>
-
-struct lttng_index_allocator;
-
-enum lttng_index_allocator_status {
- LTTNG_INDEX_ALLOCATOR_STATUS_OK,
- LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
- LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
-};
-
-/*
- * Create an index allocator of `index_count` slots.
- */
-extern "C" LTTNG_EXPORT
-struct lttng_index_allocator *lttng_index_allocator_create(
- uint64_t index_count);
-
-/*
- * Get the number of indexes currently in use.
- */
-extern "C" LTTNG_EXPORT
-uint64_t lttng_index_allocator_get_index_count(
- struct lttng_index_allocator *allocator);
-
-/*
- * Allocate (i.e. reserve) a slot.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_index_allocator_status lttng_index_allocator_alloc(
- struct lttng_index_allocator *allocator,
- uint64_t *index);
-
-/*
- * Release a slot by index. The slot will be re-used by the index allocator
- * in future 'alloc' calls.
- */
-extern "C" LTTNG_EXPORT
-enum lttng_index_allocator_status lttng_index_allocator_release(
- struct lttng_index_allocator *allocator, uint64_t index);
-
-/*
- * Destroy an index allocator.
- */
-extern "C" LTTNG_EXPORT
-void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
-
-#endif /* _COMMON_INDEX_ALLOCATOR_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _COMMON_INDEX_ALLOCATOR_H
+#define _COMMON_INDEX_ALLOCATOR_H
+
+#include <inttypes.h>
+#include <lttng/lttng-export.h>
+
+struct lttng_index_allocator;
+
+enum lttng_index_allocator_status {
+ LTTNG_INDEX_ALLOCATOR_STATUS_OK,
+ LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY,
+ LTTNG_INDEX_ALLOCATOR_STATUS_ERROR,
+};
+
+/*
+ * Create an index allocator of `index_count` slots.
+ */
+extern "C" LTTNG_EXPORT
+struct lttng_index_allocator *lttng_index_allocator_create(
+ uint64_t index_count);
+
+/*
+ * Get the number of indexes currently in use.
+ */
+extern "C" LTTNG_EXPORT
+uint64_t lttng_index_allocator_get_index_count(
+ struct lttng_index_allocator *allocator);
+
+/*
+ * Allocate (i.e. reserve) a slot.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_index_allocator_status lttng_index_allocator_alloc(
+ struct lttng_index_allocator *allocator,
+ uint64_t *index);
+
+/*
+ * Release a slot by index. The slot will be re-used by the index allocator
+ * in future 'alloc' calls.
+ */
+extern "C" LTTNG_EXPORT
+enum lttng_index_allocator_status lttng_index_allocator_release(
+ struct lttng_index_allocator *allocator, uint64_t index);
+
+/*
+ * Destroy an index allocator.
+ */
+extern "C" LTTNG_EXPORT
+void lttng_index_allocator_destroy(struct lttng_index_allocator *allocator);
+
+#endif /* _COMMON_INDEX_ALLOCATOR_H */
+++ /dev/null
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_INDEX_H
-#define LTTNG_INDEX_H
-
-#include <common/compat/endian.h>
-#include <common/macros.h>
-
-#include <stdint.h>
-#include <limits.h>
-#include <stddef.h>
-
-#define CTF_INDEX_MAGIC 0xC1F1DCC1
-#define CTF_INDEX_MAJOR 1
-#define CTF_INDEX_MINOR 1
-
-/*
- * Header at the beginning of each index file.
- * All integer fields are stored in big endian.
- */
-struct ctf_packet_index_file_hdr {
- uint32_t magic;
- uint32_t index_major;
- uint32_t index_minor;
- /* struct packet_index_len, in bytes */
- uint32_t packet_index_len;
-} __attribute__((__packed__));
-
-/*
- * Packet index generated for each trace packet stored in a trace file.
- * All integer fields are stored in big endian.
- */
-struct ctf_packet_index {
- uint64_t offset; /* offset of the packet in the file, in bytes */
- uint64_t packet_size; /* packet size, in bits */
- uint64_t content_size; /* content size, in bits */
- uint64_t timestamp_begin;
- uint64_t timestamp_end;
- uint64_t events_discarded;
- uint64_t stream_id; /* ID of the channel */
- /* CTF_INDEX 1.0 limit */
- uint64_t stream_instance_id; /* ID of the channel instance */
- uint64_t packet_seq_num; /* packet sequence number */
-} __attribute__((__packed__));
-
-static inline size_t ctf_packet_index_len(uint32_t major, uint32_t minor)
-{
- if (major == 1) {
- switch (minor) {
- case 0:
- return offsetof(struct ctf_packet_index, stream_id)
- + member_sizeof(struct ctf_packet_index,
- stream_id);
- case 1:
- return offsetof(struct ctf_packet_index, packet_seq_num)
- + member_sizeof(struct ctf_packet_index,
- packet_seq_num);
- default:
- abort();
- }
- }
- abort();
-}
-
-static inline uint32_t lttng_to_index_major(uint32_t lttng_major,
- uint32_t lttng_minor __attribute__((unused)))
-{
- if (lttng_major == 2) {
- return 1;
- }
- abort();
-}
-
-static inline uint32_t lttng_to_index_minor(uint32_t lttng_major,
- uint32_t lttng_minor)
-{
- if (lttng_major == 2) {
- if (lttng_minor < 8) {
- return 0;
- } else {
- return 1;
- }
- }
- abort();
-}
-
-static inline void ctf_packet_index_file_hdr_init(
- struct ctf_packet_index_file_hdr *hdr,
- uint32_t idx_major, uint32_t idx_minor)
-{
- memset(hdr, 0, sizeof(*hdr));
- hdr->magic = htobe32(CTF_INDEX_MAGIC);
- hdr->index_major = htobe32(idx_major);
- hdr->index_minor = htobe32(idx_minor);
- hdr->packet_index_len = htobe32(
- ctf_packet_index_len(idx_major, idx_minor));
-}
-
-#endif /* LTTNG_INDEX_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_INDEX_H
+#define LTTNG_INDEX_H
+
+#include <common/compat/endian.hpp>
+#include <common/macros.hpp>
+
+#include <stdint.h>
+#include <limits.h>
+#include <stddef.h>
+
+#define CTF_INDEX_MAGIC 0xC1F1DCC1
+#define CTF_INDEX_MAJOR 1
+#define CTF_INDEX_MINOR 1
+
+/*
+ * Header at the beginning of each index file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index_file_hdr {
+ uint32_t magic;
+ uint32_t index_major;
+ uint32_t index_minor;
+ /* struct packet_index_len, in bytes */
+ uint32_t packet_index_len;
+} __attribute__((__packed__));
+
+/*
+ * Packet index generated for each trace packet stored in a trace file.
+ * All integer fields are stored in big endian.
+ */
+struct ctf_packet_index {
+ uint64_t offset; /* offset of the packet in the file, in bytes */
+ uint64_t packet_size; /* packet size, in bits */
+ uint64_t content_size; /* content size, in bits */
+ uint64_t timestamp_begin;
+ uint64_t timestamp_end;
+ uint64_t events_discarded;
+ uint64_t stream_id; /* ID of the channel */
+ /* CTF_INDEX 1.0 limit */
+ uint64_t stream_instance_id; /* ID of the channel instance */
+ uint64_t packet_seq_num; /* packet sequence number */
+} __attribute__((__packed__));
+
+static inline size_t ctf_packet_index_len(uint32_t major, uint32_t minor)
+{
+ if (major == 1) {
+ switch (minor) {
+ case 0:
+ return offsetof(struct ctf_packet_index, stream_id)
+ + member_sizeof(struct ctf_packet_index,
+ stream_id);
+ case 1:
+ return offsetof(struct ctf_packet_index, packet_seq_num)
+ + member_sizeof(struct ctf_packet_index,
+ packet_seq_num);
+ default:
+ abort();
+ }
+ }
+ abort();
+}
+
+static inline uint32_t lttng_to_index_major(uint32_t lttng_major,
+ uint32_t lttng_minor __attribute__((unused)))
+{
+ if (lttng_major == 2) {
+ return 1;
+ }
+ abort();
+}
+
+static inline uint32_t lttng_to_index_minor(uint32_t lttng_major,
+ uint32_t lttng_minor)
+{
+ if (lttng_major == 2) {
+ if (lttng_minor < 8) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ abort();
+}
+
+static inline void ctf_packet_index_file_hdr_init(
+ struct ctf_packet_index_file_hdr *hdr,
+ uint32_t idx_major, uint32_t idx_minor)
+{
+ memset(hdr, 0, sizeof(*hdr));
+ hdr->magic = htobe32(CTF_INDEX_MAGIC);
+ hdr->index_major = htobe32(idx_major);
+ hdr->index_minor = htobe32(idx_minor);
+ hdr->packet_index_len = htobe32(
+ ctf_packet_index_len(idx_major, idx_minor));
+}
+
+#endif /* LTTNG_INDEX_H */
#include <fcntl.h>
#include <lttng/constant.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/endian.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/endian.hpp>
+#include <common/utils.hpp>
-#include "index.h"
+#include "index.hpp"
#define WRITE_FILE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC)
#define READ_ONLY_FILE_FLAGS O_RDONLY
+++ /dev/null
-/*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _INDEX_H
-#define _INDEX_H
-
-#include <inttypes.h>
-#include <urcu/ref.h>
-
-#include "ctf-index.h"
-#include <common/fs-handle.h>
-#include <common/trace-chunk.h>
-
-struct lttng_index_file {
- struct fs_handle *file;
- uint32_t major;
- uint32_t minor;
- uint32_t element_len;
- struct lttng_trace_chunk *trace_chunk;
- struct urcu_ref ref;
-};
-
-/*
- * create and open have refcount of 1. Use put to decrement the
- * refcount. Destroys when reaching 0. Use "get" to increment refcount.
- */
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
- struct lttng_trace_chunk *chunk,
- const char *channel_path, const char *stream_name,
- uint64_t stream_file_size, uint64_t stream_count,
- uint32_t index_major, uint32_t index_minor,
- bool unlink_existing_file, struct lttng_index_file **file);
-
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
- struct lttng_trace_chunk *chunk,
- const char *channel_path, const char *stream_name,
- uint64_t stream_file_size, uint64_t stream_file_index,
- uint32_t index_major, uint32_t index_minor,
- bool expect_no_file, struct lttng_index_file **file);
-
-int lttng_index_file_write(const struct lttng_index_file *index_file,
- const struct ctf_packet_index *element);
-int lttng_index_file_read(const struct lttng_index_file *index_file,
- struct ctf_packet_index *element);
-
-void lttng_index_file_get(struct lttng_index_file *index_file);
-void lttng_index_file_put(struct lttng_index_file *index_file);
-
-#endif /* _INDEX_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _INDEX_H
+#define _INDEX_H
+
+#include <inttypes.h>
+#include <urcu/ref.h>
+
+#include "ctf-index.hpp"
+#include <common/fs-handle.hpp>
+#include <common/trace-chunk.hpp>
+
+struct lttng_index_file {
+ struct fs_handle *file;
+ uint32_t major;
+ uint32_t minor;
+ uint32_t element_len;
+ struct lttng_trace_chunk *trace_chunk;
+ struct urcu_ref ref;
+};
+
+/*
+ * create and open have refcount of 1. Use put to decrement the
+ * refcount. Destroys when reaching 0. Use "get" to increment refcount.
+ */
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
+ struct lttng_trace_chunk *chunk,
+ const char *channel_path, const char *stream_name,
+ uint64_t stream_file_size, uint64_t stream_count,
+ uint32_t index_major, uint32_t index_minor,
+ bool unlink_existing_file, struct lttng_index_file **file);
+
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
+ struct lttng_trace_chunk *chunk,
+ const char *channel_path, const char *stream_name,
+ uint64_t stream_file_size, uint64_t stream_file_index,
+ uint32_t index_major, uint32_t index_minor,
+ bool expect_no_file, struct lttng_index_file **file);
+
+int lttng_index_file_write(const struct lttng_index_file *index_file,
+ const struct ctf_packet_index *element);
+int lttng_index_file_read(const struct lttng_index_file *index_file,
+ struct ctf_packet_index *element);
+
+void lttng_index_file_get(struct lttng_index_file *index_file);
+void lttng_index_file_put(struct lttng_index_file *index_file);
+
+#endif /* _INDEX_H */
*
*/
-#include "ini-config.h"
+#include "ini-config.hpp"
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/ini-config/ini.h>
-#include <common/macros.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/ini-config/ini.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
#include <ctype.h>
LTTNG_EXPORT const char *config_str_yes = "yes";
+++ /dev/null
-/*
- * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef INI_CONFIG_H
-#define INI_CONFIG_H
-
-struct config_entry {
- /* section is NULL if the entry is not in a section */
- const char *section;
- const char *name;
- const char *value;
-};
-
-/*
- * A config_entry_handler_cb receives config_entry structures belonging to the
- * sections the handler has been registered to.
- *
- * The config_entry and its members are only valid for the duration of the call
- * and must not be freed.
- *
- * config_entry_handler_cb may return negative value to indicate an error in
- * the configuration file.
- */
-typedef int (*config_entry_handler_cb)(const struct config_entry *, void *);
-
-/*
- * Read a section's entries in an INI configuration file.
- *
- * path may be NULL, in which case the following paths will be tried:
- * 1) $HOME/.lttng/lttng.conf
- * 2) /etc/lttng/lttng.conf
- *
- * handler will only be called with entries belonging to the provided section.
- * If section is NULL, all entries will be relayed to handler. If section is
- * "", only the global entries are relayed.
- *
- * Returns 0 on success. Negative values are error codes. If the return value
- * is positive, it represents the line number on which a parsing error occurred.
- */
-int config_get_section_entries(const char *path, const char *section,
- config_entry_handler_cb handler, void *user_data);
-
-/*
- * Parse a configuration value.
- *
- * This function expects either an unsigned integer or a boolean text option.
- * The following strings are recognized: true, yes, on, false, no and off.
- *
- * Returns either the value of the parsed integer, or 0/1 if a boolean text
- * string was recognized. Negative values indicate an error.
- */
-int config_parse_value(const char *value);
-
-#endif /* INI_CONFIG_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef INI_CONFIG_H
+#define INI_CONFIG_H
+
+struct config_entry {
+ /* section is NULL if the entry is not in a section */
+ const char *section;
+ const char *name;
+ const char *value;
+};
+
+/*
+ * A config_entry_handler_cb receives config_entry structures belonging to the
+ * sections the handler has been registered to.
+ *
+ * The config_entry and its members are only valid for the duration of the call
+ * and must not be freed.
+ *
+ * config_entry_handler_cb may return negative value to indicate an error in
+ * the configuration file.
+ */
+typedef int (*config_entry_handler_cb)(const struct config_entry *, void *);
+
+/*
+ * Read a section's entries in an INI configuration file.
+ *
+ * path may be NULL, in which case the following paths will be tried:
+ * 1) $HOME/.lttng/lttng.conf
+ * 2) /etc/lttng/lttng.conf
+ *
+ * handler will only be called with entries belonging to the provided section.
+ * If section is NULL, all entries will be relayed to handler. If section is
+ * "", only the global entries are relayed.
+ *
+ * Returns 0 on success. Negative values are error codes. If the return value
+ * is positive, it represents the line number on which a parsing error occurred.
+ */
+int config_get_section_entries(const char *path, const char *section,
+ config_entry_handler_cb handler, void *user_data);
+
+/*
+ * Parse a configuration value.
+ *
+ * This function expects either an unsigned integer or a boolean text option.
+ * The following strings are recognized: true, yes, on, false, no and off.
+ *
+ * Returns either the value of the parsed integer, or 0/1 if a boolean text
+ * string was recognized. Negative values indicate an error.
+ */
+int config_parse_value(const char *value);
+
+#endif /* INI_CONFIG_H */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include <common/common.h>
+#include <common/common.hpp>
-#include "ini.h"
+#include "ini.hpp"
#if !INI_USE_STACK
#include <stdlib.h>
+++ /dev/null
-/*
- * inih -- simple .INI file parser
- *
- * The "inih" library is distributed under the New BSD license:
- *
- * Copyright (C) 2009 Brush Technology - All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Brush Technology nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://code.google.com/p/inih/
- */
-
-#ifndef __INI_H__
-#define __INI_H__
-
-/* Make this header file easier to include in C++ code */
-#include <stdio.h>
-
-typedef int (*ini_entry_handler)(void *, const char *, const char *,
- const char *);
-
-/*
- * Parse given INI-style file. May have [section]s, name=value pairs
- * (whitespace stripped), and comments starting with ';' (semicolon). Section
- * is "" if name=value pair parsed before any section heading. name:value
- * pairs are also supported as a concession to Python's ConfigParser.
- *
- * For each name=value pair parsed, call handler function with given user
- * pointer as well as section, name, and value (data only valid for duration
- * of handler call). Handler should return zero on success, < 0 on error.
- *
- * Returns 0 on success, line number of first error on parse error (doesn't
- * stop on first error), -1 on file open error, or -2 on memory allocation
- * error (only when INI_USE_STACK is zero).
- */
-int ini_parse(const char *filename, ini_entry_handler handler, void *user);
-
-/*
- * Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
- * close the file when it's finished -- the caller must do that.
- */
-int ini_parse_file(FILE *file, ini_entry_handler handler, void *user);
-
-/*
- * Nonzero to allow multi-line value parsing, in the style of Python's
- * ConfigParser. If allowed, ini_parse() will call the handler with the same
- * name for each subsequent line parsed.
- */
-#ifndef INI_ALLOW_MULTILINE
-#define INI_ALLOW_MULTILINE 1
-#endif
-
-/*
- * Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
- * the file. See http://code.google.com/p/inih/issues/detail?id=21
- */
-#ifndef INI_ALLOW_BOM
-#define INI_ALLOW_BOM 1
-#endif
-
-/* Nonzero to use stack, zero to use heap (malloc/free). */
-#ifndef INI_USE_STACK
-#define INI_USE_STACK 1
-#endif
-
-/* Maximum line length for any line in INI file. */
-#ifndef INI_MAX_LINE
-#define INI_MAX_LINE 200
-#endif
-
-#endif /* __INI_H__ */
--- /dev/null
+/*
+ * inih -- simple .INI file parser
+ *
+ * The "inih" library is distributed under the New BSD license:
+ *
+ * Copyright (C) 2009 Brush Technology - All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Brush Technology nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://code.google.com/p/inih/
+ */
+
+#ifndef __INI_H__
+#define __INI_H__
+
+/* Make this header file easier to include in C++ code */
+#include <stdio.h>
+
+typedef int (*ini_entry_handler)(void *, const char *, const char *,
+ const char *);
+
+/*
+ * Parse given INI-style file. May have [section]s, name=value pairs
+ * (whitespace stripped), and comments starting with ';' (semicolon). Section
+ * is "" if name=value pair parsed before any section heading. name:value
+ * pairs are also supported as a concession to Python's ConfigParser.
+ *
+ * For each name=value pair parsed, call handler function with given user
+ * pointer as well as section, name, and value (data only valid for duration
+ * of handler call). Handler should return zero on success, < 0 on error.
+ *
+ * Returns 0 on success, line number of first error on parse error (doesn't
+ * stop on first error), -1 on file open error, or -2 on memory allocation
+ * error (only when INI_USE_STACK is zero).
+ */
+int ini_parse(const char *filename, ini_entry_handler handler, void *user);
+
+/*
+ * Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
+ * close the file when it's finished -- the caller must do that.
+ */
+int ini_parse_file(FILE *file, ini_entry_handler handler, void *user);
+
+/*
+ * Nonzero to allow multi-line value parsing, in the style of Python's
+ * ConfigParser. If allowed, ini_parse() will call the handler with the same
+ * name for each subsequent line parsed.
+ */
+#ifndef INI_ALLOW_MULTILINE
+#define INI_ALLOW_MULTILINE 1
+#endif
+
+/*
+ * Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
+ * the file. See http://code.google.com/p/inih/issues/detail?id=21
+ */
+#ifndef INI_ALLOW_BOM
+#define INI_ALLOW_BOM 1
+#endif
+
+/* Nonzero to use stack, zero to use heap (malloc/free). */
+#ifndef INI_USE_STACK
+#define INI_USE_STACK 1
+#endif
+
+/* Maximum line length for any line in INI file. */
+#ifndef INI_MAX_LINE
+#define INI_MAX_LINE 200
+#endif
+
+#endif /* __INI_H__ */
#include <sys/stat.h>
#include <stdint.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/kernel-ctl/kernel-ctl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/compat/fcntl.h>
-#include <common/compat/endian.h>
-#include <common/pipe.h>
-#include <common/relayd/relayd.h>
-#include <common/utils.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/index/index.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/optional.h>
-#include <common/buffer-view.h>
-#include <common/consumer/consumer.h>
-#include <common/consumer/metadata-bucket.h>
-
-#include "kernel-consumer.h"
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/compat/endian.hpp>
+#include <common/pipe.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/utils.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/index/index.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/optional.hpp>
+#include <common/buffer-view.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/consumer/metadata-bucket.hpp>
+
+#include "kernel-consumer.hpp"
extern struct lttng_consumer_global_data the_consumer_data;
extern int consumer_poll_timeout;
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KCONSUMER_H
-#define _LTTNG_KCONSUMER_H
-
-#include <stdbool.h>
-#include <common/consumer/consumer.h>
-
-int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_kconsumer_sample_snapshot_positions(
- struct lttng_consumer_stream *stream);
-int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos);
-int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos);
-int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll);
-int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
-int lttng_kconsumer_data_pending(struct lttng_consumer_stream *stream);
-enum sync_metadata_status lttng_kconsumer_sync_metadata(
- struct lttng_consumer_stream *metadata);
-
-#endif /* _LTTNG_KCONSUMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KCONSUMER_H
+#define _LTTNG_KCONSUMER_H
+
+#include <stdbool.h>
+#include <common/consumer/consumer.hpp>
+
+int lttng_kconsumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_kconsumer_sample_snapshot_positions(
+ struct lttng_consumer_stream *stream);
+int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos);
+int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+ int sock, struct pollfd *consumer_sockpoll);
+int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
+int lttng_kconsumer_data_pending(struct lttng_consumer_stream *stream);
+enum sync_metadata_status lttng_kconsumer_sync_metadata(
+ struct lttng_consumer_stream *metadata);
+
+#endif /* _LTTNG_KCONSUMER_H */
#define __USE_LINUX_IOCTL_DEFS
#include <sys/ioctl.h>
#include <string.h>
-#include <common/align.h>
-#include <common/macros.h>
-#include <common/compat/errno.h>
+#include <common/align.hpp>
+#include <common/macros.hpp>
+#include <common/compat/errno.hpp>
#include <stdarg.h>
-#include <common/time.h>
+#include <common/time.hpp>
-#include "kernel-ctl.h"
-#include "kernel-ioctl.h"
+#include "kernel-ctl.hpp"
+#include "kernel-ioctl.hpp"
#define LTTNG_IOCTL_CHECK(fildes, request, ...) \
({ \
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_CTL_H
-#define _LTTNG_KERNEL_CTL_H
-
-#include <stdbool.h>
-
-#include <lttng/lttng.h>
-#include <common/lttng-kernel.h>
-#include <common/lttng-kernel-old.h>
-#include <common/sessiond-comm/sessiond-comm.h> /* for struct lttng_filter_bytecode */
-
-int kernctl_create_session(int fd);
-int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops);
-int kernctl_create_channel(int fd, struct lttng_channel_attr *chops);
-int kernctl_create_stream(int fd);
-int kernctl_create_event(int fd, struct lttng_kernel_abi_event *ev);
-int kernctl_add_context(int fd, struct lttng_kernel_abi_context *ctx);
-
-int kernctl_enable(int fd);
-int kernctl_disable(int fd);
-int kernctl_start_session(int fd);
-int kernctl_stop_session(int fd);
-
-int kernctl_create_event_notifier_group(int fd);
-
-/* Apply on event notifier_group file descriptor. */
-int kernctl_create_event_notifier_group_notification_fd(int fd);
-int kernctl_create_event_notifier_group_error_counter(int fd,
- const struct lttng_kernel_abi_counter_conf *error_counter_conf);
-int kernctl_create_event_notifier(int fd,
- const struct lttng_kernel_abi_event_notifier *event_notifier);
-
-int kernctl_counter_get_aggregate_value(int counter_fd,
- struct lttng_kernel_abi_counter_aggregate *value);
-int kernctl_counter_clear(int counter_fd,
- struct lttng_kernel_abi_counter_clear *clear);
-
-/* Apply on event file descriptor. */
-int kernctl_filter(int fd, const struct lttng_bytecode *filter);
-int kernctl_add_callsite(int fd, struct lttng_kernel_abi_event_callsite *callsite);
-int kernctl_capture(int fd, const struct lttng_bytecode *capture);
-
-int kernctl_tracepoint_list(int fd);
-int kernctl_syscall_list(int fd);
-int kernctl_tracer_version(int fd, struct lttng_kernel_abi_tracer_version *v);
-int kernctl_tracer_abi_version(int fd, struct lttng_kernel_abi_tracer_abi_version *v);
-int kernctl_wait_quiescent(int fd);
-
-/*
- * kernctl_syscall_mask - Get syscall mask associated to a channel file
- * descriptor.
- *
- * The parameter @syscall_mask should initially be either NULL or point
- * to memory allocated with malloc(3) or realloc(3). When the function
- * returns, it will point to a memory area of the size required for the
- * bitmask (using realloc(3) to resize the memory).
- *
- * It returns 0 if OK, -1 on error. In all cases (error and OK),
- * @syscall_mask should be freed by the caller with free(3).
- */
-int kernctl_syscall_mask(int fd, char **syscall_mask,
- uint32_t *nr_bits);
-
-/* Process ID tracking can be applied to session file descriptor. */
-int kernctl_track_pid(int fd, int pid);
-int kernctl_untrack_pid(int fd, int pid);
-int kernctl_list_tracker_pids(int fd);
-
-int kernctl_track_id(int fd, enum lttng_process_attr process_attr, int id);
-int kernctl_untrack_id(int fd, enum lttng_process_attr process_attr, int id);
-int kernctl_list_tracker_ids(int fd, enum lttng_process_attr process_attr);
-
-int kernctl_session_regenerate_metadata(int fd);
-int kernctl_session_regenerate_statedump(int fd);
-int kernctl_session_set_name(int fd, const char *name);
-int kernctl_session_set_creation_time(int fd, time_t time);
-
-/* Buffer operations */
-
-/* For mmap mode, readable without "get" operation */
-int kernctl_get_mmap_len(int fd, unsigned long *len);
-int kernctl_get_max_subbuf_size(int fd, unsigned long *len);
-
-/*
- * For mmap mode, operate on the current packet (between get/put or
- * get_next/put_next).
- */
-int kernctl_get_mmap_read_offset(int fd, unsigned long *len);
-int kernctl_get_subbuf_size(int fd, unsigned long *len);
-int kernctl_get_padded_subbuf_size(int fd, unsigned long *len);
-
-int kernctl_get_next_subbuf(int fd);
-int kernctl_put_next_subbuf(int fd);
-
-/* snapshot */
-int kernctl_snapshot(int fd);
-int kernctl_snapshot_sample_positions(int fd);
-int kernctl_snapshot_get_consumed(int fd, unsigned long *pos);
-int kernctl_snapshot_get_produced(int fd, unsigned long *pos);
-int kernctl_get_subbuf(int fd, unsigned long *pos);
-int kernctl_put_subbuf(int fd);
-
-int kernctl_buffer_flush(int fd);
-int kernctl_buffer_flush_empty(int fd);
-int kernctl_buffer_clear(int fd);
-int kernctl_get_metadata_version(int fd, uint64_t *version);
-int kernctl_metadata_cache_dump(int fd);
-int kernctl_get_next_subbuf_metadata_check(int fd, bool *consistent);
-
-/* index */
-int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin);
-int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end);
-int kernctl_get_events_discarded(int fd, uint64_t *events_discarded);
-int kernctl_get_content_size(int fd, uint64_t *content_size);
-int kernctl_get_packet_size(int fd, uint64_t *packet_size);
-int kernctl_get_stream_id(int fd, uint64_t *stream_id);
-int kernctl_get_current_timestamp(int fd, uint64_t *ts);
-int kernctl_get_sequence_number(int fd, uint64_t *seq);
-int kernctl_get_instance_id(int fd, uint64_t *seq);
-
-#endif /* _LTTNG_KERNEL_CTL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_CTL_H
+#define _LTTNG_KERNEL_CTL_H
+
+#include <stdbool.h>
+
+#include <lttng/lttng.h>
+#include <common/lttng-kernel.hpp>
+#include <common/lttng-kernel-old.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp> /* for struct lttng_filter_bytecode */
+
+int kernctl_create_session(int fd);
+int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops);
+int kernctl_create_channel(int fd, struct lttng_channel_attr *chops);
+int kernctl_create_stream(int fd);
+int kernctl_create_event(int fd, struct lttng_kernel_abi_event *ev);
+int kernctl_add_context(int fd, struct lttng_kernel_abi_context *ctx);
+
+int kernctl_enable(int fd);
+int kernctl_disable(int fd);
+int kernctl_start_session(int fd);
+int kernctl_stop_session(int fd);
+
+int kernctl_create_event_notifier_group(int fd);
+
+/* Apply on event notifier_group file descriptor. */
+int kernctl_create_event_notifier_group_notification_fd(int fd);
+int kernctl_create_event_notifier_group_error_counter(int fd,
+ const struct lttng_kernel_abi_counter_conf *error_counter_conf);
+int kernctl_create_event_notifier(int fd,
+ const struct lttng_kernel_abi_event_notifier *event_notifier);
+
+int kernctl_counter_get_aggregate_value(int counter_fd,
+ struct lttng_kernel_abi_counter_aggregate *value);
+int kernctl_counter_clear(int counter_fd,
+ struct lttng_kernel_abi_counter_clear *clear);
+
+/* Apply on event file descriptor. */
+int kernctl_filter(int fd, const struct lttng_bytecode *filter);
+int kernctl_add_callsite(int fd, struct lttng_kernel_abi_event_callsite *callsite);
+int kernctl_capture(int fd, const struct lttng_bytecode *capture);
+
+int kernctl_tracepoint_list(int fd);
+int kernctl_syscall_list(int fd);
+int kernctl_tracer_version(int fd, struct lttng_kernel_abi_tracer_version *v);
+int kernctl_tracer_abi_version(int fd, struct lttng_kernel_abi_tracer_abi_version *v);
+int kernctl_wait_quiescent(int fd);
+
+/*
+ * kernctl_syscall_mask - Get syscall mask associated to a channel file
+ * descriptor.
+ *
+ * The parameter @syscall_mask should initially be either NULL or point
+ * to memory allocated with malloc(3) or realloc(3). When the function
+ * returns, it will point to a memory area of the size required for the
+ * bitmask (using realloc(3) to resize the memory).
+ *
+ * It returns 0 if OK, -1 on error. In all cases (error and OK),
+ * @syscall_mask should be freed by the caller with free(3).
+ */
+int kernctl_syscall_mask(int fd, char **syscall_mask,
+ uint32_t *nr_bits);
+
+/* Process ID tracking can be applied to session file descriptor. */
+int kernctl_track_pid(int fd, int pid);
+int kernctl_untrack_pid(int fd, int pid);
+int kernctl_list_tracker_pids(int fd);
+
+int kernctl_track_id(int fd, enum lttng_process_attr process_attr, int id);
+int kernctl_untrack_id(int fd, enum lttng_process_attr process_attr, int id);
+int kernctl_list_tracker_ids(int fd, enum lttng_process_attr process_attr);
+
+int kernctl_session_regenerate_metadata(int fd);
+int kernctl_session_regenerate_statedump(int fd);
+int kernctl_session_set_name(int fd, const char *name);
+int kernctl_session_set_creation_time(int fd, time_t time);
+
+/* Buffer operations */
+
+/* For mmap mode, readable without "get" operation */
+int kernctl_get_mmap_len(int fd, unsigned long *len);
+int kernctl_get_max_subbuf_size(int fd, unsigned long *len);
+
+/*
+ * For mmap mode, operate on the current packet (between get/put or
+ * get_next/put_next).
+ */
+int kernctl_get_mmap_read_offset(int fd, unsigned long *len);
+int kernctl_get_subbuf_size(int fd, unsigned long *len);
+int kernctl_get_padded_subbuf_size(int fd, unsigned long *len);
+
+int kernctl_get_next_subbuf(int fd);
+int kernctl_put_next_subbuf(int fd);
+
+/* snapshot */
+int kernctl_snapshot(int fd);
+int kernctl_snapshot_sample_positions(int fd);
+int kernctl_snapshot_get_consumed(int fd, unsigned long *pos);
+int kernctl_snapshot_get_produced(int fd, unsigned long *pos);
+int kernctl_get_subbuf(int fd, unsigned long *pos);
+int kernctl_put_subbuf(int fd);
+
+int kernctl_buffer_flush(int fd);
+int kernctl_buffer_flush_empty(int fd);
+int kernctl_buffer_clear(int fd);
+int kernctl_get_metadata_version(int fd, uint64_t *version);
+int kernctl_metadata_cache_dump(int fd);
+int kernctl_get_next_subbuf_metadata_check(int fd, bool *consistent);
+
+/* index */
+int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin);
+int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end);
+int kernctl_get_events_discarded(int fd, uint64_t *events_discarded);
+int kernctl_get_content_size(int fd, uint64_t *content_size);
+int kernctl_get_packet_size(int fd, uint64_t *packet_size);
+int kernctl_get_stream_id(int fd, uint64_t *stream_id);
+int kernctl_get_current_timestamp(int fd, uint64_t *ts);
+int kernctl_get_sequence_number(int fd, uint64_t *seq);
+int kernctl_get_instance_id(int fd, uint64_t *seq);
+
+#endif /* _LTTNG_KERNEL_CTL_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_KERNEL_IOCTL_H
-#define _LTT_KERNEL_IOCTL_H
-
-#define LTTNG_KERNEL_ABI_MAJOR_VERSION 2
-#define LTTNG_KERNEL_ABI_MINOR_VERSION 6
-
-/* Get a snapshot of the current ring buffer producer and consumer positions */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00)
-/* Get the consumer position (iteration start) */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED _IOR(0xF6, 0x01, unsigned long)
-/* Get the producer position (iteration end) */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED _IOR(0xF6, 0x02, unsigned long)
-/* Get exclusive read access to the specified sub-buffer position */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF _IOW(0xF6, 0x03, unsigned long)
-/* Release exclusive sub-buffer access */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF _IO(0xF6, 0x04)
-
-/* Get exclusive read access to the next sub-buffer that can be read. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF _IO(0xF6, 0x05)
-/* Release exclusive sub-buffer access, move consumer forward. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF _IO(0xF6, 0x06)
-/* returns the size of the current sub-buffer, without padding (for mmap). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, unsigned long)
-/* returns the size of the current sub-buffer, with padding (for splice). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE _IOR(0xF6, 0x08, unsigned long)
-/* returns the maximum size for sub-buffers. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, unsigned long)
-/* returns the length to mmap. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
-/* returns the offset of the subbuffer belonging to the mmap reader. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
-/* Flush the current sub-buffer, if non-empty. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH _IO(0xF6, 0x0C)
-/* Get the current version of the metadata cache (after a get_next). */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION _IOR(0xF6, 0x0D, uint64_t)
-/*
- * Get a snapshot of the current ring buffer producer and consumer positions,
- * regardless of whether or not the two positions are contained within the same
- * sub-buffer.
- */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E)
-/* Flush the current sub-buffer, even if empty. */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY _IO(0xF6, 0x0F)
-/*
- * Reset the position of what has been consumed from the metadata cache to 0
- * so it can be read again.
- */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_METADATA_CACHE_DUMP _IO(0xF6, 0x10)
-/* Clear ring buffer content */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR _IO(0xF6, 0x11)
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK _IOR(0xF6, 0x12, uint32_t)
-
-/* returns the timestamp begin of the current sub-buffer */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t)
-/* returns the timestamp end of the current sub-buffer */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t)
-/* returns the number of events discarded */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t)
-/* returns the packet payload size */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t)
-/* returns the actual packet size */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t)
-/* returns the stream id */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t)
-/* returns the current timestamp */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t)
-/* returns the packet sequence number */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t)
-/* returns the stream instance id */
-#define LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t)
-
-/* Old ABI (without support for 32/64 bits compat) */
-/* LTTng file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_OLD_SESSION _IO(0xF6, 0x40)
-#define LTTNG_KERNEL_ABI_OLD_TRACER_VERSION \
- _IOR(0xF6, 0x41, struct lttng_kernel_abi_old_tracer_version)
-#define LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST _IO(0xF6, 0x42)
-#define LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT _IO(0xF6, 0x43)
-
-/* Session FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_METADATA \
- _IOW(0xF6, 0x50, struct lttng_kernel_abi_old_channel)
-#define LTTNG_KERNEL_ABI_OLD_CHANNEL \
- _IOW(0xF6, 0x51, struct lttng_kernel_abi_old_channel)
-#define LTTNG_KERNEL_ABI_OLD_SESSION_START _IO(0xF6, 0x52)
-#define LTTNG_KERNEL_ABI_OLD_SESSION_STOP _IO(0xF6, 0x53)
-
-/* Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_STREAM _IO(0xF6, 0x60)
-#define LTTNG_KERNEL_ABI_OLD_EVENT \
- _IOW(0xF6, 0x61, struct lttng_kernel_abi_old_event)
-
-/* Event and Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT \
- _IOW(0xF6, 0x70, struct lttng_kernel_abi_old_context)
-
-/* Event, Channel and Session ioctl */
-#define LTTNG_KERNEL_ABI_OLD_ENABLE _IO(0xF6, 0x80)
-#define LTTNG_KERNEL_ABI_OLD_DISABLE _IO(0xF6, 0x81)
-
-
-/* Current ABI (with suport for 32/64 bits compat) */
-/* LTTng file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_SESSION _IO(0xF6, 0x45)
-#define LTTNG_KERNEL_ABI_TRACER_VERSION \
- _IOR(0xF6, 0x46, struct lttng_kernel_abi_tracer_version)
-#define LTTNG_KERNEL_ABI_TRACEPOINT_LIST _IO(0xF6, 0x47)
-#define LTTNG_KERNEL_ABI_WAIT_QUIESCENT _IO(0xF6, 0x48)
-#define LTTNG_KERNEL_ABI_SYSCALL_LIST _IO(0xF6, 0x4A)
-#define LTTNG_KERNEL_ABI_TRACER_ABI_VERSION \
- _IOR(0xF6, 0x4B, struct lttng_kernel_abi_tracer_abi_version)
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE \
- _IO(0xF6, 0x4C)
-
-/* Session FD ioctl */
-#define LTTNG_KERNEL_ABI_METADATA \
- _IOW(0xF6, 0x54, struct lttng_kernel_abi_channel)
-#define LTTNG_KERNEL_ABI_CHANNEL \
- _IOW(0xF6, 0x55, struct lttng_kernel_abi_channel)
-#define LTTNG_KERNEL_ABI_SESSION_START _IO(0xF6, 0x56)
-#define LTTNG_KERNEL_ABI_SESSION_STOP _IO(0xF6, 0x57)
-#define LTTNG_KERNEL_ABI_SESSION_TRACK_PID \
- _IOW(0xF6, 0x58, int32_t)
-#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID \
- _IOW(0xF6, 0x59, int32_t)
-/*
- * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
- * are generating two different ioctl numbers, but this was not done on
- * purpose. We should generally try to avoid those duplications.
- */
-#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
-#define LTTNG_KERNEL_ABI_SESSION_METADATA_REGEN _IO(0xF6, 0x59)
-/* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */
-#define LTTNG_KERNEL_ABI_SESSION_STATEDUMP _IO(0xF6, 0x5C)
-#define LTTNG_KERNEL_ABI_SESSION_SET_NAME \
- _IOW(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
-#define LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME \
- _IOW(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
-
-/* Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_STREAM _IO(0xF6, 0x62)
-#define LTTNG_KERNEL_ABI_EVENT \
- _IOW(0xF6, 0x63, struct lttng_kernel_abi_event)
-#define LTTNG_KERNEL_ABI_SYSCALL_MASK \
- _IOWR(0xF6, 0x64, struct lttng_kernel_abi_syscall_mask)
-
-/* Event and Channel FD ioctl */
-#define LTTNG_KERNEL_ABI_CONTEXT \
- _IOW(0xF6, 0x71, struct lttng_kernel_abi_context)
-
-/* Event, event notifier, Channel and Session ioctl */
-#define LTTNG_KERNEL_ABI_ENABLE _IO(0xF6, 0x82)
-#define LTTNG_KERNEL_ABI_DISABLE _IO(0xF6, 0x83)
-
-/* Event notifier group ioctl */
-#define LTTNG_KERNEL_ABI_COUNTER \
- _IOW(0xF6, 0x84, struct lttng_kernel_abi_counter_conf)
-
-/* Event and event notifier FD ioctl */
-#define LTTNG_KERNEL_ABI_FILTER _IO(0xF6, 0x90)
-#define LTTNG_KERNEL_ABI_ADD_CALLSITE _IO(0xF6, 0x91)
-
-/* Session FD ioctl (continued) */
-#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS \
- _IOW(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
-#define LTTNG_KERNEL_ABI_SESSION_TRACK_ID \
- _IOW(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
-#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID \
- _IOW(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
-
-/* Event notifier group file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE \
- _IOW(0xF6, 0xB0, struct lttng_kernel_abi_event_notifier)
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD \
- _IO(0xF6, 0xB1)
-
-/* Event notifier file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_CAPTURE _IO(0xF6, 0xB8)
-
-/* Counter file descriptor ioctl */
-#define LTTNG_KERNEL_ABI_COUNTER_READ \
- IOWR(0xF6, 0xC0, struct lttng_kernel_abi_counter_read)
-#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE \
- _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_counter_aggregate)
-#define LTTNG_KERNEL_ABI_COUNTER_CLEAR \
- _IOW(0xF6, 0xC2, struct lttng_kernel_abi_counter_clear)
-
-/*
- * Those ioctl numbers use the wrong direction, but are kept for ABI backward
- * compatibility.
- */
- #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME \
- _IOR(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME \
- _IOR(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID \
- _IOW(0xF6, 0x58, int32_t)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID \
- _IOW(0xF6, 0x59, int32_t)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS \
- _IOR(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID \
- _IOR(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
- #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID \
- _IOR(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
-
-#endif /* _LTT_KERNEL_IOCTL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_KERNEL_IOCTL_H
+#define _LTT_KERNEL_IOCTL_H
+
+#define LTTNG_KERNEL_ABI_MAJOR_VERSION 2
+#define LTTNG_KERNEL_ABI_MINOR_VERSION 6
+
+/* Get a snapshot of the current ring buffer producer and consumer positions */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00)
+/* Get the consumer position (iteration start) */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED _IOR(0xF6, 0x01, unsigned long)
+/* Get the producer position (iteration end) */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED _IOR(0xF6, 0x02, unsigned long)
+/* Get exclusive read access to the specified sub-buffer position */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF _IOW(0xF6, 0x03, unsigned long)
+/* Release exclusive sub-buffer access */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF _IO(0xF6, 0x04)
+
+/* Get exclusive read access to the next sub-buffer that can be read. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF _IO(0xF6, 0x05)
+/* Release exclusive sub-buffer access, move consumer forward. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF _IO(0xF6, 0x06)
+/* returns the size of the current sub-buffer, without padding (for mmap). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, unsigned long)
+/* returns the size of the current sub-buffer, with padding (for splice). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE _IOR(0xF6, 0x08, unsigned long)
+/* returns the maximum size for sub-buffers. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, unsigned long)
+/* returns the length to mmap. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
+/* returns the offset of the subbuffer belonging to the mmap reader. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
+/* Flush the current sub-buffer, if non-empty. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH _IO(0xF6, 0x0C)
+/* Get the current version of the metadata cache (after a get_next). */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION _IOR(0xF6, 0x0D, uint64_t)
+/*
+ * Get a snapshot of the current ring buffer producer and consumer positions,
+ * regardless of whether or not the two positions are contained within the same
+ * sub-buffer.
+ */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E)
+/* Flush the current sub-buffer, even if empty. */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY _IO(0xF6, 0x0F)
+/*
+ * Reset the position of what has been consumed from the metadata cache to 0
+ * so it can be read again.
+ */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_METADATA_CACHE_DUMP _IO(0xF6, 0x10)
+/* Clear ring buffer content */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR _IO(0xF6, 0x11)
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK _IOR(0xF6, 0x12, uint32_t)
+
+/* returns the timestamp begin of the current sub-buffer */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t)
+/* returns the timestamp end of the current sub-buffer */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t)
+/* returns the number of events discarded */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t)
+/* returns the packet payload size */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t)
+/* returns the actual packet size */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t)
+/* returns the stream id */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t)
+/* returns the current timestamp */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t)
+/* returns the packet sequence number */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t)
+/* returns the stream instance id */
+#define LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t)
+
+/* Old ABI (without support for 32/64 bits compat) */
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_OLD_SESSION _IO(0xF6, 0x40)
+#define LTTNG_KERNEL_ABI_OLD_TRACER_VERSION \
+ _IOR(0xF6, 0x41, struct lttng_kernel_abi_old_tracer_version)
+#define LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST _IO(0xF6, 0x42)
+#define LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT _IO(0xF6, 0x43)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_METADATA \
+ _IOW(0xF6, 0x50, struct lttng_kernel_abi_old_channel)
+#define LTTNG_KERNEL_ABI_OLD_CHANNEL \
+ _IOW(0xF6, 0x51, struct lttng_kernel_abi_old_channel)
+#define LTTNG_KERNEL_ABI_OLD_SESSION_START _IO(0xF6, 0x52)
+#define LTTNG_KERNEL_ABI_OLD_SESSION_STOP _IO(0xF6, 0x53)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_STREAM _IO(0xF6, 0x60)
+#define LTTNG_KERNEL_ABI_OLD_EVENT \
+ _IOW(0xF6, 0x61, struct lttng_kernel_abi_old_event)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT \
+ _IOW(0xF6, 0x70, struct lttng_kernel_abi_old_context)
+
+/* Event, Channel and Session ioctl */
+#define LTTNG_KERNEL_ABI_OLD_ENABLE _IO(0xF6, 0x80)
+#define LTTNG_KERNEL_ABI_OLD_DISABLE _IO(0xF6, 0x81)
+
+
+/* Current ABI (with suport for 32/64 bits compat) */
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_SESSION _IO(0xF6, 0x45)
+#define LTTNG_KERNEL_ABI_TRACER_VERSION \
+ _IOR(0xF6, 0x46, struct lttng_kernel_abi_tracer_version)
+#define LTTNG_KERNEL_ABI_TRACEPOINT_LIST _IO(0xF6, 0x47)
+#define LTTNG_KERNEL_ABI_WAIT_QUIESCENT _IO(0xF6, 0x48)
+#define LTTNG_KERNEL_ABI_SYSCALL_LIST _IO(0xF6, 0x4A)
+#define LTTNG_KERNEL_ABI_TRACER_ABI_VERSION \
+ _IOR(0xF6, 0x4B, struct lttng_kernel_abi_tracer_abi_version)
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE \
+ _IO(0xF6, 0x4C)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_ABI_METADATA \
+ _IOW(0xF6, 0x54, struct lttng_kernel_abi_channel)
+#define LTTNG_KERNEL_ABI_CHANNEL \
+ _IOW(0xF6, 0x55, struct lttng_kernel_abi_channel)
+#define LTTNG_KERNEL_ABI_SESSION_START _IO(0xF6, 0x56)
+#define LTTNG_KERNEL_ABI_SESSION_STOP _IO(0xF6, 0x57)
+#define LTTNG_KERNEL_ABI_SESSION_TRACK_PID \
+ _IOW(0xF6, 0x58, int32_t)
+#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID \
+ _IOW(0xF6, 0x59, int32_t)
+/*
+ * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
+ * are generating two different ioctl numbers, but this was not done on
+ * purpose. We should generally try to avoid those duplications.
+ */
+#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
+#define LTTNG_KERNEL_ABI_SESSION_METADATA_REGEN _IO(0xF6, 0x59)
+/* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */
+#define LTTNG_KERNEL_ABI_SESSION_STATEDUMP _IO(0xF6, 0x5C)
+#define LTTNG_KERNEL_ABI_SESSION_SET_NAME \
+ _IOW(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
+#define LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME \
+ _IOW(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_STREAM _IO(0xF6, 0x62)
+#define LTTNG_KERNEL_ABI_EVENT \
+ _IOW(0xF6, 0x63, struct lttng_kernel_abi_event)
+#define LTTNG_KERNEL_ABI_SYSCALL_MASK \
+ _IOWR(0xF6, 0x64, struct lttng_kernel_abi_syscall_mask)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_ABI_CONTEXT \
+ _IOW(0xF6, 0x71, struct lttng_kernel_abi_context)
+
+/* Event, event notifier, Channel and Session ioctl */
+#define LTTNG_KERNEL_ABI_ENABLE _IO(0xF6, 0x82)
+#define LTTNG_KERNEL_ABI_DISABLE _IO(0xF6, 0x83)
+
+/* Event notifier group ioctl */
+#define LTTNG_KERNEL_ABI_COUNTER \
+ _IOW(0xF6, 0x84, struct lttng_kernel_abi_counter_conf)
+
+/* Event and event notifier FD ioctl */
+#define LTTNG_KERNEL_ABI_FILTER _IO(0xF6, 0x90)
+#define LTTNG_KERNEL_ABI_ADD_CALLSITE _IO(0xF6, 0x91)
+
+/* Session FD ioctl (continued) */
+#define LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS \
+ _IOW(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
+#define LTTNG_KERNEL_ABI_SESSION_TRACK_ID \
+ _IOW(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
+#define LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID \
+ _IOW(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
+
+/* Event notifier group file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE \
+ _IOW(0xF6, 0xB0, struct lttng_kernel_abi_event_notifier)
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD \
+ _IO(0xF6, 0xB1)
+
+/* Event notifier file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_CAPTURE _IO(0xF6, 0xB8)
+
+/* Counter file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_COUNTER_READ \
+ IOWR(0xF6, 0xC0, struct lttng_kernel_abi_counter_read)
+#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE \
+ _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_counter_aggregate)
+#define LTTNG_KERNEL_ABI_COUNTER_CLEAR \
+ _IOW(0xF6, 0xC2, struct lttng_kernel_abi_counter_clear)
+
+/*
+ * Those ioctl numbers use the wrong direction, but are kept for ABI backward
+ * compatibility.
+ */
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME \
+ _IOR(0xF6, 0x5D, struct lttng_kernel_abi_session_name)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME \
+ _IOR(0xF6, 0x5E, struct lttng_kernel_abi_session_creation_time)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID \
+ _IOW(0xF6, 0x58, int32_t)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID \
+ _IOW(0xF6, 0x59, int32_t)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS \
+ _IOR(0xF6, 0xA0, struct lttng_kernel_abi_tracker_args)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID \
+ _IOR(0xF6, 0xA1, struct lttng_kernel_abi_tracker_args)
+ #define LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID \
+ _IOR(0xF6, 0xA2, struct lttng_kernel_abi_tracker_args)
+
+#endif /* _LTT_KERNEL_IOCTL_H */
*/
#include "lttng/lttng-error.h"
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <fcntl.h>
#include <lttng/constant.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
#include <sys/stat.h>
#include <sys/types.h>
*
*/
-#include <lttng/location-internal.h>
-#include <common/macros.h>
+#include <lttng/location-internal.hpp>
+#include <common/macros.hpp>
#include <stdlib.h>
-#include <common/error.h>
+#include <common/error.hpp>
static
struct lttng_trace_archive_location *lttng_trace_archive_location_create(
*
*/
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <lttng/log-level-rule-internal.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <lttng/log-level-rule-internal.hpp>
#include <lttng/log-level-rule.h>
#include <stdbool.h>
#include <stdlib.h>
*/
#include <algorithm>
-#include <common/compat/endian.h>
-#include <common/error.h>
-#include <common/lttng-elf.h>
-#include <common/macros.h>
-#include <common/readwrite.h>
+#include <common/compat/endian.hpp>
+#include <common/error.hpp>
+#include <common/lttng-elf.hpp>
+#include <common/macros.hpp>
+#include <common/readwrite.hpp>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
+++ /dev/null
-#ifndef _LTTNG_ELF_H
-#define _LTTNG_ELF_H
-/*
- * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
- * Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-#include <lttng/lttng-export.h>
-
-extern "C" LTTNG_EXPORT
-int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset);
-
-extern "C" LTTNG_EXPORT
-int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
- const char *probe_name, uint64_t **offsets, uint32_t *nb_probe);
-
-#endif /* _LTTNG_ELF_H */
--- /dev/null
+#ifndef _LTTNG_ELF_H
+#define _LTTNG_ELF_H
+/*
+ * Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
+ * Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+#include <lttng/lttng-export.h>
+
+extern "C" LTTNG_EXPORT
+int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset);
+
+extern "C" LTTNG_EXPORT
+int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
+ const char *probe_name, uint64_t **offsets, uint32_t *nb_probe);
+
+#endif /* _LTTNG_ELF_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_OLD_H
-#define _LTTNG_KERNEL_OLD_H
-
-#include <stdint.h>
-#include <common/lttng-kernel.h>
-
-/*
- * LTTng DebugFS ABI structures.
- *
- * This is the kernel ABI copied from lttng-modules tree.
- */
-
-/* Perf counter attributes */
-struct lttng_kernel_abi_old_perf_counter_ctx {
- uint32_t type;
- uint64_t config;
- char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/* Event/Channel context */
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1 16
-#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_old_context {
- enum lttng_kernel_abi_context_type ctx;
- char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1];
-
- union {
- struct lttng_kernel_abi_old_perf_counter_ctx perf_counter;
- char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2];
- } u;
-};
-
-struct lttng_kernel_abi_old_kretprobe {
- uint64_t addr;
-
- uint64_t offset;
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/*
- * Either addr is used, or symbol_name and offset.
- */
-struct lttng_kernel_abi_old_kprobe {
- uint64_t addr;
-
- uint64_t offset;
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-/* Function tracer */
-struct lttng_kernel_abi_old_function {
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-};
-
-#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1 16
-#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_old_event {
- char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
- enum lttng_kernel_abi_instrumentation instrumentation;
- char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1];
-
- /* Per instrumentation type configuration */
- union {
- struct lttng_kernel_abi_old_kretprobe kretprobe;
- struct lttng_kernel_abi_old_kprobe kprobe;
- struct lttng_kernel_abi_old_function ftrace;
- char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2];
- } u;
-};
-
-struct lttng_kernel_abi_old_tracer_version {
- uint32_t major;
- uint32_t minor;
- uint32_t patchlevel;
-};
-
-/*
- * kernel channel
- */
-#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
-struct lttng_kernel_abi_old_channel {
- int overwrite; /* 1: overwrite, 0: discard */
- uint64_t subbuf_size; /* bytes */
- uint64_t num_subbuf; /* power of 2 */
- unsigned int switch_timer_interval; /* usec */
- unsigned int read_timer_interval; /* usec */
- enum lttng_event_output output; /* splice, mmap */
-
- char padding[LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1];
-};
-
-#endif /* _LTTNG_KERNEL_OLD_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_OLD_H
+#define _LTTNG_KERNEL_OLD_H
+
+#include <stdint.h>
+#include <common/lttng-kernel.hpp>
+
+/*
+ * LTTng DebugFS ABI structures.
+ *
+ * This is the kernel ABI copied from lttng-modules tree.
+ */
+
+/* Perf counter attributes */
+struct lttng_kernel_abi_old_perf_counter_ctx {
+ uint32_t type;
+ uint64_t config;
+ char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/* Event/Channel context */
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1 16
+#define LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_old_context {
+ enum lttng_kernel_abi_context_type ctx;
+ char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING1];
+
+ union {
+ struct lttng_kernel_abi_old_perf_counter_ctx perf_counter;
+ char padding[LTTNG_KERNEL_ABI_OLD_CONTEXT_PADDING2];
+ } u;
+};
+
+struct lttng_kernel_abi_old_kretprobe {
+ uint64_t addr;
+
+ uint64_t offset;
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_abi_old_kprobe {
+ uint64_t addr;
+
+ uint64_t offset;
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+/* Function tracer */
+struct lttng_kernel_abi_old_function {
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+};
+
+#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1 16
+#define LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_old_event {
+ char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+ enum lttng_kernel_abi_instrumentation instrumentation;
+ char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING1];
+
+ /* Per instrumentation type configuration */
+ union {
+ struct lttng_kernel_abi_old_kretprobe kretprobe;
+ struct lttng_kernel_abi_old_kprobe kprobe;
+ struct lttng_kernel_abi_old_function ftrace;
+ char padding[LTTNG_KERNEL_ABI_OLD_EVENT_PADDING2];
+ } u;
+};
+
+struct lttng_kernel_abi_old_tracer_version {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patchlevel;
+};
+
+/*
+ * kernel channel
+ */
+#define LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
+struct lttng_kernel_abi_old_channel {
+ int overwrite; /* 1: overwrite, 0: discard */
+ uint64_t subbuf_size; /* bytes */
+ uint64_t num_subbuf; /* power of 2 */
+ unsigned int switch_timer_interval; /* usec */
+ unsigned int read_timer_interval; /* usec */
+ enum lttng_event_output output; /* splice, mmap */
+
+ char padding[LTTNG_KERNEL_ABI_OLD_CHANNEL_PADDING1];
+};
+
+#endif /* _LTTNG_KERNEL_OLD_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2011 EfficiOS Inc.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_KERNEL_H
-#define _LTTNG_KERNEL_H
-
-#include <stdint.h>
-#include <common/macros.h>
-#include <lttng/constant.h>
-#include <lttng/event.h>
-
-#define LTTNG_KERNEL_ABI_SYM_NAME_LEN 256
-#define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM 32
-#define LTTNG_KERNEL_ABI_SESSION_NAME_LEN 256
-#define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN 26
-
-/*
- * LTTng DebugFS ABI structures.
- *
- * This is the kernel ABI copied from lttng-modules tree.
- */
-
-enum lttng_kernel_abi_instrumentation {
- LTTNG_KERNEL_ABI_ALL = -1, /* Used within lttng-tools */
- LTTNG_KERNEL_ABI_TRACEPOINT = 0,
- LTTNG_KERNEL_ABI_KPROBE = 1,
- LTTNG_KERNEL_ABI_FUNCTION = 2,
- LTTNG_KERNEL_ABI_KRETPROBE = 3,
- LTTNG_KERNEL_ABI_NOOP = 4, /* not hooked */
- LTTNG_KERNEL_ABI_SYSCALL = 5,
- LTTNG_KERNEL_ABI_UPROBE = 6,
-};
-
-enum lttng_kernel_abi_context_type {
- LTTNG_KERNEL_ABI_CONTEXT_PID = 0,
- LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1,
- LTTNG_KERNEL_ABI_CONTEXT_PROCNAME = 2,
- LTTNG_KERNEL_ABI_CONTEXT_PRIO = 3,
- LTTNG_KERNEL_ABI_CONTEXT_NICE = 4,
- LTTNG_KERNEL_ABI_CONTEXT_VPID = 5,
- LTTNG_KERNEL_ABI_CONTEXT_TID = 6,
- LTTNG_KERNEL_ABI_CONTEXT_VTID = 7,
- LTTNG_KERNEL_ABI_CONTEXT_PPID = 8,
- LTTNG_KERNEL_ABI_CONTEXT_VPPID = 9,
- LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME = 10,
- LTTNG_KERNEL_ABI_CONTEXT_CPU_ID = 11,
- LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE = 12,
- LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE = 13,
- LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14,
- LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE = 15,
- LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16,
- LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER = 17,
- LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS = 18,
- LTTNG_KERNEL_ABI_CONTEXT_IPC_NS = 19,
- LTTNG_KERNEL_ABI_CONTEXT_MNT_NS = 20,
- LTTNG_KERNEL_ABI_CONTEXT_NET_NS = 21,
- LTTNG_KERNEL_ABI_CONTEXT_PID_NS = 22,
- LTTNG_KERNEL_ABI_CONTEXT_USER_NS = 23,
- LTTNG_KERNEL_ABI_CONTEXT_UTS_NS = 24,
- LTTNG_KERNEL_ABI_CONTEXT_UID = 25,
- LTTNG_KERNEL_ABI_CONTEXT_EUID = 26,
- LTTNG_KERNEL_ABI_CONTEXT_SUID = 27,
- LTTNG_KERNEL_ABI_CONTEXT_GID = 28,
- LTTNG_KERNEL_ABI_CONTEXT_EGID = 29,
- LTTNG_KERNEL_ABI_CONTEXT_SGID = 30,
- LTTNG_KERNEL_ABI_CONTEXT_VUID = 31,
- LTTNG_KERNEL_ABI_CONTEXT_VEUID = 32,
- LTTNG_KERNEL_ABI_CONTEXT_VSUID = 33,
- LTTNG_KERNEL_ABI_CONTEXT_VGID = 34,
- LTTNG_KERNEL_ABI_CONTEXT_VEGID = 35,
- LTTNG_KERNEL_ABI_CONTEXT_VSGID = 36,
- LTTNG_KERNEL_ABI_CONTEXT_TIME_NS = 37,
-};
-
-/* Perf counter attributes */
-struct lttng_kernel_abi_perf_counter_ctx {
- uint32_t type;
- uint64_t config;
- char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-/* Event/Channel context */
-#define LTTNG_KERNEL_ABI_CONTEXT_PADDING1 16
-#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_context {
- enum lttng_kernel_abi_context_type ctx;
- char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1];
-
- union {
- struct lttng_kernel_abi_perf_counter_ctx perf_counter;
- char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_kretprobe {
- uint64_t addr;
-
- uint64_t offset;
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * Either addr is used, or symbol_name and offset.
- */
-struct lttng_kernel_abi_kprobe {
- uint64_t addr;
-
- uint64_t offset;
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_uprobe {
- int fd;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_event_callsite_uprobe {
- uint64_t offset;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_event_callsite {
- union {
- struct lttng_kernel_abi_event_callsite_uprobe uprobe;
- } u;
-} LTTNG_PACKED;
-
-enum lttng_kernel_abi_syscall_entryexit {
- LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT = 0,
- LTTNG_KERNEL_ABI_SYSCALL_ENTRY = 1,
- LTTNG_KERNEL_ABI_SYSCALL_EXIT = 2,
-};
-
-enum lttng_kernel_abi_syscall_abi {
- LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL = 0,
- LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1,
- LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2,
-};
-
-enum lttng_kernel_abi_syscall_match {
- LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
- LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR = 1,
-};
-
-struct lttng_kernel_abi_syscall {
- uint8_t entryexit; /* enum lttng_kernel_abi_syscall_entryexit */
- uint8_t abi; /* enum lttng_kernel_abi_syscall_abi */
- uint8_t match; /* enum lttng_kernel_abi_syscall_match */
- uint8_t padding;
- uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */
-} LTTNG_PACKED;
-
-/* Function tracer */
-struct lttng_kernel_abi_function {
- char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_PADDING1 8
-#define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
-struct lttng_kernel_abi_event {
- char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
- enum lttng_kernel_abi_instrumentation instrumentation;
- uint64_t token;
- char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
-
- /* Per instrumentation type configuration */
- union {
- struct lttng_kernel_abi_kretprobe kretprobe;
- struct lttng_kernel_abi_kprobe kprobe;
- struct lttng_kernel_abi_function ftrace;
- struct lttng_kernel_abi_uprobe uprobe;
- struct lttng_kernel_abi_syscall syscall;
- char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2];
- } u;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING 32
-struct lttng_kernel_abi_event_notifier {
- struct lttng_kernel_abi_event event;
- uint64_t error_counter_idx;
-
- char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4
-
-enum lttng_kernel_abi_counter_arithmetic {
- LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
-};
-
-enum lttng_kernel_abi_counter_bitness {
- LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
- LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
-};
-
-struct lttng_kernel_abi_counter_dimension {
- uint64_t size;
- uint64_t underflow_index;
- uint64_t overflow_index;
- uint8_t has_underflow;
- uint8_t has_overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1 67
-struct lttng_kernel_abi_counter_conf {
- uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
- uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
- uint32_t number_dimensions;
- int64_t global_sum_step;
- struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
- uint8_t coalesce_hits;
- char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_counter_index {
- uint32_t number_dimensions;
- uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_counter_value {
- int64_t value;
- uint8_t underflow;
- uint8_t overflow;
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
-struct lttng_kernel_abi_counter_read {
- struct lttng_kernel_abi_counter_index index;
- int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */
- struct lttng_kernel_abi_counter_value value; /* output */
- char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
-struct lttng_kernel_abi_counter_aggregate {
- struct lttng_kernel_abi_counter_index index;
- struct lttng_kernel_abi_counter_value value; /* output */
- char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
-struct lttng_kernel_abi_counter_clear {
- struct lttng_kernel_abi_counter_index index;
- char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
-struct lttng_kernel_abi_event_notifier_notification {
- uint64_t token;
- uint16_t capture_buf_size;
- char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
-} LTTNG_PACKED;
-
-#define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
-struct lttng_kernel_abi_capture_bytecode {
- uint32_t len;
- uint32_t reloc_offset;
- uint64_t seqnum;
- char data[0];
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_tracer_version {
- uint32_t major;
- uint32_t minor;
- uint32_t patchlevel;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_tracer_abi_version {
- uint32_t major;
- uint32_t minor;
-} LTTNG_PACKED;
-
-struct lttng_kernel_abi_syscall_mask {
- uint32_t len; /* in bits */
- char mask[];
-} LTTNG_PACKED;
-
-/*
- * kernel channel
- */
-#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
-struct lttng_kernel_abi_channel {
- uint64_t subbuf_size; /* bytes */
- uint64_t num_subbuf; /* power of 2 */
- unsigned int switch_timer_interval; /* usec */
- unsigned int read_timer_interval; /* usec */
- enum lttng_event_output output; /* splice, mmap */
-
- int overwrite; /* 1: overwrite, 0: discard */
- char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
-} LTTNG_PACKED;
-
-#define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
-struct lttng_kernel_abi_filter_bytecode {
- uint32_t len;
- uint32_t reloc_offset;
- uint64_t seqnum;
- char data[0];
-} LTTNG_PACKED;
-
-/*
- * kernel session name
- */
-struct lttng_kernel_abi_session_name {
- char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * kernel session creation datetime
- */
-struct lttng_kernel_abi_session_creation_time {
- char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
-} LTTNG_PACKED;
-
-enum lttng_kernel_abi_tracker_type {
- LTTNG_KERNEL_ABI_TRACKER_UNKNOWN = -1,
-
- LTTNG_KERNEL_ABI_TRACKER_PID = 0,
- LTTNG_KERNEL_ABI_TRACKER_VPID = 1,
- LTTNG_KERNEL_ABI_TRACKER_UID = 2,
- LTTNG_KERNEL_ABI_TRACKER_VUID = 3,
- LTTNG_KERNEL_ABI_TRACKER_GID = 4,
- LTTNG_KERNEL_ABI_TRACKER_VGID = 5,
-};
-
-struct lttng_kernel_abi_tracker_args {
- enum lttng_kernel_abi_tracker_type type;
- int32_t id;
-};
-
-#endif /* _LTTNG_KERNEL_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2011 EfficiOS Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_KERNEL_H
+#define _LTTNG_KERNEL_H
+
+#include <stdint.h>
+#include <common/macros.hpp>
+#include <lttng/constant.h>
+#include <lttng/event.h>
+
+#define LTTNG_KERNEL_ABI_SYM_NAME_LEN 256
+#define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM 32
+#define LTTNG_KERNEL_ABI_SESSION_NAME_LEN 256
+#define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN 26
+
+/*
+ * LTTng DebugFS ABI structures.
+ *
+ * This is the kernel ABI copied from lttng-modules tree.
+ */
+
+enum lttng_kernel_abi_instrumentation {
+ LTTNG_KERNEL_ABI_ALL = -1, /* Used within lttng-tools */
+ LTTNG_KERNEL_ABI_TRACEPOINT = 0,
+ LTTNG_KERNEL_ABI_KPROBE = 1,
+ LTTNG_KERNEL_ABI_FUNCTION = 2,
+ LTTNG_KERNEL_ABI_KRETPROBE = 3,
+ LTTNG_KERNEL_ABI_NOOP = 4, /* not hooked */
+ LTTNG_KERNEL_ABI_SYSCALL = 5,
+ LTTNG_KERNEL_ABI_UPROBE = 6,
+};
+
+enum lttng_kernel_abi_context_type {
+ LTTNG_KERNEL_ABI_CONTEXT_PID = 0,
+ LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1,
+ LTTNG_KERNEL_ABI_CONTEXT_PROCNAME = 2,
+ LTTNG_KERNEL_ABI_CONTEXT_PRIO = 3,
+ LTTNG_KERNEL_ABI_CONTEXT_NICE = 4,
+ LTTNG_KERNEL_ABI_CONTEXT_VPID = 5,
+ LTTNG_KERNEL_ABI_CONTEXT_TID = 6,
+ LTTNG_KERNEL_ABI_CONTEXT_VTID = 7,
+ LTTNG_KERNEL_ABI_CONTEXT_PPID = 8,
+ LTTNG_KERNEL_ABI_CONTEXT_VPPID = 9,
+ LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME = 10,
+ LTTNG_KERNEL_ABI_CONTEXT_CPU_ID = 11,
+ LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE = 12,
+ LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE = 13,
+ LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14,
+ LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE = 15,
+ LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16,
+ LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER = 17,
+ LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS = 18,
+ LTTNG_KERNEL_ABI_CONTEXT_IPC_NS = 19,
+ LTTNG_KERNEL_ABI_CONTEXT_MNT_NS = 20,
+ LTTNG_KERNEL_ABI_CONTEXT_NET_NS = 21,
+ LTTNG_KERNEL_ABI_CONTEXT_PID_NS = 22,
+ LTTNG_KERNEL_ABI_CONTEXT_USER_NS = 23,
+ LTTNG_KERNEL_ABI_CONTEXT_UTS_NS = 24,
+ LTTNG_KERNEL_ABI_CONTEXT_UID = 25,
+ LTTNG_KERNEL_ABI_CONTEXT_EUID = 26,
+ LTTNG_KERNEL_ABI_CONTEXT_SUID = 27,
+ LTTNG_KERNEL_ABI_CONTEXT_GID = 28,
+ LTTNG_KERNEL_ABI_CONTEXT_EGID = 29,
+ LTTNG_KERNEL_ABI_CONTEXT_SGID = 30,
+ LTTNG_KERNEL_ABI_CONTEXT_VUID = 31,
+ LTTNG_KERNEL_ABI_CONTEXT_VEUID = 32,
+ LTTNG_KERNEL_ABI_CONTEXT_VSUID = 33,
+ LTTNG_KERNEL_ABI_CONTEXT_VGID = 34,
+ LTTNG_KERNEL_ABI_CONTEXT_VEGID = 35,
+ LTTNG_KERNEL_ABI_CONTEXT_VSGID = 36,
+ LTTNG_KERNEL_ABI_CONTEXT_TIME_NS = 37,
+};
+
+/* Perf counter attributes */
+struct lttng_kernel_abi_perf_counter_ctx {
+ uint32_t type;
+ uint64_t config;
+ char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+/* Event/Channel context */
+#define LTTNG_KERNEL_ABI_CONTEXT_PADDING1 16
+#define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_context {
+ enum lttng_kernel_abi_context_type ctx;
+ char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1];
+
+ union {
+ struct lttng_kernel_abi_perf_counter_ctx perf_counter;
+ char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_kretprobe {
+ uint64_t addr;
+
+ uint64_t offset;
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_abi_kprobe {
+ uint64_t addr;
+
+ uint64_t offset;
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_uprobe {
+ int fd;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_event_callsite_uprobe {
+ uint64_t offset;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_event_callsite {
+ union {
+ struct lttng_kernel_abi_event_callsite_uprobe uprobe;
+ } u;
+} LTTNG_PACKED;
+
+enum lttng_kernel_abi_syscall_entryexit {
+ LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT = 0,
+ LTTNG_KERNEL_ABI_SYSCALL_ENTRY = 1,
+ LTTNG_KERNEL_ABI_SYSCALL_EXIT = 2,
+};
+
+enum lttng_kernel_abi_syscall_abi {
+ LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL = 0,
+ LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1,
+ LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2,
+};
+
+enum lttng_kernel_abi_syscall_match {
+ LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
+ LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR = 1,
+};
+
+struct lttng_kernel_abi_syscall {
+ uint8_t entryexit; /* enum lttng_kernel_abi_syscall_entryexit */
+ uint8_t abi; /* enum lttng_kernel_abi_syscall_abi */
+ uint8_t match; /* enum lttng_kernel_abi_syscall_match */
+ uint8_t padding;
+ uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */
+} LTTNG_PACKED;
+
+/* Function tracer */
+struct lttng_kernel_abi_function {
+ char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_PADDING1 8
+#define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
+struct lttng_kernel_abi_event {
+ char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+ enum lttng_kernel_abi_instrumentation instrumentation;
+ uint64_t token;
+ char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
+
+ /* Per instrumentation type configuration */
+ union {
+ struct lttng_kernel_abi_kretprobe kretprobe;
+ struct lttng_kernel_abi_kprobe kprobe;
+ struct lttng_kernel_abi_function ftrace;
+ struct lttng_kernel_abi_uprobe uprobe;
+ struct lttng_kernel_abi_syscall syscall;
+ char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2];
+ } u;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING 32
+struct lttng_kernel_abi_event_notifier {
+ struct lttng_kernel_abi_event event;
+ uint64_t error_counter_idx;
+
+ char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4
+
+enum lttng_kernel_abi_counter_arithmetic {
+ LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
+};
+
+enum lttng_kernel_abi_counter_bitness {
+ LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
+ LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
+};
+
+struct lttng_kernel_abi_counter_dimension {
+ uint64_t size;
+ uint64_t underflow_index;
+ uint64_t overflow_index;
+ uint8_t has_underflow;
+ uint8_t has_overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1 67
+struct lttng_kernel_abi_counter_conf {
+ uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
+ uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
+ uint32_t number_dimensions;
+ int64_t global_sum_step;
+ struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
+ uint8_t coalesce_hits;
+ char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_counter_index {
+ uint32_t number_dimensions;
+ uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_counter_value {
+ int64_t value;
+ uint8_t underflow;
+ uint8_t overflow;
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
+struct lttng_kernel_abi_counter_read {
+ struct lttng_kernel_abi_counter_index index;
+ int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */
+ struct lttng_kernel_abi_counter_value value; /* output */
+ char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
+struct lttng_kernel_abi_counter_aggregate {
+ struct lttng_kernel_abi_counter_index index;
+ struct lttng_kernel_abi_counter_value value; /* output */
+ char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
+struct lttng_kernel_abi_counter_clear {
+ struct lttng_kernel_abi_counter_index index;
+ char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
+struct lttng_kernel_abi_event_notifier_notification {
+ uint64_t token;
+ uint16_t capture_buf_size;
+ char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
+} LTTNG_PACKED;
+
+#define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
+struct lttng_kernel_abi_capture_bytecode {
+ uint32_t len;
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ char data[0];
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_tracer_version {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patchlevel;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_tracer_abi_version {
+ uint32_t major;
+ uint32_t minor;
+} LTTNG_PACKED;
+
+struct lttng_kernel_abi_syscall_mask {
+ uint32_t len; /* in bits */
+ char mask[];
+} LTTNG_PACKED;
+
+/*
+ * kernel channel
+ */
+#define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
+struct lttng_kernel_abi_channel {
+ uint64_t subbuf_size; /* bytes */
+ uint64_t num_subbuf; /* power of 2 */
+ unsigned int switch_timer_interval; /* usec */
+ unsigned int read_timer_interval; /* usec */
+ enum lttng_event_output output; /* splice, mmap */
+
+ int overwrite; /* 1: overwrite, 0: discard */
+ char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
+} LTTNG_PACKED;
+
+#define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
+struct lttng_kernel_abi_filter_bytecode {
+ uint32_t len;
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ char data[0];
+} LTTNG_PACKED;
+
+/*
+ * kernel session name
+ */
+struct lttng_kernel_abi_session_name {
+ char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * kernel session creation datetime
+ */
+struct lttng_kernel_abi_session_creation_time {
+ char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
+} LTTNG_PACKED;
+
+enum lttng_kernel_abi_tracker_type {
+ LTTNG_KERNEL_ABI_TRACKER_UNKNOWN = -1,
+
+ LTTNG_KERNEL_ABI_TRACKER_PID = 0,
+ LTTNG_KERNEL_ABI_TRACKER_VPID = 1,
+ LTTNG_KERNEL_ABI_TRACKER_UID = 2,
+ LTTNG_KERNEL_ABI_TRACKER_VUID = 3,
+ LTTNG_KERNEL_ABI_TRACKER_GID = 4,
+ LTTNG_KERNEL_ABI_TRACKER_VGID = 5,
+};
+
+struct lttng_kernel_abi_tracker_args {
+ enum lttng_kernel_abi_tracker_type type;
+ int32_t id;
+};
+
+#endif /* _LTTNG_KERNEL_H */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _MACROS_H
-#define _MACROS_H
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <common/compat/string.h>
-
-/*
- * Takes a pointer x and transform it so we can use it to access members
- * without a function call. Here an example:
- *
- * #define GET_SIZE(x) LTTNG_REF(x)->size
- *
- * struct { int size; } s;
- *
- * printf("size : %d\n", GET_SIZE(&s));
- *
- * For this example we can't use something like this for compatibility purpose
- * since this will fail:
- *
- * #define GET_SIZE(x) x->size;
- *
- * This is mostly use for the compatibility layer of lttng-tools. See
- * poll/epoll for a good example. Since x can be on the stack or allocated
- * memory using malloc(), we must use generic accessors for compat in order to
- * *not* use a function to access members and not the variable name.
- */
-#define LTTNG_REF(x) ((typeof(*x) *)(x))
-
-/*
- * Memory allocation zeroed
- */
-static inline
-void *zmalloc(size_t len)
-{
- return calloc(1, len);
-}
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(array) (sizeof(array) / (sizeof((array)[0])))
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) \
- ({ \
- const typeof(((type *)NULL)->member) * __ptr = (ptr); \
- (type *)((char *)__ptr - offsetof(type, member)); \
- })
-#endif
-
-#ifndef LTTNG_PACKED
-#define LTTNG_PACKED __attribute__((__packed__))
-#endif
-
-#ifndef LTTNG_NO_SANITIZE_ADDRESS
-#if defined(__clang__) || defined (__GNUC__)
-#define LTTNG_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
-#else
-#define LTTNG_NO_SANITIZE_ADDRESS
-#endif
-#endif
-
-#define member_sizeof(type, field) sizeof(((type *) 0)->field)
-
-#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&lock))
-#define ASSERT_RCU_READ_LOCKED(lock) LTTNG_ASSERT(rcu_read_ongoing())
-
-/* Attribute suitable to tag functions as having printf()-like arguments. */
-#define ATTR_FORMAT_PRINTF(_string_index, _first_to_check) \
- __attribute__((format(printf, _string_index, _first_to_check)))
-
-/* Attribute suitable to tag functions as having strftime()-like arguments. */
-#define ATTR_FORMAT_STRFTIME(_string_index) \
- __attribute__((format(strftime, _string_index, 0)))
-
-/* Macros used to ignore specific compiler diagnostics. */
-
-#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
-#define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
-
-#if defined(__clang__)
- /* Clang */
-# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
-# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
- _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
-# define DIAGNOSTIC_IGNORE_LOGICAL_OP
-#else
- /* GCC */
-# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \
- _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=format\"")
-# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
- _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
-# define DIAGNOSTIC_IGNORE_LOGICAL_OP \
- _Pragma("GCC diagnostic ignored \"-Wlogical-op\"")
-#endif
-
-/* Used to make specific C++ functions to C code. */
-#ifdef __cplusplus
-#define C_LINKAGE extern "C"
-#else
-#define C_LINKAGE
-#endif
-
-/*
- * lttng_strncpy returns 0 on success, or nonzero on failure.
- * It checks that the @src string fits into @dst_len before performing
- * the copy. On failure, no copy has been performed.
- *
- * Assumes that 'src' is null-terminated.
- *
- * dst_len includes the string's trailing NULL.
- */
-static inline
-int lttng_strncpy(char *dst, const char *src, size_t dst_len)
-{
- if (strlen(src) >= dst_len) {
- /* Fail since copying would result in truncation. */
- return -1;
- }
- strcpy(dst, src);
- return 0;
-}
-
-#ifdef NDEBUG
-/*
-* Force usage of the assertion condition to prevent unused variable warnings
-* when `assert()` are disabled by the `NDEBUG` definition.
-*/
-# define LTTNG_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
-#else
-# include <assert.h>
-# define LTTNG_ASSERT(_cond) assert(_cond)
-#endif
-
-#endif /* _MACROS_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _MACROS_H
+#define _MACROS_H
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <common/compat/string.hpp>
+
+/*
+ * Takes a pointer x and transform it so we can use it to access members
+ * without a function call. Here an example:
+ *
+ * #define GET_SIZE(x) LTTNG_REF(x)->size
+ *
+ * struct { int size; } s;
+ *
+ * printf("size : %d\n", GET_SIZE(&s));
+ *
+ * For this example we can't use something like this for compatibility purpose
+ * since this will fail:
+ *
+ * #define GET_SIZE(x) x->size;
+ *
+ * This is mostly use for the compatibility layer of lttng-tools. See
+ * poll/epoll for a good example. Since x can be on the stack or allocated
+ * memory using malloc(), we must use generic accessors for compat in order to
+ * *not* use a function to access members and not the variable name.
+ */
+#define LTTNG_REF(x) ((typeof(*x) *)(x))
+
+/*
+ * Memory allocation zeroed
+ */
+static inline
+void *zmalloc(size_t len)
+{
+ return calloc(1, len);
+}
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(array) (sizeof(array) / (sizeof((array)[0])))
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)NULL)->member) * __ptr = (ptr); \
+ (type *)((char *)__ptr - offsetof(type, member)); \
+ })
+#endif
+
+#ifndef LTTNG_PACKED
+#define LTTNG_PACKED __attribute__((__packed__))
+#endif
+
+#ifndef LTTNG_NO_SANITIZE_ADDRESS
+#if defined(__clang__) || defined (__GNUC__)
+#define LTTNG_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#else
+#define LTTNG_NO_SANITIZE_ADDRESS
+#endif
+#endif
+
+#define member_sizeof(type, field) sizeof(((type *) 0)->field)
+
+#define ASSERT_LOCKED(lock) LTTNG_ASSERT(pthread_mutex_trylock(&lock))
+#define ASSERT_RCU_READ_LOCKED(lock) LTTNG_ASSERT(rcu_read_ongoing())
+
+/* Attribute suitable to tag functions as having printf()-like arguments. */
+#define ATTR_FORMAT_PRINTF(_string_index, _first_to_check) \
+ __attribute__((format(printf, _string_index, _first_to_check)))
+
+/* Attribute suitable to tag functions as having strftime()-like arguments. */
+#define ATTR_FORMAT_STRFTIME(_string_index) \
+ __attribute__((format(strftime, _string_index, 0)))
+
+/* Macros used to ignore specific compiler diagnostics. */
+
+#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
+#define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
+
+#if defined(__clang__)
+ /* Clang */
+# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT
+# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
+ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+# define DIAGNOSTIC_IGNORE_LOGICAL_OP
+#else
+ /* GCC */
+# define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \
+ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=format\"")
+# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
+ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
+# define DIAGNOSTIC_IGNORE_LOGICAL_OP \
+ _Pragma("GCC diagnostic ignored \"-Wlogical-op\"")
+#endif
+
+/* Used to make specific C++ functions to C code. */
+#ifdef __cplusplus
+#define C_LINKAGE extern "C"
+#else
+#define C_LINKAGE
+#endif
+
+/*
+ * lttng_strncpy returns 0 on success, or nonzero on failure.
+ * It checks that the @src string fits into @dst_len before performing
+ * the copy. On failure, no copy has been performed.
+ *
+ * Assumes that 'src' is null-terminated.
+ *
+ * dst_len includes the string's trailing NULL.
+ */
+static inline
+int lttng_strncpy(char *dst, const char *src, size_t dst_len)
+{
+ if (strlen(src) >= dst_len) {
+ /* Fail since copying would result in truncation. */
+ return -1;
+ }
+ strcpy(dst, src);
+ return 0;
+}
+
+#ifdef NDEBUG
+/*
+* Force usage of the assertion condition to prevent unused variable warnings
+* when `assert()` are disabled by the `NDEBUG` definition.
+*/
+# define LTTNG_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
+#else
+# include <assert.h>
+# define LTTNG_ASSERT(_cond) assert(_cond)
+#endif
+
+#endif /* _MACROS_H */
#include "lttng/tracker.h"
#define _LGPL_SOURCE
-#include "mi-lttng.h"
-#include <common/config/session-config.h>
-#include <common/defaults.h>
-#include <common/tracker.h>
+#include "mi-lttng.hpp"
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/tracker.hpp>
#include <lttng/channel.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
#define MI_SCHEMA_MAJOR_VERSION 4
+++ /dev/null
-/*
- * Copyright (C) 2014 EfficiOS Inc.
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _MI_LTTNG_H
-#define _MI_LTTNG_H
-
-#include <stdint.h>
-
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/config/session-config.h>
-#include <lttng/lttng.h>
-
-/* Don't want to reference snapshot-internal.h here */
-struct lttng_snapshot_output;
-
-/* Instance of a machine interface writer. */
-struct mi_writer {
- struct config_writer *writer;
- enum lttng_mi_output_type type;
-};
-
-/*
- * Version information for the machine interface.
- */
-struct mi_lttng_version_data {
- char version[LTTNG_NAME_MAX]; /* Version number of package */
- uint32_t version_major; /* LTTng-Tools major version number */
- uint32_t version_minor; /* LTTng-Tools minor version number */
- uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
- char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
- char version_name[LTTNG_NAME_MAX];
- 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 */
-LTTNG_EXPORT extern const char * const mi_lttng_element_command;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_action;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_add_context;
-extern const char * const mi_lttng_element_command_add_trigger;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_create;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_destroy;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_channel;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_event;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_channels;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_event;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_list;
-extern const char * const mi_lttng_element_command_list_trigger;
-LTTNG_EXPORT 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;
-extern const char * const mi_lttng_element_command_regenerate;
-extern const char * const mi_lttng_element_command_regenerate_action;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_name;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_output;
-extern const char * const mi_lttng_element_command_remove_trigger;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_save;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_set_session;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_add;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_del;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_list;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_record;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_start;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_stop;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_success;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_track;
-LTTNG_EXPORT extern const char * const mi_lttng_element_command_untrack;
-LTTNG_EXPORT 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 */
-LTTNG_EXPORT extern const char * const mi_lttng_element_version;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_commit;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_description;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_license;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_major;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_minor;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_patch_level;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_str;
-LTTNG_EXPORT extern const char * const mi_lttng_element_version_web;
-
-/* String related to a lttng_event_field */
-LTTNG_EXPORT extern const char * const mi_lttng_element_event_field;
-LTTNG_EXPORT extern const char * const mi_lttng_element_event_fields;
-
-/* String related to lttng_event_perf_counter_ctx */
-LTTNG_EXPORT extern const char * const mi_lttng_element_perf_counter_context;
-
-/* Strings related to pid */
-LTTNG_EXPORT extern const char * const mi_lttng_element_pid_id;
-
-/* Strings related to save command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_save;
-
-/* Strings related to load command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_load;
-extern const char * const mi_lttng_element_load_overrides;
-extern const char * const mi_lttng_element_load_override_url;
-
-/* General element of mi_lttng */
-LTTNG_EXPORT extern const char * const mi_lttng_element_empty;
-LTTNG_EXPORT extern const char * const mi_lttng_element_id;
-LTTNG_EXPORT extern const char * const mi_lttng_element_nowrite;
-LTTNG_EXPORT extern const char * const mi_lttng_element_success;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_enum;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_float;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_integer;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_other;
-LTTNG_EXPORT extern const char * const mi_lttng_element_type_string;
-
-/* String related to loglevel */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_alert;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_crit;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_function;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_line;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_module;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_process;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_program;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_system;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_unit;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_emerg;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_err;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_notice;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_unknown;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_warning;
-
-/* String related to loglevel JUL */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_all;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_config;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_fine;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finer;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finest;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_off;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_severe;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_warning;
-
-/* String related to loglevel Log4j */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_off;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_fatal;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_error;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_warn;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_trace;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_all;
-
-/* String related to loglevel Python */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_critical;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_error;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_warning;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_info;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_debug;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_notset;
-
-/* String related to loglevel type */
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_all;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_range;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_single;
-LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_unknown;
-
-/* String related to a lttng_snapshot */
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_ctrl_url;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_data_url;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_max_size;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_n_ptr;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_session_name;
-LTTNG_EXPORT extern const char * const mi_lttng_element_snapshots;
-
-/* String related to track/untrack command */
-LTTNG_EXPORT extern const char * const mi_lttng_element_track_untrack_all_wildcard;
-
-extern const char * const mi_lttng_element_session_name;
-
-/* String related to rotate command */
-extern const char * const mi_lttng_element_rotation;
-extern const char * const mi_lttng_element_rotate_status;
-extern const char * const mi_lttng_element_rotation_schedule;
-extern const char * const mi_lttng_element_rotation_schedules;
-extern const char * const mi_lttng_element_rotation_schedule_periodic;
-extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
-extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
-extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
-extern const char * const mi_lttng_element_rotation_schedule_result;
-extern const char * const mi_lttng_element_rotation_schedule_results;
-extern const char * const mi_lttng_element_rotation_state;
-extern const char * const mi_lttng_element_rotation_location;
-extern const char * const mi_lttng_element_rotation_location_local;
-extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
-extern const char * const mi_lttng_element_rotation_location_relay;
-extern const char * const mi_lttng_element_rotation_location_relay_host;
-extern const char * const mi_lttng_element_rotation_location_relay_control_port;
-extern const char * const mi_lttng_element_rotation_location_relay_data_port;
-extern const char * const mi_lttng_element_rotation_location_relay_protocol;
-extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
-
-/* String related to enum lttng_rotation_state */
-extern const char * const mi_lttng_rotation_state_str_ongoing;
-extern const char * const mi_lttng_rotation_state_str_completed;
-extern const char * const mi_lttng_rotation_state_str_expired;
-extern const char * const mi_lttng_rotation_state_str_error;
-
-/* String related to enum lttng_trace_archive_location_relay_protocol_type */
-extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
-
-/* String related to rate_policy elements */
-extern const char *const mi_lttng_element_rate_policy;
-extern const char *const mi_lttng_element_rate_policy_every_n;
-extern const char *const mi_lttng_element_rate_policy_once_after_n;
-
-extern const char
- *const mi_lttng_element_rate_policy_every_n_interval;
-extern const char
- *const mi_lttng_element_rate_policy_once_after_n_threshold;
-
-/* String related to action elements */
-extern const char *const mi_lttng_element_action;
-extern const char *const mi_lttng_element_action_list;
-extern const char *const mi_lttng_element_action_notify;
-extern const char *const mi_lttng_element_action_start_session;
-extern const char *const mi_lttng_element_action_stop_session;
-extern const char *const mi_lttng_element_action_rotate_session;
-extern const char *const mi_lttng_element_action_snapshot_session;
-extern const char
- *const mi_lttng_element_action_snapshot_session_output;
-
-/* String related to condition */
-extern const char *const mi_lttng_element_condition;
-extern const char
- *const mi_lttng_element_condition_buffer_usage_high;
-extern const char
- *const mi_lttng_element_condition_buffer_usage_low;
-extern const char
- *const mi_lttng_element_condition_event_rule_matches;
-extern const char
- *const mi_lttng_element_condition_session_consumed_size;
-extern const char
- *const mi_lttng_element_condition_session_rotation;
-extern const char
- *const mi_lttng_element_condition_session_rotation_completed;
-extern const char
- *const mi_lttng_element_condition_session_rotation_ongoing;
-extern const char *const mi_lttng_element_condition_channel_name;
-extern const char *const mi_lttng_element_condition_threshold_ratio;
-extern const char *const mi_lttng_element_condition_threshold_bytes;
-
-/* String related to capture descriptor */
-extern const char *const mi_lttng_element_capture_descriptor;
-extern const char *const mi_lttng_element_capture_descriptors;
-
-/* String related to event expression */
-extern const char *const mi_lttng_element_event_expr;
-extern const char *const mi_lttng_element_event_expr_payload_field;
-extern const char
- *const mi_lttng_element_event_expr_channel_context_field;
-extern const char
- *const mi_lttng_element_event_expr_app_specific_context_field;
-extern const char
- *const mi_lttng_element_event_expr_array_field_element;
-
-extern const char *const mi_lttng_element_event_expr_provider_name;
-extern const char *const mi_lttng_element_event_expr_type_name;
-extern const char *const mi_lttng_element_event_expr_index;
-
-/* String related to event rule */
-extern const char *const mi_lttng_element_event_rule;
-
-/* String related to lttng_event_rule */
-extern const char *const mi_lttng_element_event_rule_event_name;
-extern const char *const mi_lttng_element_event_rule_name_pattern;
-extern const char
- *const mi_lttng_element_event_rule_filter_expression;
-extern const char *const mi_lttng_element_event_rule_jul_logging;
-extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
-extern const char *const mi_lttng_element_event_rule_kernel_syscall;
-extern const char
- *const mi_lttng_element_event_rule_kernel_tracepoint;
-extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
-extern const char *const mi_lttng_element_event_rule_log4j_logging;
-extern const char *const mi_lttng_element_event_rule_python_logging;
-extern const char
- *const mi_lttng_element_event_rule_user_tracepoint;
-
-/* String related to lttng_event_rule_kernel_syscall. */
-extern const char
- *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
-
-/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
-extern const char *const
- mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
-extern const char
- *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
-extern const char
- *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
-
-extern const char *const
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
-extern const char *const
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
-
-/* String related to log level rule. */
-extern const char *const mi_lttng_element_log_level_rule;
-extern const char *const mi_lttng_element_log_level_rule_exactly;
-extern const char
- *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
-extern const char *const
- mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
-extern const char *const mi_lttng_element_log_level_rule_level;
-
-/* String related to kernel probe location. */
-extern const char *const mi_lttng_element_kernel_probe_location;
-extern const char
- *const mi_lttng_element_kernel_probe_location_symbol_offset;
-extern const char *const
- mi_lttng_element_kernel_probe_location_symbol_offset_name;
-extern const char *const
- mi_lttng_element_kernel_probe_location_symbol_offset_offset;
-extern const char
- *const mi_lttng_element_kernel_probe_location_address;
-extern const char
- *const mi_lttng_element_kernel_probe_location_address_address;
-
-/* String related to userspace probe location. */
-extern const char *const mi_lttng_element_userspace_probe_location;
-extern const char
- *const mi_lttng_element_userspace_probe_location_binary_path;
-extern const char
- *const mi_lttng_element_userspace_probe_location_function;
-extern const char
- *const mi_lttng_element_userspace_probe_location_function_name;
-extern const char
- *const mi_lttng_element_userspace_probe_location_lookup_method;
-extern const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_function_default;
-extern const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
-extern const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
-extern const char
- *const mi_lttng_element_userspace_probe_location_tracepoint;
-extern const char *const
- mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
-extern const char *const
- mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
-
-/* String related to enum
- * lttng_userspace_probe_location_function_instrumentation_type */
-extern const char *const
- mi_lttng_element_userspace_probe_location_function_instrumentation_type;
-extern const char *const
- mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
-
-/* String related to trigger */
-extern const char *const mi_lttng_element_triggers;
-extern const char *const mi_lttng_element_trigger;
-extern const char *const mi_lttng_element_trigger_owner_uid;
-
-/* String related to error_query. */
-extern const char *const mi_lttng_element_error_query_result;
-extern const char
- *const mi_lttng_element_error_query_result_counter;
-extern const char
- *const mi_lttng_element_error_query_result_counter_value;
-extern const char
- *const mi_lttng_element_error_query_result_description;
-extern const char *const mi_lttng_element_error_query_result_name;
-extern const char *const mi_lttng_element_error_query_result_type;
-extern const char *const mi_lttng_element_error_query_results;
-
-/* String related to add-context command */
-extern const char * const mi_lttng_element_context_symbol;
-
-/* Utility string function */
-const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
-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.
- *
- * fd_output File to which the XML content must be written. The file will be
- * closed once the mi_writer has been destroyed.
- *
- * Returns an instance of a machine interface writer on success, NULL on
- * error.
- */
-struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
-
-/*
- * Destroy an instance of a machine interface writer.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly. Negative values
- * indicate an error.
- */
-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.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
-
-/*
- * Close a command tag.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-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.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_open_element(struct mi_writer *writer,
- const char *element_name);
-
-/*
- * Close the current element tag.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the XML document could be closed cleanly.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_close_element(struct mi_writer *writer);
-
-/*
- * Close multiple element.
- *
- * writer An instance of a machine interface writer.
- * nb_element Number of elements.
- *
- * 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.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
- const char *element_name, uint64_t value);
-
-/*
- * 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.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
- const char *element_name, int64_t value);
-
-/*
- * Write an element of type boolean.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value Boolean 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_bool(struct mi_writer *writer,
- const char *element_name, int value);
-
-/*
- * Write an element of type string.
- *
- * writer An instance of a machine interface writer.
- * element_name Element name.
- * value String 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_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.
- *
- * 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.
- * Negative values indicate an error.
- */
-int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version_data *version,
- const char *lttng_description, const char *lttng_license);
-
-/*
- * Machine interface: open a sessions 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_sessions_open(struct mi_writer *writer);
-
-/*
- * Machine interface of struct 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 additional information on a session
- * ex: domain,channel event.
- *
- * 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 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.
- * domain Event's domain
- *
- * 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, enum lttng_domain_type domain);
-
-/*
- * 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
- * domain Event's domain
- *
- * 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, enum lttng_domain_type domain);
-
-/*
- * 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 have be written.
- * Negative values indicate an error.
- */
-int mi_lttng_event_fields_open(struct mi_writer *writer);
-
-/*
- * Machine interface: open a trackers 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_trackers_open(struct mi_writer *writer);
-
-/*
- * Machine interface: open a process attribute tracker element.
- *
- * writer An instance of a machine interface writer.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- *
- * Note: A targets element is also opened for each tracker definition
- */
-int mi_lttng_process_attribute_tracker_open(
- struct mi_writer *writer, enum lttng_process_attr process_attr);
-
-/*
- * 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: open a processes 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_processes_open(struct mi_writer *writer);
-
-/*
- * Machine interface of a Process.
- *
- * 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_process(struct mi_writer *writer, pid_t pid , const char *name,
- int is_open);
-
-/*
- * TODO: move pid of lttng list -u to process semantic on mi api bump
- * Machine interface of a Process.
- *
- * 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 *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 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_all_process_attribute_value(struct mi_writer *writer,
- enum lttng_process_attr process_attr,
- bool is_open);
-
-/*
- * 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_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.
- *
- * writer An instance of a machine interface writer
- *
- * context An instance of a lttng_event_context
- *
- * is_open Define if we close the context element
- * This should be used carefully and the client
- * need to close the context element.
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_context(struct mi_writer *writer,
- struct lttng_event_context *context, int is_open);
-
-/*
- * Machine interface of a perf_counter_context.
- *
- * writer An instance of a machine interface writer
- *
- * contest An instance of a lttng_event_perf_counter_ctx
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_perf_counter_context(struct mi_writer *writer,
- struct lttng_event_perf_counter_ctx *perf_context);
-
-/*
- * Machine interface of the snapshot list_output.
- * It specifies the session for which we are listing snapshots,
- * and it opens a snapshots element to list a sequence
- * of snapshots.
- *
- * writer An instance of a machine interface writer.
- *
- * session_name: Snapshot output for session "session_name".
- *
- * Note: The client has to close the session and the snapshots elements after
- * having listed every lttng_snapshot_output.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
- const char *session_name);
-
-/*
- * Machine interface of the snapshot output.
- * The machine interface serializes the following attributes:
- * - id: ID of the snapshot output.
- * - name: Name of the output.
- * - data_url : Destination of the output.
- * - ctrl_url: Destination of the output.
- * - max_size: total size of all stream combined.
- *
- * writer An instance of a machine interface writer.
- *
- * output: A list of snapshot_output.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_list_output(struct mi_writer *writer,
- const struct lttng_snapshot_output *output);
-
-/*
- * Machine interface of the output of the command snapshot del output
- * when deleting a snapshot either by id or by name.
- * If the snapshot was found and successfully deleted using its id,
- * it return the id of the snapshot and the current session name on which it
- * was attached.
- *
- * Otherwise, it do the same process with the name of the snapshot, if the
- * snapshot output id is undefined.
- *
- * writer An instance of a machine interface writer.
- *
- * id: ID of the snapshot output.
- *
- * name: Name of the snapshot.
- *
- * current_session_name: Session to which the snapshot belongs.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
- const char *name, const char *current_session_name);
-
-/*
- * Machine interface of the output of the command snapshot add output
- * when adding a snapshot from a user URL.
- *
- * If the snapshot was successfully added, the machine interface lists
- * these information:
- * - id: ID of the newly add snapshot output.
- * - current_session_name: Name of the session to which the output was added.
- * - ctrl_url: Destination of the output.
- * - max_size: total size of all stream combined.
- *
- * writer An instance of a machine interface writer.
- *
- * current_session_name: Session to which the snapshot belongs.
- *
- * n_ptr:
- *
- * output: iterator over a lttng_snapshot_output_list which contain
- * the snapshot output informations.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_add_output(struct mi_writer *writer,
- const char *current_session_name, const char *n_ptr,
- struct lttng_snapshot_output *output);
-
-/*
- * Machine interface of the output of the command snapshot
- * record from a URL (if given).
- *
- * If the snapshot is successfully recorded from a url, the machine interface
- * output the following information:
- * - url: Destination of the output stored in the snapshot.
- *
- * Otherwise, the machine interface output the data and ctrl url received
- * from the command-line.
- *
- * writer An instance of a machine interface writer.
- *
- * ctrl_url, data_url: Destination of the output receive from the command-line.
- *
- * Returns zero if the element's value could be written.
- * Negative values indicate an error.
- */
-int mi_lttng_snapshot_record(struct mi_writer *writer, 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 */
--- /dev/null
+/*
+ * Copyright (C) 2014 EfficiOS Inc.
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _MI_LTTNG_H
+#define _MI_LTTNG_H
+
+#include <stdint.h>
+
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/config/session-config.hpp>
+#include <lttng/lttng.h>
+
+/* Don't want to reference snapshot-internal.h here */
+struct lttng_snapshot_output;
+
+/* Instance of a machine interface writer. */
+struct mi_writer {
+ struct config_writer *writer;
+ enum lttng_mi_output_type type;
+};
+
+/*
+ * Version information for the machine interface.
+ */
+struct mi_lttng_version_data {
+ char version[LTTNG_NAME_MAX]; /* Version number of package */
+ uint32_t version_major; /* LTTng-Tools major version number */
+ uint32_t version_minor; /* LTTng-Tools minor version number */
+ uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */
+ char version_commit[LTTNG_NAME_MAX]; /* Commit hash of the current version */
+ char version_name[LTTNG_NAME_MAX];
+ 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 */
+LTTNG_EXPORT extern const char * const mi_lttng_element_command;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_action;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_add_context;
+extern const char * const mi_lttng_element_command_add_trigger;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_create;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_destroy;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_channel;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_disable_event;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_channels;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_enable_event;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_list;
+extern const char * const mi_lttng_element_command_list_trigger;
+LTTNG_EXPORT 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;
+extern const char * const mi_lttng_element_command_regenerate;
+extern const char * const mi_lttng_element_command_regenerate_action;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_name;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_output;
+extern const char * const mi_lttng_element_command_remove_trigger;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_save;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_set_session;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_add;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_del;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_list;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_snapshot_record;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_start;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_stop;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_success;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_track;
+LTTNG_EXPORT extern const char * const mi_lttng_element_command_untrack;
+LTTNG_EXPORT 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 */
+LTTNG_EXPORT extern const char * const mi_lttng_element_version;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_commit;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_description;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_license;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_major;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_minor;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_patch_level;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_str;
+LTTNG_EXPORT extern const char * const mi_lttng_element_version_web;
+
+/* String related to a lttng_event_field */
+LTTNG_EXPORT extern const char * const mi_lttng_element_event_field;
+LTTNG_EXPORT extern const char * const mi_lttng_element_event_fields;
+
+/* String related to lttng_event_perf_counter_ctx */
+LTTNG_EXPORT extern const char * const mi_lttng_element_perf_counter_context;
+
+/* Strings related to pid */
+LTTNG_EXPORT extern const char * const mi_lttng_element_pid_id;
+
+/* Strings related to save command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_save;
+
+/* Strings related to load command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_load;
+extern const char * const mi_lttng_element_load_overrides;
+extern const char * const mi_lttng_element_load_override_url;
+
+/* General element of mi_lttng */
+LTTNG_EXPORT extern const char * const mi_lttng_element_empty;
+LTTNG_EXPORT extern const char * const mi_lttng_element_id;
+LTTNG_EXPORT extern const char * const mi_lttng_element_nowrite;
+LTTNG_EXPORT extern const char * const mi_lttng_element_success;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_enum;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_float;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_integer;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_other;
+LTTNG_EXPORT extern const char * const mi_lttng_element_type_string;
+
+/* String related to loglevel */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_alert;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_crit;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_function;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_line;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_module;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_process;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_program;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_system;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_debug_unit;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_emerg;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_err;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_notice;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_unknown;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_warning;
+
+/* String related to loglevel JUL */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_all;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_config;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_fine;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finer;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_finest;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_off;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_severe;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_jul_warning;
+
+/* String related to loglevel Log4j */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_off;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_fatal;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_error;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_warn;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_trace;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_log4j_all;
+
+/* String related to loglevel Python */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_critical;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_error;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_warning;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_info;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_debug;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_str_python_notset;
+
+/* String related to loglevel type */
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_all;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_range;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_single;
+LTTNG_EXPORT extern const char * const mi_lttng_loglevel_type_unknown;
+
+/* String related to a lttng_snapshot */
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_ctrl_url;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_data_url;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_max_size;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_n_ptr;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshot_session_name;
+LTTNG_EXPORT extern const char * const mi_lttng_element_snapshots;
+
+/* String related to track/untrack command */
+LTTNG_EXPORT extern const char * const mi_lttng_element_track_untrack_all_wildcard;
+
+extern const char * const mi_lttng_element_session_name;
+
+/* String related to rotate command */
+extern const char * const mi_lttng_element_rotation;
+extern const char * const mi_lttng_element_rotate_status;
+extern const char * const mi_lttng_element_rotation_schedule;
+extern const char * const mi_lttng_element_rotation_schedules;
+extern const char * const mi_lttng_element_rotation_schedule_periodic;
+extern const char * const mi_lttng_element_rotation_schedule_periodic_time_us;
+extern const char * const mi_lttng_element_rotation_schedule_size_threshold;
+extern const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes;
+extern const char * const mi_lttng_element_rotation_schedule_result;
+extern const char * const mi_lttng_element_rotation_schedule_results;
+extern const char * const mi_lttng_element_rotation_state;
+extern const char * const mi_lttng_element_rotation_location;
+extern const char * const mi_lttng_element_rotation_location_local;
+extern const char * const mi_lttng_element_rotation_location_local_absolute_path;
+extern const char * const mi_lttng_element_rotation_location_relay;
+extern const char * const mi_lttng_element_rotation_location_relay_host;
+extern const char * const mi_lttng_element_rotation_location_relay_control_port;
+extern const char * const mi_lttng_element_rotation_location_relay_data_port;
+extern const char * const mi_lttng_element_rotation_location_relay_protocol;
+extern const char * const mi_lttng_element_rotation_location_relay_relative_path;
+
+/* String related to enum lttng_rotation_state */
+extern const char * const mi_lttng_rotation_state_str_ongoing;
+extern const char * const mi_lttng_rotation_state_str_completed;
+extern const char * const mi_lttng_rotation_state_str_expired;
+extern const char * const mi_lttng_rotation_state_str_error;
+
+/* String related to enum lttng_trace_archive_location_relay_protocol_type */
+extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
+
+/* String related to rate_policy elements */
+extern const char *const mi_lttng_element_rate_policy;
+extern const char *const mi_lttng_element_rate_policy_every_n;
+extern const char *const mi_lttng_element_rate_policy_once_after_n;
+
+extern const char
+ *const mi_lttng_element_rate_policy_every_n_interval;
+extern const char
+ *const mi_lttng_element_rate_policy_once_after_n_threshold;
+
+/* String related to action elements */
+extern const char *const mi_lttng_element_action;
+extern const char *const mi_lttng_element_action_list;
+extern const char *const mi_lttng_element_action_notify;
+extern const char *const mi_lttng_element_action_start_session;
+extern const char *const mi_lttng_element_action_stop_session;
+extern const char *const mi_lttng_element_action_rotate_session;
+extern const char *const mi_lttng_element_action_snapshot_session;
+extern const char
+ *const mi_lttng_element_action_snapshot_session_output;
+
+/* String related to condition */
+extern const char *const mi_lttng_element_condition;
+extern const char
+ *const mi_lttng_element_condition_buffer_usage_high;
+extern const char
+ *const mi_lttng_element_condition_buffer_usage_low;
+extern const char
+ *const mi_lttng_element_condition_event_rule_matches;
+extern const char
+ *const mi_lttng_element_condition_session_consumed_size;
+extern const char
+ *const mi_lttng_element_condition_session_rotation;
+extern const char
+ *const mi_lttng_element_condition_session_rotation_completed;
+extern const char
+ *const mi_lttng_element_condition_session_rotation_ongoing;
+extern const char *const mi_lttng_element_condition_channel_name;
+extern const char *const mi_lttng_element_condition_threshold_ratio;
+extern const char *const mi_lttng_element_condition_threshold_bytes;
+
+/* String related to capture descriptor */
+extern const char *const mi_lttng_element_capture_descriptor;
+extern const char *const mi_lttng_element_capture_descriptors;
+
+/* String related to event expression */
+extern const char *const mi_lttng_element_event_expr;
+extern const char *const mi_lttng_element_event_expr_payload_field;
+extern const char
+ *const mi_lttng_element_event_expr_channel_context_field;
+extern const char
+ *const mi_lttng_element_event_expr_app_specific_context_field;
+extern const char
+ *const mi_lttng_element_event_expr_array_field_element;
+
+extern const char *const mi_lttng_element_event_expr_provider_name;
+extern const char *const mi_lttng_element_event_expr_type_name;
+extern const char *const mi_lttng_element_event_expr_index;
+
+/* String related to event rule */
+extern const char *const mi_lttng_element_event_rule;
+
+/* String related to lttng_event_rule */
+extern const char *const mi_lttng_element_event_rule_event_name;
+extern const char *const mi_lttng_element_event_rule_name_pattern;
+extern const char
+ *const mi_lttng_element_event_rule_filter_expression;
+extern const char *const mi_lttng_element_event_rule_jul_logging;
+extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
+extern const char *const mi_lttng_element_event_rule_kernel_syscall;
+extern const char
+ *const mi_lttng_element_event_rule_kernel_tracepoint;
+extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
+extern const char *const mi_lttng_element_event_rule_log4j_logging;
+extern const char *const mi_lttng_element_event_rule_python_logging;
+extern const char
+ *const mi_lttng_element_event_rule_user_tracepoint;
+
+/* String related to lttng_event_rule_kernel_syscall. */
+extern const char
+ *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
+
+/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
+extern const char *const
+ mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
+extern const char
+ *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
+extern const char
+ *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
+
+extern const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
+extern const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
+
+/* String related to log level rule. */
+extern const char *const mi_lttng_element_log_level_rule;
+extern const char *const mi_lttng_element_log_level_rule_exactly;
+extern const char
+ *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
+extern const char *const
+ mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
+extern const char *const mi_lttng_element_log_level_rule_level;
+
+/* String related to kernel probe location. */
+extern const char *const mi_lttng_element_kernel_probe_location;
+extern const char
+ *const mi_lttng_element_kernel_probe_location_symbol_offset;
+extern const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_name;
+extern const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_offset;
+extern const char
+ *const mi_lttng_element_kernel_probe_location_address;
+extern const char
+ *const mi_lttng_element_kernel_probe_location_address_address;
+
+/* String related to userspace probe location. */
+extern const char *const mi_lttng_element_userspace_probe_location;
+extern const char
+ *const mi_lttng_element_userspace_probe_location_binary_path;
+extern const char
+ *const mi_lttng_element_userspace_probe_location_function;
+extern const char
+ *const mi_lttng_element_userspace_probe_location_function_name;
+extern const char
+ *const mi_lttng_element_userspace_probe_location_lookup_method;
+extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+extern const char
+ *const mi_lttng_element_userspace_probe_location_tracepoint;
+extern const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
+extern const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
+
+/* String related to enum
+ * lttng_userspace_probe_location_function_instrumentation_type */
+extern const char *const
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type;
+extern const char *const
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+
+/* String related to trigger */
+extern const char *const mi_lttng_element_triggers;
+extern const char *const mi_lttng_element_trigger;
+extern const char *const mi_lttng_element_trigger_owner_uid;
+
+/* String related to error_query. */
+extern const char *const mi_lttng_element_error_query_result;
+extern const char
+ *const mi_lttng_element_error_query_result_counter;
+extern const char
+ *const mi_lttng_element_error_query_result_counter_value;
+extern const char
+ *const mi_lttng_element_error_query_result_description;
+extern const char *const mi_lttng_element_error_query_result_name;
+extern const char *const mi_lttng_element_error_query_result_type;
+extern const char *const mi_lttng_element_error_query_results;
+
+/* String related to add-context command */
+extern const char * const mi_lttng_element_context_symbol;
+
+/* Utility string function */
+const char *mi_lttng_loglevel_string(int value, enum lttng_domain_type domain);
+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.
+ *
+ * fd_output File to which the XML content must be written. The file will be
+ * closed once the mi_writer has been destroyed.
+ *
+ * Returns an instance of a machine interface writer on success, NULL on
+ * error.
+ */
+struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);
+
+/*
+ * Destroy an instance of a machine interface writer.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly. Negative values
+ * indicate an error.
+ */
+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.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);
+
+/*
+ * Close a command tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+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.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_open_element(struct mi_writer *writer,
+ const char *element_name);
+
+/*
+ * Close the current element tag.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the XML document could be closed cleanly.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_close_element(struct mi_writer *writer);
+
+/*
+ * Close multiple element.
+ *
+ * writer An instance of a machine interface writer.
+ * nb_element Number of elements.
+ *
+ * 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.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
+ const char *element_name, uint64_t value);
+
+/*
+ * 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.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
+ const char *element_name, int64_t value);
+
+/*
+ * Write an element of type boolean.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value Boolean 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_bool(struct mi_writer *writer,
+ const char *element_name, int value);
+
+/*
+ * Write an element of type string.
+ *
+ * writer An instance of a machine interface writer.
+ * element_name Element name.
+ * value String 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_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.
+ *
+ * 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.
+ * Negative values indicate an error.
+ */
+int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version_data *version,
+ const char *lttng_description, const char *lttng_license);
+
+/*
+ * Machine interface: open a sessions 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_sessions_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of struct 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 additional information on a session
+ * ex: domain,channel event.
+ *
+ * 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 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.
+ * domain Event's domain
+ *
+ * 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, enum lttng_domain_type domain);
+
+/*
+ * 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
+ * domain Event's domain
+ *
+ * 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, enum lttng_domain_type domain);
+
+/*
+ * 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 have be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_event_fields_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a trackers 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_trackers_open(struct mi_writer *writer);
+
+/*
+ * Machine interface: open a process attribute tracker element.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ *
+ * Note: A targets element is also opened for each tracker definition
+ */
+int mi_lttng_process_attribute_tracker_open(
+ struct mi_writer *writer, enum lttng_process_attr process_attr);
+
+/*
+ * 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: open a processes 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_processes_open(struct mi_writer *writer);
+
+/*
+ * Machine interface of a Process.
+ *
+ * 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_process(struct mi_writer *writer, pid_t pid , const char *name,
+ int is_open);
+
+/*
+ * TODO: move pid of lttng list -u to process semantic on mi api bump
+ * Machine interface of a Process.
+ *
+ * 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 *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 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_all_process_attribute_value(struct mi_writer *writer,
+ enum lttng_process_attr process_attr,
+ bool is_open);
+
+/*
+ * 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_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.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * context An instance of a lttng_event_context
+ *
+ * is_open Define if we close the context element
+ * This should be used carefully and the client
+ * need to close the context element.
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_context(struct mi_writer *writer,
+ struct lttng_event_context *context, int is_open);
+
+/*
+ * Machine interface of a perf_counter_context.
+ *
+ * writer An instance of a machine interface writer
+ *
+ * contest An instance of a lttng_event_perf_counter_ctx
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_perf_counter_context(struct mi_writer *writer,
+ struct lttng_event_perf_counter_ctx *perf_context);
+
+/*
+ * Machine interface of the snapshot list_output.
+ * It specifies the session for which we are listing snapshots,
+ * and it opens a snapshots element to list a sequence
+ * of snapshots.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * session_name: Snapshot output for session "session_name".
+ *
+ * Note: The client has to close the session and the snapshots elements after
+ * having listed every lttng_snapshot_output.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
+ const char *session_name);
+
+/*
+ * Machine interface of the snapshot output.
+ * The machine interface serializes the following attributes:
+ * - id: ID of the snapshot output.
+ * - name: Name of the output.
+ * - data_url : Destination of the output.
+ * - ctrl_url: Destination of the output.
+ * - max_size: total size of all stream combined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * output: A list of snapshot_output.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_list_output(struct mi_writer *writer,
+ const struct lttng_snapshot_output *output);
+
+/*
+ * Machine interface of the output of the command snapshot del output
+ * when deleting a snapshot either by id or by name.
+ * If the snapshot was found and successfully deleted using its id,
+ * it return the id of the snapshot and the current session name on which it
+ * was attached.
+ *
+ * Otherwise, it do the same process with the name of the snapshot, if the
+ * snapshot output id is undefined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * id: ID of the snapshot output.
+ *
+ * name: Name of the snapshot.
+ *
+ * current_session_name: Session to which the snapshot belongs.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
+ const char *name, const char *current_session_name);
+
+/*
+ * Machine interface of the output of the command snapshot add output
+ * when adding a snapshot from a user URL.
+ *
+ * If the snapshot was successfully added, the machine interface lists
+ * these information:
+ * - id: ID of the newly add snapshot output.
+ * - current_session_name: Name of the session to which the output was added.
+ * - ctrl_url: Destination of the output.
+ * - max_size: total size of all stream combined.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * current_session_name: Session to which the snapshot belongs.
+ *
+ * n_ptr:
+ *
+ * output: iterator over a lttng_snapshot_output_list which contain
+ * the snapshot output informations.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_add_output(struct mi_writer *writer,
+ const char *current_session_name, const char *n_ptr,
+ struct lttng_snapshot_output *output);
+
+/*
+ * Machine interface of the output of the command snapshot
+ * record from a URL (if given).
+ *
+ * If the snapshot is successfully recorded from a url, the machine interface
+ * output the following information:
+ * - url: Destination of the output stored in the snapshot.
+ *
+ * Otherwise, the machine interface output the data and ctrl url received
+ * from the command-line.
+ *
+ * writer An instance of a machine interface writer.
+ *
+ * ctrl_url, data_url: Destination of the output receive from the command-line.
+ *
+ * Returns zero if the element's value could be written.
+ * Negative values indicate an error.
+ */
+int mi_lttng_snapshot_record(struct mi_writer *writer, 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 */
*
*/
-#include <lttng/notification/notification-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/evaluation-internal.h>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/evaluation-internal.hpp>
#include <lttng/condition/condition.h>
#include <lttng/condition/evaluation.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
struct lttng_notification *lttng_notification_create(
struct lttng_trigger *trigger,
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_OPTIONAL_H
-#define LTTNG_OPTIONAL_H
-
-#include <stdint.h>
-
-/*
- * Define wrapper structure representing an optional value.
- *
- * This macro defines an "is_set" boolean field that must be checked
- * when accessing the optional field. This "is_set" field provides
- * the semantics that would be expected of a typical "raw pointer" field
- * which would be checked for NULL.
- *
- * Prefer using this macro where "special" values would be used, e.g.
- * -1ULL for uint64_t types.
- *
- * Declaration example:
- * struct my_struct {
- * int a;
- * LTTNG_OPTIONAL(int) b;
- * };
- *
- * Usage example:
- * struct my_struct foo = LTTNG_OPTIONAL_INIT;
- *
- * LTTNG_OPTIONAL_SET(&foo.b, 42);
- * if (foo.b.is_set) {
- * printf("%d", foo.b.value);
- * }
- *
- * LTTNG_OPTIONAL_UNSET(&foo.b);
- */
-#define LTTNG_OPTIONAL(type) \
- struct { \
- uint8_t is_set; \
- type value; \
- }
-
-/*
- * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL
- * is changed, the original layout should still be used for communication
- * purposes.
- *
- * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when
- * used for IPC / network communication.
- */
-#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL
-
-/*
- * This macro is available as a 'convenience' to allow sites that assume
- * an optional value is set to LTTNG_ASSERT() that it is set when accessing it.
- *
- * Since this returns the 'optional' by value, it is not suitable for all
- * wrapped optional types. It is meant to be used with PODs.
- */
-#define LTTNG_OPTIONAL_GET(optional) \
- ({ \
- LTTNG_ASSERT((optional).is_set); \
- (optional).value; \
- })
-
-/*
- * This macro is available as a 'convenience' to allow sites that assume
- * an optional value is set to LTTNG_ASSERT() that it is set when fecthing the
- * underlying value's address.
- */
-#define LTTNG_OPTIONAL_GET_PTR(optional) \
- ({ \
- LTTNG_ASSERT((optional).is_set); \
- &(optional).value; \
- })
-
-/*
- * Initialize an optional field as unset.
- *
- * The wrapped field is set to the value it would gave if it had static storage
- * duration.
- */
-#define LTTNG_OPTIONAL_INIT_UNSET {}
-
-/*
- * Initialize an optional field as 'set' with a given value.
- */
-#define LTTNG_OPTIONAL_INIT_VALUE(val) { .is_set = 1, .value = val }
-
-/* Set the value of an optional field. */
-#define LTTNG_OPTIONAL_SET(field_ptr, val) \
- do { \
- (field_ptr)->is_set = 1; \
- (field_ptr)->value = (val); \
- } while (0)
-
-/* Put an optional field in the "unset" (NULL-ed) state. */
-#define LTTNG_OPTIONAL_UNSET(field_ptr) \
- do { \
- (field_ptr)->is_set = 0; \
- } while (0)
-
-#endif /* LTTNG_OPTIONAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_OPTIONAL_H
+#define LTTNG_OPTIONAL_H
+
+#include <stdint.h>
+
+/*
+ * Define wrapper structure representing an optional value.
+ *
+ * This macro defines an "is_set" boolean field that must be checked
+ * when accessing the optional field. This "is_set" field provides
+ * the semantics that would be expected of a typical "raw pointer" field
+ * which would be checked for NULL.
+ *
+ * Prefer using this macro where "special" values would be used, e.g.
+ * -1ULL for uint64_t types.
+ *
+ * Declaration example:
+ * struct my_struct {
+ * int a;
+ * LTTNG_OPTIONAL(int) b;
+ * };
+ *
+ * Usage example:
+ * struct my_struct foo = LTTNG_OPTIONAL_INIT;
+ *
+ * LTTNG_OPTIONAL_SET(&foo.b, 42);
+ * if (foo.b.is_set) {
+ * printf("%d", foo.b.value);
+ * }
+ *
+ * LTTNG_OPTIONAL_UNSET(&foo.b);
+ */
+#define LTTNG_OPTIONAL(type) \
+ struct { \
+ uint8_t is_set; \
+ type value; \
+ }
+
+/*
+ * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL
+ * is changed, the original layout should still be used for communication
+ * purposes.
+ *
+ * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when
+ * used for IPC / network communication.
+ */
+#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL
+
+/*
+ * This macro is available as a 'convenience' to allow sites that assume
+ * an optional value is set to LTTNG_ASSERT() that it is set when accessing it.
+ *
+ * Since this returns the 'optional' by value, it is not suitable for all
+ * wrapped optional types. It is meant to be used with PODs.
+ */
+#define LTTNG_OPTIONAL_GET(optional) \
+ ({ \
+ LTTNG_ASSERT((optional).is_set); \
+ (optional).value; \
+ })
+
+/*
+ * This macro is available as a 'convenience' to allow sites that assume
+ * an optional value is set to LTTNG_ASSERT() that it is set when fecthing the
+ * underlying value's address.
+ */
+#define LTTNG_OPTIONAL_GET_PTR(optional) \
+ ({ \
+ LTTNG_ASSERT((optional).is_set); \
+ &(optional).value; \
+ })
+
+/*
+ * Initialize an optional field as unset.
+ *
+ * The wrapped field is set to the value it would gave if it had static storage
+ * duration.
+ */
+#define LTTNG_OPTIONAL_INIT_UNSET {}
+
+/*
+ * Initialize an optional field as 'set' with a given value.
+ */
+#define LTTNG_OPTIONAL_INIT_VALUE(val) { .is_set = 1, .value = val }
+
+/* Set the value of an optional field. */
+#define LTTNG_OPTIONAL_SET(field_ptr, val) \
+ do { \
+ (field_ptr)->is_set = 1; \
+ (field_ptr)->value = (val); \
+ } while (0)
+
+/* Put an optional field in the "unset" (NULL-ed) state. */
+#define LTTNG_OPTIONAL_UNSET(field_ptr) \
+ do { \
+ (field_ptr)->is_set = 0; \
+ } while (0)
+
+#endif /* LTTNG_OPTIONAL_H */
*/
#define _LGPL_SOURCE
-#include <common/macros.h>
-#include <common/common.h>
-#include <common/path.h>
+#include <common/macros.hpp>
+#include <common/common.hpp>
+#include <common/path.hpp>
/*
* Return a partial realpath(3) of the path even if the full path does not
+++ /dev/null
-/*
- * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#ifndef _COMMON_PATH_H
-#define _COMMON_PATH_H
-
-char *utils_expand_path(const char *path);
-char *utils_expand_path_keep_symlink(const char *path);
-
-#endif /* _COMMON_PATH_H */
--- /dev/null
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#ifndef _COMMON_PATH_H
+#define _COMMON_PATH_H
+
+char *utils_expand_path(const char *path);
+char *utils_expand_path_keep_symlink(const char *path);
+
+#endif /* _COMMON_PATH_H */
*
*/
-#include <common/dynamic-array.h>
-#include <common/buffer-view.h>
-#include "payload-view.h"
-#include "payload.h"
+#include <common/dynamic-array.hpp>
+#include <common/buffer-view.hpp>
+#include "payload-view.hpp"
+#include "payload.hpp"
#include <stddef.h>
bool lttng_payload_view_is_valid(const struct lttng_payload_view *view)
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_VIEW_H
-#define LTTNG_PAYLOAD_VIEW_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_payload;
-struct fd_handle;
-
-/*
- * An lttng_payload_view references a payload and allows code to share
- * a `const` version of a subset of a payload.
- *
- * A payload view is invalidated whenever its source (a payload, or another
- * payload view) is modified.
- *
- * While a payload view does not allow users to modify the underlying bytes
- * of the payload, it can be used to 'pop' file descriptor handles using an
- * iterator belonging to the top-level payload view.
- *
- * Hence, a payload view created from a payload or a dynamic buffer contains
- * an implicit file descriptor handle iterator. Any payload view created from
- * another payload view will share the same underlying file descriptor handle
- * iterator.
- *
- * The rationale for this is that a payload is never consumed directly, it must
- * be consumed through a payload view.
- *
- * Typically, a payload view will be used to rebuild a previously serialized
- * object hierarchy. Sharing an underlying iterator allows aggregate objects
- * to provide a restricted view of the payload to their members, which will
- * report the number of bytes consumed and `pop` the file descriptor handle they
- * should own. In return, those objects can create an even narrower view for
- * their children, allowing them to also consume file descriptor handles.
- *
- * Note that a payload view never assumes any ownership of the underlying
- * payload.
- */
-struct lttng_payload_view {
- struct lttng_buffer_view buffer;
- /* private */
-
- const struct lttng_dynamic_pointer_array _fd_handles;
-
- struct {
- size_t *p_fd_handles_position;
- size_t fd_handles_position;
- } _iterator;
-};
-
-/**
- * Checks if a payload view's buffer is safe to access.
- *
- * After calling the payload view creation functions, callers should verify
- * if the resquested length (if any is explicitly provided) could be mapped
- * to a new view.
- *
- * @view Payload to validate
- */
-bool lttng_payload_view_is_valid(const struct lttng_payload_view *view);
-
-/**
- * Return a payload view referencing a subset of a payload.
- *
- * @payload Source payload to reference
- * @offset Offset to apply to the payload's buffer
- * @len Length of the contents to reference. Passing -1 will
- * cause the view to reference the whole payload from the
- * offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_payload(
- const struct lttng_payload *payload, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a payload referenced by
- * another payload view.
- *
- * @view Source payload view to reference
- * @offset Offset to apply to the payload view's buffer view
- * @len Length of the contents to reference. Passing -1 will
- * cause the payload view to reference the whole payload view's
- * buffer view from the offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_view(
- struct lttng_payload_view *view, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing dynamic buffer.
- *
- * @src Source dynamic buffer to reference
- * @offset Offset to apply to the dynamic buffer
- * @len Length of the buffer contents to reference. Passing -1 will
- * cause the payload view to reference the whole payload from the
- * offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *buffer, size_t offset,
- ptrdiff_t len);
-/**
- *
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing buffer view.
- *
- * @src Source buffer view to reference
- * @offset Offset to apply to the buffer view
- * @len Length of the buffer contents to reference. Passing -1 will
- * cause the payload view to reference the whole payload from the
- * offset provided.
- */
-struct lttng_payload_view lttng_payload_view_from_buffer_view(
- const struct lttng_buffer_view *view, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of the memory referenced by a raw
- * pointer.
- *
- * @src Source buffer to reference
- * @offset Offset to apply to the source memory buffer
- * @len Length of the memory contents to reference.
- *
- * Note that a payload view never assumes the ownership of the memory it
- * references.
- */
-struct lttng_payload_view lttng_payload_view_init_from_buffer(
- const char *src, size_t offset, ptrdiff_t len);
-
-/**
- * Get the number of file descriptor handles left in a payload view.
- *
- * @payload Payload instance
- *
- * Returns the number of file descriptor handles left on success, -1 on error.
- */
-int lttng_payload_view_get_fd_handle_count(
- const struct lttng_payload_view *payload_view);
-
-/**
- * Pop an fd handle from a payload view.
- *
- * A reference to the returned fd_handle is acquired on behalf of the caller.
- *
- * @payload Payload instance
- *
- * Returns an fd_handle on success, -1 on error.
- */
-struct fd_handle *lttng_payload_view_pop_fd_handle(
- struct lttng_payload_view *payload_view);
-
-#endif /* LTTNG_PAYLOAD_VIEW_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_VIEW_H
+#define LTTNG_PAYLOAD_VIEW_H
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+
+struct lttng_payload;
+struct fd_handle;
+
+/*
+ * An lttng_payload_view references a payload and allows code to share
+ * a `const` version of a subset of a payload.
+ *
+ * A payload view is invalidated whenever its source (a payload, or another
+ * payload view) is modified.
+ *
+ * While a payload view does not allow users to modify the underlying bytes
+ * of the payload, it can be used to 'pop' file descriptor handles using an
+ * iterator belonging to the top-level payload view.
+ *
+ * Hence, a payload view created from a payload or a dynamic buffer contains
+ * an implicit file descriptor handle iterator. Any payload view created from
+ * another payload view will share the same underlying file descriptor handle
+ * iterator.
+ *
+ * The rationale for this is that a payload is never consumed directly, it must
+ * be consumed through a payload view.
+ *
+ * Typically, a payload view will be used to rebuild a previously serialized
+ * object hierarchy. Sharing an underlying iterator allows aggregate objects
+ * to provide a restricted view of the payload to their members, which will
+ * report the number of bytes consumed and `pop` the file descriptor handle they
+ * should own. In return, those objects can create an even narrower view for
+ * their children, allowing them to also consume file descriptor handles.
+ *
+ * Note that a payload view never assumes any ownership of the underlying
+ * payload.
+ */
+struct lttng_payload_view {
+ struct lttng_buffer_view buffer;
+ /* private */
+
+ const struct lttng_dynamic_pointer_array _fd_handles;
+
+ struct {
+ size_t *p_fd_handles_position;
+ size_t fd_handles_position;
+ } _iterator;
+};
+
+/**
+ * Checks if a payload view's buffer is safe to access.
+ *
+ * After calling the payload view creation functions, callers should verify
+ * if the resquested length (if any is explicitly provided) could be mapped
+ * to a new view.
+ *
+ * @view Payload to validate
+ */
+bool lttng_payload_view_is_valid(const struct lttng_payload_view *view);
+
+/**
+ * Return a payload view referencing a subset of a payload.
+ *
+ * @payload Source payload to reference
+ * @offset Offset to apply to the payload's buffer
+ * @len Length of the contents to reference. Passing -1 will
+ * cause the view to reference the whole payload from the
+ * offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_payload(
+ const struct lttng_payload *payload, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a payload referenced by
+ * another payload view.
+ *
+ * @view Source payload view to reference
+ * @offset Offset to apply to the payload view's buffer view
+ * @len Length of the contents to reference. Passing -1 will
+ * cause the payload view to reference the whole payload view's
+ * buffer view from the offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_view(
+ struct lttng_payload_view *view, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing dynamic buffer.
+ *
+ * @src Source dynamic buffer to reference
+ * @offset Offset to apply to the dynamic buffer
+ * @len Length of the buffer contents to reference. Passing -1 will
+ * cause the payload view to reference the whole payload from the
+ * offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+ const struct lttng_dynamic_buffer *buffer, size_t offset,
+ ptrdiff_t len);
+/**
+ *
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing buffer view.
+ *
+ * @src Source buffer view to reference
+ * @offset Offset to apply to the buffer view
+ * @len Length of the buffer contents to reference. Passing -1 will
+ * cause the payload view to reference the whole payload from the
+ * offset provided.
+ */
+struct lttng_payload_view lttng_payload_view_from_buffer_view(
+ const struct lttng_buffer_view *view, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of the memory referenced by a raw
+ * pointer.
+ *
+ * @src Source buffer to reference
+ * @offset Offset to apply to the source memory buffer
+ * @len Length of the memory contents to reference.
+ *
+ * Note that a payload view never assumes the ownership of the memory it
+ * references.
+ */
+struct lttng_payload_view lttng_payload_view_init_from_buffer(
+ const char *src, size_t offset, ptrdiff_t len);
+
+/**
+ * Get the number of file descriptor handles left in a payload view.
+ *
+ * @payload Payload instance
+ *
+ * Returns the number of file descriptor handles left on success, -1 on error.
+ */
+int lttng_payload_view_get_fd_handle_count(
+ const struct lttng_payload_view *payload_view);
+
+/**
+ * Pop an fd handle from a payload view.
+ *
+ * A reference to the returned fd_handle is acquired on behalf of the caller.
+ *
+ * @payload Payload instance
+ *
+ * Returns an fd_handle on success, -1 on error.
+ */
+struct fd_handle *lttng_payload_view_pop_fd_handle(
+ struct lttng_payload_view *payload_view);
+
+#endif /* LTTNG_PAYLOAD_VIEW_H */
*
*/
-#include "payload.h"
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
+#include "payload.hpp"
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
static
void release_fd_handle_ref(void *ptr)
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_H
-#define LTTNG_PAYLOAD_H
-
-#include <common/dynamic-buffer.h>
-#include <common/dynamic-array.h>
-#include <common/fd-handle.h>
-
-/*
- * An lttng_payload encompasses the 'data' (bytes) and any passed file
- * descriptors as part of a message between liblttng-ctl and the session
- * daemon.
- */
-struct lttng_payload {
- struct lttng_dynamic_buffer buffer;
- /* private */
- struct lttng_dynamic_pointer_array _fd_handles;
-};
-
-/*
- * Initialize a payload. This performs no allocation and is meant
- * to be used instead of zero-ing the payload structure.
- */
-void lttng_payload_init(struct lttng_payload *payload);
-
-/* Copy a payload. */
-int lttng_payload_copy(const struct lttng_payload *src_payload,
- struct lttng_payload *dst_payload);
-
-/* Release any memory and references held by the payload. */
-void lttng_payload_reset(struct lttng_payload *payload);
-
-/*
- * Empty the contents of a payload, releasing all references held.
- * This should be used to put a payload in a re-usable state.
- *
- * lttng_payload_reset must still be called on an lttng_payload to
- * free all allocated memory.
- */
-void lttng_payload_clear(struct lttng_payload *payload);
-
-/**
- * Add an fd to the payload.
- * The payload acquires a reference to the fd_handle.
- *
- * @payload Payload instance
- * @fd_handle File descriptor handle to add to the payload
- *
- * Returns 0 on success, -1 on allocation error.
- */
-int lttng_payload_push_fd_handle(struct lttng_payload *payload,
- struct fd_handle *fd_handle);
-
-#endif /* LTTNG_PAYLOAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_H
+#define LTTNG_PAYLOAD_H
+
+#include <common/dynamic-buffer.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/fd-handle.hpp>
+
+/*
+ * An lttng_payload encompasses the 'data' (bytes) and any passed file
+ * descriptors as part of a message between liblttng-ctl and the session
+ * daemon.
+ */
+struct lttng_payload {
+ struct lttng_dynamic_buffer buffer;
+ /* private */
+ struct lttng_dynamic_pointer_array _fd_handles;
+};
+
+/*
+ * Initialize a payload. This performs no allocation and is meant
+ * to be used instead of zero-ing the payload structure.
+ */
+void lttng_payload_init(struct lttng_payload *payload);
+
+/* Copy a payload. */
+int lttng_payload_copy(const struct lttng_payload *src_payload,
+ struct lttng_payload *dst_payload);
+
+/* Release any memory and references held by the payload. */
+void lttng_payload_reset(struct lttng_payload *payload);
+
+/*
+ * Empty the contents of a payload, releasing all references held.
+ * This should be used to put a payload in a re-usable state.
+ *
+ * lttng_payload_reset must still be called on an lttng_payload to
+ * free all allocated memory.
+ */
+void lttng_payload_clear(struct lttng_payload *payload);
+
+/**
+ * Add an fd to the payload.
+ * The payload acquires a reference to the fd_handle.
+ *
+ * @payload Payload instance
+ * @fd_handle File descriptor handle to add to the payload
+ *
+ * Returns 0 on success, -1 on allocation error.
+ */
+int lttng_payload_push_fd_handle(struct lttng_payload *payload,
+ struct fd_handle *fd_handle);
+
+#endif /* LTTNG_PAYLOAD_H */
#include <sys/types.h>
#include <sys/stat.h>
-#include <common/common.h>
+#include <common/common.hpp>
-#include "pipe.h"
+#include "pipe.hpp"
/*
* Lock read side of a pipe.
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef LTTNG_PIPE_H
-#define LTTNG_PIPE_H
-
-#include <pthread.h>
-#include <common/macros.h>
-#include <sys/types.h>
-
-enum lttng_pipe_state {
- LTTNG_PIPE_STATE_OPENED = 1,
- LTTNG_PIPE_STATE_CLOSED = 2,
-};
-
-struct lttng_pipe {
- /* Read: 0, Write: 1. */
- int fd[2];
- /*
- * Flags of the pipe once opened. pipe(2) specifies either O_NONBLOCK or
- * O_CLOEXEC can be used. Flags are set using fcntl(2) call.
- */
- int flags;
-
- /*
- * These states are protected by the operation mutex below.
- */
- enum lttng_pipe_state r_state;
- enum lttng_pipe_state w_state;
-
- /* Held for each read(2) operation. */
- pthread_mutex_t read_mutex;
- /* Held for each write(2) operation. */
- pthread_mutex_t write_mutex;
-};
-
-/*
- * Return 1 if read side is open else 0.
- */
-static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe)
-{
- return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
-}
-
-/*
- * Return 1 if write side is open else 0.
- */
-static inline int lttng_pipe_is_write_open(const struct lttng_pipe *pipe)
-{
- return pipe->w_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
-}
-
-static inline int lttng_pipe_get_readfd(const struct lttng_pipe *pipe)
-{
- return pipe->fd[0];
-}
-
-static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe)
-{
- return pipe->fd[1];
-}
-
-struct lttng_pipe *lttng_pipe_open(int flags);
-struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
- int flags);
-int lttng_pipe_write_close(struct lttng_pipe *pipe);
-int lttng_pipe_read_close(struct lttng_pipe *pipe);
-/* Close both side of pipe. */
-int lttng_pipe_close(struct lttng_pipe *pipe);
-void lttng_pipe_destroy(struct lttng_pipe *pipe);
-
-ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count);
-ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
- size_t count);
-/* Returns and releases the read end of the pipe. */
-int lttng_pipe_release_readfd(struct lttng_pipe *pipe);
-/* Returns and releases the write end of the pipe. */
-int lttng_pipe_release_writefd(struct lttng_pipe *pipe);
-
-#endif /* LTTNG_PIPE_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_PIPE_H
+#define LTTNG_PIPE_H
+
+#include <pthread.h>
+#include <common/macros.hpp>
+#include <sys/types.h>
+
+enum lttng_pipe_state {
+ LTTNG_PIPE_STATE_OPENED = 1,
+ LTTNG_PIPE_STATE_CLOSED = 2,
+};
+
+struct lttng_pipe {
+ /* Read: 0, Write: 1. */
+ int fd[2];
+ /*
+ * Flags of the pipe once opened. pipe(2) specifies either O_NONBLOCK or
+ * O_CLOEXEC can be used. Flags are set using fcntl(2) call.
+ */
+ int flags;
+
+ /*
+ * These states are protected by the operation mutex below.
+ */
+ enum lttng_pipe_state r_state;
+ enum lttng_pipe_state w_state;
+
+ /* Held for each read(2) operation. */
+ pthread_mutex_t read_mutex;
+ /* Held for each write(2) operation. */
+ pthread_mutex_t write_mutex;
+};
+
+/*
+ * Return 1 if read side is open else 0.
+ */
+static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe)
+{
+ return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
+}
+
+/*
+ * Return 1 if write side is open else 0.
+ */
+static inline int lttng_pipe_is_write_open(const struct lttng_pipe *pipe)
+{
+ return pipe->w_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0;
+}
+
+static inline int lttng_pipe_get_readfd(const struct lttng_pipe *pipe)
+{
+ return pipe->fd[0];
+}
+
+static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe)
+{
+ return pipe->fd[1];
+}
+
+struct lttng_pipe *lttng_pipe_open(int flags);
+struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
+ int flags);
+int lttng_pipe_write_close(struct lttng_pipe *pipe);
+int lttng_pipe_read_close(struct lttng_pipe *pipe);
+/* Close both side of pipe. */
+int lttng_pipe_close(struct lttng_pipe *pipe);
+void lttng_pipe_destroy(struct lttng_pipe *pipe);
+
+ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count);
+ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
+ size_t count);
+/* Returns and releases the read end of the pipe. */
+int lttng_pipe_release_readfd(struct lttng_pipe *pipe);
+/* Returns and releases the write end of the pipe. */
+int lttng_pipe_release_writefd(struct lttng_pipe *pipe);
+
+#endif /* LTTNG_PIPE_H */
#include <limits.h>
#include <unistd.h>
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
-#include "readwrite.h"
+#include "readwrite.hpp"
/*
* lttng_read and lttng_write take care of EINTR and partial read/write.
+++ /dev/null
-#ifndef LTTNG_COMMON_READWRITE_H
-#define LTTNG_COMMON_READWRITE_H
-
-/*
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <unistd.h>
-#include <common/macros.h>
-
-/*
- * lttng_read and lttng_write take care of EINTR and partial read/write.
- * Upon success, they return the "count" received as parameter.
- * They can return a negative value if an error occurs.
- * If a value lower than the requested "count" is returned, it means an
- * error occurred.
- * The error can be checked by querying errno.
- */
-ssize_t lttng_read(int fd, void *buf, size_t count);
-ssize_t lttng_write(int fd, const void *buf, size_t count);
-
-#endif /* LTTNG_COMMON_READWRITE_H */
--- /dev/null
+#ifndef LTTNG_COMMON_READWRITE_H
+#define LTTNG_COMMON_READWRITE_H
+
+/*
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <unistd.h>
+#include <common/macros.hpp>
+
+/*
+ * lttng_read and lttng_write take care of EINTR and partial read/write.
+ * Upon success, they return the "count" received as parameter.
+ * They can return a negative value if an error occurs.
+ * If a value lower than the requested "count" is returned, it means an
+ * error occurred.
+ * The error can be checked by querying errno.
+ */
+ssize_t lttng_read(int fd, void *buf, size_t count);
+ssize_t lttng_write(int fd, const void *buf, size_t count);
+
+#endif /* LTTNG_COMMON_READWRITE_H */
#include <sys/stat.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/index/ctf-index.h>
-#include <common/trace-chunk.h>
-#include <common/string-utils/format.h>
-
-#include "relayd.h"
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/string-utils/format.hpp>
+
+#include "relayd.hpp"
static
bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _RELAYD_H
-#define _RELAYD_H
-
-#include <unistd.h>
-#include <stdbool.h>
-
-#include <common/sessiond-comm/relayd.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/trace-chunk.h>
-#include <common/dynamic-array.h>
-
-struct relayd_stream_rotation_position {
- uint64_t stream_id;
- /*
- * Packet sequence number of the first packet belonging to the new
- * "destination" trace chunk to which the stream is rotating.
- *
- * Ignored for metadata streams.
- */
- uint64_t rotate_at_seq_num;
-};
-
-int relayd_connect(struct lttcomm_relayd_sock *sock);
-int relayd_close(struct lttcomm_relayd_sock *sock);
-int relayd_create_session(struct lttcomm_relayd_sock *rsock,
- uint64_t *relayd_session_id,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- unsigned int snapshot, uint64_t sessiond_session_id,
- const lttng_uuid sessiond_uuid,
- const uint64_t *current_chunk_id,
- time_t creation_time, bool session_name_contains_creation_time,
- char *output_path);
-int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
- const char *domain_name, const char *pathname, uint64_t *stream_id,
- uint64_t tracefile_size, uint64_t tracefile_count,
- struct lttng_trace_chunk *trace_chunk);
-int relayd_streams_sent(struct lttcomm_relayd_sock *rsock);
-int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
- uint64_t last_net_seq_num);
-int relayd_version_check(struct lttcomm_relayd_sock *sock);
-int relayd_start_data(struct lttcomm_relayd_sock *sock);
-int relayd_send_metadata(struct lttcomm_relayd_sock *sock, size_t len);
-int relayd_send_data_hdr(struct lttcomm_relayd_sock *sock,
- struct lttcomm_relayd_data_hdr *hdr, size_t size);
-int relayd_data_pending(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
- uint64_t last_net_seq_num);
-int relayd_quiescent_control(struct lttcomm_relayd_sock *sock,
- uint64_t metadata_stream_id);
-int relayd_begin_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id);
-int relayd_end_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id,
- unsigned int *is_data_inflight);
-int relayd_send_index(struct lttcomm_relayd_sock *rsock,
- struct ctf_packet_index *index, uint64_t relay_stream_id,
- uint64_t net_seq_num);
-int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
- uint64_t stream_id, uint64_t version);
-/* `positions` is an array of `stream_count` relayd_stream_rotation_position. */
-int relayd_rotate_streams(struct lttcomm_relayd_sock *sock,
- unsigned int stream_count, const uint64_t *new_chunk_id,
- const struct relayd_stream_rotation_position *positions);
-int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
- struct lttng_trace_chunk *chunk);
-int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
- struct lttng_trace_chunk *chunk,
- char *path);
-int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
- uint64_t chunk_id, bool *chunk_exists);
-int relayd_get_configuration(struct lttcomm_relayd_sock *sock,
- uint64_t query_flags,
- uint64_t *result_flags);
-
-#endif /* _RELAYD_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _RELAYD_H
+#define _RELAYD_H
+
+#include <unistd.h>
+#include <stdbool.h>
+
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/dynamic-array.hpp>
+
+struct relayd_stream_rotation_position {
+ uint64_t stream_id;
+ /*
+ * Packet sequence number of the first packet belonging to the new
+ * "destination" trace chunk to which the stream is rotating.
+ *
+ * Ignored for metadata streams.
+ */
+ uint64_t rotate_at_seq_num;
+};
+
+int relayd_connect(struct lttcomm_relayd_sock *sock);
+int relayd_close(struct lttcomm_relayd_sock *sock);
+int relayd_create_session(struct lttcomm_relayd_sock *rsock,
+ uint64_t *relayd_session_id,
+ const char *session_name, const char *hostname,
+ const char *base_path, int session_live_timer,
+ unsigned int snapshot, uint64_t sessiond_session_id,
+ const lttng_uuid sessiond_uuid,
+ const uint64_t *current_chunk_id,
+ time_t creation_time, bool session_name_contains_creation_time,
+ char *output_path);
+int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
+ const char *domain_name, const char *pathname, uint64_t *stream_id,
+ uint64_t tracefile_size, uint64_t tracefile_count,
+ struct lttng_trace_chunk *trace_chunk);
+int relayd_streams_sent(struct lttcomm_relayd_sock *rsock);
+int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
+ uint64_t last_net_seq_num);
+int relayd_version_check(struct lttcomm_relayd_sock *sock);
+int relayd_start_data(struct lttcomm_relayd_sock *sock);
+int relayd_send_metadata(struct lttcomm_relayd_sock *sock, size_t len);
+int relayd_send_data_hdr(struct lttcomm_relayd_sock *sock,
+ struct lttcomm_relayd_data_hdr *hdr, size_t size);
+int relayd_data_pending(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
+ uint64_t last_net_seq_num);
+int relayd_quiescent_control(struct lttcomm_relayd_sock *sock,
+ uint64_t metadata_stream_id);
+int relayd_begin_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id);
+int relayd_end_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id,
+ unsigned int *is_data_inflight);
+int relayd_send_index(struct lttcomm_relayd_sock *rsock,
+ struct ctf_packet_index *index, uint64_t relay_stream_id,
+ uint64_t net_seq_num);
+int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
+ uint64_t stream_id, uint64_t version);
+/* `positions` is an array of `stream_count` relayd_stream_rotation_position. */
+int relayd_rotate_streams(struct lttcomm_relayd_sock *sock,
+ unsigned int stream_count, const uint64_t *new_chunk_id,
+ const struct relayd_stream_rotation_position *positions);
+int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
+ struct lttng_trace_chunk *chunk);
+int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
+ struct lttng_trace_chunk *chunk,
+ char *path);
+int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
+ uint64_t chunk_id, bool *chunk_exists);
+int relayd_get_configuration(struct lttcomm_relayd_sock *sock,
+ uint64_t query_flags,
+ uint64_t *result_flags);
+
+#endif /* _RELAYD_H */
#include <sys/wait.h>
#include <unistd.h>
-#include <common/bytecode/bytecode.h>
-#include <common/lttng-kernel.h>
-#include <common/common.h>
-#include <common/utils.h>
-#include <common/compat/errno.h>
-#include <common/compat/getenv.h>
-#include <common/compat/string.h>
-#include <common/unix.h>
-#include <common/defaults.h>
-#include <common/lttng-elf.h>
-#include <common/thread.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/lttng-kernel.hpp>
+#include <common/common.hpp>
+#include <common/utils.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/unix.hpp>
+#include <common/defaults.hpp>
+#include <common/lttng-elf.hpp>
+#include <common/thread.hpp>
#include <lttng/constant.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/filter/filter-ast.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/filter/filter-ast.hpp>
-#include "runas.h"
+#include "runas.hpp"
#define GETPW_BUFFER_FALLBACK_SIZE 4096
+++ /dev/null
-#ifndef _RUNAS_H
-#define _RUNAS_H
-
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <common/macros.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-/*
- * The run-as process is launched by forking without an exec*() call. This means
- * that any resource allocated before the run-as worker is launched should be
- * cleaned-up after the fork(). This callback allows the user to perform this
- * clean-up.
- *
- * Note that the callback will _not_ be invoked if the LTTNG_DEBUG_NOCLONE
- * environment variable is set as the clean-up is not needed (and may not be
- * expected).
- *
- * A negative return value will cause the run-as process to exit with a non-zero
- * value.
- */
-typedef int (*post_fork_cleanup_cb)(void *user_data);
-
-int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
- uid_t uid, gid_t gid);
-int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int run_as_mkdirat(int dirfd, const char *path, mode_t mode,
- uid_t uid, gid_t gid);
-int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
-int run_as_openat(int dirfd, const char *filename, int flags, mode_t mode,
- uid_t uid, gid_t gid);
-int run_as_unlink(const char *path, uid_t uid, gid_t gid);
-int run_as_unlinkat(int dirfd, const char *filename, uid_t uid, gid_t gid);
-int run_as_rmdir(const char *path, uid_t uid, gid_t gid);
-int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid, int flags);
-int run_as_rmdirat(int dirfd, const char *path, uid_t uid, gid_t gid);
-int run_as_rmdirat_recursive(int dirfd, const char *path, uid_t uid, gid_t gid, int flags);
-int run_as_rename(const char *old_name, const char *new_name, uid_t uid, gid_t gid);
-int run_as_renameat(int old_dirfd, const char *old_name,
- int new_dirfd, const char *new_name, uid_t uid, gid_t gid);
-int run_as_extract_elf_symbol_offset(int fd, const char* function,
- uid_t uid, gid_t gid, uint64_t *offset);
-int run_as_extract_sdt_probe_offsets(int fd, const char *provider_name,
- const char* probe_name, uid_t uid, gid_t gid,
- uint64_t **offsets, uint32_t *num_offset);
-int run_as_generate_filter_bytecode(const char *filter_expression,
- const struct lttng_credentials *creds,
- struct lttng_bytecode **bytecode);
-int run_as_create_worker(const char *procname,
- post_fork_cleanup_cb clean_up_func, void *clean_up_user_data);
-void run_as_destroy_worker(void);
-
-#endif /* _RUNAS_H */
--- /dev/null
+#ifndef _RUNAS_H
+#define _RUNAS_H
+
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+/*
+ * The run-as process is launched by forking without an exec*() call. This means
+ * that any resource allocated before the run-as worker is launched should be
+ * cleaned-up after the fork(). This callback allows the user to perform this
+ * clean-up.
+ *
+ * Note that the callback will _not_ be invoked if the LTTNG_DEBUG_NOCLONE
+ * environment variable is set as the clean-up is not needed (and may not be
+ * expected).
+ *
+ * A negative return value will cause the run-as process to exit with a non-zero
+ * value.
+ */
+typedef int (*post_fork_cleanup_cb)(void *user_data);
+
+int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
+ uid_t uid, gid_t gid);
+int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int run_as_mkdirat(int dirfd, const char *path, mode_t mode,
+ uid_t uid, gid_t gid);
+int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid);
+int run_as_openat(int dirfd, const char *filename, int flags, mode_t mode,
+ uid_t uid, gid_t gid);
+int run_as_unlink(const char *path, uid_t uid, gid_t gid);
+int run_as_unlinkat(int dirfd, const char *filename, uid_t uid, gid_t gid);
+int run_as_rmdir(const char *path, uid_t uid, gid_t gid);
+int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid, int flags);
+int run_as_rmdirat(int dirfd, const char *path, uid_t uid, gid_t gid);
+int run_as_rmdirat_recursive(int dirfd, const char *path, uid_t uid, gid_t gid, int flags);
+int run_as_rename(const char *old_name, const char *new_name, uid_t uid, gid_t gid);
+int run_as_renameat(int old_dirfd, const char *old_name,
+ int new_dirfd, const char *new_name, uid_t uid, gid_t gid);
+int run_as_extract_elf_symbol_offset(int fd, const char* function,
+ uid_t uid, gid_t gid, uint64_t *offset);
+int run_as_extract_sdt_probe_offsets(int fd, const char *provider_name,
+ const char* probe_name, uid_t uid, gid_t gid,
+ uint64_t **offsets, uint32_t *num_offset);
+int run_as_generate_filter_bytecode(const char *filter_expression,
+ const struct lttng_credentials *creds,
+ struct lttng_bytecode **bytecode);
+int run_as_create_worker(const char *procname,
+ post_fork_cleanup_cb clean_up_func, void *clean_up_user_data);
+void run_as_destroy_worker(void);
+
+#endif /* _RUNAS_H */
* SPDX-License-Identifier: LGPL-2.1-only
*/
-#include <lttng/session-descriptor-internal.h>
-#include <common/macros.h>
-#include <common/uri.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <common/macros.hpp>
+#include <common/uri.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
#include <time.h>
#include <stdio.h>
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef AGENT_COMM
-#define AGENT_COMM
-
-#include <stdint.h>
-
-#include <common/macros.h>
-#include <lttng/lttng.h>
-
-/*
- * Command value passed in the header.
- */
-enum lttcomm_agent_command {
- AGENT_CMD_LIST = 1,
- AGENT_CMD_ENABLE = 2,
- AGENT_CMD_DISABLE = 3,
- AGENT_CMD_REG_DONE = 4, /* End registration process. */
- AGENT_CMD_APP_CTX_ENABLE = 5,
- AGENT_CMD_APP_CTX_DISABLE = 6,
-};
-
-/*
- * Return codes from the agent.
- */
-enum lttcomm_agent_ret_code {
- /* Success, assumed to be the first entry */
- AGENT_RET_CODE_SUCCESS = 1,
- /* Invalid command */
- AGENT_RET_CODE_INVALID = 2,
- /* Unknown logger name */
- AGENT_RET_CODE_UNKNOWN_NAME = 3,
- AGENT_RET_CODE_NR,
-};
-
-/*
- * Agent application communication header.
- */
-struct lttcomm_agent_hdr {
- uint64_t data_size; /* data size following this header */
- uint32_t cmd; /* Enum of agent command. */
- uint32_t cmd_version; /* command version */
-} LTTNG_PACKED;
-
-/*
- * Enable event command payload. Will be immediately followed by the
- * variable-length string representing the filter expression.
- */
-struct lttcomm_agent_enable_event {
- uint32_t loglevel_value;
- uint32_t loglevel_type;
- char name[LTTNG_SYMBOL_NAME_LEN];
- uint32_t filter_expression_length;
-} LTTNG_PACKED;
-
-/*
- * Disable event command payload.
- */
-struct lttcomm_agent_disable_event {
- char name[LTTNG_SYMBOL_NAME_LEN];
-} LTTNG_PACKED;
-
-/*
- * Generic reply coming from the agent.
- */
-struct lttcomm_agent_generic_reply {
- uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * List command reply header.
- */
-struct lttcomm_agent_list_reply_hdr {
- uint32_t ret_code;
- uint32_t data_size;
-} LTTNG_PACKED;
-
-/*
- * List command reply payload coming from the agent.
- */
-struct lttcomm_agent_list_reply {
- uint32_t nb_event;
- /* List of event name each of them ending by a NULL byte. */
- char payload[];
-} LTTNG_PACKED;
-
-#endif /* AGENT_COMM */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef AGENT_COMM
+#define AGENT_COMM
+
+#include <stdint.h>
+
+#include <common/macros.hpp>
+#include <lttng/lttng.h>
+
+/*
+ * Command value passed in the header.
+ */
+enum lttcomm_agent_command {
+ AGENT_CMD_LIST = 1,
+ AGENT_CMD_ENABLE = 2,
+ AGENT_CMD_DISABLE = 3,
+ AGENT_CMD_REG_DONE = 4, /* End registration process. */
+ AGENT_CMD_APP_CTX_ENABLE = 5,
+ AGENT_CMD_APP_CTX_DISABLE = 6,
+};
+
+/*
+ * Return codes from the agent.
+ */
+enum lttcomm_agent_ret_code {
+ /* Success, assumed to be the first entry */
+ AGENT_RET_CODE_SUCCESS = 1,
+ /* Invalid command */
+ AGENT_RET_CODE_INVALID = 2,
+ /* Unknown logger name */
+ AGENT_RET_CODE_UNKNOWN_NAME = 3,
+ AGENT_RET_CODE_NR,
+};
+
+/*
+ * Agent application communication header.
+ */
+struct lttcomm_agent_hdr {
+ uint64_t data_size; /* data size following this header */
+ uint32_t cmd; /* Enum of agent command. */
+ uint32_t cmd_version; /* command version */
+} LTTNG_PACKED;
+
+/*
+ * Enable event command payload. Will be immediately followed by the
+ * variable-length string representing the filter expression.
+ */
+struct lttcomm_agent_enable_event {
+ uint32_t loglevel_value;
+ uint32_t loglevel_type;
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ uint32_t filter_expression_length;
+} LTTNG_PACKED;
+
+/*
+ * Disable event command payload.
+ */
+struct lttcomm_agent_disable_event {
+ char name[LTTNG_SYMBOL_NAME_LEN];
+} LTTNG_PACKED;
+
+/*
+ * Generic reply coming from the agent.
+ */
+struct lttcomm_agent_generic_reply {
+ uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * List command reply header.
+ */
+struct lttcomm_agent_list_reply_hdr {
+ uint32_t ret_code;
+ uint32_t data_size;
+} LTTNG_PACKED;
+
+/*
+ * List command reply payload coming from the agent.
+ */
+struct lttcomm_agent_list_reply {
+ uint32_t nb_event;
+ /* List of event name each of them ending by a NULL byte. */
+ char payload[];
+} LTTNG_PACKED;
+
+#endif /* AGENT_COMM */
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <poll.h>
-#include <common/common.h>
-#include <common/time.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
+#include <common/compat/errno.hpp>
-#include "inet.h"
+#include "inet.hpp"
#define RECONNECT_DELAY 200 /* ms */
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTCOMM_INET_H
-#define _LTTCOMM_INET_H
-
-#include <limits.h>
-
-#include "sessiond-comm.h"
-
-/* See man tcp(7) for more detail about this value. */
-#define LTTCOMM_INET_PROC_SYN_RETRIES_PATH "/proc/sys/net/ipv4/tcp_syn_retries"
-#define LTTCOMM_INET_PROC_FIN_TIMEOUT_PATH "/proc/sys/net/ipv4/tcp_fin_timeout"
-
-/*
- * The timeout value of a connect() is computed with an algorithm inside the
- * kernel using the defined TCP SYN retries so the end value in time is
- * approximative. According to tcp(7) man page, a value of 5 is roughly 180
- * seconds of timeout. With that information, we've computed a factor of 36
- * (180/5) by considering that it grows linearly. This is of course uncertain
- * but this is the best approximation we can do at runtime.
- */
-#define LTTCOMM_INET_SYN_TIMEOUT_FACTOR 36
-
-/*
- * Maximum timeout value in seconds of a TCP connection for both send/recv and
- * connect operations.
- */
-LTTNG_EXPORT extern unsigned long lttcomm_inet_tcp_timeout;
-
-/* Stub */
-struct lttcomm_sock;
-
-/* Net family callback */
-extern int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type,
- int proto);
-
-extern struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_bind_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_close_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_connect_inet_sock(struct lttcomm_sock *sock);
-extern int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog);
-
-extern ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
- size_t len, int flags);
-extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock,
- const void *buf, size_t len, int flags);
-
-/* Initialize inet communication layer. */
-extern void lttcomm_inet_init(void);
-
-#endif /* _LTTCOMM_INET_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTCOMM_INET_H
+#define _LTTCOMM_INET_H
+
+#include <limits.h>
+
+#include "sessiond-comm.hpp"
+
+/* See man tcp(7) for more detail about this value. */
+#define LTTCOMM_INET_PROC_SYN_RETRIES_PATH "/proc/sys/net/ipv4/tcp_syn_retries"
+#define LTTCOMM_INET_PROC_FIN_TIMEOUT_PATH "/proc/sys/net/ipv4/tcp_fin_timeout"
+
+/*
+ * The timeout value of a connect() is computed with an algorithm inside the
+ * kernel using the defined TCP SYN retries so the end value in time is
+ * approximative. According to tcp(7) man page, a value of 5 is roughly 180
+ * seconds of timeout. With that information, we've computed a factor of 36
+ * (180/5) by considering that it grows linearly. This is of course uncertain
+ * but this is the best approximation we can do at runtime.
+ */
+#define LTTCOMM_INET_SYN_TIMEOUT_FACTOR 36
+
+/*
+ * Maximum timeout value in seconds of a TCP connection for both send/recv and
+ * connect operations.
+ */
+LTTNG_EXPORT extern unsigned long lttcomm_inet_tcp_timeout;
+
+/* Stub */
+struct lttcomm_sock;
+
+/* Net family callback */
+extern int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type,
+ int proto);
+
+extern struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_bind_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_close_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_connect_inet_sock(struct lttcomm_sock *sock);
+extern int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog);
+
+extern ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
+ size_t len, int flags);
+extern ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock,
+ const void *buf, size_t len, int flags);
+
+/* Initialize inet communication layer. */
+extern void lttcomm_inet_init(void);
+
+#endif /* _LTTCOMM_INET_H */
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <poll.h>
-#include <common/common.h>
-#include <common/time.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/time.hpp>
+#include <common/compat/errno.hpp>
-#include "inet6.h"
+#include "inet6.hpp"
#define RECONNECT_DELAY 200 /* ms */
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTCOMM_INET6_H
-#define _LTTCOMM_INET6_H
-
-#include <limits.h>
-
-#include "sessiond-comm.h"
-
-/* Stub */
-struct lttcomm_sock;
-
-/* Net family callback */
-extern int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type,
- int proto);
-
-extern struct lttcomm_sock *lttcomm_accept_inet6_sock(
- struct lttcomm_sock *sock);
-extern int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_close_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock);
-extern int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog);
-
-extern ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
- size_t len, int flags);
-extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock,
- const void *buf, size_t len, int flags);
-
-#endif /* _LTTCOMM_INET6_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTCOMM_INET6_H
+#define _LTTCOMM_INET6_H
+
+#include <limits.h>
+
+#include "sessiond-comm.hpp"
+
+/* Stub */
+struct lttcomm_sock;
+
+/* Net family callback */
+extern int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type,
+ int proto);
+
+extern struct lttcomm_sock *lttcomm_accept_inet6_sock(
+ struct lttcomm_sock *sock);
+extern int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_close_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock);
+extern int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog);
+
+extern ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
+ size_t len, int flags);
+extern ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock,
+ const void *buf, size_t len, int flags);
+
+#endif /* _LTTCOMM_INET6_H */
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2012 Julien Desfossez <julien.desfossez@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _RELAYD_COMM
-#define _RELAYD_COMM
-
-#include <limits.h>
-#include <stdint.h>
-
-#include <lttng/lttng.h>
-#include <common/defaults.h>
-#include <common/index/ctf-index.h>
-#include <common/macros.h>
-#include <common/uuid.h>
-#include <common/optional.h>
-
-#define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
-#define RELAYD_VERSION_COMM_MINOR VERSION_MINOR
-
-#define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4 64
-#define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255
-#define RELAYD_COMM_LTTNG_PATH_MAX 4096
-#define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN 264 /* 256 + 8 */
-
-/*
- * lttng-relayd communication header.
- */
-struct lttcomm_relayd_hdr {
- /* Circuit ID not used for now so always ignored */
- uint64_t circuit_id;
- uint64_t data_size; /* data size following this header */
- uint32_t cmd; /* enum lttcomm_relayd_command */
- uint32_t cmd_version; /* command version */
-} LTTNG_PACKED;
-
-/*
- * lttng-relayd data header.
- */
-struct lttcomm_relayd_data_hdr {
- /* Circuit ID not used for now so always ignored */
- uint64_t circuit_id;
- uint64_t stream_id; /* Stream ID known by the relayd */
- uint64_t net_seq_num; /* Network sequence number, per stream. */
- uint32_t data_size; /* data size following this header */
- uint32_t padding_size; /* Size of 0 padding the data */
-} LTTNG_PACKED;
-
-/*
- * Reply from a create session command.
- */
-struct lttcomm_relayd_status_session {
- uint64_t session_id;
- uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Used to add a stream on the relay daemon.
- */
-struct lttcomm_relayd_add_stream {
- char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
- char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
-} LTTNG_PACKED;
-
-/*
- * Used to add a stream on the relay daemon.
- * Protocol version 2.2
- */
-struct lttcomm_relayd_add_stream_2_2 {
- char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
- char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
- uint64_t tracefile_size;
- uint64_t tracefile_count;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_add_stream_2_11 {
- uint32_t channel_name_len;
- uint32_t pathname_len;
- uint64_t tracefile_size;
- uint64_t tracefile_count;
- uint64_t trace_chunk_id;
- char names[];
-} LTTNG_PACKED;
-
-/*
- * Answer from an add stream command.
- */
-struct lttcomm_relayd_status_stream {
- uint64_t handle;
- uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Used to return command code for command not needing special data.
- */
-struct lttcomm_relayd_generic_reply {
- uint32_t ret_code;
-} LTTNG_PACKED;
-
-/*
- * Version command.
- */
-struct lttcomm_relayd_version {
- uint32_t major;
- uint32_t minor;
-} LTTNG_PACKED;
-
-/*
- * Metadata payload used when metadata command is sent.
- */
-struct lttcomm_relayd_metadata_payload {
- uint64_t stream_id;
- uint32_t padding_size;
- char payload[];
-} LTTNG_PACKED;
-
-/*
- * Used to indicate that a specific stream id can now be closed.
- */
-struct lttcomm_relayd_close_stream {
- uint64_t stream_id;
- uint64_t last_net_seq_num; /* sequence number of last packet */
-} LTTNG_PACKED;
-
-/*
- * Used to test if for a given stream id the data is pending on the relayd side
- * for reading.
- */
-struct lttcomm_relayd_data_pending {
- uint64_t stream_id;
- uint64_t last_net_seq_num; /* Sequence number of the last packet */
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_begin_data_pending {
- uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_end_data_pending {
- uint64_t session_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_quiescent_control {
- uint64_t stream_id;
-} LTTNG_PACKED;
-
-/*
- * Index data.
- */
-struct lttcomm_relayd_index {
- uint64_t relay_stream_id;
- uint64_t net_seq_num;
- uint64_t packet_size;
- uint64_t content_size;
- uint64_t timestamp_begin;
- uint64_t timestamp_end;
- uint64_t events_discarded;
- uint64_t stream_id;
- /* 2.8+ */
- uint64_t stream_instance_id;
- uint64_t packet_seq_num;
-} LTTNG_PACKED;
-
-static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
-{
- if (major == 1) {
- switch (minor) {
- case 0:
- return offsetof(struct lttcomm_relayd_index, stream_id)
- + member_sizeof(struct lttcomm_relayd_index,
- stream_id);
- case 1:
- return offsetof(struct lttcomm_relayd_index, packet_seq_num)
- + member_sizeof(struct lttcomm_relayd_index,
- packet_seq_num);
- default:
- abort();
- }
- }
- abort();
-}
-
-/*
- * Create session in 2.4 adds additionnal parameters for live reading.
- */
-struct lttcomm_relayd_create_session_2_4 {
- char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4];
- char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4];
- uint32_t live_timer;
- uint32_t snapshot;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_session_2_11 {
- uint32_t session_name_len;
- uint32_t hostname_len;
- /* Optional, set to 0 to indicate it is not user-specified. */
- uint32_t base_path_len;
- uint32_t live_timer;
- uint8_t snapshot;
- uint8_t session_name_contains_creation_time;
- /* Sessiond instance UUID */
- lttng_uuid sessiond_uuid;
- /* Sessiond session id */
- uint64_t session_id;
- /* Session creation time, in seconds since UNIX Epoch. */
- uint64_t creation_time;
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id;
- /* Contains the session_name, hostname, base_path. */
- char names[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_session_reply_2_11 {
- struct lttcomm_relayd_status_session generic;
- /* Includes the '\0' terminator. */
- uint32_t output_path_length;
- char output_path[];
-} LTTNG_PACKED;
-
-/*
- * Used to ask the relay to reset the metadata trace file (regeneration).
- * Send the new version of the metadata (starts at 0).
- */
-struct lttcomm_relayd_reset_metadata {
- uint64_t stream_id;
- uint64_t version;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_stream_rotation_position {
- uint64_t stream_id;
- /*
- * Sequence number of the first packet belonging to the new
- * "destination" trace chunk to which the stream is rotating.
- *
- * Ignored for metadata streams.
- */
- uint64_t rotate_at_seq_num;
-} LTTNG_PACKED;
-
-/*
- * For certain releases, the LTTNG_PACKED annotation was missing on the
- * `new_chunk_id` field which causes padding to be added between the
- * "optional" structure's `is_set` and `value` fields.
- *
- * Three alignment cases are handled:
- * - `value` is aligned to the next byte boundary after `is_set`
- * no padding is produced, see
- * `struct lttcomm_relayd_rotate_streams_packed`,
- * - `value` is aligned to the next 4-byte boundary after `is_set`
- * (e.g. x86), 3 bytes of padding are produced, see
- * `struct lttcomm_relayd_rotate_streams_3_bytes_padding`,
- * - `value` is aligned to the next 8-byte boundary after `is_set`
- * (e.g. x86-64), 7 bytes of padding are produced, see
- * `struct lttcomm_relayd_rotate_streams_7_bytes_padding`.
- *
- * Note that since this structure's advertised size is used to determine
- * the size of the padding it includes, it can't be extended with new
- * optional fields. A new command would be needed.
- */
-struct lttcomm_relayd_rotate_streams {
- uint32_t stream_count;
- /*
- * Streams can be rotated outside of a chunk but not be parented to
- * a new chunk.
- *
- * Improperly packed, but left as-is for backwards compatibility
- * with unpatched relay daemons.
- */
- LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id;
- /* `stream_count` positions follow. */
- struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_packed {
- uint32_t stream_count;
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED new_chunk_id;
- struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_3_bytes_padding {
- uint32_t stream_count;
- struct {
- union {
- uint8_t is_set;
- uint32_t padding;
- };
- uint64_t value;
- } LTTNG_PACKED new_chunk_id;
- struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_rotate_streams_7_bytes_padding {
- uint32_t stream_count;
- struct {
- union {
- uint8_t is_set;
- uint64_t padding;
- };
- uint64_t value;
- } LTTNG_PACKED new_chunk_id;
- struct lttcomm_relayd_stream_rotation_position rotation_positions[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_create_trace_chunk {
- uint64_t chunk_id;
- /* Seconds since EPOCH. */
- uint64_t creation_timestamp;
- /* Includes trailing NULL. */
- uint32_t override_name_length;
- char override_name[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_close_trace_chunk {
- uint64_t chunk_id;
- /* Seconds since EPOCH. */
- uint64_t close_timestamp;
- /* enum lttng_trace_chunk_command_type */
- LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_close_trace_chunk_reply {
- struct lttcomm_relayd_generic_reply generic;
- /* Includes trailing NULL. */
- uint32_t path_length;
- char path[];
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_trace_chunk_exists {
- uint64_t chunk_id;
-} LTTNG_PACKED;
-
-struct lttcomm_relayd_trace_chunk_exists_reply {
- struct lttcomm_relayd_generic_reply generic;
- uint8_t trace_chunk_exists;
-} LTTNG_PACKED;
-
-enum lttcomm_relayd_configuration_flag {
- /* The relay daemon (2.12) is configured to allow clear operations. */
- LTTCOMM_RELAYD_CONFIGURATION_FLAG_CLEAR_ALLOWED = (1 << 0),
-};
-
-struct lttcomm_relayd_get_configuration {
- uint64_t query_flags;
-} LTTNG_PACKED;
-
-/*
- * Used to return a relay daemon's configuration in reply to the
- * RELAYD_GET_CONFIGURATION command.
- */
-struct lttcomm_relayd_get_configuration_reply {
- struct lttcomm_relayd_generic_reply generic;
- /* Set of lttcomm_relayd_configuration_flag. */
- uint64_t relayd_configuration_flags;
- /* Optional variable-length payload. */
- char payload[];
-} LTTNG_PACKED;
-
-#endif /* _RELAYD_COMM */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2012 Julien Desfossez <julien.desfossez@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _RELAYD_COMM
+#define _RELAYD_COMM
+
+#include <limits.h>
+#include <stdint.h>
+
+#include <lttng/lttng.h>
+#include <common/defaults.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/macros.hpp>
+#include <common/uuid.hpp>
+#include <common/optional.hpp>
+
+#define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
+#define RELAYD_VERSION_COMM_MINOR VERSION_MINOR
+
+#define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4 64
+#define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255
+#define RELAYD_COMM_LTTNG_PATH_MAX 4096
+#define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN 264 /* 256 + 8 */
+
+/*
+ * lttng-relayd communication header.
+ */
+struct lttcomm_relayd_hdr {
+ /* Circuit ID not used for now so always ignored */
+ uint64_t circuit_id;
+ uint64_t data_size; /* data size following this header */
+ uint32_t cmd; /* enum lttcomm_relayd_command */
+ uint32_t cmd_version; /* command version */
+} LTTNG_PACKED;
+
+/*
+ * lttng-relayd data header.
+ */
+struct lttcomm_relayd_data_hdr {
+ /* Circuit ID not used for now so always ignored */
+ uint64_t circuit_id;
+ uint64_t stream_id; /* Stream ID known by the relayd */
+ uint64_t net_seq_num; /* Network sequence number, per stream. */
+ uint32_t data_size; /* data size following this header */
+ uint32_t padding_size; /* Size of 0 padding the data */
+} LTTNG_PACKED;
+
+/*
+ * Reply from a create session command.
+ */
+struct lttcomm_relayd_status_session {
+ uint64_t session_id;
+ uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Used to add a stream on the relay daemon.
+ */
+struct lttcomm_relayd_add_stream {
+ char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
+ char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
+} LTTNG_PACKED;
+
+/*
+ * Used to add a stream on the relay daemon.
+ * Protocol version 2.2
+ */
+struct lttcomm_relayd_add_stream_2_2 {
+ char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
+ char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_add_stream_2_11 {
+ uint32_t channel_name_len;
+ uint32_t pathname_len;
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+ uint64_t trace_chunk_id;
+ char names[];
+} LTTNG_PACKED;
+
+/*
+ * Answer from an add stream command.
+ */
+struct lttcomm_relayd_status_stream {
+ uint64_t handle;
+ uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Used to return command code for command not needing special data.
+ */
+struct lttcomm_relayd_generic_reply {
+ uint32_t ret_code;
+} LTTNG_PACKED;
+
+/*
+ * Version command.
+ */
+struct lttcomm_relayd_version {
+ uint32_t major;
+ uint32_t minor;
+} LTTNG_PACKED;
+
+/*
+ * Metadata payload used when metadata command is sent.
+ */
+struct lttcomm_relayd_metadata_payload {
+ uint64_t stream_id;
+ uint32_t padding_size;
+ char payload[];
+} LTTNG_PACKED;
+
+/*
+ * Used to indicate that a specific stream id can now be closed.
+ */
+struct lttcomm_relayd_close_stream {
+ uint64_t stream_id;
+ uint64_t last_net_seq_num; /* sequence number of last packet */
+} LTTNG_PACKED;
+
+/*
+ * Used to test if for a given stream id the data is pending on the relayd side
+ * for reading.
+ */
+struct lttcomm_relayd_data_pending {
+ uint64_t stream_id;
+ uint64_t last_net_seq_num; /* Sequence number of the last packet */
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_begin_data_pending {
+ uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_end_data_pending {
+ uint64_t session_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_quiescent_control {
+ uint64_t stream_id;
+} LTTNG_PACKED;
+
+/*
+ * Index data.
+ */
+struct lttcomm_relayd_index {
+ uint64_t relay_stream_id;
+ uint64_t net_seq_num;
+ uint64_t packet_size;
+ uint64_t content_size;
+ uint64_t timestamp_begin;
+ uint64_t timestamp_end;
+ uint64_t events_discarded;
+ uint64_t stream_id;
+ /* 2.8+ */
+ uint64_t stream_instance_id;
+ uint64_t packet_seq_num;
+} LTTNG_PACKED;
+
+static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
+{
+ if (major == 1) {
+ switch (minor) {
+ case 0:
+ return offsetof(struct lttcomm_relayd_index, stream_id)
+ + member_sizeof(struct lttcomm_relayd_index,
+ stream_id);
+ case 1:
+ return offsetof(struct lttcomm_relayd_index, packet_seq_num)
+ + member_sizeof(struct lttcomm_relayd_index,
+ packet_seq_num);
+ default:
+ abort();
+ }
+ }
+ abort();
+}
+
+/*
+ * Create session in 2.4 adds additionnal parameters for live reading.
+ */
+struct lttcomm_relayd_create_session_2_4 {
+ char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4];
+ char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4];
+ uint32_t live_timer;
+ uint32_t snapshot;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_session_2_11 {
+ uint32_t session_name_len;
+ uint32_t hostname_len;
+ /* Optional, set to 0 to indicate it is not user-specified. */
+ uint32_t base_path_len;
+ uint32_t live_timer;
+ uint8_t snapshot;
+ uint8_t session_name_contains_creation_time;
+ /* Sessiond instance UUID */
+ lttng_uuid sessiond_uuid;
+ /* Sessiond session id */
+ uint64_t session_id;
+ /* Session creation time, in seconds since UNIX Epoch. */
+ uint64_t creation_time;
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id;
+ /* Contains the session_name, hostname, base_path. */
+ char names[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_session_reply_2_11 {
+ struct lttcomm_relayd_status_session generic;
+ /* Includes the '\0' terminator. */
+ uint32_t output_path_length;
+ char output_path[];
+} LTTNG_PACKED;
+
+/*
+ * Used to ask the relay to reset the metadata trace file (regeneration).
+ * Send the new version of the metadata (starts at 0).
+ */
+struct lttcomm_relayd_reset_metadata {
+ uint64_t stream_id;
+ uint64_t version;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_stream_rotation_position {
+ uint64_t stream_id;
+ /*
+ * Sequence number of the first packet belonging to the new
+ * "destination" trace chunk to which the stream is rotating.
+ *
+ * Ignored for metadata streams.
+ */
+ uint64_t rotate_at_seq_num;
+} LTTNG_PACKED;
+
+/*
+ * For certain releases, the LTTNG_PACKED annotation was missing on the
+ * `new_chunk_id` field which causes padding to be added between the
+ * "optional" structure's `is_set` and `value` fields.
+ *
+ * Three alignment cases are handled:
+ * - `value` is aligned to the next byte boundary after `is_set`
+ * no padding is produced, see
+ * `struct lttcomm_relayd_rotate_streams_packed`,
+ * - `value` is aligned to the next 4-byte boundary after `is_set`
+ * (e.g. x86), 3 bytes of padding are produced, see
+ * `struct lttcomm_relayd_rotate_streams_3_bytes_padding`,
+ * - `value` is aligned to the next 8-byte boundary after `is_set`
+ * (e.g. x86-64), 7 bytes of padding are produced, see
+ * `struct lttcomm_relayd_rotate_streams_7_bytes_padding`.
+ *
+ * Note that since this structure's advertised size is used to determine
+ * the size of the padding it includes, it can't be extended with new
+ * optional fields. A new command would be needed.
+ */
+struct lttcomm_relayd_rotate_streams {
+ uint32_t stream_count;
+ /*
+ * Streams can be rotated outside of a chunk but not be parented to
+ * a new chunk.
+ *
+ * Improperly packed, but left as-is for backwards compatibility
+ * with unpatched relay daemons.
+ */
+ LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id;
+ /* `stream_count` positions follow. */
+ struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_packed {
+ uint32_t stream_count;
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED new_chunk_id;
+ struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_3_bytes_padding {
+ uint32_t stream_count;
+ struct {
+ union {
+ uint8_t is_set;
+ uint32_t padding;
+ };
+ uint64_t value;
+ } LTTNG_PACKED new_chunk_id;
+ struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_rotate_streams_7_bytes_padding {
+ uint32_t stream_count;
+ struct {
+ union {
+ uint8_t is_set;
+ uint64_t padding;
+ };
+ uint64_t value;
+ } LTTNG_PACKED new_chunk_id;
+ struct lttcomm_relayd_stream_rotation_position rotation_positions[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_create_trace_chunk {
+ uint64_t chunk_id;
+ /* Seconds since EPOCH. */
+ uint64_t creation_timestamp;
+ /* Includes trailing NULL. */
+ uint32_t override_name_length;
+ char override_name[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_close_trace_chunk {
+ uint64_t chunk_id;
+ /* Seconds since EPOCH. */
+ uint64_t close_timestamp;
+ /* enum lttng_trace_chunk_command_type */
+ LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_close_trace_chunk_reply {
+ struct lttcomm_relayd_generic_reply generic;
+ /* Includes trailing NULL. */
+ uint32_t path_length;
+ char path[];
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_trace_chunk_exists {
+ uint64_t chunk_id;
+} LTTNG_PACKED;
+
+struct lttcomm_relayd_trace_chunk_exists_reply {
+ struct lttcomm_relayd_generic_reply generic;
+ uint8_t trace_chunk_exists;
+} LTTNG_PACKED;
+
+enum lttcomm_relayd_configuration_flag {
+ /* The relay daemon (2.12) is configured to allow clear operations. */
+ LTTCOMM_RELAYD_CONFIGURATION_FLAG_CLEAR_ALLOWED = (1 << 0),
+};
+
+struct lttcomm_relayd_get_configuration {
+ uint64_t query_flags;
+} LTTNG_PACKED;
+
+/*
+ * Used to return a relay daemon's configuration in reply to the
+ * RELAYD_GET_CONFIGURATION command.
+ */
+struct lttcomm_relayd_get_configuration_reply {
+ struct lttcomm_relayd_generic_reply generic;
+ /* Set of lttcomm_relayd_configuration_flag. */
+ uint64_t relayd_configuration_flags;
+ /* Optional variable-length payload. */
+ char payload[];
+} LTTNG_PACKED;
+
+#endif /* _RELAYD_COMM */
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
-#include "sessiond-comm.h"
+#include "sessiond-comm.hpp"
/* For Unix socket */
-#include <common/unix.h>
+#include <common/unix.hpp>
/* For Inet socket */
-#include "inet.h"
+#include "inet.hpp"
/* For Inet6 socket */
-#include "inet6.h"
+#include "inet6.hpp"
#define NETWORK_TIMEOUT_ENV "LTTNG_NETWORK_SOCKET_TIMEOUT"
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-/*
- * This header is meant for liblttng and libust internal use ONLY. These
- * declarations should NOT be considered stable API.
- */
-
-#ifndef _LTTNG_SESSIOND_COMM_H
-#define _LTTNG_SESSIOND_COMM_H
-
-#include <limits.h>
-#include <lttng/lttng.h>
-#include <lttng/snapshot-internal.h>
-#include <lttng/save-internal.h>
-#include <lttng/channel-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/rotate-internal.h>
-#include <common/compat/socket.h>
-#include <common/uri.h>
-#include <common/defaults.h>
-#include <common/uuid.h>
-#include <common/macros.h>
-#include <common/optional.h>
-
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <stdint.h>
-#include <sys/un.h>
-
-#include "inet.h"
-#include "inet6.h"
-#include <common/unix.h>
-
-/* Queue size of listen(2) */
-#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
-
-/* Maximum number of FDs that can be sent over a Unix socket */
-#if defined(__linux__)
-/* Based on the kernel's SCM_MAX_FD which is 253 since 2.6.38 (255 before) */
-#define LTTCOMM_MAX_SEND_FDS 253
-#else
-#define LTTCOMM_MAX_SEND_FDS 16
-#endif
-
-enum lttcomm_sessiond_command {
- /* Tracer command */
- LTTNG_ADD_CONTEXT = 0,
- /* LTTNG_CALIBRATE used to be here */
- LTTNG_DISABLE_CHANNEL = 2,
- LTTNG_DISABLE_EVENT = 3,
- LTTNG_LIST_SYSCALLS = 4,
- LTTNG_ENABLE_CHANNEL = 5,
- LTTNG_ENABLE_EVENT = 6,
- /* 7 */
- /* Session daemon command */
- /* 8 */
- LTTNG_DESTROY_SESSION = 9,
- LTTNG_LIST_CHANNELS = 10,
- LTTNG_LIST_DOMAINS = 11,
- LTTNG_LIST_EVENTS = 12,
- LTTNG_LIST_SESSIONS = 13,
- LTTNG_LIST_TRACEPOINTS = 14,
- LTTNG_REGISTER_CONSUMER = 15,
- LTTNG_START_TRACE = 16,
- LTTNG_STOP_TRACE = 17,
- LTTNG_LIST_TRACEPOINT_FIELDS = 18,
-
- /* Consumer */
- LTTNG_DISABLE_CONSUMER = 19,
- LTTNG_ENABLE_CONSUMER = 20,
- LTTNG_SET_CONSUMER_URI = 21,
- /* 22 */
- /* 23 */
- LTTNG_DATA_PENDING = 24,
- LTTNG_SNAPSHOT_ADD_OUTPUT = 25,
- LTTNG_SNAPSHOT_DEL_OUTPUT = 26,
- LTTNG_SNAPSHOT_LIST_OUTPUT = 27,
- LTTNG_SNAPSHOT_RECORD = 28,
- /* 29 */
- /* 30 */
- LTTNG_SAVE_SESSION = 31,
- LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE = 32,
- LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE = 33,
- LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY = 34,
- LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY = 35,
- LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET = 36,
- LTTNG_SET_SESSION_SHM_PATH = 40,
- LTTNG_REGENERATE_METADATA = 41,
- LTTNG_REGENERATE_STATEDUMP = 42,
- LTTNG_REGISTER_TRIGGER = 43,
- LTTNG_UNREGISTER_TRIGGER = 44,
- LTTNG_ROTATE_SESSION = 45,
- LTTNG_ROTATION_GET_INFO = 46,
- LTTNG_ROTATION_SET_SCHEDULE = 47,
- LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
- LTTNG_CREATE_SESSION_EXT = 49,
- LTTNG_CLEAR_SESSION = 50,
- LTTNG_LIST_TRIGGERS = 51,
- LTTNG_EXECUTE_ERROR_QUERY = 52,
-};
-
-static inline
-const char *lttcomm_sessiond_command_str(enum lttcomm_sessiond_command cmd)
-{
- switch (cmd) {
- case LTTNG_ADD_CONTEXT:
- return "LTTNG_ADD_CONTEXT";
- case LTTNG_DISABLE_CHANNEL:
- return "LTTNG_DISABLE_CHANNEL";
- case LTTNG_DISABLE_EVENT:
- return "LTTNG_DISABLE_EVENT";
- case LTTNG_LIST_SYSCALLS:
- return "LTTNG_LIST_SYSCALLS";
- case LTTNG_ENABLE_CHANNEL:
- return "LTTNG_ENABLE_CHANNEL";
- case LTTNG_ENABLE_EVENT:
- return "LTTNG_ENABLE_EVENT";
- case LTTNG_DESTROY_SESSION:
- return "LTTNG_DESTROY_SESSION";
- case LTTNG_LIST_CHANNELS:
- return "LTTNG_LIST_CHANNELS";
- case LTTNG_LIST_DOMAINS:
- return "LTTNG_LIST_DOMAINS";
- case LTTNG_LIST_EVENTS:
- return "LTTNG_LIST_EVENTS";
- case LTTNG_LIST_SESSIONS:
- return "LTTNG_LIST_SESSIONS";
- case LTTNG_LIST_TRACEPOINTS:
- return "LTTNG_LIST_TRACEPOINTS";
- case LTTNG_REGISTER_CONSUMER:
- return "LTTNG_REGISTER_CONSUMER";
- case LTTNG_START_TRACE:
- return "LTTNG_START_TRACE";
- case LTTNG_STOP_TRACE:
- return "LTTNG_STOP_TRACE";
- case LTTNG_LIST_TRACEPOINT_FIELDS:
- return "LTTNG_LIST_TRACEPOINT_FIELDS";
- case LTTNG_DISABLE_CONSUMER:
- return "LTTNG_DISABLE_CONSUMER";
- case LTTNG_ENABLE_CONSUMER:
- return "LTTNG_ENABLE_CONSUMER";
- case LTTNG_SET_CONSUMER_URI:
- return "LTTNG_SET_CONSUMER_URI";
- case LTTNG_DATA_PENDING:
- return "LTTNG_DATA_PENDING";
- case LTTNG_SNAPSHOT_ADD_OUTPUT:
- return "LTTNG_SNAPSHOT_ADD_OUTPUT";
- case LTTNG_SNAPSHOT_DEL_OUTPUT:
- return "LTTNG_SNAPSHOT_DEL_OUTPUT";
- case LTTNG_SNAPSHOT_LIST_OUTPUT:
- return "LTTNG_SNAPSHOT_LIST_OUTPUT";
- case LTTNG_SNAPSHOT_RECORD:
- return "LTTNG_SNAPSHOT_RECORD";
- case LTTNG_SAVE_SESSION:
- return "LTTNG_SAVE_SESSION";
- case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE:
- return "LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE";
- case LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE:
- return "LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE";
- case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY:
- return "LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY";
- case LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY:
- return "LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY";
- case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET:
- return "LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET";
- case LTTNG_SET_SESSION_SHM_PATH:
- return "LTTNG_SET_SESSION_SHM_PATH";
- case LTTNG_REGENERATE_METADATA:
- return "LTTNG_REGENERATE_METADATA";
- case LTTNG_REGENERATE_STATEDUMP:
- return "LTTNG_REGENERATE_STATEDUMP";
- case LTTNG_REGISTER_TRIGGER:
- return "LTTNG_REGISTER_TRIGGER";
- case LTTNG_UNREGISTER_TRIGGER:
- return "LTTNG_UNREGISTER_TRIGGER";
- case LTTNG_ROTATE_SESSION:
- return "LTTNG_ROTATE_SESSION";
- case LTTNG_ROTATION_GET_INFO:
- return "LTTNG_ROTATION_GET_INFO";
- case LTTNG_ROTATION_SET_SCHEDULE:
- return "LTTNG_ROTATION_SET_SCHEDULE";
- case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
- return "LTTNG_SESSION_LIST_ROTATION_SCHEDULES";
- case LTTNG_CREATE_SESSION_EXT:
- return "LTTNG_CREATE_SESSION_EXT";
- case LTTNG_CLEAR_SESSION:
- return "LTTNG_CLEAR_SESSION";
- case LTTNG_LIST_TRIGGERS:
- return "LTTNG_LIST_TRIGGERS";
- case LTTNG_EXECUTE_ERROR_QUERY:
- return "LTTNG_EXECUTE_ERROR_QUERY";
- default:
- abort();
- }
-}
-
-enum lttcomm_relayd_command {
- RELAYD_ADD_STREAM = 1,
- RELAYD_CREATE_SESSION = 2,
- RELAYD_START_DATA = 3,
- RELAYD_UPDATE_SYNC_INFO = 4,
- RELAYD_VERSION = 5,
- RELAYD_SEND_METADATA = 6,
- RELAYD_CLOSE_STREAM = 7,
- RELAYD_DATA_PENDING = 8,
- RELAYD_QUIESCENT_CONTROL = 9,
- RELAYD_BEGIN_DATA_PENDING = 10,
- RELAYD_END_DATA_PENDING = 11,
- RELAYD_ADD_INDEX = 12,
- RELAYD_SEND_INDEX = 13,
- RELAYD_CLOSE_INDEX = 14,
- /* Live-reading commands (2.4+). */
- RELAYD_LIST_SESSIONS = 15,
- /* All streams of the channel have been sent to the relayd (2.4+). */
- RELAYD_STREAMS_SENT = 16,
- /* Ask the relay to reset the metadata trace file (2.8+) */
- RELAYD_RESET_METADATA = 17,
- /* Ask the relay to rotate a set of stream files (2.11+) */
- RELAYD_ROTATE_STREAMS = 18,
- /* Ask the relay to create a trace chunk (2.11+) */
- RELAYD_CREATE_TRACE_CHUNK = 19,
- /* Ask the relay to close a trace chunk (2.11+) */
- RELAYD_CLOSE_TRACE_CHUNK = 20,
- /* Ask the relay whether a trace chunk exists (2.11+) */
- RELAYD_TRACE_CHUNK_EXISTS = 21,
- /* Get the current configuration of a relayd peer (2.12+) */
- RELAYD_GET_CONFIGURATION = 22,
-
- /* Feature branch specific commands start at 10000. */
-};
-
-static inline
-const char *lttcomm_relayd_command_str(lttcomm_relayd_command cmd)
-{
- switch (cmd) {
- case RELAYD_ADD_STREAM:
- return "RELAYD_ADD_STREAM";
- case RELAYD_CREATE_SESSION:
- return "RELAYD_CREATE_SESSION";
- case RELAYD_START_DATA:
- return "RELAYD_START_DATA";
- case RELAYD_UPDATE_SYNC_INFO:
- return "RELAYD_UPDATE_SYNC_INFO";
- case RELAYD_VERSION:
- return "RELAYD_VERSION";
- case RELAYD_SEND_METADATA:
- return "RELAYD_SEND_METADATA";
- case RELAYD_CLOSE_STREAM:
- return "RELAYD_CLOSE_STREAM";
- case RELAYD_DATA_PENDING:
- return "RELAYD_DATA_PENDING";
- case RELAYD_QUIESCENT_CONTROL:
- return "RELAYD_QUIESCENT_CONTROL";
- case RELAYD_BEGIN_DATA_PENDING:
- return "RELAYD_BEGIN_DATA_PENDING";
- case RELAYD_END_DATA_PENDING:
- return "RELAYD_END_DATA_PENDING";
- case RELAYD_ADD_INDEX:
- return "RELAYD_ADD_INDEX";
- case RELAYD_SEND_INDEX:
- return "RELAYD_SEND_INDEX";
- case RELAYD_CLOSE_INDEX:
- return "RELAYD_CLOSE_INDEX";
- case RELAYD_LIST_SESSIONS:
- return "RELAYD_LIST_SESSIONS";
- case RELAYD_STREAMS_SENT:
- return "RELAYD_STREAMS_SENT";
- case RELAYD_RESET_METADATA:
- return "RELAYD_RESET_METADATA";
- case RELAYD_ROTATE_STREAMS:
- return "RELAYD_ROTATE_STREAMS";
- case RELAYD_CREATE_TRACE_CHUNK:
- return "RELAYD_CREATE_TRACE_CHUNK";
- case RELAYD_CLOSE_TRACE_CHUNK:
- return "RELAYD_CLOSE_TRACE_CHUNK";
- case RELAYD_TRACE_CHUNK_EXISTS:
- return "RELAYD_TRACE_CHUNK_EXISTS";
- case RELAYD_GET_CONFIGURATION:
- return "RELAYD_GET_CONFIGURATION";
- default:
- abort();
- }
-}
-
-/*
- * lttcomm error code.
- */
-enum lttcomm_return_code {
- LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
- /*
- * Some code paths use -1 to express an error, others
- * negate this consumer return code. Starting codes at
- * 100 ensures there is no mix-up between this error value
- * and legitimate status codes.
- */
- LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 100, /* Command socket ready */
- LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */
- LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */
- LTTCOMM_CONSUMERD_ERROR_RECV_CMD, /* Error on receiving command */
- LTTCOMM_CONSUMERD_POLL_ERROR, /* Error in polling thread */
- LTTCOMM_CONSUMERD_POLL_NVAL, /* Poll on closed fd */
- LTTCOMM_CONSUMERD_POLL_HUP, /* All fds have hungup */
- LTTCOMM_CONSUMERD_EXIT_SUCCESS, /* Consumerd exiting normally */
- LTTCOMM_CONSUMERD_EXIT_FAILURE, /* Consumerd exiting on error */
- LTTCOMM_CONSUMERD_OUTFD_ERROR, /* Error opening the tracefile */
- LTTCOMM_CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
- LTTCOMM_CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
- LTTCOMM_CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
- LTTCOMM_CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
- LTTCOMM_CONSUMERD_ENOMEM, /* Consumer is out of memory */
- LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
- LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
- LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
- LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
- LTTCOMM_CONSUMERD_CHAN_NOT_FOUND, /* Channel not found. */
- LTTCOMM_CONSUMERD_ALREADY_SET, /* Resource already set. */
- LTTCOMM_CONSUMERD_ROTATION_FAIL, /* Rotation has failed. */
- LTTCOMM_CONSUMERD_SNAPSHOT_FAILED, /* snapshot has failed. */
- LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED,/* Trace chunk creation failed. */
- LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED, /* Trace chunk close failed. */
- LTTCOMM_CONSUMERD_INVALID_PARAMETERS, /* Invalid parameters. */
- LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_LOCAL, /* Trace chunk exists on consumer daemon. */
- LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE,/* Trace chunk exists on relay daemon. */
- LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK, /* Unknown trace chunk. */
- LTTCOMM_CONSUMERD_RELAYD_CLEAR_DISALLOWED, /* Relayd does not accept clear command. */
- LTTCOMM_CONSUMERD_UNKNOWN_ERROR, /* Unknown error. */
-
- /* MUST be last element */
- LTTCOMM_NR, /* Last element */
-};
-
-/* lttng socket protocol. */
-enum lttcomm_sock_proto {
- LTTCOMM_SOCK_UDP,
- LTTCOMM_SOCK_TCP,
-};
-
-/*
- * Index in the net_families array below. Please keep in sync!
- */
-enum lttcomm_sock_domain {
- LTTCOMM_INET = 0,
- LTTCOMM_INET6 = 1,
-};
-
-enum lttcomm_metadata_command {
- LTTCOMM_METADATA_REQUEST = 1,
-};
-
-/*
- * Commands sent from the consumerd to the sessiond to request if new metadata
- * is available. This message is used to find the per UID _or_ per PID registry
- * for the channel key. For per UID lookup, the triplet
- * bits_per_long/uid/session_id is used. On lookup failure, we search for the
- * per PID registry indexed by session id ignoring the other values.
- */
-struct lttcomm_metadata_request_msg {
- uint64_t session_id; /* Tracing session id */
- uint64_t session_id_per_pid; /* Tracing session id for per-pid */
- uint32_t bits_per_long; /* Consumer ABI */
- uint32_t uid;
- uint64_t key; /* Metadata channel key. */
-} LTTNG_PACKED;
-
-struct lttcomm_sockaddr {
- enum lttcomm_sock_domain type;
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } addr;
-};
-
-struct lttcomm_sock {
- int32_t fd;
- enum lttcomm_sock_proto proto;
- struct lttcomm_sockaddr sockaddr;
- const struct lttcomm_proto_ops *ops;
-};
-
-/*
- * Relayd sock. Adds the protocol version to use for the communications with
- * the relayd.
- */
-struct lttcomm_relayd_sock {
- struct lttcomm_sock sock;
- uint32_t major;
- uint32_t minor;
-};
-
-struct lttcomm_net_family {
- int family;
- int (*create) (struct lttcomm_sock *sock, int type, int proto);
-};
-
-struct lttcomm_proto_ops {
- int (*bind) (struct lttcomm_sock *sock);
- int (*close) (struct lttcomm_sock *sock);
- int (*connect) (struct lttcomm_sock *sock);
- struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
- int (*listen) (struct lttcomm_sock *sock, int backlog);
- ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
- int flags);
- ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
- size_t len, int flags);
-};
-
-struct process_attr_integral_value_comm {
- union {
- int64_t _signed;
- uint64_t _unsigned;
- } u;
-} LTTNG_PACKED;
-
-/*
- * Data structure received from lttng client to session daemon.
- */
-struct lttcomm_session_msg {
- uint32_t cmd_type; /* enum lttcomm_sessiond_command */
- struct lttng_session session;
- struct lttng_domain domain;
- union {
- /* Event data */
- struct {
- char channel_name[LTTNG_SYMBOL_NAME_LEN];
- uint32_t length;
- } LTTNG_PACKED enable;
- struct {
- char channel_name[LTTNG_SYMBOL_NAME_LEN];
- uint32_t length;
- } LTTNG_PACKED disable;
- /* Create channel */
- struct {
- uint32_t length;
- } LTTNG_PACKED channel;
- /* Context */
- struct {
- char channel_name[LTTNG_SYMBOL_NAME_LEN];
- uint32_t length;
- } LTTNG_PACKED context;
- /* Use by register_consumer */
- struct {
- char path[PATH_MAX];
- } LTTNG_PACKED reg;
- /* List */
- struct {
- char channel_name[LTTNG_SYMBOL_NAME_LEN];
- } LTTNG_PACKED list;
- struct lttng_calibrate calibrate;
- /* Used by the set_consumer_url and used by create_session also call */
- struct {
- /* Number of lttng_uri following */
- uint32_t size;
- } LTTNG_PACKED uri;
- struct {
- struct lttng_snapshot_output output;
- } LTTNG_PACKED snapshot_output;
- struct {
- uint32_t wait;
- struct lttng_snapshot_output output;
- } LTTNG_PACKED snapshot_record;
- struct {
- uint32_t nb_uri;
- unsigned int timer_interval; /* usec */
- } LTTNG_PACKED session_live;
- struct {
- struct lttng_save_session_attr attr;
- } LTTNG_PACKED save_session;
- struct {
- char shm_path[PATH_MAX];
- } LTTNG_PACKED set_shm_path;
- struct {
- /* enum lttng_process_attr */
- int32_t process_attr;
- /* enum lttng_process_attr_value_type */
- int32_t value_type;
-
- struct process_attr_integral_value_comm integral_value;
- /*
- * For user/group names, a variable length,
- * zero-terminated, string of length 'name_len'
- * (including the terminator) follows.
- *
- * integral_value should not be used in those cases.
- */
- uint32_t name_len;
- } LTTNG_PACKED process_attr_tracker_add_remove_include_value;
- struct {
- /* enum lttng_process_attr */
- int32_t process_attr;
- } LTTNG_PACKED process_attr_tracker_get_inclusion_set;
- struct {
- /* enum lttng_process_attr */
- int32_t process_attr;
- } LTTNG_PACKED process_attr_tracker_get_tracking_policy;
- struct {
- /* enum lttng_process_attr */
- int32_t process_attr;
- /* enum lttng_tracking_policy */
- int32_t tracking_policy;
- } LTTNG_PACKED process_attr_tracker_set_tracking_policy;
- struct {
- uint32_t length;
- uint8_t is_trigger_anonymous;
- } LTTNG_PACKED trigger;
- struct {
- uint32_t length;
- } LTTNG_PACKED error_query;
- struct {
- uint64_t rotation_id;
- } LTTNG_PACKED get_rotation_info;
- struct {
- /* enum lttng_rotation_schedule_type */
- uint8_t type;
- /*
- * If set == 1, set schedule to value, if set == 0,
- * clear this schedule type.
- */
- uint8_t set;
- uint64_t value;
- } LTTNG_PACKED rotation_set_schedule;
- struct {
- /*
- * Includes the null-terminator.
- * Must be an absolute path.
- *
- * Size bounded by LTTNG_PATH_MAX.
- */
- uint16_t home_dir_size;
- uint64_t session_descriptor_size;
- /* An lttng_session_descriptor follows. */
- } LTTNG_PACKED create_session;
- } u;
- /* Count of fds sent. */
- uint32_t fd_count;
-} LTTNG_PACKED;
-
-#define LTTNG_FILTER_MAX_LEN 65536
-#define LTTNG_SESSION_DESCRIPTOR_MAX_LEN 65536
-
-/*
- * Filter bytecode data. The reloc table is located at the end of the
- * bytecode. It is made of tuples: (uint16_t, var. len. string). It
- * starts at reloc_table_offset.
- */
-#define LTTNG_FILTER_PADDING 32
-struct lttng_bytecode {
- uint32_t len; /* len of data */
- uint32_t reloc_table_offset;
- uint64_t seqnum;
- char padding[LTTNG_FILTER_PADDING];
- char data[0];
-} LTTNG_PACKED;
-
-/*
- * Event exclusion data. At the end of the structure, there will actually
- * by zero or more names, where the actual number of names is given by
- * the 'count' item of the structure.
- */
-#define LTTNG_EVENT_EXCLUSION_PADDING 32
-struct lttng_event_exclusion {
- uint32_t count;
- char padding[LTTNG_EVENT_EXCLUSION_PADDING];
- char names[][LTTNG_SYMBOL_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
- ((_exclusion)->names[_i])
-
-/*
- * Listing command header.
- */
-struct lttcomm_list_command_header {
- /* Number of elements */
- uint32_t count;
-} LTTNG_PACKED;
-
-/*
- * Event extended info header. This is the structure preceding each
- * extended info data.
- */
-struct lttcomm_event_extended_header {
- /*
- * Size of filter string immediately following this header.
- * This size includes the terminal null character.
- */
- uint32_t filter_len;
-
- /*
- * Number of exclusion names, immediately following the filter
- * string. Each exclusion name has a fixed length of
- * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
- * character.
- */
- uint32_t nb_exclusions;
-
- /*
- * Size of the event's userspace probe location (if applicable).
- */
- uint32_t userspace_probe_location_len;
-} LTTNG_PACKED;
-
-/*
- * Command header of the reply to an LTTNG_DESTROY_SESSION command.
- */
-struct lttcomm_session_destroy_command_header {
- /* enum lttng_session */
- int32_t rotation_state;
-};
-
-/*
- * tracker command header.
- */
-struct lttcomm_tracker_command_header {
- uint32_t nb_tracker_id;
-} LTTNG_PACKED;
-
-/*
- * Data structure for the response from sessiond to the lttng client.
- */
-struct lttcomm_lttng_msg {
- uint32_t cmd_type; /* enum lttcomm_sessiond_command */
- uint32_t ret_code; /* enum lttcomm_return_code */
- uint32_t pid; /* pid_t */
- uint32_t cmd_header_size;
- uint32_t data_size;
- uint32_t fd_count;
-} LTTNG_PACKED;
-
-struct lttcomm_lttng_output_id {
- uint32_t id;
-} LTTNG_PACKED;
-
-/*
- * lttcomm_consumer_msg is the message sent from sessiond to consumerd
- * to either add a channel, add a stream, update a stream, or stop
- * operation.
- */
-struct lttcomm_consumer_msg {
- uint32_t cmd_type; /* enum lttng_consumer_command */
- union {
- struct {
- uint64_t channel_key;
- uint64_t session_id;
- /* ID of the session's current trace chunk. */
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
- char pathname[PATH_MAX];
- uint64_t relayd_id;
- /* nb_init_streams is the number of streams open initially. */
- uint32_t nb_init_streams;
- char name[LTTNG_SYMBOL_NAME_LEN];
- /* Use splice or mmap to consume this fd */
- enum lttng_event_output output;
- int type; /* Per cpu or metadata. */
- uint64_t tracefile_size; /* bytes */
- uint32_t tracefile_count; /* number of tracefiles */
- /* If the channel's streams have to be monitored or not. */
- uint32_t monitor;
- /* timer to check the streams usage in live mode (usec). */
- unsigned int live_timer_interval;
- /* is part of a live session */
- uint8_t is_live;
- /* timer to sample a channel's positions (usec). */
- unsigned int monitor_timer_interval;
- } LTTNG_PACKED channel; /* Only used by Kernel. */
- struct {
- uint64_t stream_key;
- uint64_t channel_key;
- int32_t cpu; /* On which CPU this stream is assigned. */
- /* Tells the consumer if the stream should be or not monitored. */
- uint32_t no_monitor;
- } LTTNG_PACKED stream; /* Only used by Kernel. */
- struct {
- uint64_t net_index;
- enum lttng_stream_type type;
- uint32_t major;
- uint32_t minor;
- uint8_t relayd_socket_protocol;
- /* Tracing session id associated to the relayd. */
- uint64_t session_id;
- /* Relayd session id, only used with control socket. */
- uint64_t relayd_session_id;
- } LTTNG_PACKED relayd_sock;
- struct {
- uint64_t net_seq_idx;
- } LTTNG_PACKED destroy_relayd;
- struct {
- uint64_t session_id;
- } LTTNG_PACKED data_pending;
- struct {
- uint64_t subbuf_size; /* bytes */
- uint64_t num_subbuf; /* power of 2 */
- int32_t overwrite; /* 1: overwrite, 0: discard */
- uint32_t switch_timer_interval; /* usec */
- uint32_t read_timer_interval; /* usec */
- unsigned int live_timer_interval; /* usec */
- uint8_t is_live; /* is part of a live session */
- uint32_t monitor_timer_interval; /* usec */
- int32_t output; /* splice, mmap */
- int32_t type; /* metadata or per_cpu */
- uint64_t session_id; /* Tracing session id */
- char pathname[PATH_MAX]; /* Channel file path. */
- char name[LTTNG_SYMBOL_NAME_LEN]; /* Channel name. */
- /* Credentials used to open the UST buffer shared mappings. */
- struct {
- uint32_t uid;
- uint32_t gid;
- } LTTNG_PACKED buffer_credentials;
- uint64_t relayd_id; /* Relayd id if apply. */
- uint64_t key; /* Unique channel key. */
- /* ID of the session's current trace chunk. */
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
- unsigned char uuid[LTTNG_UUID_LEN]; /* uuid for ust tracer. */
- uint32_t chan_id; /* Channel ID on the tracer side. */
- uint64_t tracefile_size; /* bytes */
- uint32_t tracefile_count; /* number of tracefiles */
- uint64_t session_id_per_pid; /* Per-pid session ID. */
- /* Tells the consumer if the stream should be or not monitored. */
- uint32_t monitor;
- /*
- * For UST per UID buffers, this is the application UID of the
- * channel. This can be different from the user UID requesting the
- * channel creation and used for the rights on the stream file
- * because the application can be in the tracing for instance.
- */
- uint32_t ust_app_uid;
- int64_t blocking_timeout;
- char root_shm_path[PATH_MAX];
- char shm_path[PATH_MAX];
- } LTTNG_PACKED ask_channel;
- struct {
- uint64_t key;
- } LTTNG_PACKED get_channel;
- struct {
- uint64_t key;
- } LTTNG_PACKED destroy_channel;
- struct {
- uint64_t key; /* Metadata channel key. */
- uint64_t target_offset; /* Offset in the consumer */
- uint64_t len; /* Length of metadata to be received. */
- uint64_t version; /* Version of the metadata. */
- } LTTNG_PACKED push_metadata;
- struct {
- uint64_t key; /* Metadata channel key. */
- } LTTNG_PACKED close_metadata;
- struct {
- uint64_t key; /* Metadata channel key. */
- } LTTNG_PACKED setup_metadata;
- struct {
- uint64_t key; /* Channel key. */
- } LTTNG_PACKED flush_channel;
- struct {
- uint64_t key; /* Channel key. */
- } LTTNG_PACKED clear_quiescent_channel;
- struct {
- char pathname[PATH_MAX];
- /* Indicate if the snapshot goes on the relayd or locally. */
- uint32_t use_relayd;
- uint32_t metadata; /* This a metadata snapshot. */
- uint64_t relayd_id; /* Relayd id if apply. */
- uint64_t key;
- uint64_t nb_packets_per_stream;
- } LTTNG_PACKED snapshot_channel;
- struct {
- uint64_t channel_key;
- uint64_t net_seq_idx;
- } LTTNG_PACKED sent_streams;
- struct {
- uint64_t session_id;
- uint64_t channel_key;
- } LTTNG_PACKED discarded_events;
- struct {
- uint64_t session_id;
- uint64_t channel_key;
- } LTTNG_PACKED lost_packets;
- struct {
- uint64_t session_id;
- } LTTNG_PACKED regenerate_metadata;
- struct {
- uint32_t metadata; /* This is a metadata channel. */
- uint64_t relayd_id; /* Relayd id if apply. */
- uint64_t key;
- } LTTNG_PACKED rotate_channel;
- struct {
- uint64_t session_id;
- uint64_t chunk_id;
- } LTTNG_PACKED check_rotation_pending_local;
- struct {
- uint64_t relayd_id;
- uint64_t session_id;
- uint64_t chunk_id;
- } LTTNG_PACKED check_rotation_pending_relay;
- struct {
- /*
- * Relayd id, if applicable (remote).
- *
- * A directory file descriptor referring to the chunk's
- * output folder is transmitted if the chunk is local
- * (relayd_id unset).
- *
- * `override_name` is left NULL (all-zeroes) if the
- * chunk's name is not overridden.
- */
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
- char override_name[LTTNG_NAME_MAX];
- uint64_t session_id;
- uint64_t chunk_id;
- uint64_t creation_timestamp;
- LTTNG_OPTIONAL_COMM(struct {
- uint32_t uid;
- uint32_t gid;
- } LTTNG_PACKED ) LTTNG_PACKED credentials;
- } LTTNG_PACKED create_trace_chunk;
- struct {
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
- uint64_t session_id;
- uint64_t chunk_id;
- uint64_t close_timestamp;
- /* enum lttng_trace_chunk_command_type */
- LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
- } LTTNG_PACKED close_trace_chunk;
- struct {
- LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
- uint64_t session_id;
- uint64_t chunk_id;
- } LTTNG_PACKED trace_chunk_exists;
- struct {
- lttng_uuid sessiond_uuid;
- } LTTNG_PACKED init;
- struct {
- uint64_t key;
- } LTTNG_PACKED clear_channel;
- struct {
- uint64_t key;
- } LTTNG_PACKED open_channel_packets;
- } u;
-} LTTNG_PACKED;
-
-/*
- * Channel monitoring message returned to the session daemon on every
- * monitor timer expiration.
- */
-struct lttcomm_consumer_channel_monitor_msg {
- /* Key of the sampled channel. */
- uint64_t key;
- /*
- * Lowest and highest usage (bytes) at the moment the sample was taken.
- */
- uint64_t lowest, highest;
- /*
- * Sum of all the consumed positions for a channel.
- */
- uint64_t total_consumed;
-} LTTNG_PACKED;
-
-/*
- * Status message returned to the sessiond after a received command.
- */
-struct lttcomm_consumer_status_msg {
- enum lttcomm_return_code ret_code;
-} LTTNG_PACKED;
-
-struct lttcomm_consumer_status_channel {
- enum lttcomm_return_code ret_code;
- uint64_t key;
- unsigned int stream_count;
-} LTTNG_PACKED;
-
-struct lttcomm_consumer_close_trace_chunk_reply {
- enum lttcomm_return_code ret_code;
- uint32_t path_length;
- char path[];
-};
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-#include <lttng/ust-abi.h>
-
-/*
- * Data structure for the commands sent from sessiond to UST.
- */
-struct lttcomm_ust_msg {
- uint32_t handle;
- uint32_t cmd;
- union {
- struct lttng_ust_abi_channel channel;
- struct lttng_ust_abi_stream stream;
- struct lttng_ust_abi_event event;
- struct lttng_ust_abi_context context;
- struct lttng_ust_abi_tracer_version version;
- } u;
-} LTTNG_PACKED;
-
-/*
- * Data structure for the response from UST to the session daemon.
- * cmd_type is sent back in the reply for validation.
- */
-struct lttcomm_ust_reply {
- uint32_t handle;
- uint32_t cmd;
- uint32_t ret_code; /* enum lttcomm_return_code */
- uint32_t ret_val; /* return value */
- union {
- struct {
- uint64_t memory_map_size;
- } LTTNG_PACKED channel;
- struct {
- uint64_t memory_map_size;
- } LTTNG_PACKED stream;
- struct lttng_ust_abi_tracer_version version;
- } u;
-} LTTNG_PACKED;
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
-
-int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
- const char *ip, unsigned int port);
-int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
- const char *ip, unsigned int port);
-
-struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
-int lttcomm_populate_sock_from_open_socket(struct lttcomm_sock *sock,
- int fd,
- enum lttcomm_sock_proto protocol);
-int lttcomm_create_sock(struct lttcomm_sock *sock);
-struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
-void lttcomm_destroy_sock(struct lttcomm_sock *sock);
-struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
-void lttcomm_copy_sock(struct lttcomm_sock *dst,
- struct lttcomm_sock *src);
-
-/* Relayd socket object. */
-struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
- struct lttng_uri *uri, uint32_t major, uint32_t minor);
-
-int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
-int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
-
-int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
- uint16_t *port);
-/*
- * Set a port to an lttcomm_sock. This will have no effect is the socket is
- * already bound.
- */
-int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
-
-void lttcomm_init(void);
-/* Get network timeout, in milliseconds */
-unsigned long lttcomm_get_network_timeout(void);
-
-#endif /* _LTTNG_SESSIOND_COMM_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY. These
+ * declarations should NOT be considered stable API.
+ */
+
+#ifndef _LTTNG_SESSIOND_COMM_H
+#define _LTTNG_SESSIOND_COMM_H
+
+#include <limits.h>
+#include <lttng/lttng.h>
+#include <lttng/snapshot-internal.hpp>
+#include <lttng/save-internal.hpp>
+#include <lttng/channel-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <common/compat/socket.hpp>
+#include <common/uri.hpp>
+#include <common/defaults.hpp>
+#include <common/uuid.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <sys/un.h>
+
+#include "inet.hpp"
+#include "inet6.hpp"
+#include <common/unix.hpp>
+
+/* Queue size of listen(2) */
+#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
+
+/* Maximum number of FDs that can be sent over a Unix socket */
+#if defined(__linux__)
+/* Based on the kernel's SCM_MAX_FD which is 253 since 2.6.38 (255 before) */
+#define LTTCOMM_MAX_SEND_FDS 253
+#else
+#define LTTCOMM_MAX_SEND_FDS 16
+#endif
+
+enum lttcomm_sessiond_command {
+ /* Tracer command */
+ LTTNG_ADD_CONTEXT = 0,
+ /* LTTNG_CALIBRATE used to be here */
+ LTTNG_DISABLE_CHANNEL = 2,
+ LTTNG_DISABLE_EVENT = 3,
+ LTTNG_LIST_SYSCALLS = 4,
+ LTTNG_ENABLE_CHANNEL = 5,
+ LTTNG_ENABLE_EVENT = 6,
+ /* 7 */
+ /* Session daemon command */
+ /* 8 */
+ LTTNG_DESTROY_SESSION = 9,
+ LTTNG_LIST_CHANNELS = 10,
+ LTTNG_LIST_DOMAINS = 11,
+ LTTNG_LIST_EVENTS = 12,
+ LTTNG_LIST_SESSIONS = 13,
+ LTTNG_LIST_TRACEPOINTS = 14,
+ LTTNG_REGISTER_CONSUMER = 15,
+ LTTNG_START_TRACE = 16,
+ LTTNG_STOP_TRACE = 17,
+ LTTNG_LIST_TRACEPOINT_FIELDS = 18,
+
+ /* Consumer */
+ LTTNG_DISABLE_CONSUMER = 19,
+ LTTNG_ENABLE_CONSUMER = 20,
+ LTTNG_SET_CONSUMER_URI = 21,
+ /* 22 */
+ /* 23 */
+ LTTNG_DATA_PENDING = 24,
+ LTTNG_SNAPSHOT_ADD_OUTPUT = 25,
+ LTTNG_SNAPSHOT_DEL_OUTPUT = 26,
+ LTTNG_SNAPSHOT_LIST_OUTPUT = 27,
+ LTTNG_SNAPSHOT_RECORD = 28,
+ /* 29 */
+ /* 30 */
+ LTTNG_SAVE_SESSION = 31,
+ LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE = 32,
+ LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE = 33,
+ LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY = 34,
+ LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY = 35,
+ LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET = 36,
+ LTTNG_SET_SESSION_SHM_PATH = 40,
+ LTTNG_REGENERATE_METADATA = 41,
+ LTTNG_REGENERATE_STATEDUMP = 42,
+ LTTNG_REGISTER_TRIGGER = 43,
+ LTTNG_UNREGISTER_TRIGGER = 44,
+ LTTNG_ROTATE_SESSION = 45,
+ LTTNG_ROTATION_GET_INFO = 46,
+ LTTNG_ROTATION_SET_SCHEDULE = 47,
+ LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
+ LTTNG_CREATE_SESSION_EXT = 49,
+ LTTNG_CLEAR_SESSION = 50,
+ LTTNG_LIST_TRIGGERS = 51,
+ LTTNG_EXECUTE_ERROR_QUERY = 52,
+};
+
+static inline
+const char *lttcomm_sessiond_command_str(enum lttcomm_sessiond_command cmd)
+{
+ switch (cmd) {
+ case LTTNG_ADD_CONTEXT:
+ return "LTTNG_ADD_CONTEXT";
+ case LTTNG_DISABLE_CHANNEL:
+ return "LTTNG_DISABLE_CHANNEL";
+ case LTTNG_DISABLE_EVENT:
+ return "LTTNG_DISABLE_EVENT";
+ case LTTNG_LIST_SYSCALLS:
+ return "LTTNG_LIST_SYSCALLS";
+ case LTTNG_ENABLE_CHANNEL:
+ return "LTTNG_ENABLE_CHANNEL";
+ case LTTNG_ENABLE_EVENT:
+ return "LTTNG_ENABLE_EVENT";
+ case LTTNG_DESTROY_SESSION:
+ return "LTTNG_DESTROY_SESSION";
+ case LTTNG_LIST_CHANNELS:
+ return "LTTNG_LIST_CHANNELS";
+ case LTTNG_LIST_DOMAINS:
+ return "LTTNG_LIST_DOMAINS";
+ case LTTNG_LIST_EVENTS:
+ return "LTTNG_LIST_EVENTS";
+ case LTTNG_LIST_SESSIONS:
+ return "LTTNG_LIST_SESSIONS";
+ case LTTNG_LIST_TRACEPOINTS:
+ return "LTTNG_LIST_TRACEPOINTS";
+ case LTTNG_REGISTER_CONSUMER:
+ return "LTTNG_REGISTER_CONSUMER";
+ case LTTNG_START_TRACE:
+ return "LTTNG_START_TRACE";
+ case LTTNG_STOP_TRACE:
+ return "LTTNG_STOP_TRACE";
+ case LTTNG_LIST_TRACEPOINT_FIELDS:
+ return "LTTNG_LIST_TRACEPOINT_FIELDS";
+ case LTTNG_DISABLE_CONSUMER:
+ return "LTTNG_DISABLE_CONSUMER";
+ case LTTNG_ENABLE_CONSUMER:
+ return "LTTNG_ENABLE_CONSUMER";
+ case LTTNG_SET_CONSUMER_URI:
+ return "LTTNG_SET_CONSUMER_URI";
+ case LTTNG_DATA_PENDING:
+ return "LTTNG_DATA_PENDING";
+ case LTTNG_SNAPSHOT_ADD_OUTPUT:
+ return "LTTNG_SNAPSHOT_ADD_OUTPUT";
+ case LTTNG_SNAPSHOT_DEL_OUTPUT:
+ return "LTTNG_SNAPSHOT_DEL_OUTPUT";
+ case LTTNG_SNAPSHOT_LIST_OUTPUT:
+ return "LTTNG_SNAPSHOT_LIST_OUTPUT";
+ case LTTNG_SNAPSHOT_RECORD:
+ return "LTTNG_SNAPSHOT_RECORD";
+ case LTTNG_SAVE_SESSION:
+ return "LTTNG_SAVE_SESSION";
+ case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE:
+ return "LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE";
+ case LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE:
+ return "LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE";
+ case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY:
+ return "LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY";
+ case LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY:
+ return "LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY";
+ case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET:
+ return "LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET";
+ case LTTNG_SET_SESSION_SHM_PATH:
+ return "LTTNG_SET_SESSION_SHM_PATH";
+ case LTTNG_REGENERATE_METADATA:
+ return "LTTNG_REGENERATE_METADATA";
+ case LTTNG_REGENERATE_STATEDUMP:
+ return "LTTNG_REGENERATE_STATEDUMP";
+ case LTTNG_REGISTER_TRIGGER:
+ return "LTTNG_REGISTER_TRIGGER";
+ case LTTNG_UNREGISTER_TRIGGER:
+ return "LTTNG_UNREGISTER_TRIGGER";
+ case LTTNG_ROTATE_SESSION:
+ return "LTTNG_ROTATE_SESSION";
+ case LTTNG_ROTATION_GET_INFO:
+ return "LTTNG_ROTATION_GET_INFO";
+ case LTTNG_ROTATION_SET_SCHEDULE:
+ return "LTTNG_ROTATION_SET_SCHEDULE";
+ case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
+ return "LTTNG_SESSION_LIST_ROTATION_SCHEDULES";
+ case LTTNG_CREATE_SESSION_EXT:
+ return "LTTNG_CREATE_SESSION_EXT";
+ case LTTNG_CLEAR_SESSION:
+ return "LTTNG_CLEAR_SESSION";
+ case LTTNG_LIST_TRIGGERS:
+ return "LTTNG_LIST_TRIGGERS";
+ case LTTNG_EXECUTE_ERROR_QUERY:
+ return "LTTNG_EXECUTE_ERROR_QUERY";
+ default:
+ abort();
+ }
+}
+
+enum lttcomm_relayd_command {
+ RELAYD_ADD_STREAM = 1,
+ RELAYD_CREATE_SESSION = 2,
+ RELAYD_START_DATA = 3,
+ RELAYD_UPDATE_SYNC_INFO = 4,
+ RELAYD_VERSION = 5,
+ RELAYD_SEND_METADATA = 6,
+ RELAYD_CLOSE_STREAM = 7,
+ RELAYD_DATA_PENDING = 8,
+ RELAYD_QUIESCENT_CONTROL = 9,
+ RELAYD_BEGIN_DATA_PENDING = 10,
+ RELAYD_END_DATA_PENDING = 11,
+ RELAYD_ADD_INDEX = 12,
+ RELAYD_SEND_INDEX = 13,
+ RELAYD_CLOSE_INDEX = 14,
+ /* Live-reading commands (2.4+). */
+ RELAYD_LIST_SESSIONS = 15,
+ /* All streams of the channel have been sent to the relayd (2.4+). */
+ RELAYD_STREAMS_SENT = 16,
+ /* Ask the relay to reset the metadata trace file (2.8+) */
+ RELAYD_RESET_METADATA = 17,
+ /* Ask the relay to rotate a set of stream files (2.11+) */
+ RELAYD_ROTATE_STREAMS = 18,
+ /* Ask the relay to create a trace chunk (2.11+) */
+ RELAYD_CREATE_TRACE_CHUNK = 19,
+ /* Ask the relay to close a trace chunk (2.11+) */
+ RELAYD_CLOSE_TRACE_CHUNK = 20,
+ /* Ask the relay whether a trace chunk exists (2.11+) */
+ RELAYD_TRACE_CHUNK_EXISTS = 21,
+ /* Get the current configuration of a relayd peer (2.12+) */
+ RELAYD_GET_CONFIGURATION = 22,
+
+ /* Feature branch specific commands start at 10000. */
+};
+
+static inline
+const char *lttcomm_relayd_command_str(lttcomm_relayd_command cmd)
+{
+ switch (cmd) {
+ case RELAYD_ADD_STREAM:
+ return "RELAYD_ADD_STREAM";
+ case RELAYD_CREATE_SESSION:
+ return "RELAYD_CREATE_SESSION";
+ case RELAYD_START_DATA:
+ return "RELAYD_START_DATA";
+ case RELAYD_UPDATE_SYNC_INFO:
+ return "RELAYD_UPDATE_SYNC_INFO";
+ case RELAYD_VERSION:
+ return "RELAYD_VERSION";
+ case RELAYD_SEND_METADATA:
+ return "RELAYD_SEND_METADATA";
+ case RELAYD_CLOSE_STREAM:
+ return "RELAYD_CLOSE_STREAM";
+ case RELAYD_DATA_PENDING:
+ return "RELAYD_DATA_PENDING";
+ case RELAYD_QUIESCENT_CONTROL:
+ return "RELAYD_QUIESCENT_CONTROL";
+ case RELAYD_BEGIN_DATA_PENDING:
+ return "RELAYD_BEGIN_DATA_PENDING";
+ case RELAYD_END_DATA_PENDING:
+ return "RELAYD_END_DATA_PENDING";
+ case RELAYD_ADD_INDEX:
+ return "RELAYD_ADD_INDEX";
+ case RELAYD_SEND_INDEX:
+ return "RELAYD_SEND_INDEX";
+ case RELAYD_CLOSE_INDEX:
+ return "RELAYD_CLOSE_INDEX";
+ case RELAYD_LIST_SESSIONS:
+ return "RELAYD_LIST_SESSIONS";
+ case RELAYD_STREAMS_SENT:
+ return "RELAYD_STREAMS_SENT";
+ case RELAYD_RESET_METADATA:
+ return "RELAYD_RESET_METADATA";
+ case RELAYD_ROTATE_STREAMS:
+ return "RELAYD_ROTATE_STREAMS";
+ case RELAYD_CREATE_TRACE_CHUNK:
+ return "RELAYD_CREATE_TRACE_CHUNK";
+ case RELAYD_CLOSE_TRACE_CHUNK:
+ return "RELAYD_CLOSE_TRACE_CHUNK";
+ case RELAYD_TRACE_CHUNK_EXISTS:
+ return "RELAYD_TRACE_CHUNK_EXISTS";
+ case RELAYD_GET_CONFIGURATION:
+ return "RELAYD_GET_CONFIGURATION";
+ default:
+ abort();
+ }
+}
+
+/*
+ * lttcomm error code.
+ */
+enum lttcomm_return_code {
+ LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
+ /*
+ * Some code paths use -1 to express an error, others
+ * negate this consumer return code. Starting codes at
+ * 100 ensures there is no mix-up between this error value
+ * and legitimate status codes.
+ */
+ LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 100, /* Command socket ready */
+ LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */
+ LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */
+ LTTCOMM_CONSUMERD_ERROR_RECV_CMD, /* Error on receiving command */
+ LTTCOMM_CONSUMERD_POLL_ERROR, /* Error in polling thread */
+ LTTCOMM_CONSUMERD_POLL_NVAL, /* Poll on closed fd */
+ LTTCOMM_CONSUMERD_POLL_HUP, /* All fds have hungup */
+ LTTCOMM_CONSUMERD_EXIT_SUCCESS, /* Consumerd exiting normally */
+ LTTCOMM_CONSUMERD_EXIT_FAILURE, /* Consumerd exiting on error */
+ LTTCOMM_CONSUMERD_OUTFD_ERROR, /* Error opening the tracefile */
+ LTTCOMM_CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
+ LTTCOMM_CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
+ LTTCOMM_CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
+ LTTCOMM_CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
+ LTTCOMM_CONSUMERD_ENOMEM, /* Consumer is out of memory */
+ LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
+ LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
+ LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
+ LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
+ LTTCOMM_CONSUMERD_CHAN_NOT_FOUND, /* Channel not found. */
+ LTTCOMM_CONSUMERD_ALREADY_SET, /* Resource already set. */
+ LTTCOMM_CONSUMERD_ROTATION_FAIL, /* Rotation has failed. */
+ LTTCOMM_CONSUMERD_SNAPSHOT_FAILED, /* snapshot has failed. */
+ LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED,/* Trace chunk creation failed. */
+ LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED, /* Trace chunk close failed. */
+ LTTCOMM_CONSUMERD_INVALID_PARAMETERS, /* Invalid parameters. */
+ LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_LOCAL, /* Trace chunk exists on consumer daemon. */
+ LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE,/* Trace chunk exists on relay daemon. */
+ LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK, /* Unknown trace chunk. */
+ LTTCOMM_CONSUMERD_RELAYD_CLEAR_DISALLOWED, /* Relayd does not accept clear command. */
+ LTTCOMM_CONSUMERD_UNKNOWN_ERROR, /* Unknown error. */
+
+ /* MUST be last element */
+ LTTCOMM_NR, /* Last element */
+};
+
+/* lttng socket protocol. */
+enum lttcomm_sock_proto {
+ LTTCOMM_SOCK_UDP,
+ LTTCOMM_SOCK_TCP,
+};
+
+/*
+ * Index in the net_families array below. Please keep in sync!
+ */
+enum lttcomm_sock_domain {
+ LTTCOMM_INET = 0,
+ LTTCOMM_INET6 = 1,
+};
+
+enum lttcomm_metadata_command {
+ LTTCOMM_METADATA_REQUEST = 1,
+};
+
+/*
+ * Commands sent from the consumerd to the sessiond to request if new metadata
+ * is available. This message is used to find the per UID _or_ per PID registry
+ * for the channel key. For per UID lookup, the triplet
+ * bits_per_long/uid/session_id is used. On lookup failure, we search for the
+ * per PID registry indexed by session id ignoring the other values.
+ */
+struct lttcomm_metadata_request_msg {
+ uint64_t session_id; /* Tracing session id */
+ uint64_t session_id_per_pid; /* Tracing session id for per-pid */
+ uint32_t bits_per_long; /* Consumer ABI */
+ uint32_t uid;
+ uint64_t key; /* Metadata channel key. */
+} LTTNG_PACKED;
+
+struct lttcomm_sockaddr {
+ enum lttcomm_sock_domain type;
+ union {
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ } addr;
+};
+
+struct lttcomm_sock {
+ int32_t fd;
+ enum lttcomm_sock_proto proto;
+ struct lttcomm_sockaddr sockaddr;
+ const struct lttcomm_proto_ops *ops;
+};
+
+/*
+ * Relayd sock. Adds the protocol version to use for the communications with
+ * the relayd.
+ */
+struct lttcomm_relayd_sock {
+ struct lttcomm_sock sock;
+ uint32_t major;
+ uint32_t minor;
+};
+
+struct lttcomm_net_family {
+ int family;
+ int (*create) (struct lttcomm_sock *sock, int type, int proto);
+};
+
+struct lttcomm_proto_ops {
+ int (*bind) (struct lttcomm_sock *sock);
+ int (*close) (struct lttcomm_sock *sock);
+ int (*connect) (struct lttcomm_sock *sock);
+ struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
+ int (*listen) (struct lttcomm_sock *sock, int backlog);
+ ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
+ int flags);
+ ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
+ size_t len, int flags);
+};
+
+struct process_attr_integral_value_comm {
+ union {
+ int64_t _signed;
+ uint64_t _unsigned;
+ } u;
+} LTTNG_PACKED;
+
+/*
+ * Data structure received from lttng client to session daemon.
+ */
+struct lttcomm_session_msg {
+ uint32_t cmd_type; /* enum lttcomm_sessiond_command */
+ struct lttng_session session;
+ struct lttng_domain domain;
+ union {
+ /* Event data */
+ struct {
+ char channel_name[LTTNG_SYMBOL_NAME_LEN];
+ uint32_t length;
+ } LTTNG_PACKED enable;
+ struct {
+ char channel_name[LTTNG_SYMBOL_NAME_LEN];
+ uint32_t length;
+ } LTTNG_PACKED disable;
+ /* Create channel */
+ struct {
+ uint32_t length;
+ } LTTNG_PACKED channel;
+ /* Context */
+ struct {
+ char channel_name[LTTNG_SYMBOL_NAME_LEN];
+ uint32_t length;
+ } LTTNG_PACKED context;
+ /* Use by register_consumer */
+ struct {
+ char path[PATH_MAX];
+ } LTTNG_PACKED reg;
+ /* List */
+ struct {
+ char channel_name[LTTNG_SYMBOL_NAME_LEN];
+ } LTTNG_PACKED list;
+ struct lttng_calibrate calibrate;
+ /* Used by the set_consumer_url and used by create_session also call */
+ struct {
+ /* Number of lttng_uri following */
+ uint32_t size;
+ } LTTNG_PACKED uri;
+ struct {
+ struct lttng_snapshot_output output;
+ } LTTNG_PACKED snapshot_output;
+ struct {
+ uint32_t wait;
+ struct lttng_snapshot_output output;
+ } LTTNG_PACKED snapshot_record;
+ struct {
+ uint32_t nb_uri;
+ unsigned int timer_interval; /* usec */
+ } LTTNG_PACKED session_live;
+ struct {
+ struct lttng_save_session_attr attr;
+ } LTTNG_PACKED save_session;
+ struct {
+ char shm_path[PATH_MAX];
+ } LTTNG_PACKED set_shm_path;
+ struct {
+ /* enum lttng_process_attr */
+ int32_t process_attr;
+ /* enum lttng_process_attr_value_type */
+ int32_t value_type;
+
+ struct process_attr_integral_value_comm integral_value;
+ /*
+ * For user/group names, a variable length,
+ * zero-terminated, string of length 'name_len'
+ * (including the terminator) follows.
+ *
+ * integral_value should not be used in those cases.
+ */
+ uint32_t name_len;
+ } LTTNG_PACKED process_attr_tracker_add_remove_include_value;
+ struct {
+ /* enum lttng_process_attr */
+ int32_t process_attr;
+ } LTTNG_PACKED process_attr_tracker_get_inclusion_set;
+ struct {
+ /* enum lttng_process_attr */
+ int32_t process_attr;
+ } LTTNG_PACKED process_attr_tracker_get_tracking_policy;
+ struct {
+ /* enum lttng_process_attr */
+ int32_t process_attr;
+ /* enum lttng_tracking_policy */
+ int32_t tracking_policy;
+ } LTTNG_PACKED process_attr_tracker_set_tracking_policy;
+ struct {
+ uint32_t length;
+ uint8_t is_trigger_anonymous;
+ } LTTNG_PACKED trigger;
+ struct {
+ uint32_t length;
+ } LTTNG_PACKED error_query;
+ struct {
+ uint64_t rotation_id;
+ } LTTNG_PACKED get_rotation_info;
+ struct {
+ /* enum lttng_rotation_schedule_type */
+ uint8_t type;
+ /*
+ * If set == 1, set schedule to value, if set == 0,
+ * clear this schedule type.
+ */
+ uint8_t set;
+ uint64_t value;
+ } LTTNG_PACKED rotation_set_schedule;
+ struct {
+ /*
+ * Includes the null-terminator.
+ * Must be an absolute path.
+ *
+ * Size bounded by LTTNG_PATH_MAX.
+ */
+ uint16_t home_dir_size;
+ uint64_t session_descriptor_size;
+ /* An lttng_session_descriptor follows. */
+ } LTTNG_PACKED create_session;
+ } u;
+ /* Count of fds sent. */
+ uint32_t fd_count;
+} LTTNG_PACKED;
+
+#define LTTNG_FILTER_MAX_LEN 65536
+#define LTTNG_SESSION_DESCRIPTOR_MAX_LEN 65536
+
+/*
+ * Filter bytecode data. The reloc table is located at the end of the
+ * bytecode. It is made of tuples: (uint16_t, var. len. string). It
+ * starts at reloc_table_offset.
+ */
+#define LTTNG_FILTER_PADDING 32
+struct lttng_bytecode {
+ uint32_t len; /* len of data */
+ uint32_t reloc_table_offset;
+ uint64_t seqnum;
+ char padding[LTTNG_FILTER_PADDING];
+ char data[0];
+} LTTNG_PACKED;
+
+/*
+ * Event exclusion data. At the end of the structure, there will actually
+ * by zero or more names, where the actual number of names is given by
+ * the 'count' item of the structure.
+ */
+#define LTTNG_EVENT_EXCLUSION_PADDING 32
+struct lttng_event_exclusion {
+ uint32_t count;
+ char padding[LTTNG_EVENT_EXCLUSION_PADDING];
+ char names[][LTTNG_SYMBOL_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
+ ((_exclusion)->names[_i])
+
+/*
+ * Listing command header.
+ */
+struct lttcomm_list_command_header {
+ /* Number of elements */
+ uint32_t count;
+} LTTNG_PACKED;
+
+/*
+ * Event extended info header. This is the structure preceding each
+ * extended info data.
+ */
+struct lttcomm_event_extended_header {
+ /*
+ * Size of filter string immediately following this header.
+ * This size includes the terminal null character.
+ */
+ uint32_t filter_len;
+
+ /*
+ * Number of exclusion names, immediately following the filter
+ * string. Each exclusion name has a fixed length of
+ * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
+ * character.
+ */
+ uint32_t nb_exclusions;
+
+ /*
+ * Size of the event's userspace probe location (if applicable).
+ */
+ uint32_t userspace_probe_location_len;
+} LTTNG_PACKED;
+
+/*
+ * Command header of the reply to an LTTNG_DESTROY_SESSION command.
+ */
+struct lttcomm_session_destroy_command_header {
+ /* enum lttng_session */
+ int32_t rotation_state;
+};
+
+/*
+ * tracker command header.
+ */
+struct lttcomm_tracker_command_header {
+ uint32_t nb_tracker_id;
+} LTTNG_PACKED;
+
+/*
+ * Data structure for the response from sessiond to the lttng client.
+ */
+struct lttcomm_lttng_msg {
+ uint32_t cmd_type; /* enum lttcomm_sessiond_command */
+ uint32_t ret_code; /* enum lttcomm_return_code */
+ uint32_t pid; /* pid_t */
+ uint32_t cmd_header_size;
+ uint32_t data_size;
+ uint32_t fd_count;
+} LTTNG_PACKED;
+
+struct lttcomm_lttng_output_id {
+ uint32_t id;
+} LTTNG_PACKED;
+
+/*
+ * lttcomm_consumer_msg is the message sent from sessiond to consumerd
+ * to either add a channel, add a stream, update a stream, or stop
+ * operation.
+ */
+struct lttcomm_consumer_msg {
+ uint32_t cmd_type; /* enum lttng_consumer_command */
+ union {
+ struct {
+ uint64_t channel_key;
+ uint64_t session_id;
+ /* ID of the session's current trace chunk. */
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
+ char pathname[PATH_MAX];
+ uint64_t relayd_id;
+ /* nb_init_streams is the number of streams open initially. */
+ uint32_t nb_init_streams;
+ char name[LTTNG_SYMBOL_NAME_LEN];
+ /* Use splice or mmap to consume this fd */
+ enum lttng_event_output output;
+ int type; /* Per cpu or metadata. */
+ uint64_t tracefile_size; /* bytes */
+ uint32_t tracefile_count; /* number of tracefiles */
+ /* If the channel's streams have to be monitored or not. */
+ uint32_t monitor;
+ /* timer to check the streams usage in live mode (usec). */
+ unsigned int live_timer_interval;
+ /* is part of a live session */
+ uint8_t is_live;
+ /* timer to sample a channel's positions (usec). */
+ unsigned int monitor_timer_interval;
+ } LTTNG_PACKED channel; /* Only used by Kernel. */
+ struct {
+ uint64_t stream_key;
+ uint64_t channel_key;
+ int32_t cpu; /* On which CPU this stream is assigned. */
+ /* Tells the consumer if the stream should be or not monitored. */
+ uint32_t no_monitor;
+ } LTTNG_PACKED stream; /* Only used by Kernel. */
+ struct {
+ uint64_t net_index;
+ enum lttng_stream_type type;
+ uint32_t major;
+ uint32_t minor;
+ uint8_t relayd_socket_protocol;
+ /* Tracing session id associated to the relayd. */
+ uint64_t session_id;
+ /* Relayd session id, only used with control socket. */
+ uint64_t relayd_session_id;
+ } LTTNG_PACKED relayd_sock;
+ struct {
+ uint64_t net_seq_idx;
+ } LTTNG_PACKED destroy_relayd;
+ struct {
+ uint64_t session_id;
+ } LTTNG_PACKED data_pending;
+ struct {
+ uint64_t subbuf_size; /* bytes */
+ uint64_t num_subbuf; /* power of 2 */
+ int32_t overwrite; /* 1: overwrite, 0: discard */
+ uint32_t switch_timer_interval; /* usec */
+ uint32_t read_timer_interval; /* usec */
+ unsigned int live_timer_interval; /* usec */
+ uint8_t is_live; /* is part of a live session */
+ uint32_t monitor_timer_interval; /* usec */
+ int32_t output; /* splice, mmap */
+ int32_t type; /* metadata or per_cpu */
+ uint64_t session_id; /* Tracing session id */
+ char pathname[PATH_MAX]; /* Channel file path. */
+ char name[LTTNG_SYMBOL_NAME_LEN]; /* Channel name. */
+ /* Credentials used to open the UST buffer shared mappings. */
+ struct {
+ uint32_t uid;
+ uint32_t gid;
+ } LTTNG_PACKED buffer_credentials;
+ uint64_t relayd_id; /* Relayd id if apply. */
+ uint64_t key; /* Unique channel key. */
+ /* ID of the session's current trace chunk. */
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
+ unsigned char uuid[LTTNG_UUID_LEN]; /* uuid for ust tracer. */
+ uint32_t chan_id; /* Channel ID on the tracer side. */
+ uint64_t tracefile_size; /* bytes */
+ uint32_t tracefile_count; /* number of tracefiles */
+ uint64_t session_id_per_pid; /* Per-pid session ID. */
+ /* Tells the consumer if the stream should be or not monitored. */
+ uint32_t monitor;
+ /*
+ * For UST per UID buffers, this is the application UID of the
+ * channel. This can be different from the user UID requesting the
+ * channel creation and used for the rights on the stream file
+ * because the application can be in the tracing for instance.
+ */
+ uint32_t ust_app_uid;
+ int64_t blocking_timeout;
+ char root_shm_path[PATH_MAX];
+ char shm_path[PATH_MAX];
+ } LTTNG_PACKED ask_channel;
+ struct {
+ uint64_t key;
+ } LTTNG_PACKED get_channel;
+ struct {
+ uint64_t key;
+ } LTTNG_PACKED destroy_channel;
+ struct {
+ uint64_t key; /* Metadata channel key. */
+ uint64_t target_offset; /* Offset in the consumer */
+ uint64_t len; /* Length of metadata to be received. */
+ uint64_t version; /* Version of the metadata. */
+ } LTTNG_PACKED push_metadata;
+ struct {
+ uint64_t key; /* Metadata channel key. */
+ } LTTNG_PACKED close_metadata;
+ struct {
+ uint64_t key; /* Metadata channel key. */
+ } LTTNG_PACKED setup_metadata;
+ struct {
+ uint64_t key; /* Channel key. */
+ } LTTNG_PACKED flush_channel;
+ struct {
+ uint64_t key; /* Channel key. */
+ } LTTNG_PACKED clear_quiescent_channel;
+ struct {
+ char pathname[PATH_MAX];
+ /* Indicate if the snapshot goes on the relayd or locally. */
+ uint32_t use_relayd;
+ uint32_t metadata; /* This a metadata snapshot. */
+ uint64_t relayd_id; /* Relayd id if apply. */
+ uint64_t key;
+ uint64_t nb_packets_per_stream;
+ } LTTNG_PACKED snapshot_channel;
+ struct {
+ uint64_t channel_key;
+ uint64_t net_seq_idx;
+ } LTTNG_PACKED sent_streams;
+ struct {
+ uint64_t session_id;
+ uint64_t channel_key;
+ } LTTNG_PACKED discarded_events;
+ struct {
+ uint64_t session_id;
+ uint64_t channel_key;
+ } LTTNG_PACKED lost_packets;
+ struct {
+ uint64_t session_id;
+ } LTTNG_PACKED regenerate_metadata;
+ struct {
+ uint32_t metadata; /* This is a metadata channel. */
+ uint64_t relayd_id; /* Relayd id if apply. */
+ uint64_t key;
+ } LTTNG_PACKED rotate_channel;
+ struct {
+ uint64_t session_id;
+ uint64_t chunk_id;
+ } LTTNG_PACKED check_rotation_pending_local;
+ struct {
+ uint64_t relayd_id;
+ uint64_t session_id;
+ uint64_t chunk_id;
+ } LTTNG_PACKED check_rotation_pending_relay;
+ struct {
+ /*
+ * Relayd id, if applicable (remote).
+ *
+ * A directory file descriptor referring to the chunk's
+ * output folder is transmitted if the chunk is local
+ * (relayd_id unset).
+ *
+ * `override_name` is left NULL (all-zeroes) if the
+ * chunk's name is not overridden.
+ */
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+ char override_name[LTTNG_NAME_MAX];
+ uint64_t session_id;
+ uint64_t chunk_id;
+ uint64_t creation_timestamp;
+ LTTNG_OPTIONAL_COMM(struct {
+ uint32_t uid;
+ uint32_t gid;
+ } LTTNG_PACKED ) LTTNG_PACKED credentials;
+ } LTTNG_PACKED create_trace_chunk;
+ struct {
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+ uint64_t session_id;
+ uint64_t chunk_id;
+ uint64_t close_timestamp;
+ /* enum lttng_trace_chunk_command_type */
+ LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command;
+ } LTTNG_PACKED close_trace_chunk;
+ struct {
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
+ uint64_t session_id;
+ uint64_t chunk_id;
+ } LTTNG_PACKED trace_chunk_exists;
+ struct {
+ lttng_uuid sessiond_uuid;
+ } LTTNG_PACKED init;
+ struct {
+ uint64_t key;
+ } LTTNG_PACKED clear_channel;
+ struct {
+ uint64_t key;
+ } LTTNG_PACKED open_channel_packets;
+ } u;
+} LTTNG_PACKED;
+
+/*
+ * Channel monitoring message returned to the session daemon on every
+ * monitor timer expiration.
+ */
+struct lttcomm_consumer_channel_monitor_msg {
+ /* Key of the sampled channel. */
+ uint64_t key;
+ /*
+ * Lowest and highest usage (bytes) at the moment the sample was taken.
+ */
+ uint64_t lowest, highest;
+ /*
+ * Sum of all the consumed positions for a channel.
+ */
+ uint64_t total_consumed;
+} LTTNG_PACKED;
+
+/*
+ * Status message returned to the sessiond after a received command.
+ */
+struct lttcomm_consumer_status_msg {
+ enum lttcomm_return_code ret_code;
+} LTTNG_PACKED;
+
+struct lttcomm_consumer_status_channel {
+ enum lttcomm_return_code ret_code;
+ uint64_t key;
+ unsigned int stream_count;
+} LTTNG_PACKED;
+
+struct lttcomm_consumer_close_trace_chunk_reply {
+ enum lttcomm_return_code ret_code;
+ uint32_t path_length;
+ char path[];
+};
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+#include <lttng/ust-abi.h>
+
+/*
+ * Data structure for the commands sent from sessiond to UST.
+ */
+struct lttcomm_ust_msg {
+ uint32_t handle;
+ uint32_t cmd;
+ union {
+ struct lttng_ust_abi_channel channel;
+ struct lttng_ust_abi_stream stream;
+ struct lttng_ust_abi_event event;
+ struct lttng_ust_abi_context context;
+ struct lttng_ust_abi_tracer_version version;
+ } u;
+} LTTNG_PACKED;
+
+/*
+ * Data structure for the response from UST to the session daemon.
+ * cmd_type is sent back in the reply for validation.
+ */
+struct lttcomm_ust_reply {
+ uint32_t handle;
+ uint32_t cmd;
+ uint32_t ret_code; /* enum lttcomm_return_code */
+ uint32_t ret_val; /* return value */
+ union {
+ struct {
+ uint64_t memory_map_size;
+ } LTTNG_PACKED channel;
+ struct {
+ uint64_t memory_map_size;
+ } LTTNG_PACKED stream;
+ struct lttng_ust_abi_tracer_version version;
+ } u;
+} LTTNG_PACKED;
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
+
+int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
+ const char *ip, unsigned int port);
+int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
+ const char *ip, unsigned int port);
+
+struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
+int lttcomm_populate_sock_from_open_socket(struct lttcomm_sock *sock,
+ int fd,
+ enum lttcomm_sock_proto protocol);
+int lttcomm_create_sock(struct lttcomm_sock *sock);
+struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
+void lttcomm_destroy_sock(struct lttcomm_sock *sock);
+struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
+void lttcomm_copy_sock(struct lttcomm_sock *dst,
+ struct lttcomm_sock *src);
+
+/* Relayd socket object. */
+struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
+ struct lttng_uri *uri, uint32_t major, uint32_t minor);
+
+int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
+int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
+
+int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
+ uint16_t *port);
+/*
+ * Set a port to an lttcomm_sock. This will have no effect is the socket is
+ * already bound.
+ */
+int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
+
+void lttcomm_init(void);
+/* Get network timeout, in milliseconds */
+unsigned long lttcomm_get_network_timeout(void);
+
+#endif /* _LTTNG_SESSIOND_COMM_H */
#include <unistd.h>
#include <urcu.h>
-#include <common/error.h>
+#include <common/error.hpp>
-#include "shm.h"
+#include "shm.hpp"
/*
* Using fork to set umask in the child process (not multi-thread safe). We
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTT_SHM_H
-#define _LTT_SHM_H
-
-char *shm_ust_get_mmap(char *shm_path, int global);
-
-int shm_create_anonymous(const char *owner_name);
-
-#endif /* _LTT_SHM_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTT_SHM_H
+#define _LTT_SHM_H
+
+char *shm_ust_get_mmap(char *shm_path, int global);
+
+int shm_create_anonymous(const char *owner_name);
+
+#endif /* _LTT_SHM_H */
*
*/
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/snapshot.h>
-#include <lttng/snapshot-internal.h>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/snapshot.hpp>
+#include <lttng/snapshot-internal.hpp>
#include <lttng/snapshot.h>
#include <stdlib.h>
+++ /dev/null
-/*
- * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef COMMON_SNAPSHOT_H
-#define COMMON_SNAPSHOT_H
-
-#include <common/macros.h>
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct lttng_payload_view;
-struct lttng_payload;
-struct lttng_snapshot_output;
-struct mi_writer;
-
-bool lttng_snapshot_output_validate(const struct lttng_snapshot_output *output);
-
-bool lttng_snapshot_output_is_equal(
- const struct lttng_snapshot_output *a,
- const struct lttng_snapshot_output *b);
-
-int lttng_snapshot_output_serialize(
- const struct lttng_snapshot_output *output,
- struct lttng_payload *payload);
-
-ssize_t lttng_snapshot_output_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_snapshot_output **output_p);
-
-enum lttng_error_code lttng_snapshot_output_mi_serialize(
- const struct lttng_snapshot_output *output,
- struct mi_writer *writer);
-
-#endif /* COMMON_SNAPSHOT_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Simon Marchi <simon.marchi@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef COMMON_SNAPSHOT_H
+#define COMMON_SNAPSHOT_H
+
+#include <common/macros.hpp>
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+struct lttng_payload_view;
+struct lttng_payload;
+struct lttng_snapshot_output;
+struct mi_writer;
+
+bool lttng_snapshot_output_validate(const struct lttng_snapshot_output *output);
+
+bool lttng_snapshot_output_is_equal(
+ const struct lttng_snapshot_output *a,
+ const struct lttng_snapshot_output *b);
+
+int lttng_snapshot_output_serialize(
+ const struct lttng_snapshot_output *output,
+ struct lttng_payload *payload);
+
+ssize_t lttng_snapshot_output_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_snapshot_output **output_p);
+
+enum lttng_error_code lttng_snapshot_output_mi_serialize(
+ const struct lttng_snapshot_output *output,
+ struct mi_writer *writer);
+
+#endif /* COMMON_SNAPSHOT_H */
#include <lttng/constant.h>
-#include <common/compat/errno.h>
-#include "error.h"
-#include "macros.h"
-#include "spawn-viewer.h"
+#include <common/compat/errno.hpp>
+#include "error.hpp"
+#include "macros.hpp"
+#include "spawn-viewer.hpp"
static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
+++ /dev/null
-#ifndef LTTNG_SPAWN_VIEWER_H
-#define LTTNG_SPAWN_VIEWER_H
-
-/*
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <lttng/lttng-export.h>
-#include <stdbool.h>
-
-/*
- * Read the trace by `exec()ing` the provided viewer program if any. If
- * `opt_viewer` is NULL, try to read the trace with the default trace reader.
- * On success, this function doesn't return.
- * Returns -1 if the `opt_viewer` string or the default trace viewer can't be
- * `exec()`.
- *
- * This symbol was mistakenly made public before the 2.12 release. It can't
- * be removed (but it can be stubbed-out if necessary).
- */
-extern "C" LTTNG_EXPORT
-int spawn_viewer(const char *trace_path, char *opt_viewer, bool opt_live_mode);
-
-#endif /* ifndef LTTNG_SPAWN_VIEWER_H */
--- /dev/null
+#ifndef LTTNG_SPAWN_VIEWER_H
+#define LTTNG_SPAWN_VIEWER_H
+
+/*
+ * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <lttng/lttng-export.h>
+#include <stdbool.h>
+
+/*
+ * Read the trace by `exec()ing` the provided viewer program if any. If
+ * `opt_viewer` is NULL, try to read the trace with the default trace reader.
+ * On success, this function doesn't return.
+ * Returns -1 if the `opt_viewer` string or the default trace viewer can't be
+ * `exec()`.
+ *
+ * This symbol was mistakenly made public before the 2.12 release. It can't
+ * be removed (but it can be stubbed-out if necessary).
+ */
+extern "C" LTTNG_EXPORT
+int spawn_viewer(const char *trace_path, char *opt_viewer, bool opt_live_mode);
+
+#endif /* ifndef LTTNG_SPAWN_VIEWER_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _STRING_UTILS_FORMAT_H
-#define _STRING_UTILS_FORMAT_H
-
-/*
- * Maximal length of `val` when formatted in decimal.
- *
- * Note that this is an upper bound that can exceed the length
- * required to hold the largest textual value of `val`. Note that this length
- * assumes that no grouping/locale-aware formatting is performed (i.e. using
- * the `'` specifier in POSIX formatting functions).
- */
-#define MAX_INT_DEC_LEN(val) ((3 * sizeof(val)) + 2)
-
-#endif /* _STRING_UTILS_FORMAT_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _STRING_UTILS_FORMAT_H
+#define _STRING_UTILS_FORMAT_H
+
+/*
+ * Maximal length of `val` when formatted in decimal.
+ *
+ * Note that this is an upper bound that can exceed the length
+ * required to hold the largest textual value of `val`. Note that this length
+ * assumes that no grouping/locale-aware formatting is performed (i.e. using
+ * the `'` specifier in POSIX formatting functions).
+ */
+#define MAX_INT_DEC_LEN(val) ((3 * sizeof(val)) + 2)
+
+#endif /* _STRING_UTILS_FORMAT_H */
#include <errno.h>
#include <stdarg.h>
-#include "string-utils.h"
-#include "../macros.h"
+#include "string-utils.hpp"
+#include "../macros.hpp"
enum star_glob_pattern_type_flags {
STAR_GLOB_PATTERN_TYPE_FLAG_NONE = 0,
+++ /dev/null
-/*
- * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _STRING_UTILS_H
-#define _STRING_UTILS_H
-
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/dynamic-array.h>
-
-void strutils_normalize_star_glob_pattern(char *pattern);
-
-bool strutils_is_star_glob_pattern(const char *pattern);
-
-bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern);
-
-char *strutils_unescape_string(const char *input, char only_char);
-
-int strutils_split(const char *input, char delim, bool escape_delim,
- struct lttng_dynamic_pointer_array *out_strings);
-
-void strutils_free_null_terminated_array_of_strings(char **array);
-
-size_t strutils_array_of_strings_len(char * const *array);
-
-/*
- * Append `append` to the malloc-end string `str`.
- *
- * On success, `str` is free'd (if not NULL) and assigned a new malloc-ed
- * string. On failure, `str` is not modified.
- *
- * Return 0 on success, -ENOMEM on failure.
- */
-C_LINKAGE int strutils_append_str(char **str, const char *append);
-
-/*
- * Like `strutils_append_str`, but the appended string is formatted using
- * `fmt` and the following arguments.
- */
-C_LINKAGE ATTR_FORMAT_PRINTF(2, 3)
-int strutils_appendf(char **s, const char *fmt, ...);
-
-#endif /* _STRING_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _STRING_UTILS_H
+#define _STRING_UTILS_H
+
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/dynamic-array.hpp>
+
+void strutils_normalize_star_glob_pattern(char *pattern);
+
+bool strutils_is_star_glob_pattern(const char *pattern);
+
+bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern);
+
+char *strutils_unescape_string(const char *input, char only_char);
+
+int strutils_split(const char *input, char delim, bool escape_delim,
+ struct lttng_dynamic_pointer_array *out_strings);
+
+void strutils_free_null_terminated_array_of_strings(char **array);
+
+size_t strutils_array_of_strings_len(char * const *array);
+
+/*
+ * Append `append` to the malloc-end string `str`.
+ *
+ * On success, `str` is free'd (if not NULL) and assigned a new malloc-ed
+ * string. On failure, `str` is not modified.
+ *
+ * Return 0 on success, -ENOMEM on failure.
+ */
+C_LINKAGE int strutils_append_str(char **str, const char *append);
+
+/*
+ * Like `strutils_append_str`, but the appended string is formatted using
+ * `fmt` and the following arguments.
+ */
+C_LINKAGE ATTR_FORMAT_PRINTF(2, 3)
+int strutils_appendf(char **s, const char *fmt, ...);
+
+#endif /* _STRING_UTILS_H */
#include <stdlib.h> /* for getenv */
#include <string.h> /* for strncmp */
-#include "testpoint.h"
+#include "testpoint.hpp"
/* Environment variable used to enable the testpoints facilities. */
static const char *lttng_testpoint_env_var = "LTTNG_TESTPOINT_ENABLE";
+++ /dev/null
-/*
- * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifdef NTESTPOINT
-
-#define testpoint(name)
-#define TESTPOINT_DECL(name)
-
-#else /* NTESTPOINT */
-
-#include <urcu.h> /* for caa_likely/unlikely */
-
-extern int lttng_testpoint_activated;
-
-void *lttng_testpoint_lookup(const char *name);
-
-/*
- * Testpoint is only active if the global lttng_testpoint_activated flag is
- * set.
- * Return a non-zero error code to indicate failure.
- */
-#define testpoint(name) \
- ((caa_unlikely(lttng_testpoint_activated)) \
- ? __testpoint_##name##_wrapper() : 0)
-
-/*
- * One wrapper per testpoint is generated. This is to keep track of the symbol
- * lookup status and the corresponding function pointer, if any.
- */
-#define _TESTPOINT_DECL(_name) \
- static inline int __testpoint_##_name##_wrapper(void) \
- { \
- int ret = 0; \
- static int (*tp)(void); \
- static int found; \
- const char *tp_name = "__testpoint_" #_name; \
- \
- if (tp) { \
- ret = tp(); \
- } else { \
- if (!found) { \
- tp = (int (*)(void)) lttng_testpoint_lookup(tp_name); \
- if (tp) { \
- found = 1; \
- ret = tp(); \
- } else { \
- found = -1; \
- } \
- } \
- } \
- return ret; \
- }
-
-/* Testpoint declaration */
-#define TESTPOINT_DECL(name) \
- _TESTPOINT_DECL(name)
-
-#endif /* NTESTPOINT */
--- /dev/null
+/*
+ * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifdef NTESTPOINT
+
+#define testpoint(name)
+#define TESTPOINT_DECL(name)
+
+#else /* NTESTPOINT */
+
+#include <urcu.h> /* for caa_likely/unlikely */
+
+extern int lttng_testpoint_activated;
+
+void *lttng_testpoint_lookup(const char *name);
+
+/*
+ * Testpoint is only active if the global lttng_testpoint_activated flag is
+ * set.
+ * Return a non-zero error code to indicate failure.
+ */
+#define testpoint(name) \
+ ((caa_unlikely(lttng_testpoint_activated)) \
+ ? __testpoint_##name##_wrapper() : 0)
+
+/*
+ * One wrapper per testpoint is generated. This is to keep track of the symbol
+ * lookup status and the corresponding function pointer, if any.
+ */
+#define _TESTPOINT_DECL(_name) \
+ static inline int __testpoint_##_name##_wrapper(void) \
+ { \
+ int ret = 0; \
+ static int (*tp)(void); \
+ static int found; \
+ const char *tp_name = "__testpoint_" #_name; \
+ \
+ if (tp) { \
+ ret = tp(); \
+ } else { \
+ if (!found) { \
+ tp = (int (*)(void)) lttng_testpoint_lookup(tp_name); \
+ if (tp) { \
+ found = 1; \
+ ret = tp(); \
+ } else { \
+ found = -1; \
+ } \
+ } \
+ } \
+ return ret; \
+ }
+
+/* Testpoint declaration */
+#define TESTPOINT_DECL(name) \
+ _TESTPOINT_DECL(name)
+
+#endif /* NTESTPOINT */
#include <string.h>
-#include <common/compat/pthread.h>
-#include "thread.h"
+#include <common/compat/pthread.hpp>
+#include "thread.hpp"
int lttng_thread_setname(const char *name)
+++ /dev/null
-/*
- * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_THREAD_H
-#define LTTNG_THREAD_H
-
-#include <common/macros.h>
-
-/*
- * Set the current thread name on platforms that support it. The name can
- * be of arbitrary length and will be truncated to the platform limit,
- * usually 16.
- */
-int lttng_thread_setname(const char *name);
-
-#endif /* LTTNG_THREAD_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_THREAD_H
+#define LTTNG_THREAD_H
+
+#include <common/macros.hpp>
+
+/*
+ * Set the current thread name on platforms that support it. The name can
+ * be of arbitrary length and will be truncated to the platform limit,
+ * usually 16.
+ */
+int lttng_thread_setname(const char *name);
+
+#endif /* LTTNG_THREAD_H */
*
*/
-#include <common/time.h>
-#include <common/error.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/compat/errno.h>
+#include <common/time.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/error.hpp>
+#include <common/compat/errno.hpp>
#include <stddef.h>
#include <stdint.h>
#include <limits.h>
+++ /dev/null
-/*
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-#ifndef LTTNG_TIME_H
-#define LTTNG_TIME_H
-
-#include <time.h>
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/compat/time.h>
-
-#define MSEC_PER_SEC 1000ULL
-#define NSEC_PER_SEC 1000000000ULL
-#define NSEC_PER_MSEC 1000000ULL
-#define NSEC_PER_USEC 1000ULL
-#define USEC_PER_SEC 1000000ULL
-#define USEC_PER_MSEC 1000ULL
-
-#define SEC_PER_MINUTE 60ULL
-#define MINUTE_PER_HOUR 60ULL
-
-#define USEC_PER_MINUTE (USEC_PER_SEC * SEC_PER_MINUTE)
-#define USEC_PER_HOURS (USEC_PER_MINUTE * MINUTE_PER_HOUR)
-
-#define ISO8601_STR_LEN sizeof("YYYYmmddTHHMMSS+HHMM")
-#define DATETIME_STR_LEN sizeof("YYYYmmdd-HHMMSS")
-
-bool locale_supports_utf8(void);
-
-#define NSEC_UNIT "ns"
-#define USEC_UNIT (locale_supports_utf8() ? "µs" : "us")
-#define MSEC_UNIT "ms"
-#define SEC_UNIT "s"
-#define MIN_UNIT "m"
-#define HR_UNIT "h"
-
-/*
- * timespec_to_ms: Convert timespec to milliseconds.
- *
- * Returns 0 on success, else -1 on error. errno is set to EOVERFLOW if
- * input would overflow the output in milliseconds.
- */
-int timespec_to_ms(struct timespec ts, unsigned long *ms);
-
-/*
- * timespec_abs_diff: Absolute difference between timespec.
- */
-struct timespec timespec_abs_diff(struct timespec ts_a, struct timespec ts_b);
-
-/*
- * Format a Unix timestamp to an ISO 8601 compatible timestamp of
- * the form "YYYYmmddTHHMMSS+HHMM" in local time. `len` must >= to
- * ISO8601_STR_LEN.
- *
- * Returns 0 on success, else -1 on error.
- */
-int time_to_iso8601_str(time_t time, char *str, size_t len);
-
-int time_to_datetime_str(time_t time, char *str, size_t len);
-
-#endif /* LTTNG_TIME_H */
--- /dev/null
+/*
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+#ifndef LTTNG_TIME_H
+#define LTTNG_TIME_H
+
+#include <time.h>
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/compat/time.hpp>
+
+#define MSEC_PER_SEC 1000ULL
+#define NSEC_PER_SEC 1000000000ULL
+#define NSEC_PER_MSEC 1000000ULL
+#define NSEC_PER_USEC 1000ULL
+#define USEC_PER_SEC 1000000ULL
+#define USEC_PER_MSEC 1000ULL
+
+#define SEC_PER_MINUTE 60ULL
+#define MINUTE_PER_HOUR 60ULL
+
+#define USEC_PER_MINUTE (USEC_PER_SEC * SEC_PER_MINUTE)
+#define USEC_PER_HOURS (USEC_PER_MINUTE * MINUTE_PER_HOUR)
+
+#define ISO8601_STR_LEN sizeof("YYYYmmddTHHMMSS+HHMM")
+#define DATETIME_STR_LEN sizeof("YYYYmmdd-HHMMSS")
+
+bool locale_supports_utf8(void);
+
+#define NSEC_UNIT "ns"
+#define USEC_UNIT (locale_supports_utf8() ? "µs" : "us")
+#define MSEC_UNIT "ms"
+#define SEC_UNIT "s"
+#define MIN_UNIT "m"
+#define HR_UNIT "h"
+
+/*
+ * timespec_to_ms: Convert timespec to milliseconds.
+ *
+ * Returns 0 on success, else -1 on error. errno is set to EOVERFLOW if
+ * input would overflow the output in milliseconds.
+ */
+int timespec_to_ms(struct timespec ts, unsigned long *ms);
+
+/*
+ * timespec_abs_diff: Absolute difference between timespec.
+ */
+struct timespec timespec_abs_diff(struct timespec ts_a, struct timespec ts_b);
+
+/*
+ * Format a Unix timestamp to an ISO 8601 compatible timestamp of
+ * the form "YYYYmmddTHHMMSS+HHMM" in local time. `len` must >= to
+ * ISO8601_STR_LEN.
+ *
+ * Returns 0 on success, else -1 on error.
+ */
+int time_to_iso8601_str(time_t time, char *str, size_t len);
+
+int time_to_datetime_str(time_t time, char *str, size_t len);
+
+#endif /* LTTNG_TIME_H */
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
-#define LTTNG_TRACE_CHUNK_REGISTRY_H
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <common/macros.h>
-#include <common/trace-chunk.h>
-
-struct lttng_trace_chunk_registry;
-
-/*
- * Create an lttng_trace_chunk registry.
- *
- * A trace chunk registry maintains an association between a
- * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can
- * be "unset" in the case of an anonymous trace chunk.
- *
- * Note that a trace chunk registry holds no ownership of its trace
- * chunks. Trace chunks are unpublished when their last reference is released.
- * See the documentation of lttng_trace_chunk.
- *
- * Returns a trace chunk registry on success, NULL on error.
- *
- * Note that a trace chunk registry may only be accessed by an RCU thread.
- */
-struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
-
-/*
- * Destroy an lttng trace chunk registry. The registry must be emptied
- * (i.e. all references to the trace chunks it contains must be released) before
- * it is destroyed.
- */
-void lttng_trace_chunk_registry_destroy(
- struct lttng_trace_chunk_registry *registry);
-
-/*
- * Publish a trace chunk for a given session id.
- * A reference is acquired on behalf of the caller.
- *
- * The trace chunk that is returned is the published version of the trace
- * chunk. The chunk provided should be discarded on success and it's
- * published version used in its place.
- *
- * See the documentation of lttng_trace_chunk for more information on
- * the usage of the various parameters.
- *
- * Returns an lttng_trace_chunk on success, NULL on error.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
- struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, struct lttng_trace_chunk *chunk);
-/*
- * Adds the `previously_published` parameter which allows the caller
- * to know if a trace chunk equivalent to `chunk` was previously published.
- *
- * The registry holds a reference to the published trace chunks it contains.
- * Trace chunks automatically unpublish themselves from their registry on
- * destruction.
- *
- * This information is necessary to drop the reference of newly published
- * chunks when a user doesn't wish to explicitly maintain all references
- * to a given trace chunk.
- *
- * For instance, the relay daemon doesn't need the registry to hold a
- * reference since it controls the lifetime of its trace chunks.
- * Conversely, the consumer daemons rely on the session daemon to inform
- * them of the end of life of a trace chunk and the trace chunks don't
- * belong to a specific top-level object: they are always retrieved from
- * the registry by `id`.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
- struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, struct lttng_trace_chunk *chunk,
- bool *previously_published);
-
-/*
- * Look-up a trace chunk by session_id and chunk_id.
- * A reference is acquired on behalf of the caller.
- *
- * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
- */
-struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_chunk(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, uint64_t chunk_id);
-
-/*
- * Query the existence of a trace chunk by session_id and chunk_id.
- *
- * Returns 0 on success, a negative value on error.
- */
-int lttng_trace_chunk_registry_chunk_exists(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
-
-/*
- * Look-up an anonymous trace chunk by session_id.
- * A reference is acquired on behalf of the caller.
- *
- * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
- */
-struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_anonymous_chunk(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id);
-
-unsigned int lttng_trace_chunk_registry_put_each_chunk(
- const struct lttng_trace_chunk_registry *registry);
-
-#endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
+#define LTTNG_TRACE_CHUNK_REGISTRY_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <common/macros.hpp>
+#include <common/trace-chunk.hpp>
+
+struct lttng_trace_chunk_registry;
+
+/*
+ * Create an lttng_trace_chunk registry.
+ *
+ * A trace chunk registry maintains an association between a
+ * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can
+ * be "unset" in the case of an anonymous trace chunk.
+ *
+ * Note that a trace chunk registry holds no ownership of its trace
+ * chunks. Trace chunks are unpublished when their last reference is released.
+ * See the documentation of lttng_trace_chunk.
+ *
+ * Returns a trace chunk registry on success, NULL on error.
+ *
+ * Note that a trace chunk registry may only be accessed by an RCU thread.
+ */
+struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void);
+
+/*
+ * Destroy an lttng trace chunk registry. The registry must be emptied
+ * (i.e. all references to the trace chunks it contains must be released) before
+ * it is destroyed.
+ */
+void lttng_trace_chunk_registry_destroy(
+ struct lttng_trace_chunk_registry *registry);
+
+/*
+ * Publish a trace chunk for a given session id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * The trace chunk that is returned is the published version of the trace
+ * chunk. The chunk provided should be discarded on success and it's
+ * published version used in its place.
+ *
+ * See the documentation of lttng_trace_chunk for more information on
+ * the usage of the various parameters.
+ *
+ * Returns an lttng_trace_chunk on success, NULL on error.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
+ struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id, struct lttng_trace_chunk *chunk);
+/*
+ * Adds the `previously_published` parameter which allows the caller
+ * to know if a trace chunk equivalent to `chunk` was previously published.
+ *
+ * The registry holds a reference to the published trace chunks it contains.
+ * Trace chunks automatically unpublish themselves from their registry on
+ * destruction.
+ *
+ * This information is necessary to drop the reference of newly published
+ * chunks when a user doesn't wish to explicitly maintain all references
+ * to a given trace chunk.
+ *
+ * For instance, the relay daemon doesn't need the registry to hold a
+ * reference since it controls the lifetime of its trace chunks.
+ * Conversely, the consumer daemons rely on the session daemon to inform
+ * them of the end of life of a trace chunk and the trace chunks don't
+ * belong to a specific top-level object: they are always retrieved from
+ * the registry by `id`.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk(
+ struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id, struct lttng_trace_chunk *chunk,
+ bool *previously_published);
+
+/*
+ * Look-up a trace chunk by session_id and chunk_id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
+ */
+struct lttng_trace_chunk *
+lttng_trace_chunk_registry_find_chunk(
+ const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id, uint64_t chunk_id);
+
+/*
+ * Query the existence of a trace chunk by session_id and chunk_id.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+int lttng_trace_chunk_registry_chunk_exists(
+ const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id, uint64_t chunk_id, bool *chunk_exists);
+
+/*
+ * Look-up an anonymous trace chunk by session_id.
+ * A reference is acquired on behalf of the caller.
+ *
+ * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
+ */
+struct lttng_trace_chunk *
+lttng_trace_chunk_registry_find_anonymous_chunk(
+ const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id);
+
+unsigned int lttng_trace_chunk_registry_put_each_chunk(
+ const struct lttng_trace_chunk_registry *registry);
+
+#endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */
*
*/
-#include <common/compat/directory-handle.h>
-#include <common/credentials.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/fd-tracker/utils.h>
-#include <common/fs-handle.h>
-#include <common/fs-handle-internal.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/optional.h>
-#include <common/string-utils/format.h>
-#include <common/time.h>
-#include <common/trace-chunk-registry.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/credentials.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/fs-handle.hpp>
+#include <common/fs-handle-internal.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/optional.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/time.hpp>
+#include <common/trace-chunk-registry.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
#include <lttng/constant.h>
#include <inttypes.h>
+++ /dev/null
-/*
- * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TRACE_CHUNK_H
-#define LTTNG_TRACE_CHUNK_H
-
-#include <common/compat/directory-handle.h>
-#include <common/credentials.h>
-#include <common/fd-tracker/fd-tracker.h>
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-/*
- * A trace chunk is a group of directories and files forming a (or a set of)
- * complete and independant trace(s). For instance, a trace archive chunk,
- * a snapshot, or a regular LTTng trace are all instances of a trace archive.
- *
- * A trace chunk is always contained within a session output directory.
- *
- * This facility is used by the session daemon, consumer daemon(s), and relay
- * daemon to:
- * - Control file (data stream, metadata, and index) creation relative to
- * a given output directory,
- * - Track the use of an output directory by other objects in order to
- * know if/when an output directory can be safely consumed, renamed,
- * deleted, etc.
- *
- *
- * OWNER VS USER
- * ---
- *
- * A trace chunk can either be a owner or a user of its
- * "chunk output directory".
- *
- * A "user" trace chunk is provided with a handle to the chunk output directory
- * which can then be used to create subdirectories and files.
- *
- * An "owner" chunk, on top of being able to perform the operations of a "user"
- * chunk can perform operations on its chunk output directory, such as renaming
- * or deleting it.
- *
- * A trace chunk becomes an "owner" or "user" chunk based on which of
- * 'lttng_trace_chunk_set_as_owner()' or 'lttng_trace_chunk_set_as_user()' is
- * used. These methods are _exclusive_ and must only be used once on a
- * trace chunk.
- */
-
-struct lttng_trace_chunk;
-struct fd_tracker;
-
-enum lttng_trace_chunk_status {
- LTTNG_TRACE_CHUNK_STATUS_OK,
- LTTNG_TRACE_CHUNK_STATUS_NONE,
- LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT,
- LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION,
- LTTNG_TRACE_CHUNK_STATUS_ERROR,
- LTTNG_TRACE_CHUNK_STATUS_NO_FILE,
-};
-
-enum lttng_trace_chunk_command_type {
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED = 0,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION = 1,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE = 2,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
-};
-
-struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void);
-
-struct lttng_trace_chunk *lttng_trace_chunk_create(
- uint64_t chunk_id,
- time_t chunk_creation_time,
- const char *path);
-
-void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
- struct fd_tracker *fd_tracker);
-
-/*
- * Copy a trace chunk. The copy that is returned is always a _user_
- * mode chunk even if the source chunk was an _owner_ as there can never be
- * two _owners_ of the same trace output.
- */
-struct lttng_trace_chunk *lttng_trace_chunk_copy(
- struct lttng_trace_chunk *source_chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_id(
- struct lttng_trace_chunk *chunk, uint64_t *id);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_creation_timestamp(
- struct lttng_trace_chunk *chunk, time_t *creation_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(
- struct lttng_trace_chunk *chunk, time_t *close_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(
- struct lttng_trace_chunk *chunk, time_t close_ts);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_name(
- struct lttng_trace_chunk *chunk, const char **name,
- bool *name_overridden);
-
-bool lttng_trace_chunk_get_name_overridden(struct lttng_trace_chunk *chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
- struct lttng_trace_chunk *chunk, const char *name);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(
- struct lttng_trace_chunk *chunk, const char *path);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_credentials(
- struct lttng_trace_chunk *chunk,
- struct lttng_credentials *credentials);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials(
- struct lttng_trace_chunk *chunk,
- const struct lttng_credentials *credentials);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials_current_user(
- struct lttng_trace_chunk *chunk);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_owner(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle *session_output_directory);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_user(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle *chunk_directory);
-
-enum lttng_trace_chunk_status
-lttng_trace_chunk_get_session_output_directory_handle(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle **handle);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_borrow_chunk_directory_handle(
- struct lttng_trace_chunk *chunk,
- const struct lttng_directory_handle **handle);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(
- struct lttng_trace_chunk *chunk,
- const char *subdirectory_path);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
- struct lttng_trace_chunk *chunk,
- const char *filename,
- int flags,
- mode_t mode,
- int *out_fd,
- bool expect_no_file);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(
- struct lttng_trace_chunk *chunk,
- const char *filename,
- int flags,
- mode_t mode,
- struct fs_handle **out_handle,
- bool expect_no_file);
-
-int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk,
- const char *filename);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_command(
- struct lttng_trace_chunk *chunk,
- enum lttng_trace_chunk_command_type *command_type);
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command(
- struct lttng_trace_chunk *chunk,
- enum lttng_trace_chunk_command_type command_type);
-
-const char *lttng_trace_chunk_command_type_get_name(
- enum lttng_trace_chunk_command_type command);
-
-bool lttng_trace_chunk_ids_equal(const struct lttng_trace_chunk *chunk_a,
- const struct lttng_trace_chunk *chunk_b);
-
-/* Returns true on success. */
-bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk);
-
-void lttng_trace_chunk_put(struct lttng_trace_chunk *chunk);
-
-#endif /* LTTNG_TRACE_CHUNK_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TRACE_CHUNK_H
+#define LTTNG_TRACE_CHUNK_H
+
+#include <common/compat/directory-handle.hpp>
+#include <common/credentials.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * A trace chunk is a group of directories and files forming a (or a set of)
+ * complete and independant trace(s). For instance, a trace archive chunk,
+ * a snapshot, or a regular LTTng trace are all instances of a trace archive.
+ *
+ * A trace chunk is always contained within a session output directory.
+ *
+ * This facility is used by the session daemon, consumer daemon(s), and relay
+ * daemon to:
+ * - Control file (data stream, metadata, and index) creation relative to
+ * a given output directory,
+ * - Track the use of an output directory by other objects in order to
+ * know if/when an output directory can be safely consumed, renamed,
+ * deleted, etc.
+ *
+ *
+ * OWNER VS USER
+ * ---
+ *
+ * A trace chunk can either be a owner or a user of its
+ * "chunk output directory".
+ *
+ * A "user" trace chunk is provided with a handle to the chunk output directory
+ * which can then be used to create subdirectories and files.
+ *
+ * An "owner" chunk, on top of being able to perform the operations of a "user"
+ * chunk can perform operations on its chunk output directory, such as renaming
+ * or deleting it.
+ *
+ * A trace chunk becomes an "owner" or "user" chunk based on which of
+ * 'lttng_trace_chunk_set_as_owner()' or 'lttng_trace_chunk_set_as_user()' is
+ * used. These methods are _exclusive_ and must only be used once on a
+ * trace chunk.
+ */
+
+struct lttng_trace_chunk;
+struct fd_tracker;
+
+enum lttng_trace_chunk_status {
+ LTTNG_TRACE_CHUNK_STATUS_OK,
+ LTTNG_TRACE_CHUNK_STATUS_NONE,
+ LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT,
+ LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION,
+ LTTNG_TRACE_CHUNK_STATUS_ERROR,
+ LTTNG_TRACE_CHUNK_STATUS_NO_FILE,
+};
+
+enum lttng_trace_chunk_command_type {
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED = 0,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION = 1,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE = 2,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
+};
+
+struct lttng_trace_chunk *lttng_trace_chunk_create_anonymous(void);
+
+struct lttng_trace_chunk *lttng_trace_chunk_create(
+ uint64_t chunk_id,
+ time_t chunk_creation_time,
+ const char *path);
+
+void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
+ struct fd_tracker *fd_tracker);
+
+/*
+ * Copy a trace chunk. The copy that is returned is always a _user_
+ * mode chunk even if the source chunk was an _owner_ as there can never be
+ * two _owners_ of the same trace output.
+ */
+struct lttng_trace_chunk *lttng_trace_chunk_copy(
+ struct lttng_trace_chunk *source_chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_id(
+ struct lttng_trace_chunk *chunk, uint64_t *id);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_creation_timestamp(
+ struct lttng_trace_chunk *chunk, time_t *creation_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(
+ struct lttng_trace_chunk *chunk, time_t *close_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(
+ struct lttng_trace_chunk *chunk, time_t close_ts);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_name(
+ struct lttng_trace_chunk *chunk, const char **name,
+ bool *name_overridden);
+
+bool lttng_trace_chunk_get_name_overridden(struct lttng_trace_chunk *chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
+ struct lttng_trace_chunk *chunk, const char *name);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(
+ struct lttng_trace_chunk *chunk, const char *path);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_credentials(
+ struct lttng_trace_chunk *chunk,
+ struct lttng_credentials *credentials);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials(
+ struct lttng_trace_chunk *chunk,
+ const struct lttng_credentials *credentials);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials_current_user(
+ struct lttng_trace_chunk *chunk);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_as_owner(
+ struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle *session_output_directory);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_as_user(
+ struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle *chunk_directory);
+
+enum lttng_trace_chunk_status
+lttng_trace_chunk_get_session_output_directory_handle(
+ struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle **handle);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_borrow_chunk_directory_handle(
+ struct lttng_trace_chunk *chunk,
+ const struct lttng_directory_handle **handle);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(
+ struct lttng_trace_chunk *chunk,
+ const char *subdirectory_path);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
+ struct lttng_trace_chunk *chunk,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ int *out_fd,
+ bool expect_no_file);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(
+ struct lttng_trace_chunk *chunk,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ struct fs_handle **out_handle,
+ bool expect_no_file);
+
+int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk,
+ const char *filename);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_get_close_command(
+ struct lttng_trace_chunk *chunk,
+ enum lttng_trace_chunk_command_type *command_type);
+
+enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command(
+ struct lttng_trace_chunk *chunk,
+ enum lttng_trace_chunk_command_type command_type);
+
+const char *lttng_trace_chunk_command_type_get_name(
+ enum lttng_trace_chunk_command_type command);
+
+bool lttng_trace_chunk_ids_equal(const struct lttng_trace_chunk *chunk_a,
+ const struct lttng_trace_chunk *chunk_b);
+
+/* Returns true on success. */
+bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk);
+
+void lttng_trace_chunk_put(struct lttng_trace_chunk *chunk);
+
+#endif /* LTTNG_TRACE_CHUNK_H */
#include <lttng/lttng-error.h>
#include <lttng/tracker.h>
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/tracker.h>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/tracker.hpp>
#include <stdbool.h>
+++ /dev/null
-/*
- * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_COMMON_TRACKER_H
-#define LTTNG_COMMON_TRACKER_H
-
-#include <lttng/lttng-error.h>
-#include <lttng/tracker.h>
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-struct process_attr_value {
- enum lttng_process_attr_value_type type;
- union value {
- pid_t pid;
- uid_t uid;
- char *user_name;
- gid_t gid;
- char *group_name;
- } value;
-};
-
-struct lttng_process_attr_values {
- /* Array of struct process_attr_tracker_value. */
- struct lttng_dynamic_pointer_array array;
-};
-
-const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr);
-
-struct lttng_process_attr_values *lttng_process_attr_values_create(void);
-
-/* Prefixed with '_' since the name conflicts with a public API. */
-unsigned int _lttng_process_attr_values_get_count(
- const struct lttng_process_attr_values *values);
-
-const struct process_attr_value *lttng_process_attr_tracker_values_get_at_index(
- const struct lttng_process_attr_values *values,
- unsigned int index);
-
-int lttng_process_attr_values_serialize(
- const struct lttng_process_attr_values *values,
- struct lttng_dynamic_buffer *buffer);
-
-ssize_t lttng_process_attr_values_create_from_buffer(
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct lttng_buffer_view *buffer_view,
- struct lttng_process_attr_values **_values);
-
-void lttng_process_attr_values_destroy(
- struct lttng_process_attr_values *values);
-
-struct process_attr_value *process_attr_value_copy(
- const struct process_attr_value *value);
-
-unsigned long process_attr_value_hash(const struct process_attr_value *a);
-
-bool process_attr_tracker_value_equal(const struct process_attr_value *a,
- const struct process_attr_value *b);
-
-void process_attr_value_destroy(struct process_attr_value *value);
-
-enum lttng_error_code process_attr_value_from_comm(
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_process_attr_value_type value_type,
- const struct process_attr_integral_value_comm *integral_value,
- const struct lttng_buffer_view *value_view,
- struct process_attr_value **value);
-
-#endif /* LTTNG_COMMON_TRACKER_H */
--- /dev/null
+/*
+ * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_COMMON_TRACKER_H
+#define LTTNG_COMMON_TRACKER_H
+
+#include <lttng/lttng-error.h>
+#include <lttng/tracker.h>
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+struct process_attr_value {
+ enum lttng_process_attr_value_type type;
+ union value {
+ pid_t pid;
+ uid_t uid;
+ char *user_name;
+ gid_t gid;
+ char *group_name;
+ } value;
+};
+
+struct lttng_process_attr_values {
+ /* Array of struct process_attr_tracker_value. */
+ struct lttng_dynamic_pointer_array array;
+};
+
+const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr);
+
+struct lttng_process_attr_values *lttng_process_attr_values_create(void);
+
+/* Prefixed with '_' since the name conflicts with a public API. */
+unsigned int _lttng_process_attr_values_get_count(
+ const struct lttng_process_attr_values *values);
+
+const struct process_attr_value *lttng_process_attr_tracker_values_get_at_index(
+ const struct lttng_process_attr_values *values,
+ unsigned int index);
+
+int lttng_process_attr_values_serialize(
+ const struct lttng_process_attr_values *values,
+ struct lttng_dynamic_buffer *buffer);
+
+ssize_t lttng_process_attr_values_create_from_buffer(
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct lttng_buffer_view *buffer_view,
+ struct lttng_process_attr_values **_values);
+
+void lttng_process_attr_values_destroy(
+ struct lttng_process_attr_values *values);
+
+struct process_attr_value *process_attr_value_copy(
+ const struct process_attr_value *value);
+
+unsigned long process_attr_value_hash(const struct process_attr_value *a);
+
+bool process_attr_tracker_value_equal(const struct process_attr_value *a,
+ const struct process_attr_value *b);
+
+void process_attr_value_destroy(struct process_attr_value *value);
+
+enum lttng_error_code process_attr_value_from_comm(
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_process_attr_value_type value_type,
+ const struct process_attr_integral_value_comm *integral_value,
+ const struct lttng_buffer_view *value_view,
+ struct process_attr_value **value);
+
+#endif /* LTTNG_COMMON_TRACKER_H */
*
*/
-#include <common/credentials.h>
-#include <common/dynamic-array.h>
-#include <common/error.h>
-#include <common/mi-lttng.h>
-#include <common/optional.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/credentials.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/error.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <inttypes.h>
-#include <lttng/action/action-internal.h>
+#include <lttng/action/action-internal.hpp>
#include <lttng/condition/buffer-usage.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
#include <lttng/domain.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-expr-internal.h>
-#include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-expr-internal.hpp>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
#include <pthread.h>
bool lttng_trigger_validate(const struct lttng_trigger *trigger)
#include <sys/types.h>
#include <unistd.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/fd-handle.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/fd-handle.hpp>
-#include "unix.h"
+#include "unix.hpp"
/*
* Connect to unix socket using the path name.
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _LTTCOMM_UNIX_H
-#define _LTTCOMM_UNIX_H
-
-#include <limits.h>
-#include <sys/un.h>
-
-#include <common/compat/socket.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-
-int lttcomm_create_unix_sock(const char *pathname);
-int lttcomm_create_anon_unix_socketpair(int *fds);
-int lttcomm_connect_unix_sock(const char *pathname);
-int lttcomm_accept_unix_sock(int sock);
-int lttcomm_listen_unix_sock(int sock);
-int lttcomm_close_unix_sock(int sock);
-
-/* Send a message accompanied by fd(s) over a unix socket. */
-ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd);
-ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock,
- struct lttng_payload_view *view);
-ssize_t lttcomm_send_fds_unix_sock_non_block(
- int sock, const int *fds, size_t nb_fd);
-ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock,
- struct lttng_payload_view *view);
-
-/* Recv a message accompanied by fd(s) from a unix socket */
-ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd);
-ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
- struct lttng_payload *payload);
-ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd);
-ssize_t lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd,
- struct lttng_payload *payload);
-
-ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
-ssize_t lttcomm_recv_unix_sock_non_block(int sock, void *buf, size_t len);
-ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len);
-ssize_t lttcomm_send_unix_sock_non_block(int sock, const void *buf, size_t len);
-
-ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len);
-ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
- lttng_sock_cred *creds);
-
-int lttcomm_setsockopt_creds_unix_sock(int sock);
-
-#endif /* _LTTCOMM_UNIX_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _LTTCOMM_UNIX_H
+#define _LTTCOMM_UNIX_H
+
+#include <limits.h>
+#include <sys/un.h>
+
+#include <common/compat/socket.hpp>
+#include <common/macros.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+
+int lttcomm_create_unix_sock(const char *pathname);
+int lttcomm_create_anon_unix_socketpair(int *fds);
+int lttcomm_connect_unix_sock(const char *pathname);
+int lttcomm_accept_unix_sock(int sock);
+int lttcomm_listen_unix_sock(int sock);
+int lttcomm_close_unix_sock(int sock);
+
+/* Send a message accompanied by fd(s) over a unix socket. */
+ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd);
+ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock,
+ struct lttng_payload_view *view);
+ssize_t lttcomm_send_fds_unix_sock_non_block(
+ int sock, const int *fds, size_t nb_fd);
+ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock,
+ struct lttng_payload_view *view);
+
+/* Recv a message accompanied by fd(s) from a unix socket */
+ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd);
+ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
+ struct lttng_payload *payload);
+ssize_t lttcomm_recv_fds_unix_sock_non_block(int sock, int *fds, size_t nb_fd);
+ssize_t lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd,
+ struct lttng_payload *payload);
+
+ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
+ssize_t lttcomm_recv_unix_sock_non_block(int sock, void *buf, size_t len);
+ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len);
+ssize_t lttcomm_send_unix_sock_non_block(int sock, const void *buf, size_t len);
+
+ssize_t lttcomm_send_creds_unix_sock(int sock, const void *buf, size_t len);
+ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
+ lttng_sock_cred *creds);
+
+int lttcomm_setsockopt_creds_unix_sock(int sock);
+
+#endif /* _LTTCOMM_UNIX_H */
#define _LGPL_SOURCE
#include <arpa/inet.h>
-#include <common/compat/netdb.h>
+#include <common/compat/netdb.hpp>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
-#include "uri.h"
+#include "uri.hpp"
#define LOOPBACK_ADDR_IPV4 "127.0.0.1"
#define LOOPBACK_ADDR_IPV6 "::1"
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef URI_H
-#define URI_H
-
-#include <netinet/in.h>
-#include <lttng/lttng.h>
-#include <common/macros.h>
-
-/* Destination type of lttng URI */
-enum lttng_dst_type {
- LTTNG_DST_IPV4 = 1,
- LTTNG_DST_IPV6 = 2,
- LTTNG_DST_PATH = 3,
-};
-
-/* Type of lttng URI where it is a final destination or a hop */
-enum lttng_uri_type {
- LTTNG_URI_DST, /* The URI is a final destination */
- /*
- * Hops are not supported yet but planned for a future release.
- *
- LTTNG_URI_HOP,
- */
-};
-
-/* Communication stream type of a lttng URI */
-enum lttng_stream_type {
- LTTNG_STREAM_CONTROL,
- LTTNG_STREAM_DATA,
-};
-
-/*
- * Protocol type of a lttng URI. The value 0 indicate that the proto_type field
- * should be ignored.
- */
-enum lttng_proto_type {
- LTTNG_PROTO_TYPE_NONE = 0,
- LTTNG_TCP = 1,
- /*
- * UDP protocol is not supported for now.
- *
- LTTNG_UDP = 2,
- */
-};
-
-/*
- * Structure representing an URI supported by lttng.
- */
-struct lttng_uri {
- enum lttng_dst_type dtype;
- enum lttng_uri_type utype;
- enum lttng_stream_type stype;
- enum lttng_proto_type proto;
- uint16_t port;
- char subdir[LTTNG_PATH_MAX];
- union {
- char ipv4[INET_ADDRSTRLEN];
- char ipv6[INET6_ADDRSTRLEN];
- char path[LTTNG_PATH_MAX];
- } dst;
-} LTTNG_PACKED;
-
-int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2);
-void uri_free(struct lttng_uri *uri);
-ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris);
-ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
- struct lttng_uri **uris);
-int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size);
-
-#endif /* _LTT_URI_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef URI_H
+#define URI_H
+
+#include <netinet/in.h>
+#include <lttng/lttng.h>
+#include <common/macros.hpp>
+
+/* Destination type of lttng URI */
+enum lttng_dst_type {
+ LTTNG_DST_IPV4 = 1,
+ LTTNG_DST_IPV6 = 2,
+ LTTNG_DST_PATH = 3,
+};
+
+/* Type of lttng URI where it is a final destination or a hop */
+enum lttng_uri_type {
+ LTTNG_URI_DST, /* The URI is a final destination */
+ /*
+ * Hops are not supported yet but planned for a future release.
+ *
+ LTTNG_URI_HOP,
+ */
+};
+
+/* Communication stream type of a lttng URI */
+enum lttng_stream_type {
+ LTTNG_STREAM_CONTROL,
+ LTTNG_STREAM_DATA,
+};
+
+/*
+ * Protocol type of a lttng URI. The value 0 indicate that the proto_type field
+ * should be ignored.
+ */
+enum lttng_proto_type {
+ LTTNG_PROTO_TYPE_NONE = 0,
+ LTTNG_TCP = 1,
+ /*
+ * UDP protocol is not supported for now.
+ *
+ LTTNG_UDP = 2,
+ */
+};
+
+/*
+ * Structure representing an URI supported by lttng.
+ */
+struct lttng_uri {
+ enum lttng_dst_type dtype;
+ enum lttng_uri_type utype;
+ enum lttng_stream_type stype;
+ enum lttng_proto_type proto;
+ uint16_t port;
+ char subdir[LTTNG_PATH_MAX];
+ union {
+ char ipv4[INET_ADDRSTRLEN];
+ char ipv6[INET6_ADDRSTRLEN];
+ char path[LTTNG_PATH_MAX];
+ } dst;
+} LTTNG_PACKED;
+
+int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2);
+void uri_free(struct lttng_uri *uri);
+ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris);
+ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
+ struct lttng_uri **uris);
+int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size);
+
+#endif /* _LTT_URI_H */
*/
#include "lttng/lttng-error.h"
-#include <common/compat/string.h>
-#include <common/align.h>
-#include <common/error.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/mi-lttng.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/compat/string.hpp>
+#include <common/align.hpp>
+#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <fcntl.h>
#include <lttng/constant.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <common/common.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/relayd/relayd.h>
-#include <common/compat/fcntl.h>
-#include <common/compat/endian.h>
-#include <common/consumer/consumer-metadata-cache.h>
-#include <common/consumer/consumer-stream.h>
-#include <common/consumer/consumer-timer.h>
-#include <common/utils.h>
-#include <common/index/index.h>
-#include <common/consumer/consumer.h>
-#include <common/shm.h>
-#include <common/optional.h>
-
-#include "ust-consumer.h"
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/common.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/compat/endian.hpp>
+#include <common/consumer/consumer-metadata-cache.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/utils.hpp>
+#include <common/index/index.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/shm.hpp>
+#include <common/optional.hpp>
+
+#include "ust-consumer.hpp"
#define INT_MAX_STR_LEN 12 /* includes \0 */
+++ /dev/null
-/*
- * Copyright (C) 2011 EfficiOS Inc.
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: GPL-2.0-only
- *
- */
-
-#ifndef _LTTNG_USTCONSUMER_H
-#define _LTTNG_USTCONSUMER_H
-
-#include <common/compat/errno.h>
-#include <common/consumer/consumer.h>
-#include <stdbool.h>
-
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_sample_snapshot_positions(
- struct lttng_consumer_stream *stream);
-
-int lttng_ustconsumer_get_produced_snapshot(
- struct lttng_consumer_stream *stream, unsigned long *pos);
-int lttng_ustconsumer_get_consumed_snapshot(
- struct lttng_consumer_stream *stream, unsigned long *pos);
-
-int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll);
-
-extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan);
-extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan);
-extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan);
-extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream);
-extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream);
-
-int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx);
-int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
-
-void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
-
-int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
- int producer_active);
-int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
- uint64_t *stream_id);
-int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
-void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
-void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
-void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
- uint64_t len, uint64_t version,
- struct lttng_consumer_channel *channel, int timer, int wait);
-int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_channel *channel, int timer, int wait);
-enum sync_metadata_status lttng_ustconsumer_sync_metadata(
- struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_stream *metadata);
-int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
- int producer);
-int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
-int lttng_ustconsumer_get_current_timestamp(
- struct lttng_consumer_stream *stream, uint64_t *ts);
-int lttng_ustconsumer_get_sequence_number(
- struct lttng_consumer_stream *stream, uint64_t *seq);
-void lttng_ustconsumer_sigbus_handle(void *addr);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-static inline
-ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- struct lttng_consumer_stream *stream __attribute__((unused)),
- unsigned long len __attribute__((unused)),
- unsigned long padding __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- struct lttng_consumer_stream *uststream __attribute__((unused)),
- unsigned long len __attribute__((unused)),
- unsigned long padding __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_take_snapshot(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_sample_snapshot_positions(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_produced_snapshot(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- unsigned long *pos __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_consumed_snapshot(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- unsigned long *pos __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_recv_cmd(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- int sock __attribute__((unused)),
- struct pollfd *consumer_sockpoll __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_allocate_channel(
- struct lttng_consumer_channel *chan __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_del_channel(
- struct lttng_consumer_channel *chan __attribute__((unused)))
-{
-}
-
-static inline
-void lttng_ustconsumer_free_channel(
- struct lttng_consumer_channel *chan __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_add_stream(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_del_stream(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_read_subbuffer(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- struct lttng_consumer_local_data *ctx __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_on_recv_stream(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_on_stream_hangup(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_data_pending(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream __attribute__((unused)),
- int producer_active __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_close_all_metadata(
- struct lttng_ht *ht __attribute__((unused)))
-{
-}
-
-static inline
-void lttng_ustconsumer_close_metadata(
- struct lttng_consumer_channel *metadata __attribute__((unused)))
-{
-}
-static inline
-void lttng_ustconsumer_close_stream_wakeup(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
-}
-
-static inline
-int lttng_ustconsumer_recv_metadata(int sock __attribute__((unused)),
- uint64_t key __attribute__((unused)),
- uint64_t offset __attribute__((unused)),
- uint64_t len __attribute__((unused)),
- uint64_t version __attribute__((unused)),
- struct lttng_consumer_channel *channel __attribute__((unused)),
- int timer __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_request_metadata(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- struct lttng_consumer_channel *channel __attribute__((unused)),
- int timer __attribute__((unused)),
- int wait __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-enum sync_metadata_status lttng_ustconsumer_sync_metadata(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- struct lttng_consumer_stream *metadata __attribute__((unused)))
-{
- return SYNC_METADATA_STATUS_ERROR;
-}
-
-static inline
-int lttng_ustconsumer_flush_buffer(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- int producer __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_clear_buffer(
- struct lttng_consumer_stream *stream __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_current_timestamp(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- uint64_t *ts __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_sequence_number(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- uint64_t *seq __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-int lttng_ustconsumer_get_stream_id(
- struct lttng_consumer_stream *stream __attribute__((unused)),
- uint64_t *stream_id __attribute__((unused)))
-{
- return -ENOSYS;
-}
-
-static inline
-void lttng_ustconsumer_sigbus_handle(
- void *addr __attribute__((unused)))
-{
-}
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTTNG_USTCONSUMER_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 EfficiOS Inc.
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef _LTTNG_USTCONSUMER_H
+#define _LTTNG_USTCONSUMER_H
+
+#include <common/compat/errno.hpp>
+#include <common/consumer/consumer.hpp>
+#include <stdbool.h>
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_sample_snapshot_positions(
+ struct lttng_consumer_stream *stream);
+
+int lttng_ustconsumer_get_produced_snapshot(
+ struct lttng_consumer_stream *stream, unsigned long *pos);
+int lttng_ustconsumer_get_consumed_snapshot(
+ struct lttng_consumer_stream *stream, unsigned long *pos);
+
+int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
+ int sock, struct pollfd *consumer_sockpoll);
+
+extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan);
+extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan);
+extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan);
+extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream);
+extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream);
+
+int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx);
+int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
+
+void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
+
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
+ int producer_active);
+int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
+ uint64_t *stream_id);
+int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
+void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
+void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
+void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
+ uint64_t len, uint64_t version,
+ struct lttng_consumer_channel *channel, int timer, int wait);
+int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_channel *channel, int timer, int wait);
+enum sync_metadata_status lttng_ustconsumer_sync_metadata(
+ struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_stream *metadata);
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
+ int producer);
+int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_get_current_timestamp(
+ struct lttng_consumer_stream *stream, uint64_t *ts);
+int lttng_ustconsumer_get_sequence_number(
+ struct lttng_consumer_stream *stream, uint64_t *seq);
+void lttng_ustconsumer_sigbus_handle(void *addr);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
+ struct lttng_consumer_local_data *ctx __attribute__((unused)),
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ unsigned long len __attribute__((unused)),
+ unsigned long padding __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
+ struct lttng_consumer_local_data *ctx __attribute__((unused)),
+ struct lttng_consumer_stream *uststream __attribute__((unused)),
+ unsigned long len __attribute__((unused)),
+ unsigned long padding __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_take_snapshot(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_sample_snapshot_positions(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_produced_snapshot(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ unsigned long *pos __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_consumed_snapshot(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ unsigned long *pos __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_recv_cmd(
+ struct lttng_consumer_local_data *ctx __attribute__((unused)),
+ int sock __attribute__((unused)),
+ struct pollfd *consumer_sockpoll __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_allocate_channel(
+ struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_del_channel(
+ struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+}
+
+static inline
+void lttng_ustconsumer_free_channel(
+ struct lttng_consumer_channel *chan __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_add_stream(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_del_stream(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_read_subbuffer(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ struct lttng_consumer_local_data *ctx __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_on_recv_stream(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_on_stream_hangup(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_data_pending(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream __attribute__((unused)),
+ int producer_active __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_close_all_metadata(
+ struct lttng_ht *ht __attribute__((unused)))
+{
+}
+
+static inline
+void lttng_ustconsumer_close_metadata(
+ struct lttng_consumer_channel *metadata __attribute__((unused)))
+{
+}
+static inline
+void lttng_ustconsumer_close_stream_wakeup(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+}
+
+static inline
+int lttng_ustconsumer_recv_metadata(int sock __attribute__((unused)),
+ uint64_t key __attribute__((unused)),
+ uint64_t offset __attribute__((unused)),
+ uint64_t len __attribute__((unused)),
+ uint64_t version __attribute__((unused)),
+ struct lttng_consumer_channel *channel __attribute__((unused)),
+ int timer __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_request_metadata(
+ struct lttng_consumer_local_data *ctx __attribute__((unused)),
+ struct lttng_consumer_channel *channel __attribute__((unused)),
+ int timer __attribute__((unused)),
+ int wait __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+enum sync_metadata_status lttng_ustconsumer_sync_metadata(
+ struct lttng_consumer_local_data *ctx __attribute__((unused)),
+ struct lttng_consumer_stream *metadata __attribute__((unused)))
+{
+ return SYNC_METADATA_STATUS_ERROR;
+}
+
+static inline
+int lttng_ustconsumer_flush_buffer(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ int producer __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_clear_buffer(
+ struct lttng_consumer_stream *stream __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_current_timestamp(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ uint64_t *ts __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_sequence_number(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ uint64_t *seq __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+int lttng_ustconsumer_get_stream_id(
+ struct lttng_consumer_stream *stream __attribute__((unused)),
+ uint64_t *stream_id __attribute__((unused)))
+{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_ustconsumer_sigbus_handle(
+ void *addr __attribute__((unused)))
+{
+}
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* _LTTNG_USTCONSUMER_H */
*
*/
-#include "common/macros.h"
-#include <stdint.h>
#define _LGPL_SOURCE
#include <ctype.h>
#include <fcntl.h>
+#include <grp.h>
+#include <inttypes.h>
#include <limits.h>
+#include <pwd.h>
#include <stdlib.h>
+#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <grp.h>
-#include <pwd.h>
-#include <sys/file.h>
-#include <unistd.h>
-#include <common/common.h>
-#include <common/readwrite.h>
-#include <common/runas.h>
-#include <common/compat/getenv.h>
-#include <common/compat/string.h>
-#include <common/compat/dirent.h>
-#include <common/compat/directory-handle.h>
-#include <common/dynamic-buffer.h>
-#include <common/string-utils/format.h>
+#include <common/common.hpp>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/dirent.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/readwrite.hpp>
+#include <common/runas.hpp>
+#include <common/string-utils/format.hpp>
#include <lttng/constant.h>
-#include "utils.h"
-#include "defaults.h"
-#include "time.h"
+#include "defaults.hpp"
+#include "time.hpp"
+#include "utils.hpp"
#define PROC_MEMINFO_PATH "/proc/meminfo"
#define PROC_MEMINFO_MEMAVAILABLE_LINE "MemAvailable:"
+++ /dev/null
-/*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef _COMMON_UTILS_H
-#define _COMMON_UTILS_H
-
-#include <getopt.h>
-#include <lttng/lttng-error.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <common/compat/directory-handle.h>
-
-#define KIBI_LOG2 10
-#define MEBI_LOG2 20
-#define GIBI_LOG2 30
-
-int utils_create_pipe(int *dst);
-int utils_create_pipe_cloexec(int *dst);
-int utils_create_pipe_cloexec_nonblock(int *dst);
-void utils_close_pipe(int *src);
-char *utils_strdupdelim(const char *begin, const char *end);
-int utils_set_fd_cloexec(int fd);
-int utils_create_pid_file(pid_t pid, const char *filepath);
-int utils_mkdir(const char *path, mode_t mode, int uid, int gid);
-int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid);
-int utils_stream_file_path(const char *path_name, const char *file_name,
- uint64_t size, uint64_t count, const char *suffix,
- char *out_stream_path, size_t stream_path_len);
-int utils_parse_size_suffix(char const * const str, uint64_t * const size);
-int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
-int utils_get_count_order_u32(uint32_t x);
-int utils_get_count_order_u64(uint64_t x);
-const char *utils_get_home_dir(void);
-char *utils_get_user_home_dir(uid_t uid);
-
-size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
- ATTR_FORMAT_STRFTIME(1);
-
-int utils_get_group_id(const char *name, bool warn, gid_t *gid);
-char *utils_generate_optstring(const struct option *long_options,
- size_t opt_count);
-int utils_create_lock_file(const char *filepath);
-int utils_recursive_rmdir(const char *path);
-int utils_truncate_stream_file(int fd, off_t length);
-int utils_show_help(int section, const char *page_name, const char *help_msg);
-int utils_get_memory_available(uint64_t *value);
-int utils_get_memory_total(uint64_t *value);
-int utils_change_working_directory(const char *path);
-enum lttng_error_code utils_user_id_from_name(
- const char *user_name, uid_t *user_id);
-enum lttng_error_code utils_group_id_from_name(
- const char *group_name, gid_t *group_id);
-
-/*
- * Parse `str` as an unsigned long long value.
- *
- * Return 0 on success. Return -1 on failure which can be because:
- *
- * - `str` is zero length
- * - `str` contains invalid
- */
-int utils_parse_unsigned_long_long(const char *str,
- unsigned long long *value);
-
-#endif /* _COMMON_UTILS_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef _COMMON_UTILS_H
+#define _COMMON_UTILS_H
+
+#include <getopt.h>
+#include <lttng/lttng-error.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/compat/directory-handle.hpp>
+
+#define KIBI_LOG2 10
+#define MEBI_LOG2 20
+#define GIBI_LOG2 30
+
+int utils_create_pipe(int *dst);
+int utils_create_pipe_cloexec(int *dst);
+int utils_create_pipe_cloexec_nonblock(int *dst);
+void utils_close_pipe(int *src);
+char *utils_strdupdelim(const char *begin, const char *end);
+int utils_set_fd_cloexec(int fd);
+int utils_create_pid_file(pid_t pid, const char *filepath);
+int utils_mkdir(const char *path, mode_t mode, int uid, int gid);
+int utils_mkdir_recursive(const char *path, mode_t mode, int uid, int gid);
+int utils_stream_file_path(const char *path_name, const char *file_name,
+ uint64_t size, uint64_t count, const char *suffix,
+ char *out_stream_path, size_t stream_path_len);
+int utils_parse_size_suffix(char const * const str, uint64_t * const size);
+int utils_parse_time_suffix(char const * const str, uint64_t * const time_us);
+int utils_get_count_order_u32(uint32_t x);
+int utils_get_count_order_u64(uint64_t x);
+const char *utils_get_home_dir(void);
+char *utils_get_user_home_dir(uid_t uid);
+
+size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
+ ATTR_FORMAT_STRFTIME(1);
+
+int utils_get_group_id(const char *name, bool warn, gid_t *gid);
+char *utils_generate_optstring(const struct option *long_options,
+ size_t opt_count);
+int utils_create_lock_file(const char *filepath);
+int utils_recursive_rmdir(const char *path);
+int utils_truncate_stream_file(int fd, off_t length);
+int utils_show_help(int section, const char *page_name, const char *help_msg);
+int utils_get_memory_available(uint64_t *value);
+int utils_get_memory_total(uint64_t *value);
+int utils_change_working_directory(const char *path);
+enum lttng_error_code utils_user_id_from_name(
+ const char *user_name, uid_t *user_id);
+enum lttng_error_code utils_group_id_from_name(
+ const char *group_name, gid_t *group_id);
+
+/*
+ * Parse `str` as an unsigned long long value.
+ *
+ * Return 0 on success. Return -1 on failure which can be because:
+ *
+ * - `str` is zero length
+ * - `str` contains invalid
+ */
+int utils_parse_unsigned_long_long(const char *str,
+ unsigned long long *value);
+
+#endif /* _COMMON_UTILS_H */
*
*/
-#include <common/compat/string.h>
+#include <common/compat/string.hpp>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include "uuid.h"
+#include "uuid.hpp"
static const lttng_uuid nil_uuid = { 0 };
static bool lttng_uuid_is_init;
+++ /dev/null
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- *
- */
-
-#ifndef LTTNG_UUID_H
-#define LTTNG_UUID_H
-
-#include <common/macros.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-/*
- * Includes final \0.
- */
-#define LTTNG_UUID_STR_LEN 37
-#define LTTNG_UUID_LEN 16
-#define LTTNG_UUID_VER 4
-
-#define LTTNG_UUID_FMT \
- "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
- "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
- "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
- "%02" SCNx8
-
-#define LTTNG_UUID_FMT_VALUES(uuid) \
- (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
- (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
- (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
-
-#define LTTNG_UUID_SCAN_VALUES(uuid) \
- &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
- &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
- &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
-
-typedef uint8_t lttng_uuid[LTTNG_UUID_LEN];
-
-int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
-
-/*
- * Convert a UUID to a human-readable, NULL-terminated, string of the form
- * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- *
- * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
- */
-void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str);
-
-bool lttng_uuid_is_equal(const lttng_uuid a, const lttng_uuid b);
-
-bool lttng_uuid_is_nil(const lttng_uuid uuid);
-
-void lttng_uuid_copy(lttng_uuid dst, const lttng_uuid src);
-
-/*
- * Generate a random UUID according to RFC4122, section 4.4.
- */
-int lttng_uuid_generate(lttng_uuid uuid_out);
-
-#endif /* LTTNG_UUID_H */
--- /dev/null
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_UUID_H
+#define LTTNG_UUID_H
+
+#include <common/macros.hpp>
+#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+/*
+ * Includes final \0.
+ */
+#define LTTNG_UUID_STR_LEN 37
+#define LTTNG_UUID_LEN 16
+#define LTTNG_UUID_VER 4
+
+#define LTTNG_UUID_FMT \
+ "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 \
+ "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 "-%02" SCNx8 "%02" SCNx8 \
+ "-%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 "%02" SCNx8 \
+ "%02" SCNx8
+
+#define LTTNG_UUID_FMT_VALUES(uuid) \
+ (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
+ (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
+ (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
+
+#define LTTNG_UUID_SCAN_VALUES(uuid) \
+ &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
+ &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
+ &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
+
+typedef uint8_t lttng_uuid[LTTNG_UUID_LEN];
+
+int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
+
+/*
+ * Convert a UUID to a human-readable, NULL-terminated, string of the form
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
+ *
+ * Assumes uuid_str is at least LTTNG_UUID_STR_LEN byte long.
+ */
+void lttng_uuid_to_str(const lttng_uuid uuid, char *uuid_str);
+
+bool lttng_uuid_is_equal(const lttng_uuid a, const lttng_uuid b);
+
+bool lttng_uuid_is_nil(const lttng_uuid uuid);
+
+void lttng_uuid_copy(lttng_uuid dst, const lttng_uuid src);
+
+/*
+ * Generate a random UUID according to RFC4122, section 4.4.
+ */
+int lttng_uuid_generate(lttng_uuid uuid_out);
+
+#endif /* LTTNG_UUID_H */
*
*/
-#include "waiter.h"
+#include "waiter.hpp"
#include <urcu/uatomic.h>
#include <urcu/futex.h>
-#include "error.h"
+#include "error.hpp"
#include <poll.h>
/*
+++ /dev/null
-/*
- * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- * This code is originally adapted from userspace-rcu's urcu-wait.h
- */
-
-#ifndef LTTNG_WAITER_H
-#define LTTNG_WAITER_H
-
-#define _LGPL_SOURCE
-
-#include <stdint.h>
-#include <urcu/wfstack.h>
-#include <stdbool.h>
-#include "macros.h"
-
-struct lttng_waiter {
- struct cds_wfs_node wait_queue_node;
- int32_t state;
-};
-
-void lttng_waiter_init(struct lttng_waiter *waiter);
-
-void lttng_waiter_wait(struct lttng_waiter *waiter);
-
-/*
- * lttng_waiter_wake_up must only be called by a single waker.
- * It is invalid for multiple "wake" operations to be invoked
- * on a single waiter without re-initializing it before.
- */
-void lttng_waiter_wake_up(struct lttng_waiter *waiter);
-
-#endif /* LTTNG_WAITER_H */
--- /dev/null
+/*
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * This code is originally adapted from userspace-rcu's urcu-wait.h
+ */
+
+#ifndef LTTNG_WAITER_H
+#define LTTNG_WAITER_H
+
+#define _LGPL_SOURCE
+
+#include <stdint.h>
+#include <urcu/wfstack.h>
+#include <stdbool.h>
+#include "macros.hpp"
+
+struct lttng_waiter {
+ struct cds_wfs_node wait_queue_node;
+ int32_t state;
+};
+
+void lttng_waiter_init(struct lttng_waiter *waiter);
+
+void lttng_waiter_wait(struct lttng_waiter *waiter);
+
+/*
+ * lttng_waiter_wake_up must only be called by a single waker.
+ * It is invalid for multiple "wake" operations to be invoked
+ * on a single waiter without re-initializing it before.
+ */
+void lttng_waiter_wake_up(struct lttng_waiter *waiter);
+
+#endif /* LTTNG_WAITER_H */
load.cpp \
lttng-ctl.cpp \
lttng-ctl-health.cpp \
- lttng-ctl-helper.h \
+ lttng-ctl-helper.hpp \
rotate.cpp \
save.cpp \
snapshot.cpp \
*
*/
-#include <lttng/notification/notification-internal.h>
-#include <lttng/notification/channel-internal.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
#include <lttng/endpoint.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/dynamic-buffer.h>
-#include <common/utils.h>
-#include <common/defaults.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-#include <common/unix.h>
-#include "lttng-ctl-helper.h"
-#include <common/compat/poll.h>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+#include <common/unix.hpp>
+#include "lttng-ctl-helper.hpp"
+#include <common/compat/poll.hpp>
static
int handshake(struct lttng_notification_channel *channel);
#include <lttng/lttng-error.h>
#include <lttng/clear.h>
#include <lttng/clear-handle.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
-#include <common/compat/poll.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/optional.h>
-
-#include "lttng-ctl-helper.h"
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
+#include <common/compat/poll.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/optional.hpp>
+
+#include "lttng-ctl-helper.hpp"
enum communication_state {
COMMUNICATION_STATE_RECEIVE_LTTNG_MSG,
#include <lttng/destruction-handle.h>
#include <lttng/rotation.h>
-#include <common/optional.h>
-#include <common/compat/poll.h>
-#include <common/compat/time.h>
-#include <common/macros.h>
-#include <common/compat/poll.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/location-internal.h>
-#include "lttng-ctl-helper.h"
+#include <common/optional.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/time.hpp>
+#include <common/macros.hpp>
+#include <common/compat/poll.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/location-internal.hpp>
+#include "lttng-ctl-helper.hpp"
#include <algorithm>
#include <stdbool.h>
#define _LGPL_SOURCE
#include <stddef.h>
-#include <common/error.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/event-internal.h>
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/event-internal.hpp>
#include <lttng/event.h>
#include <lttng/lttng-error.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
struct lttng_event *lttng_event_create(void)
{
#include <lttng/lttng-error.h>
#include <lttng/load.h>
-#include <lttng/load-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/config/session-config.h>
-#include <common/uri.h>
-#include <common/macros.h>
-#include <common/compat/string.h>
-
-#include "lttng-ctl-helper.h"
+#include <lttng/load-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/config/session-config.hpp>
+#include <common/uri.hpp>
+#include <common/macros.hpp>
+#include <common/compat/string.hpp>
+
+#include "lttng-ctl-helper.hpp"
struct lttng_load_session_attr *lttng_load_session_attr_create(void)
{
#include <stdint.h>
#include <limits.h>
#include <string.h>
-#include <lttng/health-internal.h>
+#include <lttng/health-internal.hpp>
-#include <bin/lttng-sessiond/health-sessiond.h>
-#include <bin/lttng-consumerd/health-consumerd.h>
-#include <bin/lttng-relayd/health-relayd.h>
-#include <common/defaults.h>
-#include <common/utils.h>
-#include <common/compat/errno.h>
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <bin/lttng-relayd/health-relayd.hpp>
+#include <common/defaults.hpp>
+#include <common/utils.hpp>
+#include <common/compat/errno.hpp>
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
enum health_component {
HEALTH_COMPONENT_SESSIOND,
+++ /dev/null
-/*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_CTL_HELPER_H
-#define LTTNG_CTL_HELPER_H
-
-#include <stdio.h>
-
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <lttng/lttng.h>
-
-/* Copy helper functions. */
-void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
- struct lttng_domain *src);
-
-/*
- * Sends the lttcomm message to the session daemon and fills buf if the
- * returned data is not NULL.
- *
- * Return the size of the received data on success or else a negative lttng
- * error code. If buf is NULL, 0 is returned on success.
- */
-int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
- const int *fds, size_t nb_fd,
- const void *vardata, size_t vardata_len,
- void **user_payload_buf, void **user_cmd_header_buf,
- size_t *user_cmd_header_len);
-
-/*
- * Sends the lttcomm message to the session daemon and fills the reply payload.
- *
- * Return the size of the received data on success or else a negative lttng
- * error code.
- */
-int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
- struct lttng_payload *reply);
-
-/*
- * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header.
- */
-static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header(
- struct lttcomm_session_msg *lsm,
- const void *vardata,
- size_t vardata_len,
- void **user_payload_buf)
-{
- return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata,
- vardata_len, user_payload_buf, NULL, NULL);
-}
-
-/*
- * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header.
- */
-static inline
-int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm,
- const int *fds, size_t nb_fd, void **buf __attribute__((unused)))
-{
- return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL,
- 0, NULL, NULL, NULL);
-}
-/*
- * Use this if no variable length data needs to be sent.
- */
-static inline
-int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
-{
- return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf);
-}
-
-int lttng_check_tracing_group(void);
-
-int connect_sessiond(void);
-
-#endif /* LTTNG_CTL_HELPER_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_CTL_HELPER_H
+#define LTTNG_CTL_HELPER_H
+
+#include <stdio.h>
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/lttng.h>
+
+/* Copy helper functions. */
+void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
+ struct lttng_domain *src);
+
+/*
+ * Sends the lttcomm message to the session daemon and fills buf if the
+ * returned data is not NULL.
+ *
+ * Return the size of the received data on success or else a negative lttng
+ * error code. If buf is NULL, 0 is returned on success.
+ */
+int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
+ const int *fds, size_t nb_fd,
+ const void *vardata, size_t vardata_len,
+ void **user_payload_buf, void **user_cmd_header_buf,
+ size_t *user_cmd_header_len);
+
+/*
+ * Sends the lttcomm message to the session daemon and fills the reply payload.
+ *
+ * Return the size of the received data on success or else a negative lttng
+ * error code.
+ */
+int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
+ struct lttng_payload *reply);
+
+/*
+ * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header.
+ */
+static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+ struct lttcomm_session_msg *lsm,
+ const void *vardata,
+ size_t vardata_len,
+ void **user_payload_buf)
+{
+ return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata,
+ vardata_len, user_payload_buf, NULL, NULL);
+}
+
+/*
+ * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header.
+ */
+static inline
+int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm,
+ const int *fds, size_t nb_fd, void **buf __attribute__((unused)))
+{
+ return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL,
+ 0, NULL, NULL, NULL);
+}
+/*
+ * Use this if no variable length data needs to be sent.
+ */
+static inline
+int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
+{
+ return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf);
+}
+
+int lttng_check_tracing_group(void);
+
+int connect_sessiond(void);
+
+#endif /* LTTNG_CTL_HELPER_H */
#include <string.h>
#include <unistd.h>
-#include <common/bytecode/bytecode.h>
-#include <common/align.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/compat/string.h>
-#include <common/defaults.h>
-#include <common/dynamic-array.h>
-#include <common/dynamic-buffer.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
-#include <common/unix.h>
-#include <common/uri.h>
-#include <common/utils.h>
-#include <lttng/channel-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/align.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
+#include <common/unix.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <lttng/channel-internal.hpp>
#include <lttng/destruction-handle.h>
#include <lttng/endpoint.h>
-#include <lttng/error-query-internal.h>
-#include <lttng/event-internal.h>
-#include <lttng/health-internal.h>
+#include <lttng/error-query-internal.hpp>
+#include <lttng/event-internal.hpp>
+#include <lttng/health-internal.hpp>
#include <lttng/lttng-error.h>
#include <lttng/lttng.h>
-#include <lttng/session-descriptor-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/session-descriptor-internal.hpp>
+#include <lttng/session-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <lttng/userspace-probe-internal.hpp>
-#include "lttng-ctl-helper.h"
-#include <common/filter/filter-ast.h>
+#include "lttng-ctl-helper.hpp"
+#include <common/filter/filter-ast.hpp>
#include <common/filter/filter-parser.hpp>
-#include <common/filter/memstream.h>
+#include <common/filter/memstream.hpp>
#define COPY_DOMAIN_PACKED(dst, src) \
do { \
#include <lttng/lttng-error.h>
#include <lttng/rotation.h>
-#include <lttng/location-internal.h>
-#include <lttng/rotate-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/macros.h>
+#include <lttng/location-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/macros.hpp>
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
static
enum lttng_rotation_status ask_rotation_info(
#include <lttng/lttng-error.h>
#include <lttng/save.h>
-#include <lttng/save-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
+#include <lttng/save-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
struct lttng_save_session_attr *lttng_save_session_attr_create(void)
{
#define _LGPL_SOURCE
#include <string.h>
-#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
#include <lttng/lttng-error.h>
#include <lttng/snapshot.h>
-#include <lttng/snapshot-internal.h>
+#include <lttng/snapshot-internal.hpp>
-#include "lttng-ctl-helper.h"
+#include "lttng-ctl-helper.hpp"
/*
* Add an output object to a session identified by name.
*
*/
-#include <type_traits>
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
-#include "lttng-ctl-helper.h"
-#include "lttng/domain.h"
-#include "lttng/lttng-error.h"
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/tracker.h>
+#include "lttng-ctl-helper.hpp"
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/tracker.hpp>
#include <lttng/tracker.h>
+#include <type_traits>
struct lttng_process_attr_tracker_handle {
char *session_name;
#define MSGPACK_LTTNG_CONFIG_H
#include <limits.h>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
#if BYTE_ORDER == LITTLE_ENDIAN
#define MSGPACK_ENDIAN_LITTLE_BYTE 1
*
*/
-#include <stdio.h>
+#include <fcntl.h>
+#include <limits.h>
#include <poll.h>
+#include <popt.h>
+#include <pthread.h>
#include <signal.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stddef.h>
-#include <sys/select.h>
#include <sys/epoll.h>
-#include <popt.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <limits.h>
-#include <pthread.h>
#include <sys/mman.h>
-#include <common/compat/time.h>
-#include <common/error.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <common/compat/time.hpp>
+#include <common/error.hpp>
#define BUF_SIZE 256
#define NB_FD 1
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <sys/types.h>
#include <inttypes.h>
#include <stdlib.h>
#include <lttng/lttng.h>
#include <urcu/list.h>
-#include <common/common.h>
+#include <common/common.hpp>
-#include <bin/lttng-relayd/lttng-viewer-abi.h>
-#include <common/index/ctf-index.h>
+#include <bin/lttng-relayd/lttng-viewer-abi.hpp>
+#include <common/index/ctf-index.hpp>
-#include <common/compat/errno.h>
-#include <common/compat/endian.h>
+#include <common/compat/errno.hpp>
+#include <common/compat/endian.hpp>
#define SESSION1 "test1"
#define RELAYD_URL "net://localhost"
*
*/
-#include <common/compat/getenv.h>
-#include <common/consumer/consumer.h>
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/compat/getenv.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
#include <unistd.h>
#include <stdbool.h>
#include <lttng/constant.h>
#include <stdio.h>
#include <stdlib.h>
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
int lttng_opt_verbose;
int lttng_opt_mi;
#include <signal.h>
#include <poll.h>
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
#include <lttng/lttng.h>
#include <tap/tap.h>
*
*/
-#include <common/compat/getenv.h>
-#include <common/consumer/consumer.h>
-#include <common/pipe.h>
-#include <common/error.h>
+#include <common/compat/getenv.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/pipe.hpp>
+#include <common/error.hpp>
#include <unistd.h>
#include <stdbool.h>
#include <lttng/constant.h>
#include <tap/tap.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
#include <lttng/lttng.h>
#define TEST_COUNT 1
#include <stdint.h>
#include <string.h>
#include <lttng/lttng.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
#define TEST_COUNT 70
/* Utility to register some triggers, for test purposes. */
-#include <common/filter/filter-ast.h>
-#include <common/macros.h>
+#include <common/filter/filter-ast.hpp>
+#include <common/macros.hpp>
#include <lttng/lttng.h>
#include <stdlib.h>
*/
#include <stdlib.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <string.h>
#include <stdio.h>
#include <lttng/lttng-export.h>
*/
#include <stdlib.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
-#include <common/compat/errno.h>
+#include <common/compat/errno.hpp>
/*
* libfoo has a direct dependency on libbar.
*/
#include <tap/tap.h>
-#include <common/ini-config/ini-config.h>
-#include <common/utils.h>
-#include <common/path.h>
+#include <common/ini-config/ini-config.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
#include <string.h>
#include <lttng/constant.h>
#include <tap/tap.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/action-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/action-internal.hpp>
#include <lttng/action/action.h>
#include <lttng/action/notify.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
#include <lttng/action/rotate-session.h>
#include <lttng/action/snapshot-session.h>
*/
-#include <common/buffer-view.h>
+#include <common/buffer-view.hpp>
#include <tap/tap.h>
static const int TEST_COUNT = 5;
#include <lttng/event.h>
#include <lttng/event-rule/user-tracepoint.h>
-#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/domain.h>
#include <lttng/log-level-rule.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
+#include <common/dynamic-buffer.hpp>
+#include <common/buffer-view.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/directory-handle.h>
-#include <common/compat/errno.h>
-#include <common/error.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
#include <tap/tap.h>
#define TEST_COUNT 9
*
*/
-#include <common/bytecode/bytecode.h>
-#include <lttng/event-expr-internal.h>
+#include <common/bytecode/bytecode.hpp>
+#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>
#include <tap/tap.h>
#include <tap/tap.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <lttng/domain.h>
-#include <lttng/event-rule/jul-logging-internal.h>
+#include <lttng/event-rule/jul-logging-internal.hpp>
#include <lttng/event-rule/jul-logging.h>
-#include <lttng/event-rule/kernel-kprobe-internal.h>
+#include <lttng/event-rule/kernel-kprobe-internal.hpp>
#include <lttng/event-rule/kernel-kprobe.h>
-#include <lttng/event-rule/kernel-syscall-internal.h>
+#include <lttng/event-rule/kernel-syscall-internal.hpp>
#include <lttng/event-rule/kernel-syscall.h>
-#include <lttng/event-rule/python-logging-internal.h>
+#include <lttng/event-rule/python-logging-internal.hpp>
#include <lttng/event-rule/python-logging.h>
-#include <lttng/event-rule/kernel-tracepoint-internal.h>
+#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
#include <lttng/event-rule/kernel-tracepoint.h>
-#include <lttng/event-rule/kernel-uprobe-internal.h>
+#include <lttng/event-rule/kernel-uprobe-internal.hpp>
#include <lttng/event-rule/kernel-uprobe.h>
-#include <lttng/event-rule/user-tracepoint-internal.h>
+#include <lttng/event-rule/user-tracepoint-internal.hpp>
#include <lttng/event-rule/user-tracepoint.h>
#include <lttng/event.h>
-#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
-#include <lttng/userspace-probe-internal.h>
+#include <lttng/userspace-probe-internal.hpp>
#include <lttng/userspace-probe.h>
-#include "bin/lttng/loglevel.h"
+#include "bin/lttng/loglevel.hpp"
/* For error.h. */
int lttng_opt_quiet = 1;
#include <urcu.h>
-#include <common/compat/directory-handle.h>
-#include <common/compat/errno.h>
-#include <common/error.h>
-#include <common/fs-handle.h>
-#include <common/fd-tracker/fd-tracker.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
+#include <common/fs-handle.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <unistd.h>
#include <time.h>
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/trace-kernel.h>
-#include <common/defaults.h>
+#include <common/compat/errno.hpp>
+#include <bin/lttng-sessiond/trace-kernel.hpp>
+#include <common/defaults.hpp>
#include <tap/tap.h>
#include <tap/tap.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/kernel-probe-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
/* For error.h */
#include <tap/tap.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/log-level-rule-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/log-level-rule-internal.hpp>
#include <lttng/log-level-rule.h>
/* For error.h. */
#include <lttng/notification/notification.h>
#include <lttng/trigger/trigger.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <unistd.h>
-#include <common/compat/fcntl.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
+#include <common/compat/fcntl.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
#include <tap/tap.h>
static const int TEST_COUNT = 5;
#include <tap/tap.h>
-#include <common/payload-view.h>
-#include <common/payload.h>
-#include <lttng/action/rate-policy-internal.h>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
/* For error.h. */
#include <string.h>
#include <tap/tap.h>
-#include <common/time.h>
+#include <common/time.hpp>
-#include "backward-compatibility-group-by.h"
+#include "backward-compatibility-group-by.hpp"
/* Number of TAP tests in this file */
#define NUM_TESTS_PER_TEST 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <time.h>
#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
#include <urcu.h>
#include <tap/tap.h>
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/session.h>
-#include <bin/lttng-sessiond/ust-app.h>
-#include <bin/lttng-sessiond/health-sessiond.h>
-#include <bin/lttng-sessiond/thread.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/common.h>
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <bin/lttng-sessiond/session.hpp>
+#include <bin/lttng-sessiond/thread.hpp>
+#include <bin/lttng-sessiond/ust-app.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
#define SESSION1 "test1"
#include <stdbool.h>
#include <string.h>
#include <stdarg.h>
-#include <common/string-utils/string-utils.h>
+#include <common/string-utils/string-utils.hpp>
#include <tap/tap.h>
/* Number of TAP tests in this file */
*/
#include <algorithm>
-#include <common/compat/fcntl.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
-#include <common/unix.h>
-#include <common/utils.h>
-#include <common/defaults.h>
+#include <common/compat/fcntl.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/payload.hpp>
+#include <common/payload-view.hpp>
+#include <common/unix.hpp>
+#include <common/utils.hpp>
+#include <common/defaults.hpp>
#include <tap/tap.h>
#include <stdbool.h>
-#include <common/error.h>
+#include <common/error.hpp>
#include <lttng/constant.h>
#include <stdio.h>
#include <pthread.h>
#include <tap/tap.h>
-#include <common/uri.h>
+#include <common/uri.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <urcu.h>
#include <lttng/lttng.h>
-#include <bin/lttng-sessiond/lttng-ust-abi.h>
-#include <common/defaults.h>
-#include <common/compat/errno.h>
-#include <bin/lttng-sessiond/trace-ust.h>
-#include <bin/lttng-sessiond/ust-app.h>
-#include <bin/lttng-sessiond/notification-thread.h>
+#include <bin/lttng-sessiond/lttng-ust-abi.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/errno.hpp>
+#include <bin/lttng-sessiond/trace-ust.hpp>
+#include <bin/lttng-sessiond/ust-app.hpp>
+#include <bin/lttng-sessiond/notification-thread.hpp>
#include <lttng/ust-sigbus.h>
#include <tap/tap.h>
-#include <common/compat/poll.h>
-#include <common/readwrite.h>
-#include <common/pipe.h>
-#include <common/dynamic-array.h>
+#include <common/compat/poll.hpp>
+#include <common/readwrite.hpp>
+#include <common/pipe.hpp>
+#include <common/dynamic-array.hpp>
/* Verification without trashing test order in the child process */
#define childok(e, test, ...) do { \
#include <stdio.h>
#include <string.h>
-#include "common/compat/pthread.h"
+#include "common/compat/pthread.hpp"
#include <tap/tap.h>
#include <tap/tap.h>
-#include <common/utils.h>
-#include <common/path.h>
-#include <common/common.h>
+#include <common/utils.hpp>
+#include <common/path.hpp>
+#include <common/common.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <tap/tap.h>
-#include <common/utils.h>
+#include <common/utils.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <tap/tap.h>
-#include <common/utils.h>
+#include <common/utils.hpp>
/* For error.h */
int lttng_opt_quiet = 1;
#include <tap/tap.h>
-#include "common/uuid.h"
+#include "common/uuid.hpp"
#define NR_TESTS 21
gen-ust-events-ns
endif # IS_LINUX
-noinst_HEADERS = signal-helper.h
+noinst_HEADERS = signal-helper.hpp
#include <unistd.h>
#include <inttypes.h>
-#include <common/compat/tid.h>
-#include <common/macros.h>
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
#include "utils.h"
#define LTTNG_PROC_NS_PATH_MAX 40
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
-#include <common/error.h>
-#include <common/align.h>
+#include <common/error.hpp>
+#include <common/align.hpp>
#include "utils.h"
#include <unistd.h>
#include <inttypes.h>
-#include <common/compat/tid.h>
-#include <common/macros.h>
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
#include "utils.h"
#define TRACEPOINT_DEFINE
#include <poll.h>
#include <errno.h>
#include "utils.h"
-#include "signal-helper.h"
+#include "signal-helper.hpp"
#define TRACEPOINT_DEFINE
#include "tp.h"
#define _LGPL_SOURCE
#include <stdio.h>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
#define TRACEPOINT_DEFINE
#include "tp.h"
#include <sys/types.h>
#include <unistd.h>
#include "utils.h"
-#include "signal-helper.h"
+#include "signal-helper.hpp"
#define TRACEPOINT_DEFINE
#include "tp.h"
#include <sys/types.h>
#include <unistd.h>
-#include <common/macros.h>
+#include <common/macros.hpp>
#include <lttng/tracef.h>
-#include "signal-helper.h"
+#include "signal-helper.hpp"
const char *str = "test string";
+++ /dev/null
-/*
- * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_TESTAPP_SIGNAL_HELPER_H
-#define LTTNG_TESTAPP_SIGNAL_HELPER_H
-
-#include <signal.h>
-
-static volatile int should_quit;
-
-static
-void sighandler(int sig)
-{
- if (sig == SIGTERM) {
- should_quit = 1;
- }
-}
-
-static
-int set_signal_handler(void)
-{
- int ret;
- struct sigaction sa {};
- sa.sa_flags = 0;
- sa.sa_handler = sighandler;
-
- ret = sigemptyset(&sa.sa_mask);
- if (ret) {
- perror("sigemptyset");
- goto end;
- }
-
- ret = sigaction(SIGTERM, &sa, NULL);
- if (ret) {
- perror("sigaction");
- goto end;
- }
-end:
- return ret;
-}
-
-#endif /* LTTNG_TESTAPP_SIGNAL_HELPER_H */
--- /dev/null
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_TESTAPP_SIGNAL_HELPER_H
+#define LTTNG_TESTAPP_SIGNAL_HELPER_H
+
+#include <signal.h>
+
+static volatile int should_quit;
+
+static
+void sighandler(int sig)
+{
+ if (sig == SIGTERM) {
+ should_quit = 1;
+ }
+}
+
+static
+int set_signal_handler(void)
+{
+ int ret;
+ struct sigaction sa {};
+ sa.sa_flags = 0;
+ sa.sa_handler = sighandler;
+
+ ret = sigemptyset(&sa.sa_mask);
+ if (ret) {
+ perror("sigemptyset");
+ goto end;
+ }
+
+ ret = sigaction(SIGTERM, &sa, NULL);
+ if (ret) {
+ perror("sigaction");
+ goto end;
+ }
+end:
+ return ret;
+}
+
+#endif /* LTTNG_TESTAPP_SIGNAL_HELPER_H */
# no optimization
AM_CPPFLAGS = -O0
noinst_PROGRAMS = userspace-probe-elf-cxx-binary
-userspace_probe_elf_cxx_binary_SOURCES = userspace-probe-elf-cxx-binary.cpp test_class.cpp test_class.h
+userspace_probe_elf_cxx_binary_SOURCES = userspace-probe-elf-cxx-binary.cpp test_class.cpp test_class.hpp
*
*/
-#include "test_class.h"
+#include "test_class.hpp"
test_class::test_class() {
test_member = 1;
}
+++ /dev/null
-/*
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- *
- */
-
-class test_class
-{
-public:
- test_class();
- void test_method();
- volatile int test_member;
-};
-
-
--- /dev/null
+/*
+ * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ */
+
+class test_class
+{
+public:
+ test_class();
+ void test_method();
+ volatile int test_member;
+};
+
+
*
*/
-#include "test_class.h"
+#include "test_class.hpp"
volatile int not_a_function = 0;
*
*/
-#include <common/compat/time.h>
-#include <common/time.h>
+#include <common/compat/time.hpp>
+#include <common/time.hpp>
#include <fcntl.h>
#include <poll.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/errno.h>
-#include <common/macros.h>
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
#include "utils.h"
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-#include <common/defaults.h>
+#include <common/defaults.hpp>
#if defined(LIBXML_XPATH_ENABLED)
#include <libxml/parser.h>
#include <lttng/lttng-error.h>
-#include <common/macros.h>
-
-#include <common/macros.h>
+#include <common/macros.hpp>
struct validation_ctx {
xmlSchemaParserCtxtPtr parser_ctx;