+int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
+ const void *_key)
+{
+ struct ltt_ust_event *event;
+ const char *name;
+
+ assert(node);
+ assert(_key);
+
+ event = caa_container_of(node, struct ltt_ust_event, node.node);
+ name = _key;
+
+ /* Event name */
+ if (strncmp(event->attr.name, name, sizeof(event->attr.name)) != 0) {
+ goto no_match;
+ }
+
+ /* Match. */
+ return 1;
+
+no_match:
+ return 0;
+}
+
+int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key)
+{
+ struct ltt_ust_event *event;
+ const struct ltt_ust_ht_key *key;
+
+ assert(node);
+ assert(_key);
+
+ event = caa_container_of(node, struct ltt_ust_event, node.node);
+ key = _key;
+
+ /* Match the 3 elements of the key: name, filter and loglevel. */
+
+ /* Event name */
+ if (strncmp(event->attr.name, key->name, sizeof(event->attr.name)) != 0) {
+ DBG3("[Match] name failed: %s and %s",
+ event->attr.name, key->name);
+ goto no_match;
+ }
+
+ /* Event loglevel. */
+ if (event->attr.loglevel != key->loglevel) {
+ if (event->attr.loglevel_type == 0 && key->loglevel == 0 &&
+ event->attr.loglevel == -1) {
+ /*
+ * This is because on event creation, the loglevel is set to -1 if
+ * the event loglevel type is ALL so 0 and -1 are accepted for this
+ * loglevel type.
+ */
+ } else {
+ DBG3("[Match] loglevel failed: %d and %d",
+ event->attr.loglevel, key->loglevel);
+ goto no_match;
+ }
+ }
+
+ /* Only one of the filters is NULL, fail. */
+ if ((key->filter && !event->filter) || (!key->filter && event->filter)) {
+ DBG3("[Match] filters failed: k:%p and e:%p",
+ key->filter, event->filter);
+ goto no_match;
+ }
+
+ /* Both filters are NULL, success. */
+ if (!key->filter && !event->filter) {
+ goto match;
+ }
+
+ /* Both filters exists, check length followed by the bytecode. */
+ if (event->filter->len == key->filter->len &&
+ memcmp(event->filter->data, key->filter->data,
+ event->filter->len) == 0) {
+ goto match;
+ }
+
+ DBG3("[Match] filters failed: k:%p and e:%p",
+ key->filter, event->filter);
+
+no_match:
+ return 0;
+
+match:
+ DBG3("[MATCH] %s", key->name);
+ return 1;
+}
+