+static unsigned long lttng_event_rule_tracepoint_hash(
+ const struct lttng_event_rule *rule)
+{
+ unsigned long hash;
+ unsigned int i, exclusion_count;
+ enum lttng_event_rule_status status;
+ struct lttng_event_rule_tracepoint *tp_rule =
+ container_of(rule, typeof(*tp_rule), parent);
+
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_TRACEPOINT,
+ lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) tp_rule->domain, lttng_ht_seed);
+ hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
+
+ if (tp_rule->filter_expression) {
+ hash ^= hash_key_str(tp_rule->filter_expression, lttng_ht_seed);
+ }
+
+ hash ^= hash_key_ulong((void *) tp_rule->loglevel.type,
+ lttng_ht_seed);
+ if (tp_rule->loglevel.type != LTTNG_EVENT_LOGLEVEL_ALL) {
+ hash ^= hash_key_ulong(
+ (void *) (unsigned long) tp_rule->loglevel.value,
+ lttng_ht_seed);
+ }
+
+ status = lttng_event_rule_tracepoint_get_exclusions_count(rule,
+ &exclusion_count);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+
+ for (i = 0; i < exclusion_count; i++) {
+ const char *exclusion;
+
+ status = lttng_event_rule_tracepoint_get_exclusion_at_index(
+ rule, i, &exclusion);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ hash ^= hash_key_str(exclusion, lttng_ht_seed);
+ }
+
+ return hash;
+}
+
+static struct lttng_event *lttng_event_rule_tracepoint_generate_lttng_event(
+ const struct lttng_event_rule *rule)
+{
+ int ret;
+ const struct lttng_event_rule_tracepoint *tracepoint;
+ struct lttng_event *local_event = NULL;
+ struct lttng_event *event = NULL;
+
+ tracepoint = container_of(
+ rule, const struct lttng_event_rule_tracepoint, parent);
+
+ local_event = zmalloc(sizeof(*local_event));
+ if (!local_event) {
+ goto error;
+ }
+
+ local_event->type = LTTNG_EVENT_TRACEPOINT;
+ ret = lttng_strncpy(local_event->name, tracepoint->pattern,
+ sizeof(local_event->name));
+ if (ret) {
+ ERR("Truncation occurred when copying event rule pattern to `lttng_event` structure: pattern = '%s'",
+ tracepoint->pattern);
+ goto error;
+ }
+
+ local_event->loglevel_type = tracepoint->loglevel.type;
+ local_event->loglevel = tracepoint->loglevel.value;
+
+ event = local_event;
+ local_event = NULL;
+error:
+ free(local_event);
+ return event;
+}
+