Trace event: export pointer array
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 17 Feb 2011 19:32:06 +0000 (14:32 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 17 Feb 2011 19:32:06 +0000 (14:32 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/tracepoint.h
include/ust/ust_trace.h
libust/trace_event.c
libust/tracectl.c

index 05e5c11dd902c0c01ae2713b3d1d44952fd9dcc5..8be8697942f567c6890735ae4dc93bfb62df6bf7 100644 (file)
@@ -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)
index 11d5940c68bed8ae85d1bb9b1f593fd8df9156d3..66f1e878f355de9ab2651325ffdd73b5c3c92178 100644 (file)
        {                                                               \
                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;                                     \
index b54d361f2ae170e2bb64645b80ead4e51f149824..d0d9ec455e36c132f8b3eed065517940f63583b3 100644 (file)
@@ -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;
 
index 233a460d6163bdaa3ff7d61d100b646a91c763c1..d32deba978ac8d2500fa6a222d07a520a2db2ebc 100644 (file)
@@ -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();
This page took 0.02826 seconds and 4 git commands to generate.