From: Mathieu Desnoyers Date: Thu, 17 Feb 2011 19:32:06 +0000 (-0500) Subject: Trace event: export pointer array X-Git-Tag: v1.9.1~472 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fc1caebc8a71283c7766549ebed47300d1b52945;p=lttng-ust.git Trace event: export pointer array Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 05e5c11d..8be86979 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -339,17 +339,17 @@ struct trace_event { const char *name; int (*regfunc)(void *data); int (*unregfunc)(void *data); -} __attribute__((aligned(32))); +}; struct trace_event_lib { - struct trace_event *trace_events_start; + struct trace_event * const *trace_events_start; int trace_events_count; struct cds_list_head list; }; struct trace_event_iter { struct trace_event_lib *lib; - struct trace_event *trace_event; + struct trace_event * const *trace_event; }; extern void lock_trace_events(void); @@ -359,37 +359,35 @@ extern void trace_event_iter_start(struct trace_event_iter *iter); extern void trace_event_iter_next(struct trace_event_iter *iter); extern void trace_event_iter_reset(struct trace_event_iter *iter); -extern int trace_event_get_iter_range(struct trace_event **trace_event, - struct trace_event *begin, - struct trace_event *end); +extern int trace_event_get_iter_range(struct trace_event * const **trace_event, + struct trace_event * const *begin, + struct trace_event * const *end); extern void trace_event_update_process(void); extern int is_trace_event_enabled(const char *channel, const char *name); -extern int trace_event_register_lib(struct trace_event *start_trace_events, +extern int trace_event_register_lib(struct trace_event * const *start_trace_events, int trace_event_count); -extern int trace_event_unregister_lib(struct trace_event *start_trace_events); +extern int trace_event_unregister_lib(struct trace_event * const *start_trace_events); #define TRACE_EVENT_LIB \ - extern struct trace_event __start___trace_events[] \ + extern struct trace_event * const __start___trace_events_ptrs[] \ __attribute__((weak, visibility("hidden"))); \ - extern struct trace_event __stop___trace_events[] \ + extern struct trace_event * const __stop___trace_events_ptrs[] \ __attribute__((weak, visibility("hidden"))); \ static void __attribute__((constructor)) \ __trace_events__init(void) \ { \ - long trace_event_count =((long)__stop___trace_events- \ - (long)__start___trace_events) \ - /sizeof(struct trace_event); \ - trace_event_register_lib(__start___trace_events, \ - trace_event_count); \ + trace_event_register_lib(__start___trace_events_ptrs, \ + __stop___trace_events_ptrs - \ + __start___trace_events_ptrs); \ } \ \ static void __attribute__((destructor)) \ __trace_event__destroy(void) \ { \ - trace_event_unregister_lib(__start___trace_events); \ + trace_event_unregister_lib(__start___trace_events_ptrs);\ } #define DECLARE_TRACE_EVENT_CLASS(name, proto, args, tstruct, assign, print) diff --git a/include/ust/ust_trace.h b/include/ust/ust_trace.h index 11d5940c..66f1e878 100644 --- a/include/ust/ust_trace.h +++ b/include/ust/ust_trace.h @@ -76,12 +76,15 @@ { \ return unregister_trace_##name(trace_printf_##name, data); \ } \ - struct trace_event __event_##name \ - __attribute__((section("__trace_events"), aligned(32))) = { \ + struct trace_event __event_##name = { \ __tpstrtab_##name, \ register_event_##name, \ unregister_event_##name \ }; \ + static struct trace_event * const __event_ptrs_##name \ + __attribute__((used, section("__trace_events_ptrs"))) = \ + &__event_##name; \ + \ static void __attribute__((constructor)) init_##name() \ { \ void *dummy = NULL; \ diff --git a/libust/trace_event.c b/libust/trace_event.c index b54d361f..d0d9ec45 100644 --- a/libust/trace_event.c +++ b/libust/trace_event.c @@ -72,8 +72,9 @@ int lib_get_iter_trace_events(struct trace_event_iter *iter) * Returns whether a next trace_event has been found (1) or not (0). * Will return the first trace_event in the range if the input trace_event is NULL. */ -int trace_event_get_iter_range(struct trace_event **trace_event, struct trace_event *begin, - struct trace_event *end) +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) { *trace_event = begin; @@ -116,7 +117,7 @@ void trace_event_iter_reset(struct trace_event_iter *iter) iter->trace_event = NULL; } -int trace_event_register_lib(struct trace_event *trace_events_start, +int trace_event_register_lib(struct trace_event * const *trace_events_start, int trace_events_count) { struct trace_event_lib *pl; @@ -136,7 +137,7 @@ int trace_event_register_lib(struct trace_event *trace_events_start, return 0; } -int trace_event_unregister_lib(struct trace_event *trace_events_start) +int trace_event_unregister_lib(struct trace_event * const *trace_events_start) { struct trace_event_lib *lib; diff --git a/libust/tracectl.c b/libust/tracectl.c index 233a460d..d32deba9 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -119,7 +119,7 @@ static void print_trace_events(FILE *fp) trace_event_iter_start(&iter); while (iter.trace_event) { - fprintf(fp, "trace_event: %s\n", iter.trace_event->name); + fprintf(fp, "trace_event: %s\n", (*iter.trace_event)->name); trace_event_iter_next(&iter); } unlock_trace_events();