** 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>
#define TP_PROTO(args...) args
#define TP_ARGS(args...) args
#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
#define CONFIG_TRACEPOINTS
#ifdef CONFIG_TRACEPOINTS
*/
#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
extern struct tracepoint __tracepoint_##name; \
*/
#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)); \
{ \
__CHECK_TRACE(name, 0, TP_PROTO(data_proto), \
TP_ARGS(data_args)); \
TP_ARGS(data_args)); \
} \
static inline int \
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 \
{ \
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); \
{ \
return tracepoint_probe_unregister(#name, (void *)probe, \
data); \
{ } \
static inline void _trace_##name(proto) \
{ } \
{ } \
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; \
} \
{ \
return -ENOSYS; \
} \
- static inline int unregister_trace_##name(void (*probe)(proto), void *data) \
+ static inline int __unregister_trace_##name(void (*probe)(proto), void *data) \
} \
static inline int register_event_##name(void *data) \
{ \
} \
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) \
{ \
} \
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, \
} \
struct trace_event __event_##name = { \
__tpstrtab_##name, \
static void __attribute__((constructor)) init_##name() \
{ \
void *dummy = NULL; \
static void __attribute__((constructor)) init_##name() \
{ \
void *dummy = NULL; \
- register_trace_##name(trace_printf_##name, dummy); \
+ register_tracepoint(name, trace_printf_##name, dummy); \
for(i=0; i<50; i++) {
ust_marker(bar, "str %s", "FOOBAZ");
ust_marker(bar2, "number1 %d number2 %d", 53, 9800);
for(i=0; i<50; i++) {
ust_marker(bar, "str %s", "FOOBAZ");
ust_marker(bar2, "number1 %d number2 %d", 53, 9800);
+ tracepoint(hello_tptest, i);
static void __attribute__((constructor)) init()
{
DBG("connecting tracepoint...\n");
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);
}
for (i=0; i<1000; i++) {
}
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");
&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++;
&hello[j%HELLO_LENGTH])) {
usleep(10);
j++;
pthread_create(®ister_thread, NULL, register_thread_main, NULL);
for(i=0; i<1000000; i++) {
pthread_create(®ister_thread, NULL, register_thread_main, NULL);
for(i=0; i<1000000; i++) {
+ tracepoint(hello_tptest, i);
static unsigned long time, i;
for (i=0; i<10; i++) {
time=trace_clock_read64();
static unsigned long time, i;
for (i=0; i<10; i++) {
time=trace_clock_read64();
+ tracepoint(test, time, i);
static void __attribute__((constructor)) init()
{
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)
{
}
void single_trace(unsigned int v)
{
+ tracepoint(ust_event, v);
static void __attribute__((constructor)) init()
{
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 */
}
int main(int argc, char **argv) {
unsigned int v = 42;
/* Tracepoint 1 : ust_event */
+ tracepoint(ust_event, v);
/* Tracepoint 2 : ust_event2 */
/* Tracepoint 2 : ust_event2 */
+ tracepoint(ust_event2, v);