Remove dummy markers/tracepoints/trace events
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 20:57:14 +0000 (15:57 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 20:57:14 +0000 (15:57 -0500)
Add a null pointer in the marker/tp/te tables instead of a full-blown dummy
marker. Skip the null pointers in the marker/tp/te iterators.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/marker.h
include/ust/tracepoint.h
libust-initializer.c
libust/marker.c
libust/trace_event.c
libust/tracepoint.c

index c82dd30dfef04326376057ab8608579776814a1e..604aa23fa798dec2c72a830090e18d745a0a87da 100644 (file)
@@ -345,6 +345,8 @@ extern int marker_unregister_lib(struct marker * const *markers_start);
 #define MARKER_LIB                                                     \
        extern struct marker * const __start___markers_ptrs[] __attribute__((weak, visibility("hidden"))); \
        extern struct marker * const __stop___markers_ptrs[] __attribute__((weak, visibility("hidden"))); \
+       static struct marker * const __mark_ptr_dummy                   \
+               __attribute__((used, section("__markers_ptrs"))) = NULL;\
                                                                        \
        static void __attribute__((constructor)) __markers__init(void)  \
        {                                                               \
index 2d6f7abbdccd492b152b476747211da85e70c23a..49a9b6e65bcc26807b57712de321df0e6abcc069 100644 (file)
@@ -222,6 +222,8 @@ extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_star
 #define TRACEPOINT_LIB                                                 \
        extern struct tracepoint * const __start___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
        extern struct tracepoint * const __stop___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
+       static struct tracepoint * const __tracepoint_ptr_dummy         \
+       __attribute__((used, section("__tracepoints_ptrs"))) = NULL;    \
        static void __attribute__((constructor)) __tracepoints__init(void)      \
        {                                                                       \
                tracepoint_register_lib(__start___tracepoints_ptrs,                     \
@@ -377,6 +379,8 @@ extern int trace_event_unregister_lib(struct trace_event * const *start_trace_ev
        __attribute__((weak, visibility("hidden")));                    \
        extern struct trace_event * const __stop___trace_events_ptrs[]  \
        __attribute__((weak, visibility("hidden")));                    \
+       static struct trace_event * const __event_ptrs_dummy            \
+       __attribute__((used, section("__trace_events_ptrs"))) = NULL;   \
        static void __attribute__((constructor))                        \
        __trace_events__init(void)                                      \
        {                                                               \
index a7103389bf3f7611236c3ab94537b5aaf52cbdee..2314e5e0438a28d6db38bf76826f42af99d2d910 100644 (file)
 #include <ust/marker.h>
 #include <ust/tracepoint.h>
 
-/* FIXME: We have to define at least one trace_mark and
- * one tracepoint here. If we don't, the __start... and
- * __stop... symbols won't be defined and the constructors
- * won't be compilable. We should find a linker trick to
- * avoid this.
- */
-
-DECLARE_TRACE(ust_dummytp, TP_PROTO(int anint), TP_ARGS(anint));
-DEFINE_TRACE(ust_dummytp);
-
-#define CREATE_TRACE_POINTS
-#include "libust-initializer.h"
-
-void dummy_libust_initializer_func(void)
-{
-       trace_mark(ust, dummymark, MARK_NOARGS);
-       trace_ust_dummytp(0);
-       trace_ust_dummy_event(0);
-}
-
 MARKER_LIB;
 TRACEPOINT_LIB;
 TRACE_EVENT_LIB;
index 19baba08392bfe73be89ef2fef5d9c2f1aece28d..788d87691beb0ddc6fd4f51efb2df7cad151545c 100644 (file)
@@ -685,6 +685,8 @@ void marker_update_probe_range(struct marker * const *begin,
 
        pthread_mutex_lock(&markers_mutex);
        for (iter = begin; iter < end; iter++) {
+               if (!*iter)
+                       continue;       /* skip dummy */
                mark_entry = get_marker((*iter)->channel, (*iter)->name);
                if (mark_entry) {
                        set_marker(mark_entry, *iter, !!mark_entry->refcount);
@@ -1114,12 +1116,14 @@ int marker_get_iter_range(struct marker * const **marker,
        struct marker * const *begin,
        struct marker * const *end)
 {
-       if (!*marker && begin != end) {
+       if (!*marker && begin != end)
                *marker = begin;
-               return 1;
+       while (*marker >= begin && *marker < end) {
+               if (!**marker)
+                       (*marker)++;    /* skip dummy */
+               else
+                       return 1;
        }
-       if (*marker >= begin && *marker < end)
-               return 1;
        return 0;
 }
 //ust// EXPORT_SYMBOL_GPL(marker_get_iter_range);
@@ -1342,8 +1346,10 @@ static void new_markers(struct marker * const *start, struct marker * const *end
 {
        if (new_marker_cb) {
                struct marker * const *m;
-               for(m=start; m < end; m++) {
-                       new_marker_cb(*m);
+
+               for(m = start; m < end; m++) {
+                       if (*m)
+                               new_marker_cb(*m);
                }
        }
 }
@@ -1381,7 +1387,8 @@ lib_added:
        /* FIXME: update just the loaded lib */
        lib_update_markers();
 
-       DBG("just registered a markers section from %p and having %d markers", markers_start, markers_count);
+       /* markers_count - 1: skip dummy */
+       DBG("just registered a markers section from %p and having %d markers", markers_start, markers_count - 1);
        
        return 0;
 }
index 2464d444807deb21ff8dd90853cd5484f6106022..54515ef1b7d357613a4681a89ac25de8933c7a8d 100644 (file)
@@ -76,12 +76,14 @@ int trace_event_get_iter_range(struct trace_event * const **trace_event,
        struct trace_event * const *begin,
        struct trace_event * const *end)
 {
-       if (!*trace_event && begin != end) {
+       if (!*trace_event && begin != end)
                *trace_event = begin;
-               return 1;
+       while (*trace_event >= begin && *trace_event < end) {
+               if (!**trace_event)
+                       (*trace_event)++;       /* skip dummy */
+               else
+                       return 1;
        }
-       if (*trace_event >= begin && *trace_event < end)
-               return 1;
        return 0;
 }
 
@@ -145,7 +147,8 @@ int trace_event_register_lib(struct trace_event * const *trace_events_start,
 lib_added:
        pthread_mutex_unlock(&trace_events_mutex);
 
-       DBG("just registered a trace_events section from %p and having %d trace_events", trace_events_start, trace_events_count);
+       /* trace_events_count - 1: skip dummy */
+       DBG("just registered a trace_events section from %p and having %d trace_events", trace_events_start, trace_events_count - 1);
 
        return 0;
 }
index 5a834a3fc91ed8956c0faba7cba65878b8bad458..335ba4f7f53ad9ae41e971654b5303d864ac8a89 100644 (file)
@@ -295,6 +295,8 @@ void tracepoint_update_probe_range(struct tracepoint * const *begin,
 
        pthread_mutex_lock(&tracepoints_mutex);
        for (iter = begin; iter < end; iter++) {
+               if (!*iter)
+                       continue;       /* skip dummy */
                if (!(*iter)->name) {
                        disable_tracepoint(*iter);
                        continue;
@@ -550,12 +552,14 @@ int lib_get_iter_tracepoints(struct tracepoint_iter *iter)
 int tracepoint_get_iter_range(struct tracepoint * const **tracepoint,
        struct tracepoint * const *begin, struct tracepoint * const *end)
 {
-       if (!*tracepoint && begin != end) {
+       if (!*tracepoint && begin != end)
                *tracepoint = begin;
-               return 1;
+       while (*tracepoint >= begin && *tracepoint < end) {
+               if (!**tracepoint)
+                       (*tracepoint)++;        /* skip dummy */
+               else
+                       return 1;
        }
-       if (*tracepoint >= begin && *tracepoint < end)
-               return 1;
        return 0;
 }
 //ust// EXPORT_SYMBOL_GPL(tracepoint_get_iter_range);
@@ -652,8 +656,10 @@ static void new_tracepoints(struct tracepoint * const *start, struct tracepoint
 {
        if (new_tracepoint_cb) {
                struct tracepoint * const *t;
-               for(t=start; t < end; t++) {
-                       new_tracepoint_cb(*t);
+
+               for(t = start; t < end; t++) {
+                       if (*t)
+                               new_tracepoint_cb(*t);
                }
        }
 }
@@ -690,7 +696,8 @@ lib_added:
        /* FIXME: update just the loaded lib */
        lib_update_tracepoints();
 
-       DBG("just registered a tracepoints section from %p and having %d tracepoints", tracepoints_start, tracepoints_count);
+       /* tracepoints_count - 1: skip dummy */
+       DBG("just registered a tracepoints section from %p and having %d tracepoints", tracepoints_start, tracepoints_count - 1);
 
        return 0;
 }
This page took 0.028183 seconds and 4 git commands to generate.