Refactoring: namespace ust-abi.h content under regular prefix
[lttng-ust.git] / liblttng-ust / lttng-probes.c
index 5e2d29662702b2013b05b2650cf539ba839a74a7..3d3e60e7193369fb0a1562e8dee21be33c269d91 100644 (file)
@@ -1,23 +1,9 @@
 /*
- * lttng-probes.c
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
- * Holds LTTng probes registry.
- *
- * Copyright 2010-2012 (c) - 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.
+ * Copyright 2010-2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * 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 probes registry.
  */
 
 #define _LGPL_SOURCE
 #include <lttng/tracepoint.h>
 #include "tracepoint-internal.h"
 #include <assert.h>
-#include <helper.h>
+#include <ust-helper.h>
 #include <ctype.h>
 
 #include "lttng-tracer-core.h"
 #include "jhash.h"
 #include "error.h"
+#include "ust-events-internal.h"
 
 /*
  * probe list is protected by ust_lock()/ust_unlock().
@@ -63,7 +50,7 @@ int check_event_provider(struct lttng_probe_desc *desc)
        size_t provider_name_len;
 
        provider_name_len = strnlen(desc->provider,
-                               LTTNG_UST_SYM_NAME_LEN - 1);
+                               LTTNG_UST_ABI_SYM_NAME_LEN - 1);
        for (i = 0; i < desc->nr_events; i++) {
                if (strncmp(desc->event_desc[i]->name,
                                desc->provider,
@@ -147,20 +134,6 @@ struct cds_list_head *lttng_get_probe_list_head(void)
        return &_probe_list;
 }
 
-static
-const struct lttng_probe_desc *find_provider(const char *provider)
-{
-       struct lttng_probe_desc *iter;
-       struct cds_list_head *probe_list;
-
-       probe_list = lttng_get_probe_list_head();
-       cds_list_for_each_entry(iter, probe_list, head) {
-               if (!strcmp(iter->provider, provider))
-                       return iter;
-       }
-       return NULL;
-}
-
 static
 int check_provider_version(struct lttng_probe_desc *desc)
 {
@@ -195,6 +168,8 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 {
        int ret = 0;
 
+       lttng_ust_fixup_tls();
+
        /*
         * If version mismatch, don't register, but don't trigger assert
         * on caller. The version check just prints an error.
@@ -204,13 +179,6 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
 
        ust_lock_nocheck();
 
-       /*
-        * Check if the provider has already been registered.
-        */
-       if (find_provider(desc->provider)) {
-               ret = -EEXIST;
-               goto end;
-       }
        cds_list_add(&desc->lazy_init_head, &lazy_probe_init);
        desc->lazy = 1;
        DBG("adding probe %s containing %u events to lazy registration list",
@@ -222,19 +190,17 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
         */
        if (lttng_session_active())
                fixup_lazy_probes();
-end:
+
+       lttng_fix_pending_event_notifiers();
+
        ust_unlock();
        return ret;
 }
 
-/* Backward compatibility with UST 2.0 */
-int ltt_probe_register(struct lttng_probe_desc *desc)
-{
-       return lttng_probe_register(desc);
-}
-
 void lttng_probe_unregister(struct lttng_probe_desc *desc)
 {
+       lttng_ust_fixup_tls();
+
        if (!check_provider_version(desc))
                return;
 
@@ -243,14 +209,11 @@ void lttng_probe_unregister(struct lttng_probe_desc *desc)
                cds_list_del(&desc->head);
        else
                cds_list_del(&desc->lazy_init_head);
-       DBG("just unregistered probe %s", desc->provider);
-       ust_unlock();
-}
 
-/* Backward compatibility with UST 2.0 */
-void ltt_probe_unregister(struct lttng_probe_desc *desc)
-{
-       lttng_probe_unregister(desc);
+       lttng_probe_provider_unregister_events(desc);
+       DBG("just unregistered probes of provider %s", desc->provider);
+
+       ust_unlock();
 }
 
 void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list)
@@ -284,8 +247,8 @@ int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list)
                        cds_list_add(&list_entry->head, &list->head);
                        strncpy(list_entry->tp.name,
                                probe_desc->event_desc[i]->name,
-                               LTTNG_UST_SYM_NAME_LEN);
-                       list_entry->tp.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+                               LTTNG_UST_ABI_SYM_NAME_LEN);
+                       list_entry->tp.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
                        if (!probe_desc->event_desc[i]->loglevel) {
                                list_entry->tp.loglevel = TRACE_DEFAULT;
                        } else {
@@ -309,7 +272,7 @@ err_nomem:
  * Return current iteration position, advance internal iterator to next.
  * Return NULL if end of list.
  */
-struct lttng_ust_tracepoint_iter *
+struct lttng_ust_abi_tracepoint_iter *
        lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list)
 {
        struct tp_list_entry *entry;
@@ -362,10 +325,10 @@ int lttng_probes_get_field_list(struct lttng_ust_field_list *list)
                                cds_list_add(&list_entry->head, &list->head);
                                strncpy(list_entry->field.event_name,
                                        event_desc->name,
-                                       LTTNG_UST_SYM_NAME_LEN);
-                               list_entry->field.event_name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+                                       LTTNG_UST_ABI_SYM_NAME_LEN);
+                               list_entry->field.event_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
                                list_entry->field.field_name[0] = '\0';
-                               list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                               list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                if (!event_desc->loglevel) {
                                        list_entry->field.loglevel = TRACE_DEFAULT;
                                } else {
@@ -385,41 +348,41 @@ int lttng_probes_get_field_list(struct lttng_ust_field_list *list)
                                cds_list_add(&list_entry->head, &list->head);
                                strncpy(list_entry->field.event_name,
                                        event_desc->name,
-                                       LTTNG_UST_SYM_NAME_LEN);
-                               list_entry->field.event_name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+                                       LTTNG_UST_ABI_SYM_NAME_LEN);
+                               list_entry->field.event_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
                                strncpy(list_entry->field.field_name,
                                        event_field->name,
-                                       LTTNG_UST_SYM_NAME_LEN);
-                               list_entry->field.field_name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+                                       LTTNG_UST_ABI_SYM_NAME_LEN);
+                               list_entry->field.field_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
                                switch (event_field->type.atype) {
                                case atype_integer:
-                                       list_entry->field.type = LTTNG_UST_FIELD_INTEGER;
+                                       list_entry->field.type = LTTNG_UST_ABI_FIELD_INTEGER;
                                        break;
                                case atype_string:
-                                       list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                       list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
-                               case atype_array:
-                                       if (event_field->type.u.array.elem_type.atype != atype_integer
-                                               || event_field->type.u.array.elem_type.u.basic.integer.encoding == lttng_encode_none)
-                                               list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                               case atype_array_nestable:
+                                       if (event_field->type.u.array_nestable.elem_type->atype != atype_integer
+                                               || event_field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none)
+                                               list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                        else
-                                               list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                               list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
-                               case atype_sequence:
-                                       if (event_field->type.u.sequence.elem_type.atype != atype_integer
-                                               || event_field->type.u.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none)
-                                               list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                               case atype_sequence_nestable:
+                                       if (event_field->type.u.sequence_nestable.elem_type->atype != atype_integer
+                                               || event_field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none)
+                                               list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                        else
-                                               list_entry->field.type = LTTNG_UST_FIELD_STRING;
+                                               list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
                                case atype_float:
-                                       list_entry->field.type = LTTNG_UST_FIELD_FLOAT;
+                                       list_entry->field.type = LTTNG_UST_ABI_FIELD_FLOAT;
                                        break;
-                               case atype_enum:
-                                       list_entry->field.type = LTTNG_UST_FIELD_ENUM;
+                               case atype_enum_nestable:
+                                       list_entry->field.type = LTTNG_UST_ABI_FIELD_ENUM;
                                        break;
                                default:
-                                       list_entry->field.type = LTTNG_UST_FIELD_OTHER;
+                                       list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                }
                                if (!event_desc->loglevel) {
                                        list_entry->field.loglevel = TRACE_DEFAULT;
@@ -447,7 +410,7 @@ err_nomem:
  * Return current iteration position, advance internal iterator to next.
  * Return NULL if end of list.
  */
-struct lttng_ust_field_iter *
+struct lttng_ust_abi_field_iter *
        lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list)
 {
        struct tp_field_list_entry *entry;
This page took 0.029077 seconds and 4 git commands to generate.