*
*/
-#ifndef LTTNG_ACTION_GROUP_INTERNAL_H
-#define LTTNG_ACTION_GROUP_INTERNAL_H
+#ifndef LTTNG_ACTION_LIST_INTERNAL_H
+#define LTTNG_ACTION_LIST_INTERNAL_H
#include <sys/types.h>
struct lttng_payload_view;
/*
- * Create an action group from a payload view.
+ * Create an action list from a payload view.
*
* On success, return the number of bytes consumed from `view`, and the created
* group in `*group`. On failure, return -1.
*/
LTTNG_HIDDEN
-extern ssize_t lttng_action_group_create_from_payload(
+extern ssize_t lttng_action_list_create_from_payload(
struct lttng_payload_view *view,
struct lttng_action **group);
LTTNG_HIDDEN
-extern struct lttng_action *lttng_action_group_borrow_mutable_at_index(
+extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
const struct lttng_action *group, unsigned int index);
-#endif /* LTTNG_ACTION_GROUP_INTERNAL_H */
+#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
*
*/
-#ifndef LTTNG_ACTION_GROUP_H
-#define LTTNG_ACTION_GROUP_H
+#ifndef LTTNG_ACTION_LIST_H
+#define LTTNG_ACTION_LIST_H
struct lttng_action;
-struct lttng_action_group;
+struct lttng_action_list;
#ifdef __cplusplus
extern "C" {
#endif
/*
- * Create a newly allocated action group object.
+ * Create a newly allocated action list object.
*
- * Returns a new action group on success, NULL on failure. This action group
- * must be destroyed using lttng_action_group_destroy().
+ * Returns a new action list on success, NULL on failure. This action list
+ * must be destroyed using lttng_action_list_destroy().
*/
-extern struct lttng_action *lttng_action_group_create(void);
+extern struct lttng_action *lttng_action_list_create(void);
/*
- * Add an action to an lttng_action object of type LTTNG_ACTION_GROUP.
+ * Add an action to an lttng_action object of type LTTNG_ACTION_LIST.
*
- * The action group acquires a reference to the action. The action can be
+ * The action list acquires a reference to the action. The action can be
* safely destroyed after calling this function. An action must not be
* modified after adding it to a group.
*
- * Adding an action group to an action group is not supported.
+ * Adding an action list to an action list is not supported.
*/
-extern enum lttng_action_status lttng_action_group_add_action(
+extern enum lttng_action_status lttng_action_list_add_action(
struct lttng_action *group, struct lttng_action *action);
/*
- * Get the number of actions in an action group.
+ * Get the number of actions in an action list.
*/
-extern enum lttng_action_status lttng_action_group_get_count(
+extern enum lttng_action_status lttng_action_list_get_count(
const struct lttng_action *group, unsigned int *count);
/*
- * Get an action from the action group at a given index.
+ * Get an action from the action list at a given index.
*
* Note that the group maintains the ownership of the returned action.
* It must not be destroyed by the user, nor should it be held beyond
- * the lifetime of the action group.
+ * the lifetime of the action list.
*
* Returns an action, or NULL on error.
*/
-extern const struct lttng_action *lttng_action_group_get_at_index(
+extern const struct lttng_action *lttng_action_list_get_at_index(
const struct lttng_action *group,
unsigned int index);
}
#endif
-#endif /* LTTNG_ACTION_GROUP_H */
+#endif /* LTTNG_ACTION_LIST_H */
if (type == LTTNG_ACTION_TYPE_GROUP) {
unsigned int count, i;
- status = lttng_action_group_get_count(action, &count);
+ status = lttng_action_list_get_count(action, &count);
assert(status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
struct lttng_action *inner_action = NULL;
- inner_action = lttng_action_group_borrow_mutable_at_index(
+ inner_action = lttng_action_list_borrow_mutable_at_index(
action, i);
assert(inner_action);
ret = add_action_to_subitem_array(
goto end;
}
- action_status = lttng_action_group_get_count(action, &count);
+ action_status = lttng_action_list_get_count(action, &count);
assert(action_status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
const struct lttng_action *inner_action =
- lttng_action_group_get_at_index(
+ lttng_action_list_get_at_index(
action, i);
action_type = lttng_action_get_type(inner_action);
struct lttng_dynamic_pointer_array actions;
struct argpar_state *argpar_state = NULL;
struct argpar_item *argpar_item = NULL;
- struct lttng_action *action_group = NULL;
+ struct lttng_action *action_list = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
char *error = NULL;
goto error;
}
- action_group = lttng_action_group_create();
- if (!action_group) {
+ action_list = lttng_action_list_create();
+ if (!action_list) {
goto error;
}
action = lttng_dynamic_pointer_array_steal_pointer(&actions, i);
- status = lttng_action_group_add_action(action_group, action);
+ status = lttng_action_list_add_action(action_list, action);
if (status != LTTNG_ACTION_STATUS_OK) {
goto error;
}
/*
- * The `lttng_action_group_add_action()` takes a reference to
+ * The `lttng_action_list_add_action()` takes a reference to
* the action. We can destroy ours.
*/
lttng_action_destroy(action);
action = NULL;
}
- trigger = lttng_trigger_create(condition, action_group);
+ trigger = lttng_trigger_create(condition, action_list);
if (!trigger) {
goto error;
}
argpar_item_destroy(argpar_item);
lttng_dynamic_pointer_array_reset(&actions);
lttng_condition_destroy(condition);
- lttng_action_destroy(action_group);
+ lttng_action_destroy(action_list);
lttng_action_destroy(action);
lttng_trigger_destroy(trigger);
free(error);
MSG(" actions:");
- action_status = lttng_action_group_get_count(action, &count);
+ action_status = lttng_action_list_get_count(action, &count);
assert(action_status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
const struct lttng_action *subaction =
- lttng_action_group_get_at_index(
+ lttng_action_list_get_at_index(
action, i);
_MSG(" ");
lttng_action_stop_session_create_from_payload;
break;
case LTTNG_ACTION_TYPE_GROUP:
- create_from_payload_cb = lttng_action_group_create_from_payload;
+ create_from_payload_cb = lttng_action_list_create_from_payload;
break;
default:
ERR("Failed to create action from payload, unhandled action type: action-type=%u (%s)",
#define IS_GROUP_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_GROUP)
-struct lttng_action_group {
+struct lttng_action_list {
struct lttng_action parent;
/* The array owns the action elements. */
struct lttng_dynamic_pointer_array actions;
};
-struct lttng_action_group_comm {
+struct lttng_action_list_comm {
uint32_t action_count;
/*
char data[];
} LTTNG_PACKED;
-static void destroy_lttng_action_group_element(void *ptr)
+static void destroy_lttng_action_list_element(void *ptr)
{
struct lttng_action *element = (struct lttng_action *) ptr;
lttng_action_destroy(element);
}
-static struct lttng_action_group *action_group_from_action(
+static struct lttng_action_list *action_list_from_action(
const struct lttng_action *action)
{
assert(action);
- return container_of(action, struct lttng_action_group, parent);
+ return container_of(action, struct lttng_action_list, parent);
}
-static const struct lttng_action_group *action_group_from_action_const(
+static const struct lttng_action_list *action_list_from_action_const(
const struct lttng_action *action)
{
assert(action);
- return container_of(action, struct lttng_action_group, parent);
+ return container_of(action, struct lttng_action_list, parent);
}
-static bool lttng_action_group_validate(struct lttng_action *action)
+static bool lttng_action_list_validate(struct lttng_action *action)
{
unsigned int i, count;
- struct lttng_action_group *action_group;
+ struct lttng_action_list *action_list;
bool valid;
assert(IS_GROUP_ACTION(action));
- action_group = action_group_from_action(action);
+ action_list = action_list_from_action(action);
- count = lttng_dynamic_pointer_array_get_count(&action_group->actions);
+ count = lttng_dynamic_pointer_array_get_count(&action_list->actions);
for (i = 0; i < count; i++) {
struct lttng_action *child =
lttng_dynamic_pointer_array_get_pointer(
- &action_group->actions, i);
+ &action_list->actions, i);
assert(child);
return valid;
}
-static bool lttng_action_group_is_equal(
+static bool lttng_action_list_is_equal(
const struct lttng_action *_a, const struct lttng_action *_b)
{
bool is_equal = false;
unsigned int i;
unsigned int a_count, b_count;
- if (lttng_action_group_get_count(_a, &a_count) !=
+ if (lttng_action_list_get_count(_a, &a_count) !=
LTTNG_ACTION_STATUS_OK) {
goto end;
}
- if (lttng_action_group_get_count(_b, &b_count) !=
+ if (lttng_action_list_get_count(_b, &b_count) !=
LTTNG_ACTION_STATUS_OK) {
goto end;
}
for (i = 0; i < a_count; i++) {
const struct lttng_action *child_a =
- lttng_action_group_get_at_index(_a, i);
+ lttng_action_list_get_at_index(_a, i);
const struct lttng_action *child_b =
- lttng_action_group_get_at_index(_b, i);
+ lttng_action_list_get_at_index(_b, i);
assert(child_a);
assert(child_b);
return is_equal;
}
-static int lttng_action_group_serialize(
+static int lttng_action_list_serialize(
struct lttng_action *action, struct lttng_payload *payload)
{
- struct lttng_action_group *action_group;
- struct lttng_action_group_comm comm;
+ struct lttng_action_list *action_list;
+ struct lttng_action_list_comm comm;
int ret;
unsigned int i, count;
assert(payload);
assert(IS_GROUP_ACTION(action));
- action_group = action_group_from_action(action);
+ action_list = action_list_from_action(action);
- DBG("Serializing action group");
+ DBG("Serializing action list");
- count = lttng_dynamic_pointer_array_get_count(&action_group->actions);
+ count = lttng_dynamic_pointer_array_get_count(&action_list->actions);
comm.action_count = count;
for (i = 0; i < count; i++) {
struct lttng_action *child =
lttng_dynamic_pointer_array_get_pointer(
- &action_group->actions, i);
+ &action_list->actions, i);
assert(child);
return ret;
}
-static void lttng_action_group_destroy(struct lttng_action *action)
+static void lttng_action_list_destroy(struct lttng_action *action)
{
- struct lttng_action_group *action_group;
+ struct lttng_action_list *action_list;
if (!action) {
goto end;
}
- action_group = action_group_from_action(action);
- lttng_dynamic_pointer_array_reset(&action_group->actions);
- free(action_group);
+ action_list = action_list_from_action(action);
+ lttng_dynamic_pointer_array_reset(&action_list->actions);
+ free(action_list);
end:
return;
}
-ssize_t lttng_action_group_create_from_payload(
+ssize_t lttng_action_list_create_from_payload(
struct lttng_payload_view *view,
struct lttng_action **p_action)
{
ssize_t consumed_len;
- const struct lttng_action_group_comm *comm;
+ const struct lttng_action_list_comm *comm;
struct lttng_action *group;
struct lttng_action *child_action = NULL;
enum lttng_action_status status;
size_t i;
- group = lttng_action_group_create();
+ group = lttng_action_list_create();
if (!group) {
consumed_len = -1;
goto end;
comm = (typeof(comm)) view->buffer.data;
- consumed_len = sizeof(struct lttng_action_group_comm);
+ consumed_len = sizeof(struct lttng_action_list_comm);
for (i = 0; i < comm->action_count; i++) {
ssize_t consumed_len_child;
goto end;
}
- status = lttng_action_group_add_action(group, child_action);
+ status = lttng_action_list_add_action(group, child_action);
if (status != LTTNG_ACTION_STATUS_OK) {
consumed_len = -1;
goto end;
}
- /* Transfer ownership to the action group. */
+ /* Transfer ownership to the action list. */
lttng_action_put(child_action);
child_action = NULL;
group = NULL;
end:
- lttng_action_group_destroy(group);
+ lttng_action_list_destroy(group);
return consumed_len;
}
-static enum lttng_action_status lttng_action_group_add_error_query_results(
+static enum lttng_action_status lttng_action_list_add_error_query_results(
const struct lttng_action *action,
struct lttng_error_query_results *results)
{
unsigned int i, count;
enum lttng_action_status action_status;
- const struct lttng_action_group *group =
+ const struct lttng_action_list *group =
container_of(action, typeof(*group), parent);
- action_status = lttng_action_group_get_count(action, &count);
+ action_status = lttng_action_list_get_count(action, &count);
if (action_status != LTTNG_ACTION_STATUS_OK) {
goto end;
}
for (i = 0; i < count; i++) {
struct lttng_action *inner_action =
- lttng_action_group_borrow_mutable_at_index(action, i);
+ lttng_action_list_borrow_mutable_at_index(action, i);
action_status = lttng_action_add_error_query_results(
inner_action, results);
return action_status;
}
-struct lttng_action *lttng_action_group_create(void)
+struct lttng_action *lttng_action_list_create(void)
{
- struct lttng_action_group *action_group;
+ struct lttng_action_list *action_list;
struct lttng_action *action;
- action_group = zmalloc(sizeof(struct lttng_action_group));
- if (!action_group) {
+ action_list = zmalloc(sizeof(struct lttng_action_list));
+ if (!action_list) {
action = NULL;
goto end;
}
- action = &action_group->parent;
+ action = &action_list->parent;
lttng_action_init(action, LTTNG_ACTION_TYPE_GROUP,
- lttng_action_group_validate,
- lttng_action_group_serialize,
- lttng_action_group_is_equal, lttng_action_group_destroy,
+ lttng_action_list_validate,
+ lttng_action_list_serialize,
+ lttng_action_list_is_equal, lttng_action_list_destroy,
NULL,
- lttng_action_group_add_error_query_results);
+ lttng_action_list_add_error_query_results);
- lttng_dynamic_pointer_array_init(&action_group->actions,
- destroy_lttng_action_group_element);
+ lttng_dynamic_pointer_array_init(&action_list->actions,
+ destroy_lttng_action_list_element);
end:
return action;
}
-enum lttng_action_status lttng_action_group_add_action(
+enum lttng_action_status lttng_action_list_add_action(
struct lttng_action *group, struct lttng_action *action)
{
- struct lttng_action_group *action_group;
+ struct lttng_action_list *action_list;
enum lttng_action_status status;
int ret;
goto end;
}
- action_group = action_group_from_action(group);
+ action_list = action_list_from_action(group);
- ret = lttng_dynamic_pointer_array_add_pointer(&action_group->actions,
+ ret = lttng_dynamic_pointer_array_add_pointer(&action_list->actions,
action);
if (ret < 0) {
status = LTTNG_ACTION_STATUS_ERROR;
return status;
}
-enum lttng_action_status lttng_action_group_get_count(
+enum lttng_action_status lttng_action_list_get_count(
const struct lttng_action *group, unsigned int *count)
{
- const struct lttng_action_group *action_group;
+ const struct lttng_action_list *action_list;
enum lttng_action_status status = LTTNG_ACTION_STATUS_OK;
if (!group || !IS_GROUP_ACTION(group)) {
goto end;
}
- action_group = action_group_from_action_const(group);
- *count = lttng_dynamic_pointer_array_get_count(&action_group->actions);
+ action_list = action_list_from_action_const(group);
+ *count = lttng_dynamic_pointer_array_get_count(&action_list->actions);
end:
return status;
}
-const struct lttng_action *lttng_action_group_get_at_index(
+const struct lttng_action *lttng_action_list_get_at_index(
const struct lttng_action *group, unsigned int index)
{
- return lttng_action_group_borrow_mutable_at_index(group, index);
+ return lttng_action_list_borrow_mutable_at_index(group, index);
}
LTTNG_HIDDEN
-struct lttng_action *lttng_action_group_borrow_mutable_at_index(
+struct lttng_action *lttng_action_list_borrow_mutable_at_index(
const struct lttng_action *group, unsigned int index)
{
unsigned int count;
- const struct lttng_action_group *action_group;
+ const struct lttng_action_list *action_list;
struct lttng_action *action = NULL;
- if (lttng_action_group_get_count(group, &count) !=
+ if (lttng_action_list_get_count(group, &count) !=
LTTNG_ACTION_STATUS_OK) {
goto end;
}
goto end;
}
- action_group = action_group_from_action_const(group);
- action = lttng_dynamic_pointer_array_get_pointer(&action_group->actions,
+ action_list = action_list_from_action_const(group);
+ action = lttng_dynamic_pointer_array_get_pointer(&action_list->actions,
index);
end:
return action;
* action list.
*
* Note that action comparisons are performed by pointer since multiple
- * otherwise identical actions can be found in an action group (two
+ * otherwise identical actions can be found in an action list (two
* notify actions, for example).
*/
if (action != trigger->action &&
lttng_action_get_type(trigger->action) ==
LTTNG_ACTION_TYPE_GROUP) {
- unsigned int i, action_group_count;
+ unsigned int i, action_list_count;
enum lttng_action_status action_status;
- action_status = lttng_action_group_get_count(
- trigger->action, &action_group_count);
+ action_status = lttng_action_list_get_count(
+ trigger->action, &action_list_count);
if (action_status != LTTNG_ACTION_STATUS_OK) {
goto error;
}
- for (i = 0; i < action_group_count; i++) {
+ for (i = 0; i < action_list_count; i++) {
const struct lttng_action *candidate_action =
- lttng_action_group_get_at_index(
+ lttng_action_list_get_at_index(
trigger->action, i);
assert(candidate_action);
goto end;
}
- target_action = lttng_action_group_borrow_mutable_at_index(
+ target_action = lttng_action_list_borrow_mutable_at_index(
trigger_action,
LTTNG_OPTIONAL_GET(query_action->action_index));
}
goto end;
}
- target_action = lttng_action_group_get_at_index(
+ target_action = lttng_action_list_get_at_index(
trigger->action,
action_header->action_index.value);
}
static double threshold_ratio = 0.0;
static uint64_t threshold_bytes = 0;
static bool is_threshold_ratio = false;
-static bool use_action_group = false;
+static bool use_action_list = false;
static enum lttng_condition_type buffer_usage_type = LTTNG_CONDITION_TYPE_UNKNOWN;
static enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
const char *buffer_usage_threshold_type = NULL;
const char *buffer_usage_threshold_value = NULL;
const char *nr_expected_notifications_string = NULL;
- const char *use_action_group_value = NULL;
+ const char *use_action_list_value = NULL;
session_name = argv[1];
channel_name = argv[2];
buffer_usage_threshold_type = argv[5];
buffer_usage_threshold_value = argv[6];
nr_expected_notifications_string = argv[7];
- use_action_group_value = argv[8];
+ use_action_list_value = argv[8];
/* Parse arguments */
/* Domain type */
}
/* Put notify action in a group. */
- if (!strcasecmp("1", use_action_group_value)) {
- use_action_group = true;
+ if (!strcasecmp("1", use_action_list_value)) {
+ use_action_list = true;
}
return 0;
goto end;
}
- if (use_action_group) {
+ if (use_action_list) {
struct lttng_action *notify, *group;
- group = lttng_action_group_create();
+ group = lttng_action_list_create();
if (!group) {
- printf("error: Could not create action group\n");
+ printf("error: Could not create action list\n");
ret = 1;
goto end;
}
goto end;
}
- action_status = lttng_action_group_add_action(group, notify);
+ action_status = lttng_action_list_add_action(group, notify);
if (action_status != LTTNG_ACTION_STATUS_OK) {
- printf("error: Could not add action notify to action group\n");
+ printf("error: Could not add action notify to action list\n");
lttng_action_destroy(group);
lttng_action_destroy(notify);
ret = 1;
local buffer_usage_threshold_type=$6
local buffer_usage_threshold_value=$7
local nr_expected_notification=$8
- local use_action_group=$9
+ local use_action_list=$9
- ${CURDIR}/base_client ${session_name} ${channel_name} ${domain_type} ${buffer_usage_type} ${buffer_usage_threshold_type} ${buffer_usage_threshold_value} ${nr_expected_notification} ${use_action_group} > ${output_file} &
+ ${CURDIR}/base_client ${session_name} ${channel_name} ${domain_type} ${buffer_usage_type} ${buffer_usage_threshold_type} ${buffer_usage_threshold_value} ${nr_expected_notification} ${use_action_list} > ${output_file} &
pid=$!
app_pids+=("$pid")
{0, 0, 0, 0}
};
-static bool action_group_contains_notify(
- const struct lttng_action *action_group)
+static bool action_list_contains_notify(
+ const struct lttng_action *action_list)
{
unsigned int i, count;
enum lttng_action_status status =
- lttng_action_group_get_count(action_group, &count);
+ lttng_action_list_get_count(action_list, &count);
if (status != LTTNG_ACTION_STATUS_OK) {
- printf("Failed to get action count from action group\n");
+ printf("Failed to get action count from action list\n");
exit(1);
}
for (i = 0; i < count; i++) {
const struct lttng_action *action =
- lttng_action_group_get_at_index(
- action_group, i);
+ lttng_action_list_get_at_index(
+ action_list, i);
const enum lttng_action_type action_type =
lttng_action_get_type(action);
}
}
if (!((action_type == LTTNG_ACTION_TYPE_GROUP &&
- action_group_contains_notify(action)) ||
+ action_list_contains_notify(action)) ||
action_type == LTTNG_ACTION_TYPE_NOTIFY)) {
/* "The action of trigger is not notify, skipping. */
continue;
}
/*
- * Register a trigger with the given condition and an action group containing a
+ * Register a trigger with the given condition and an action list containing a
* single notify action.
*/
-static void register_trigger_action_group_notify(
+static void register_trigger_action_list_notify(
const char *trigger_name, struct lttng_condition *condition)
{
struct lttng_action *action_notify;
- struct lttng_action *action_group;
+ struct lttng_action *action_list;
enum lttng_action_status action_status;
- action_group = lttng_action_group_create();
+ action_list = lttng_action_list_create();
action_notify = lttng_action_notify_create();
- action_status = lttng_action_group_add_action(
- action_group, action_notify);
+ action_status = lttng_action_list_add_action(
+ action_list, action_notify);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- register_trigger(trigger_name, condition, action_group);
+ register_trigger(trigger_name, condition, action_list);
}
static struct lttng_condition *create_session_consumed_size_condition(
static void test_session_consumed_size_condition(void)
{
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-session-consumed-size-condition",
create_session_consumed_size_condition(
"the-session-name", 1234));
static void test_buffer_usage_conditions(void)
{
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-buffer-usage-high-bytes-condition",
create_buffer_usage_high_bytes_condition(
"the-session-name", "the-channel-name",
LTTNG_DOMAIN_UST, 1234));
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-buffer-usage-low-bytes-condition",
create_buffer_usage_low_bytes_condition(
"the-session-name", "the-channel-name",
LTTNG_DOMAIN_UST, 2345));
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-buffer-usage-high-ratio-condition",
create_buffer_usage_high_ratio_condition(
"the-session-name", "the-channel-name",
LTTNG_DOMAIN_UST, 0.25));
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-buffer-usage-low-ratio-condition",
create_buffer_usage_low_ratio_condition(
"the-session-name", "the-channel-name",
static void test_session_rotation_conditions(void)
{
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-session-rotation-ongoing-condition",
create_session_rotation_ongoing_condition(
"the-session-name"));
- register_trigger_action_group_notify(
+ register_trigger_action_list_notify(
"trigger-with-session-rotation-completed-condition",
create_session_rotation_completed_condition(
"the-session-name"));