MI: implement all objects related to trigger machine interface
[lttng-tools.git] / include / lttng / action / action-internal.h
... / ...
CommitLineData
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
22struct lttng_rate_policy;
23struct mi_writer;
24struct mi_lttng_error_query_callbacks;
25struct lttng_trigger;
26
27typedef bool (*action_validate_cb)(struct lttng_action *action);
28typedef void (*action_destroy_cb)(struct lttng_action *action);
29typedef int (*action_serialize_cb)(struct lttng_action *action,
30 struct lttng_payload *payload);
31typedef bool (*action_equal_cb)(const struct lttng_action *a,
32 const struct lttng_action *b);
33typedef ssize_t (*action_create_from_payload_cb)(
34 struct lttng_payload_view *view,
35 struct lttng_action **action);
36typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
37 const struct lttng_action *action);
38typedef enum lttng_action_status (*action_add_error_query_results_cb)(
39 const struct lttng_action *action,
40 struct lttng_error_query_results *results);
41typedef enum lttng_error_code (*action_mi_serialize_cb)(
42 const struct lttng_action *condition, struct mi_writer *writer);
43
44struct lttng_action {
45 struct urcu_ref ref;
46 enum lttng_action_type type;
47 action_validate_cb validate;
48 action_serialize_cb serialize;
49 action_equal_cb equal;
50 action_destroy_cb destroy;
51 action_get_rate_policy_cb get_rate_policy;
52 action_add_error_query_results_cb add_error_query_results;
53 action_mi_serialize_cb mi_serialize;
54
55 /* Internal use only. */
56
57 /* The number of time the actions was enqueued for execution. */
58 uint64_t execution_request_counter;
59 /*
60 * The number of time the action was actually executed.
61 * Action rate policy can impact on this number.
62 * */
63 uint64_t execution_counter;
64 /*
65 * The number of time the action execution failed.
66 * An unsigned long is used to use a type which makes atomic
67 * operations possible.
68 */
69 unsigned long execution_failure_counter;
70};
71
72struct lttng_action_comm {
73 /* enum lttng_action_type */
74 int8_t action_type;
75} LTTNG_PACKED;
76
77LTTNG_HIDDEN
78void lttng_action_init(struct lttng_action *action,
79 enum lttng_action_type type,
80 action_validate_cb validate,
81 action_serialize_cb serialize,
82 action_equal_cb equal,
83 action_destroy_cb destroy,
84 action_get_rate_policy_cb get_rate_policy,
85 action_add_error_query_results_cb add_error_query_results,
86 action_mi_serialize_cb mi);
87
88LTTNG_HIDDEN
89bool lttng_action_validate(struct lttng_action *action);
90
91LTTNG_HIDDEN
92int lttng_action_serialize(struct lttng_action *action,
93 struct lttng_payload *buf);
94
95LTTNG_HIDDEN
96ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
97 struct lttng_action **action);
98
99LTTNG_HIDDEN
100bool lttng_action_is_equal(const struct lttng_action *a,
101 const struct lttng_action *b);
102
103LTTNG_HIDDEN
104void lttng_action_get(struct lttng_action *action);
105
106LTTNG_HIDDEN
107void lttng_action_put(struct lttng_action *action);
108
109LTTNG_HIDDEN
110const char* lttng_action_type_string(enum lttng_action_type action_type);
111
112LTTNG_HIDDEN
113void lttng_action_increase_execution_request_count(struct lttng_action *action);
114
115LTTNG_HIDDEN
116void lttng_action_increase_execution_count(struct lttng_action *action);
117
118LTTNG_HIDDEN
119void lttng_action_increase_execution_failure_count(struct lttng_action *action);
120
121LTTNG_HIDDEN
122bool lttng_action_should_execute(const struct lttng_action *action);
123
124LTTNG_HIDDEN
125enum lttng_action_status lttng_action_add_error_query_results(
126 const struct lttng_action *action,
127 struct lttng_error_query_results *results);
128
129/*
130 * For use by the various lttng_action implementation. Implements the default
131 * behavior to the generic error "execution failure counter" that all actions
132 * (except list, which passes-through) provide.
133 */
134LTTNG_HIDDEN
135enum lttng_action_status lttng_action_generic_add_error_query_results(
136 const struct lttng_action *action,
137 struct lttng_error_query_results *results);
138LTTNG_HIDDEN
139enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
140 const struct lttng_action *action,
141 struct mi_writer *writer,
142 const struct mi_lttng_error_query_callbacks
143 *error_query_callbacks,
144 struct lttng_dynamic_array *action_path_indexes);
145
146#endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.026562 seconds and 4 git commands to generate.