X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Fltt-probes.c;h=02df21b2f61c847e3ba082866577daa4c40c79bc;hb=e92f3e285939848f248af08f11a39a04a7fcf852;hp=957a9b59ba55afd64794e05294b833bad1b6f17a;hpb=c8fcf224e283ed7679c84cbcccf70ac65ca7e41d;p=lttng-ust.git diff --git a/liblttng-ust/ltt-probes.c b/liblttng-ust/ltt-probes.c index 957a9b59..02df21b2 100644 --- a/liblttng-ust/ltt-probes.c +++ b/liblttng-ust/ltt-probes.c @@ -1,21 +1,39 @@ /* * ltt-probes.c * - * Copyright 2010 (c) - Mathieu Desnoyers - * * Holds LTTng probes registry. * - * Dual LGPL v2.1/GPL v2 license. + * Copyright 2010-2012 (c) - Mathieu Desnoyers + * + * 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 */ #include #include #include +#include #include +#include +#include "tracepoint-internal.h" #include #include +#include #include "ltt-tracer-core.h" +#include "jhash.h" +#include "error.h" /* * probe list is protected by ust_lock()/ust_unlock(). @@ -42,7 +60,8 @@ const struct lttng_event_desc *find_event(const char *name) cds_list_for_each_entry(probe_desc, &probe_list, head) { for (i = 0; i < probe_desc->nr_events; i++) { - if (!strcmp(probe_desc->event_desc[i]->name, name)) + if (!strncmp(probe_desc->event_desc[i]->name, name, + LTTNG_UST_SYM_NAME_LEN - 1)) return probe_desc->event_desc[i]; } } @@ -86,12 +105,18 @@ int ltt_probe_register(struct lttng_probe_desc *desc) /* We should be added at the head of the list */ cds_list_add(&desc->head, &probe_list); desc_added: - + DBG("just registered probe %s containing %u events", + desc->provider, desc->nr_events); /* * fix the events awaiting probe load. */ for (i = 0; i < desc->nr_events; i++) { - ret = pending_probe_fix_events(desc->event_desc[i]); + const struct lttng_event_desc *ed; + + ed = desc->event_desc[i]; + DBG("Registered event probe \"%s\" with signature \"%s\"", + ed->name, ed->signature); + ret = pending_probe_fix_events(ed); assert(!ret); } end: @@ -103,6 +128,7 @@ void ltt_probe_unregister(struct lttng_probe_desc *desc) { ust_lock(); cds_list_del(&desc->head); + DBG("just unregistered probe %s", desc->provider); ust_unlock(); } @@ -155,15 +181,9 @@ int ltt_probes_get_event_list(struct lttng_ust_tracepoint_list *list) LTTNG_UST_SYM_NAME_LEN); list_entry->tp.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; if (!probe_desc->event_desc[i]->loglevel) { - list_entry->tp.loglevel[0] = '\0'; - list_entry->tp.loglevel_value = 0; + list_entry->tp.loglevel = TRACE_DEFAULT; } else { - strncpy(list_entry->tp.loglevel, - (*probe_desc->event_desc[i]->loglevel)->identifier, - LTTNG_UST_SYM_NAME_LEN); - list_entry->tp.loglevel[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; - list_entry->tp.loglevel_value = - (*probe_desc->event_desc[i]->loglevel)->value; + list_entry->tp.loglevel = *(*probe_desc->event_desc[i]->loglevel); } } } @@ -198,3 +218,57 @@ struct lttng_ust_tracepoint_iter * struct tp_list_entry, head); return &entry->tp; } + +/* + * marshall all probes/all events and create those that fit the + * wildcard. Add them to the events list as created. + */ +void ltt_probes_create_wildcard_events(struct wildcard_entry *entry, + struct session_wildcard *wildcard) +{ + struct lttng_probe_desc *probe_desc; + struct lttng_ust_event event_param; + int i; + + cds_list_for_each_entry(probe_desc, &probe_list, head) { + for (i = 0; i < probe_desc->nr_events; i++) { + const struct lttng_event_desc *event_desc; + int match = 0; + + event_desc = probe_desc->event_desc[i]; + /* compare excluding final '*' */ + assert(strlen(entry->name) > 0); + if (strcmp(event_desc->name, "lttng_ust:metadata") + && (strlen(entry->name) == 1 + || !strncmp(event_desc->name, entry->name, + strlen(entry->name) - 1))) { + if (ltt_loglevel_match(event_desc, + entry->loglevel_type, + entry->loglevel)) { + match = 1; + } + } + if (match) { + struct ltt_event *ev; + int ret; + + memcpy(&event_param, &wildcard->event_param, + sizeof(event_param)); + memcpy(event_param.name, + event_desc->name, + sizeof(event_param.name)); + /* create event */ + ret = ltt_event_create(wildcard->chan, + &event_param, NULL, + &ev); + if (ret) { + DBG("Error creating event"); + continue; + } + cds_list_add(&ev->wildcard_list, + &wildcard->events); + } + } + } +} +