lttng-probes: Warn of event's and provider's name for mismatch
authorHe Zhe <zhe.he@windriver.com>
Mon, 19 Apr 2021 09:16:57 +0000 (09:16 +0000)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 19 Apr 2021 16:06:48 +0000 (12:06 -0400)
We have experience serveral cases of such mismatches. To make it easier to
debug, let's warn users of the event's and the provide's name.

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I455bf92f9f735f890753c9103d22986e56e02e5d

src/lttng-probes.c

index aba7ada5767faba1db997e748b5569dd304bb456..8cf1a75db7672182a6dedf540bb486a27f699a2d 100644 (file)
@@ -41,24 +41,31 @@ EXPORT_PER_CPU_SYMBOL_GPL(lttng_dynamic_len_stack);
 static
 int check_event_provider(struct lttng_kernel_probe_desc *desc)
 {
-       int i;
+       int i, mismatch = 0;
        size_t provider_name_len;
 
        provider_name_len = strnlen(desc->provider_name,
                                LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1);
        for (i = 0; i < desc->nr_events; i++) {
-               if (strncmp(desc->event_desc[i]->event_name,
-                               desc->provider_name,
-                               provider_name_len))
-                       return 0;       /* provider mismatch */
                /*
-                * The event needs to contain at least provider name + _ +
+                * The event name needs to start with provider name + _ +
                 * one or more letter.
                 */
-               if (strlen(desc->event_desc[i]->event_name) <= provider_name_len + 1)
-                       return 0;       /* provider mismatch */
-               if (desc->event_desc[i]->event_name[provider_name_len] != '_')
-                       return 0;       /* provider mismatch */
+               if (strncmp(desc->event_desc[i]->event_name, desc->provider_name, provider_name_len))
+                       mismatch = 1;
+               else if (strlen(desc->event_desc[i]->event_name) <= provider_name_len + 1)
+                       mismatch = 1;
+               else if (desc->event_desc[i]->event_name[provider_name_len] != '_')
+                       mismatch = 1;
+
+               if (mismatch) {
+                       printk(KERN_WARNING "LTTng: event provider mismatch: "
+                               "The event name needs to start with provider "
+                               "name + _ + one or more letter, "
+                               "provider: %s, event name: %s\n",
+                               desc->provider_name, desc->event_desc[i]->event_name);
+                       return 0;
+               }
        }
        return 1;
 }
This page took 0.026852 seconds and 4 git commands to generate.