Comment the union field (only used in call_rcu scheme)
[lttng-ust.git] / liblttng-ust / tracepoint.c
index f146d382b7717955875938a1169d8436515ee043..f74a43b0ea67076a71c1f03b7b11976a4e3c5849 100644 (file)
@@ -87,6 +87,8 @@ struct tracepoint_entry {
 struct tp_probes {
        union {
                struct cds_list_head list;
+               /* Field below only used for call_rcu scheme */
+               /* struct rcu_head head; */
        } u;
        struct tracepoint_probe probes[0];
 };
@@ -524,6 +526,20 @@ static void new_tracepoints(struct tracepoint * const *start, struct tracepoint
        }
 }
 
+static
+void lib_disable_tracepoints(struct tracepoint * const *begin,
+                       struct tracepoint * const *end)
+{
+       struct tracepoint * const *iter;
+
+       for (iter = begin; iter < end; iter++) {
+               if (!*iter)
+                       continue;       /* skip dummy */
+               disable_tracepoint(*iter);
+       }
+
+}
+
 int tracepoint_register_lib(struct tracepoint * const *tracepoints_start,
                            int tracepoints_count)
 {
@@ -566,18 +582,34 @@ lib_added:
 int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start)
 {
        struct tracepoint_lib *lib;
+       int tracepoints_count;
 
        ust_lock();
        cds_list_for_each_entry(lib, &libs, list) {
                if (lib->tracepoints_start == tracepoints_start) {
                        struct tracepoint_lib *lib2free = lib;
+
                        cds_list_del(&lib->list);
+                       tracepoints_count = lib->tracepoints_count;
                        free(lib2free);
-                       break;
+                       goto found;
                }
        }
+       goto end;
+found:
+       /*
+        * Force tracepoint disarm for all tracepoints of this lib.
+        * This takes care of destructor of library that would leave a
+        * LD_PRELOAD wrapper override function enabled for tracing, but
+        * the session teardown would not be able to reach the
+        * tracepoint anymore to disable it.
+        */
+       lib_disable_tracepoints(tracepoints_start,
+                       tracepoints_start + tracepoints_count);
+       DBG("just unregistered a tracepoints section from %p",
+               tracepoints_start);
+end:
        ust_unlock();
-
        return 0;
 }
 
This page took 0.027253 seconds and 4 git commands to generate.