From: Mathieu Desnoyers Date: Thu, 3 Mar 2011 20:57:14 +0000 (-0500) Subject: Remove dummy markers/tracepoints/trace events X-Git-Tag: v1.9.1~431 X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=f08ebbe29cc9f6fa1c108907be5d9d92d297067e;p=lttng-ust.git Remove dummy markers/tracepoints/trace events 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 --- diff --git a/include/ust/marker.h b/include/ust/marker.h index c82dd30d..604aa23f 100644 --- a/include/ust/marker.h +++ b/include/ust/marker.h @@ -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) \ { \ diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 2d6f7abb..49a9b6e6 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -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) \ { \ diff --git a/libust-initializer.c b/libust-initializer.c index a7103389..2314e5e0 100644 --- a/libust-initializer.c +++ b/libust-initializer.c @@ -11,26 +11,6 @@ #include #include -/* 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; diff --git a/libust/marker.c b/libust/marker.c index 19baba08..788d8769 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -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; } diff --git a/libust/trace_event.c b/libust/trace_event.c index 2464d444..54515ef1 100644 --- a/libust/trace_event.c +++ b/libust/trace_event.c @@ -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; } diff --git a/libust/tracepoint.c b/libust/tracepoint.c index 5a834a3f..335ba4f7 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -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; }