Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / lttng-events.c
index 4fa675ddfec454e32d2ffec16a6a2ce3958457cc..6196fc6a59fbbd89a8336f4526e62c5060109875 100644 (file)
@@ -1,23 +1,9 @@
 /*
- * lttng-events.c
- *
- * Holds LTTng per-session event registry.
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
  * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Holds LTTng per-session event registry.
  */
 
 #define _LGPL_SOURCE
@@ -869,6 +855,7 @@ int lttng_event_notifier_create(const struct lttng_event_desc *desc,
        CDS_INIT_LIST_HEAD(&event_notifier->capture_bytecode_runtime_head);
        CDS_INIT_LIST_HEAD(&event_notifier->enablers_ref_head);
        event_notifier->desc = desc;
+       event_notifier->notification_send = lttng_event_notifier_notification_send;
 
        cds_list_add(&event_notifier->node,
                        &event_notifier_group->event_notifiers_head);
@@ -1413,6 +1400,7 @@ struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
        CDS_INIT_LIST_HEAD(&event_notifier_enabler->base.excluder_head);
 
        event_notifier_enabler->user_token = event_notifier_param->event.token;
+       event_notifier_enabler->error_counter_index = event_notifier_param->error_counter_index;
        event_notifier_enabler->num_captures = 0;
 
        memcpy(&event_notifier_enabler->base.event_param.name,
@@ -1454,14 +1442,16 @@ int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler)
 
 static
 void _lttng_enabler_attach_filter_bytecode(struct lttng_enabler *enabler,
-               struct lttng_ust_bytecode_node *bytecode)
+               struct lttng_ust_bytecode_node **bytecode)
 {
-       bytecode->enabler = enabler;
-       cds_list_add_tail(&bytecode->node, &enabler->filter_bytecode_head);
+       (*bytecode)->enabler = enabler;
+       cds_list_add_tail(&(*bytecode)->node, &enabler->filter_bytecode_head);
+       /* Take ownership of bytecode */
+       *bytecode = NULL;
 }
 
 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
-               struct lttng_ust_bytecode_node *bytecode)
+               struct lttng_ust_bytecode_node **bytecode)
 {
        _lttng_enabler_attach_filter_bytecode(
                lttng_event_enabler_as_enabler(event_enabler), bytecode);
@@ -1472,14 +1462,16 @@ int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event
 
 static
 void _lttng_enabler_attach_exclusion(struct lttng_enabler *enabler,
-               struct lttng_ust_excluder_node *excluder)
+               struct lttng_ust_excluder_node **excluder)
 {
-       excluder->enabler = enabler;
-       cds_list_add_tail(&excluder->node, &enabler->excluder_head);
+       (*excluder)->enabler = enabler;
+       cds_list_add_tail(&(*excluder)->node, &enabler->excluder_head);
+       /* Take ownership of excluder */
+       *excluder = NULL;
 }
 
 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *event_enabler,
-               struct lttng_ust_excluder_node *excluder)
+               struct lttng_ust_excluder_node **excluder)
 {
        _lttng_enabler_attach_exclusion(
                lttng_event_enabler_as_enabler(event_enabler), excluder);
@@ -1508,7 +1500,7 @@ int lttng_event_notifier_enabler_disable(
 
 int lttng_event_notifier_enabler_attach_filter_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_ust_bytecode_node *bytecode)
+               struct lttng_ust_bytecode_node **bytecode)
 {
        _lttng_enabler_attach_filter_bytecode(
                lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
@@ -1520,12 +1512,14 @@ int lttng_event_notifier_enabler_attach_filter_bytecode(
 
 int lttng_event_notifier_enabler_attach_capture_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_ust_bytecode_node *bytecode)
+               struct lttng_ust_bytecode_node **bytecode)
 {
-       bytecode->enabler = lttng_event_notifier_enabler_as_enabler(
+       (*bytecode)->enabler = lttng_event_notifier_enabler_as_enabler(
                        event_notifier_enabler);
-       cds_list_add_tail(&bytecode->node,
+       cds_list_add_tail(&(*bytecode)->node,
                        &event_notifier_enabler->capture_bytecode_head);
+       /* Take ownership of bytecode */
+       *bytecode = NULL;
        event_notifier_enabler->num_captures++;
 
        lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
@@ -1534,7 +1528,7 @@ int lttng_event_notifier_enabler_attach_capture_bytecode(
 
 int lttng_event_notifier_enabler_attach_exclusion(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_ust_excluder_node *excluder)
+               struct lttng_ust_excluder_node **excluder)
 {
        _lttng_enabler_attach_exclusion(
                lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
@@ -1706,6 +1700,13 @@ void lttng_session_sync_event_enablers(struct lttng_session *session)
        __tracepoint_probe_prune_release_queue();
 }
 
+/* Support for event notifier is introduced by probe provider major version 2. */
+static
+bool lttng_ust_probe_supports_event_notifier(struct lttng_probe_desc *probe_desc)
+{
+       return probe_desc->major >= 2;
+}
+
 static
 void lttng_create_event_notifier_if_missing(
                struct lttng_event_notifier_enabler *event_notifier_enabler)
@@ -1757,6 +1758,18 @@ void lttng_create_event_notifier_if_missing(
                        if (found)
                                continue;
 
+                       /* Check that the probe supports event notifiers, else report the error. */
+                       if (!lttng_ust_probe_supports_event_notifier(probe_desc)) {
+                               ERR("Probe \"%s\" contains event \"%s\" which matches an enabled event notifier, "
+                                       "but its version (%u.%u) is too old and does not implement event notifiers. "
+                                       "It needs to be recompiled against a newer version of LTTng-UST, otherwise "
+                                       "this event will not generate any notification.",
+                                       probe_desc->provider,
+                                       desc->name,
+                                       probe_desc->major,
+                                       probe_desc->minor);
+                               continue;
+                       }
                        /*
                         * We need to create a event_notifier for this event probe.
                         */
This page took 0.02486 seconds and 4 git commands to generate.