bin: compile lttng-sessiond as C++
[lttng-tools.git] / include / lttng / action / action-internal.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_ACTION_INTERNAL_H
9 #define LTTNG_ACTION_INTERNAL_H
10
11 #include <common/buffer-view.h>
12 #include <common/dynamic-buffer.h>
13 #include <common/macros.h>
14 #include <common/payload-view.h>
15 #include <common/payload.h>
16 #include <lttng/lttng.h>
17 #include <pthread.h>
18 #include <stdbool.h>
19 #include <sys/types.h>
20 #include <urcu/ref.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 struct lttng_rate_policy;
27 struct mi_writer;
28 struct mi_lttng_error_query_callbacks;
29 struct lttng_trigger;
30
31 typedef bool (*action_validate_cb)(struct lttng_action *action);
32 typedef void (*action_destroy_cb)(struct lttng_action *action);
33 typedef int (*action_serialize_cb)(struct lttng_action *action,
34 struct lttng_payload *payload);
35 typedef bool (*action_equal_cb)(const struct lttng_action *a,
36 const struct lttng_action *b);
37 typedef ssize_t (*action_create_from_payload_cb)(
38 struct lttng_payload_view *view,
39 struct lttng_action **action);
40 typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
41 const struct lttng_action *action);
42 typedef enum lttng_action_status (*action_add_error_query_results_cb)(
43 const struct lttng_action *action,
44 struct lttng_error_query_results *results);
45 typedef enum lttng_error_code (*action_mi_serialize_cb)(
46 const struct lttng_action *condition, struct mi_writer *writer);
47
48 struct lttng_action {
49 struct urcu_ref ref;
50 enum lttng_action_type type;
51 action_validate_cb validate;
52 action_serialize_cb serialize;
53 action_equal_cb equal;
54 action_destroy_cb destroy;
55 action_get_rate_policy_cb get_rate_policy;
56 action_add_error_query_results_cb add_error_query_results;
57 action_mi_serialize_cb mi_serialize;
58
59 /* Internal use only. */
60
61 /* The number of time the actions was enqueued for execution. */
62 uint64_t execution_request_counter;
63 /*
64 * The number of time the action was actually executed.
65 * Action rate policy can impact on this number.
66 * */
67 uint64_t execution_counter;
68 /*
69 * The number of time the action execution failed.
70 * An unsigned long is used to use a type which makes atomic
71 * operations possible.
72 */
73 unsigned long execution_failure_counter;
74 };
75
76 struct lttng_action_comm {
77 /* enum lttng_action_type */
78 int8_t action_type;
79 } LTTNG_PACKED;
80
81 void lttng_action_init(struct lttng_action *action,
82 enum lttng_action_type type,
83 action_validate_cb validate,
84 action_serialize_cb serialize,
85 action_equal_cb equal,
86 action_destroy_cb destroy,
87 action_get_rate_policy_cb get_rate_policy,
88 action_add_error_query_results_cb add_error_query_results,
89 action_mi_serialize_cb mi);
90
91 bool lttng_action_validate(struct lttng_action *action);
92
93 int lttng_action_serialize(struct lttng_action *action,
94 struct lttng_payload *buf);
95
96 ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
97 struct lttng_action **action);
98
99 bool lttng_action_is_equal(const struct lttng_action *a,
100 const struct lttng_action *b);
101
102 void lttng_action_get(struct lttng_action *action);
103
104 void lttng_action_put(struct lttng_action *action);
105
106 const char* lttng_action_type_string(enum lttng_action_type action_type);
107
108 void lttng_action_increase_execution_request_count(struct lttng_action *action);
109
110 void lttng_action_increase_execution_count(struct lttng_action *action);
111
112 void lttng_action_increase_execution_failure_count(struct lttng_action *action);
113
114 bool lttng_action_should_execute(const struct lttng_action *action);
115
116 enum lttng_action_status lttng_action_add_error_query_results(
117 const struct lttng_action *action,
118 struct lttng_error_query_results *results);
119
120 /*
121 * For use by the various lttng_action implementation. Implements the default
122 * behavior to the generic error "execution failure counter" that all actions
123 * (except list, which passes-through) provide.
124 */
125 enum lttng_action_status lttng_action_generic_add_error_query_results(
126 const struct lttng_action *action,
127 struct lttng_error_query_results *results);
128 enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
129 const struct lttng_action *action,
130 struct mi_writer *writer,
131 const struct mi_lttng_error_query_callbacks
132 *error_query_callbacks,
133 struct lttng_dynamic_array *action_path_indexes);
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.03126 seconds and 4 git commands to generate.