Tracepoints: add wrapper tracepoint() macro
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Apr 2011 17:59:16 +0000 (13:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Apr 2011 17:59:16 +0000 (13:59 -0400)
** Instrumentation API change **

Moving tracepoints from

trace_name(args)
register_trace_name(...)
unregister_trace_name(...)

to

tracepoint(name, args)
register_tracepoint(name, ...)
unregister_tracepoint(name, ...)

This will allow doing macro tricks at the "tracepoint()" macro expansion
site. This will be useful for integration with SystemTAP probes, which
needs to expand an inline assembly with constraints on the arguments.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Nils Carlson <nils.carlson@ericsson.com>
CC: Steven Rostedt <srostedt@redhat.com>
CC: Josh Stone <jistone@redhat.com>
include/ust/tracepoint.h
include/ust/ust_trace.h
tests/hello/hello.c
tests/hello/tp.c
tests/register_test/register_test.c
tests/trace_event/trace_event_test.c
tests/tracepoint/benchmark/tracepoint_benchmark.c
tests/tracepoint/tracepoint_test.c

index 49a9b6e65bcc26807b57712de321df0e6abcc069..b2e03cd46bfcdbac2b01b59417ebf3ddb80e601c 100644 (file)
@@ -49,6 +49,18 @@ struct tracepoint {
 #define TP_PROTO(args...)      args
 #define TP_ARGS(args...)       args
 
+/*
+ * Tracepoints should be added to the instrumented code using the
+ * "tracepoint()" macro.
+ */
+#define tracepoint(name, args...)      __trace_##name(args)
+
+#define register_tracepoint(name, probe, data)                 \
+               __register_trace_##name(probe, data)
+
+#define unregister_tracepoint(name, probe, data)               \
+               __unregister_trace_##name(probe, data)
+
 #define CONFIG_TRACEPOINTS
 #ifdef CONFIG_TRACEPOINTS
 
@@ -99,7 +111,7 @@ struct tracepoint {
  */
 #define __DECLARE_TRACE(name, proto, args, data_proto, data_args)      \
        extern struct tracepoint __tracepoint_##name;                   \
-       static inline void trace_##name(proto)                          \
+       static inline void __trace_##name(proto)                        \
        {                                                               \
                __CHECK_TRACE(name, 0, TP_PROTO(data_proto),            \
                              TP_ARGS(data_args));                      \
@@ -110,14 +122,14 @@ struct tracepoint {
                              TP_ARGS(data_args));                      \
        }                                                               \
        static inline int                                               \
-       register_trace_##name(void (*probe)(data_proto), void *data)    \
+       __register_trace_##name(void (*probe)(data_proto), void *data)  \
        {                                                               \
                return tracepoint_probe_register(#name, (void *)probe,  \
                                                 data);                 \
                                                                        \
        }                                                               \
        static inline int                                               \
-       unregister_trace_##name(void (*probe)(data_proto), void *data)  \
+       __unregister_trace_##name(void (*probe)(data_proto), void *data)\
        {                                                               \
                return tracepoint_probe_unregister(#name, (void *)probe, \
                                                   data);               \
@@ -145,11 +157,11 @@ extern void tracepoint_update_probe_range(struct tracepoint * const *begin,
        { }                                                             \
        static inline void _trace_##name(proto)                         \
        { }                                                             \
-       static inline int register_trace_##name(void (*probe)(proto), void *data)       \
+       static inline int __register_trace_##name(void (*probe)(proto), void *data)     \
        {                                                               \
                return -ENOSYS;                                         \
        }                                                               \
-       static inline int unregister_trace_##name(void (*probe)(proto), void *data)     \
+       static inline int __unregister_trace_##name(void (*probe)(proto), void *data)   \
        {                                                               \
                return -ENOSYS;                                         \
        }
index 66f1e878f355de9ab2651325ffdd73b5c3c92178..21c941a641cb02426ef6616c6bf7135902aaa562 100644 (file)
        }                                                               \
        static inline int register_event_##name(void *data)             \
        {                                                               \
-               return register_trace_##name(trace_printf_##name, data); \
+               return register_tracepoint(name, trace_printf_##name, data); \
        }                                                               \
        static inline int unregister_event_##name(void *data)           \
        {                                                               \
-               return unregister_trace_##name(trace_printf_##name, data); \
+               return unregister_tracepoint(name, trace_printf_##name, data); \
        }                                                               \
        struct trace_event __event_##name = {                           \
                __tpstrtab_##name,                                      \
@@ -88,7 +88,7 @@
        static void __attribute__((constructor)) init_##name()          \
        {                                                               \
                void *dummy = NULL;                                     \
-               register_trace_##name(trace_printf_##name, dummy);      \
+               register_tracepoint(name, trace_printf_##name, dummy);  \
        }
 
 
index 09a35b98aba42bb54885ce6be4c08672428f31a8..a786fbf89fa90d3cbea1109824b6a3aebf92adff 100644 (file)
@@ -73,7 +73,7 @@ int main()
        for(i=0; i<50; i++) {
                ust_marker(bar, "str %s", "FOOBAZ");
                ust_marker(bar2, "number1 %d number2 %d", 53, 9800);
-               trace_hello_tptest(i);
+               tracepoint(hello_tptest, i);
                usleep(100000);
        }
 
index 3a4c6fcaf15ac93ff85b183ba8dc3dbeeedb6036..ec3e7ac73e5263733cdc8ad6e31578eb64a5c17b 100644 (file)
@@ -40,5 +40,5 @@ void tptest_probe(void *data, int anint)
 static void __attribute__((constructor)) init()
 {
        DBG("connecting tracepoint...\n");
-       register_trace_hello_tptest(tptest_probe, &hello_struct);
+       register_tracepoint(hello_tptest, tptest_probe, &hello_struct);
 }
index 4d1f0fe7e80a6f2df1b525bd8a20743462bc6cb6..02225deb56fa32fc9fe780c0137d82006fce4463 100644 (file)
@@ -65,13 +65,13 @@ static void * register_thread_main(void *data)
        }
 
        for (i=0; i<1000; i++) {
-               while (!register_trace_hello_tptest(tptest_probe,
+               while (!register_tracepoint(hello_tptest, tptest_probe,
                                                    &hello[j%HELLO_LENGTH])) {
                        usleep(10);
                        j++;
                }
                printf("Registered all\n");
-               while (!unregister_trace_hello_tptest(tptest_probe,
+               while (!unregister_tracepoint(hello_tptest, tptest_probe,
                                                      &hello[j%HELLO_LENGTH])) {
                        usleep(10);
                        j++;
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
 
        pthread_create(&register_thread, NULL, register_thread_main, NULL);
        for(i=0; i<1000000; i++) {
-               trace_hello_tptest(i);
+               tracepoint(hello_tptest, i);
        }
 
        return 0;
index f4fa90a8de9e1218704e9671b33d2258d9a8d2d9..b38e7ad20a30f99f14e8fbdd380ffd61fefbecd1 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char * argv[])
        static unsigned long time, i;
        for (i=0; i<10; i++) {
                time=trace_clock_read64();
-               trace_test(time, i);
+               tracepoint(test, time, i);
        }
        return 0;
 }
index 4d354bb1be96b2097ce31bb2721e49e8497090a6..43ec21fc81ebc872c9e1fedfc81429c6b9f16977 100644 (file)
@@ -49,12 +49,12 @@ void tp_probe(void *data, unsigned int p1)
 
 static void __attribute__((constructor)) init()
 {
-       register_trace_ust_event(tp_probe, NULL);
+       register_tracepoint(ust_event, tp_probe, NULL);
 }
 
 void single_trace(unsigned int v)
 {
-       trace_ust_event(v);
+       tracepoint(ust_event, v);
 }
 
 void do_trace(void)
index 88fa10b00916877b328ec4240e26ea96e0937483..78171b8f437d4754a0cb312add80263418dbd696 100644 (file)
@@ -90,18 +90,18 @@ void tp_probe(void *data, unsigned int p1)
 
 static void __attribute__((constructor)) init()
 {
-       register_trace_ust_event(tp_probe, NULL);
-       register_trace_ust_event(tp_probe2, NULL);
-       register_trace_ust_event(tp_probe3, &msg_probe3);
-       register_trace_ust_event2(tp_probe4, NULL);
+       register_tracepoint(ust_event, tp_probe, NULL);
+       register_tracepoint(ust_event, tp_probe2, NULL);
+       register_tracepoint(ust_event, tp_probe3, &msg_probe3);
+       register_tracepoint(ust_event2, tp_probe4, NULL);
 }
 
 int main(int argc, char **argv) {
        unsigned int v = 42;
        /* Tracepoint 1 : ust_event */
-       trace_ust_event(v);
+       tracepoint(ust_event, v);
        /* Tracepoint 2 : ust_event2 */
-       trace_ust_event2(v);
+       tracepoint(ust_event2, v);
 
        return 0;
 }
This page took 0.028755 seconds and 4 git commands to generate.