From 8d8a24c8565ce6dce7e7bd1045a95d1d2af5e536 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 8 Aug 2011 19:15:46 -0400 Subject: [PATCH] libust 2.0 + ringbuffer + TRACEPOINT_EVENT builds and runs Missing pieces: Now libust needs to talk to the session daemon. Signed-off-by: Mathieu Desnoyers --- Makefile.am | 4 +- include/ust/clock.h | 66 ++---- include/ust/lttng-events.h | 11 +- include/ust/lttng-tracepoint-event-reset.h | 8 +- include/ust/lttng-tracepoint-event.h | 152 ++++++++++---- .../ust/ringbuffer-config.h | 2 +- include/ust/tracepoint-event.h | 57 ++--- {libringbuffer => include/ust}/vatomic.h | 0 libringbuffer/backend_internal.h | 2 +- libringbuffer/frontend_internal.h | 2 +- libringbuffer/frontend_types.h | 2 +- libringbuffer/ring_buffer_backend.c | 2 +- libringbuffer/ring_buffer_frontend.c | 6 +- libust-initializer.c | 5 +- libust/Makefile.am | 10 +- libust/ltt-context.c | 21 +- libust/ltt-events.c | 9 +- libust/ltt-probes.c | 46 ++-- libust/ltt-ring-buffer-client.h | 11 +- libust/ltt-ring-buffer-metadata-client.h | 11 +- libust/ltt-tracer-core.h | 2 +- libust/trace_event.c | 196 ------------------ tests/Makefile.am | 3 +- tests/hello/Makefile.am | 1 - tests/hello/hello.c | 30 +-- tests/hello/tp.c | 45 +--- tests/hello/tp.h | 28 +-- 27 files changed, 262 insertions(+), 470 deletions(-) rename libringbuffer/config.h => include/ust/ringbuffer-config.h (99%) rename {libringbuffer => include/ust}/vatomic.h (100%) delete mode 100644 libust/trace_event.c diff --git a/Makefile.am b/Makefile.am index 0950ff5..b72f9fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,10 +5,10 @@ ACLOCAL_AMFLAGS = -I config # libust and '.' (that contains the linker script). However, '.' # must be installed after libust so it can overwrite libust.so with # the linker script. -SUBDIRS = snprintf libringbuffer libust include doc +SUBDIRS = snprintf libringbuffer libust include doc tests #temporarily disabled -# . tests libustinstr-malloc libustfork +# . libustinstr-malloc libustfork EXTRA_DIST = libust.ldscript.in libust-initializer.c libust-initializer.h diff --git a/include/ust/clock.h b/include/ust/clock.h index 5e8f755..ae44bec 100644 --- a/include/ust/clock.h +++ b/include/ust/clock.h @@ -1,9 +1,11 @@ -/* Copyright (C) 2010 Pierre-Marc Fournier +/* + * Copyright (C) 2010 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * License as published by the Free Software Foundation; version 2.1 of + * the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,30 +28,10 @@ /* TRACE CLOCK */ -/* There are two types of clocks that can be used. - - TSC based clock - - gettimeofday() clock - - Microbenchmarks on Linux 2.6.30 on Core2 Duo 3GHz (functions are inlined): - Calls (100000000) to tsc(): 4004035641 cycles or 40 cycles/call - Calls (100000000) to gettimeofday(): 9723158352 cycles or 97 cycles/call - - For merging traces with the kernel, a time source compatible with that of - the kernel is necessary. - - Instead of gettimeofday(), we are now using clock_gettime for better - precision and monotonicity. -*/ - -/* Only available for x86 arch */ -#define CLOCK_TRACE_FREQ 14 -#define CLOCK_TRACE 15 -union lttng_timespec { - struct timespec ts; - uint64_t lttng_ts; -}; - -extern int ust_clock_source; +/* + * Currently using the kernel MONOTONIC clock, waiting for kernel-side + * LTTng to implement mmap'd trace clock. + */ /* Choosing correct trace clock */ @@ -57,39 +39,17 @@ static __inline__ uint64_t trace_clock_read64(void) { struct timespec ts; uint64_t retval; - union lttng_timespec *lts = (union lttng_timespec *) &ts; - clock_gettime(ust_clock_source, &ts); - /* - * Clock source can change when loading the binary (tracectl.c) - * so we must check if the clock source has changed before - * returning the correct value - */ - if (likely(ust_clock_source == CLOCK_TRACE)) { - retval = lts->lttng_ts; - } else { /* CLOCK_MONOTONIC */ - retval = ts.tv_sec; - retval *= 1000000000; - retval += ts.tv_nsec; - } + clock_gettime(CLOCK_MONOTONIC, &ts); + retval = ts.tv_sec; + retval *= 1000000000; + retval += ts.tv_nsec; return retval; } #if __i386__ || __x86_64__ static __inline__ uint64_t trace_clock_frequency(void) -{ - struct timespec ts; - union lttng_timespec *lts = (union lttng_timespec *) &ts; - - if (likely(ust_clock_source == CLOCK_TRACE)) { - clock_gettime(CLOCK_TRACE_FREQ, &ts); - return lts->lttng_ts; - } - return 1000000000LL; -} -#else /* #if __i386__ || __x86_64__ */ -static __inline__ uint64_t trace_clock_frequency(void) { return 1000000000LL; } diff --git a/include/ust/lttng-events.h b/include/ust/lttng-events.h index a8ad82e..5ca156b 100644 --- a/include/ust/lttng-events.h +++ b/include/ust/lttng-events.h @@ -197,15 +197,16 @@ struct ltt_event { int metadata_dumped:1; }; +struct channel; + struct ltt_channel_ops { - struct channel *(*channel_create)(const char *name, + struct shm_handle *(*channel_create)(const char *name, struct ltt_channel *ltt_chan, void *buf_addr, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shmid); - void (*channel_destroy)(struct channel *chan); + unsigned int read_timer_interval); + void (*channel_destroy)(struct shm_handle *handle); struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); void (*buffer_read_close)(struct lib_ring_buffer *buf); int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, @@ -237,7 +238,7 @@ struct ltt_channel { struct cds_list_head list; /* Channel list */ struct ltt_channel_ops *ops; int header_type; /* 0: unset, 1: compact, 2: large */ - int shmfd; /* shared-memory file descriptor */ + struct shm_handle *handle; /* shared-memory handle */ int metadata_dumped:1; }; diff --git a/include/ust/lttng-tracepoint-event-reset.h b/include/ust/lttng-tracepoint-event-reset.h index 7cc8277..b765c81 100644 --- a/include/ust/lttng-tracepoint-event-reset.h +++ b/include/ust/lttng-tracepoint-event-reset.h @@ -6,7 +6,7 @@ * Dual LGPL v2.1/GPL v2 license. */ -/* Reset macros used within TRACE_EVENT to "nothing" */ +/* Reset macros used within TRACEPOINT_EVENT to "nothing" */ #undef ctf_integer_ext #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) @@ -36,5 +36,11 @@ #undef TRACEPOINT_EVENT_CLASS #define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) + #undef TRACEPOINT_EVENT_INSTANCE #define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) + +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) diff --git a/include/ust/lttng-tracepoint-event.h b/include/ust/lttng-tracepoint-event.h index c6e71e8..c006ffd 100644 --- a/include/ust/lttng-tracepoint-event.h +++ b/include/ust/lttng-tracepoint-event.h @@ -18,7 +18,9 @@ */ #include +#include #include +#include /* * Macro declarations used for all stages. @@ -79,6 +81,15 @@ TP_PARAMS(fields)) \ TRACEPOINT_EVENT_INSTANCE(name, name, TP_PARAMS(proto), TP_PARAMS(args)) +#undef TRACEPOINT_EVENT_NOARGS +#define TRACEPOINT_EVENT_NOARGS(name, fields) \ + TRACEPOINT_EVENT_CLASS_NOARGS(name, \ + TP_PARAMS(fields)) \ + TRACEPOINT_EVENT_INSTANCE_NOARGS(name, name) + +/* Helpers */ +#define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + /* * Stage 1 of the trace events. * @@ -86,8 +97,8 @@ * Each event produce an array of fields. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include /* Named field types must be defined in lttng-types.h */ @@ -150,13 +161,17 @@ #undef TP_FIELDS #define TP_FIELDS(args...) args /* Only one used in this phase */ -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ static const struct lttng_event_field __event_fields___##_name[] = { \ _fields \ }; -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ + TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) /* * Stage 2 of the trace events. @@ -164,17 +179,21 @@ * Create probe callback prototypes. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include #undef TP_PROTO #define TP_PROTO(args...) args #undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ static void __event_probe__##_name(void *__data, _proto); -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ +static void __event_probe__##_name(void *__data); + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) /* * Stage 3 of the trace events. @@ -184,23 +203,27 @@ static void __event_probe__##_name(void *__data, _proto); /* Named field types must be defined in lttng-types.h */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include -#undef TRACEPOINT_EVENT_INSTANCE -#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) \ +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \ { \ .fields = __event_fields___##_template, \ .name = #_name, \ .probe_callback = (void *) &__event_probe__##_template,\ - .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ + .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_template), \ }, +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) \ + TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) + #define TP_ID1(_token, _system) _token##_system #define TP_ID(_token, _system) TP_ID1(_token, _system) -static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = { -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +static const struct lttng_event_desc TP_ID(__event_desc___, TRACEPOINT_SYSTEM)[] = { +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) }; #undef TP_ID1 @@ -217,9 +240,9 @@ static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = { #define TP_ID(_token, _system) TP_ID1(_token, _system) /* non-const because list head will be modified when registered. */ -static struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { - .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), - .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), +static struct lttng_probe_desc TP_ID(__probe_desc___, TRACEPOINT_SYSTEM) = { + .event_desc = TP_ID(__event_desc___, TRACEPOINT_SYSTEM), + .nr_events = _TP_ARRAY_SIZE(TP_ID(__event_desc___, TRACEPOINT_SYSTEM)), }; #undef TP_ID1 @@ -231,8 +254,8 @@ static struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { * Create static inline function that calculates event size. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include /* Named field types must be defined in lttng-types.h */ @@ -284,7 +307,20 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ return __event_len; \ } -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ +static inline size_t __event_get_size__##_name(size_t *__dynamic_len) \ +{ \ + size_t __event_len = 0; \ + unsigned int __dynamic_len_idx = 0; \ + \ + if (0) \ + (void) __dynamic_len_idx; /* don't warn if unused */ \ + _fields \ + return __event_len; \ +} + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) /* * Stage 6 of the trace events. @@ -292,8 +328,8 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ * Create static inline function that calculates event payload alignment. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include /* Named field types must be defined in lttng-types.h */ @@ -333,7 +369,16 @@ static inline size_t __event_get_align__##_name(_proto) \ return __event_align; \ } -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ +static inline size_t __event_get_align__##_name(void) \ +{ \ + size_t __event_align = 1; \ + _fields \ + return __event_align; \ +} + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) /* @@ -347,8 +392,8 @@ static inline size_t __event_get_align__##_name(_proto) \ * execution order, jumping to the appropriate assignment block. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include #undef ctf_integer_ext #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ @@ -409,16 +454,16 @@ static void __event_probe__##_name(void *__data, _proto) \ struct lib_ring_buffer_ctx ctx; \ size_t __event_len, __event_align; \ size_t __dynamic_len_idx = 0; \ - size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \ + size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_name)]; \ int __ret; \ \ if (0) \ (void) __dynamic_len_idx; /* don't warn if unused */ \ - if (unlikely(!ACCESS_ONCE(__chan->session->active))) \ + if (unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ return; \ - if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ + if (unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ return; \ - if (unlikely(!ACCESS_ONCE(__event->enabled))) \ + if (unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ return; \ __event_len = __event_get_size__##_name(__dynamic_len, _args); \ __event_align = __event_get_align__##_name(_args); \ @@ -431,7 +476,38 @@ static void __event_probe__##_name(void *__data, _proto) \ __chan->ops->event_commit(&ctx); \ } -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ +static void __event_probe__##_name(void *__data) \ +{ \ + struct ltt_event *__event = __data; \ + struct ltt_channel *__chan = __event->chan; \ + struct lib_ring_buffer_ctx ctx; \ + size_t __event_len, __event_align; \ + size_t __dynamic_len_idx = 0; \ + size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_name)]; \ + int __ret; \ + \ + if (0) \ + (void) __dynamic_len_idx; /* don't warn if unused */ \ + if (unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ + return; \ + if (unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ + return; \ + if (unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ + return; \ + __event_len = __event_get_size__##_name(__dynamic_len); \ + __event_align = __event_get_align__##_name(); \ + lib_ring_buffer_ctx_init(&ctx, __chan->chan, __event, __event_len, \ + __event_align, -1); \ + __ret = __chan->ops->event_reserve(&ctx, __event->id); \ + if (__ret < 0) \ + return; \ + _fields \ + __chan->ops->event_commit(&ctx); \ +} + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) /* * Stage 8 of the trace events. @@ -439,25 +515,25 @@ static void __event_probe__##_name(void *__data, _proto) \ * Register/unregister probes at module load/unload. */ -/* Reset all macros within TRACE_EVENT */ -#include "lttng-tracepoint-events-reset.h" +/* Reset all macros within TRACEPOINT_EVENT */ +#include #define TP_ID1(_token, _system) _token##_system #define TP_ID(_token, _system) TP_ID1(_token, _system) static void __attribute__((constructor)) -TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) +TP_ID(__lttng_events_init__, TRACEPOINT_SYSTEM)(void) { int ret; - ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); + ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); assert(!ret); } static void __attribute__((destructor)) -TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) +TP_ID(__lttng_events_exit__, TRACEPOINT_SYSTEM)(void) { - ltt_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); + ltt_probe_unregister(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); } #undef TP_ID1 diff --git a/libringbuffer/config.h b/include/ust/ringbuffer-config.h similarity index 99% rename from libringbuffer/config.h rename to include/ust/ringbuffer-config.h index 900208f..8050320 100644 --- a/libringbuffer/config.h +++ b/include/ust/ringbuffer-config.h @@ -293,6 +293,6 @@ int lib_ring_buffer_check_config(const struct lib_ring_buffer_config *config, return 0; } -#include "vatomic.h" +#include #endif /* _LINUX_RING_BUFFER_CONFIG_H */ diff --git a/include/ust/tracepoint-event.h b/include/ust/tracepoint-event.h index d1d5069..2d31f64 100644 --- a/include/ust/tracepoint-event.h +++ b/include/ust/tracepoint-event.h @@ -21,16 +21,18 @@ * in their file should include this file. The following are macros that the * trace file may define: * - * TRACE_SYSTEM defines the system the tracepoint is for + * TRACEPOINT_SYSTEM defines the system the tracepoint is for: + * < [com_company_]project_[component_] > * - * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h - * This macro may be defined to tell define_trace.h what file to include. - * Note, leave off the ".h". + * TRACEPOINT_INCLUDE_FILE if the file name is something other than + * TRACEPOINT_SYSTEM.h. This macro may be defined to tell + * define_trace.h what file to include. Note, leave off the ".h". * - * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace - * then this macro can define the path to use. Note, the path is relative to - * tracepoint_event.h, not the file including it. Full path names for out of tree - * modules must be used. + * TRACEPOINT_INCLUDE_PATH if the path is something other than core + * kernel include/trace then this macro can define the path to use. + * Note, the path is relative to tracepoint_event.h, not the file + * including it. Full path names for out of tree modules must be + * used. */ #ifdef TRACEPOINT_CREATE_PROBES @@ -59,27 +61,28 @@ #define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ _DEFINE_TRACEPOINT(name) -#undef TRACE_INCLUDE -#undef __TRACE_INCLUDE +#undef TRACEPOINT_INCLUDE +#undef __TRACEPOINT_INCLUDE -#ifndef TRACE_INCLUDE_FILE -# define TRACE_INCLUDE_FILE TRACE_SYSTEM -# define UNDEF_TRACE_INCLUDE_FILE +#ifndef TRACEPOINT_INCLUDE_FILE +# define TRACEPOINT_INCLUDE_FILE TRACEPOINT_SYSTEM +# define UNDEF_TRACEPOINT_INCLUDE_FILE #endif -#ifndef TRACE_INCLUDE_PATH -# define __TRACE_INCLUDE(system) -# define UNDEF_TRACE_INCLUDE_PATH +#ifndef TRACEPOINT_INCLUDE_PATH +# define __TRACEPOINT_INCLUDE(system) +# define UNDEF_TRACEPOINT_INCLUDE_PATH #else -# define __TRACE_INCLUDE(system) __tp_stringify(TRACE_INCLUDE_PATH/system.h) +# define __TRACEPOINT_INCLUDE(system) \ + __tp_stringify(TRACEPOINT_INCLUDE_PATH/system.h) #endif -# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system) +# define TRACEPOINT_INCLUDE(system) __TRACEPOINT_INCLUDE(system) /* Let the trace headers be reread */ -#define TRACE_HEADER_MULTI_READ +#define TRACEPOINT_HEADER_MULTI_READ -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) #ifndef CONFIG_NO_EVENT_TRACING #include @@ -91,17 +94,17 @@ #undef TRACEPOINT_EVENT_NOARGS #undef TRACEPOINT_EVENT_CLASS_NOARGS #undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#undef TRACE_HEADER_MULTI_READ +#undef TRACEPOINT_HEADER_MULTI_READ /* Only undef what we defined in this file */ -#ifdef UNDEF_TRACE_INCLUDE_FILE -# undef TRACE_INCLUDE_FILE -# undef UNDEF_TRACE_INCLUDE_FILE +#ifdef UNDEF_TRACEPOINT_INCLUDE_FILE +# undef TRACEPOINT_INCLUDE_FILE +# undef UNDEF_TRACEPOINT_INCLUDE_FILE #endif -#ifdef UNDEF_TRACE_INCLUDE_PATH -# undef TRACE_INCLUDE_PATH -# undef UNDEF_TRACE_INCLUDE_PATH +#ifdef UNDEF_TRACEPOINT_INCLUDE_PATH +# undef TRACEPOINT_INCLUDE_PATH +# undef UNDEF_TRACEPOINT_INCLUDE_PATH #endif /* We may be processing more files */ diff --git a/libringbuffer/vatomic.h b/include/ust/vatomic.h similarity index 100% rename from libringbuffer/vatomic.h rename to include/ust/vatomic.h diff --git a/libringbuffer/backend_internal.h b/libringbuffer/backend_internal.h index 182ac97..061924f 100644 --- a/libringbuffer/backend_internal.h +++ b/libringbuffer/backend_internal.h @@ -14,7 +14,7 @@ #include #include -#include "config.h" +#include #include "backend_types.h" #include "frontend_types.h" #include "shm.h" diff --git a/libringbuffer/frontend_internal.h b/libringbuffer/frontend_internal.h index 6a1d3a6..7c28788 100644 --- a/libringbuffer/frontend_internal.h +++ b/libringbuffer/frontend_internal.h @@ -18,7 +18,7 @@ #include -#include "config.h" +#include #include "backend_types.h" #include "frontend_types.h" #include "shm.h" diff --git a/libringbuffer/frontend_types.h b/libringbuffer/frontend_types.h index b50b284..59611f2 100644 --- a/libringbuffer/frontend_types.h +++ b/libringbuffer/frontend_types.h @@ -24,7 +24,7 @@ #include "ust/core.h" #include "usterr_signal_safe.h" -#include "config.h" +#include #include "backend_types.h" #include "shm.h" diff --git a/libringbuffer/ring_buffer_backend.c b/libringbuffer/ring_buffer_backend.c index 797beb3..3a5e6a9 100644 --- a/libringbuffer/ring_buffer_backend.c +++ b/libringbuffer/ring_buffer_backend.c @@ -10,7 +10,7 @@ #include "ust/core.h" -#include "config.h" +#include #include "backend.h" #include "frontend.h" #include "smp.h" diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index b45ec54..b87e554 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -46,7 +46,7 @@ #include #include "smp.h" -#include "config.h" +#include #include "backend.h" #include "frontend.h" #include "shm.h" @@ -381,7 +381,7 @@ static void channel_unregister_notifiers(struct channel *chan) lib_ring_buffer_stop_switch_timer(buf); lib_ring_buffer_stop_read_timer(buf); } - channel_backend_unregister_notifiers(&chan->backend); + //channel_backend_unregister_notifiers(&chan->backend); } static void channel_free(struct shm_handle *handle) @@ -418,8 +418,6 @@ static void channel_free(struct shm_handle *handle) * padding to let readers get those sub-buffers. * Used for live streaming. * @read_timer_interval: Time interval (in us) to wake up pending readers. - * @shmfd: shared memory file descriptor (output, needs to be closed by - * the caller) * * Holds cpu hotplug. * Returns NULL on failure. diff --git a/libust-initializer.c b/libust-initializer.c index efe707e..d7eedf0 100644 --- a/libust-initializer.c +++ b/libust-initializer.c @@ -8,9 +8,8 @@ * published by the Free Software Foundation. */ -#include +//DISABLED #include #include -UST_MARKER_LIB; +//DISABLED UST_MARKER_LIB; TRACEPOINT_LIB; -TRACEPOINT_EVENT_LIB; diff --git a/libust/Makefile.am b/libust/Makefile.am index 7e5a0df..957565d 100644 --- a/libust/Makefile.am +++ b/libust/Makefile.am @@ -5,7 +5,6 @@ lib_LTLIBRARIES = libust.la libust_la_SOURCES = \ tracepoint.c \ - trace_event.c \ ltt-tracer.h \ ltt-tracer-core.h \ ltt-ring-buffer-client.h \ @@ -14,7 +13,10 @@ libust_la_SOURCES = \ ltt-ring-buffer-metadata-client.h \ ltt-ring-buffer-metadata-client.c \ ltt-events.c \ - lttng-ust-abi.c + ltt-context.c \ + ltt-probes.c \ + lttng-ust-abi.c \ + lttng-ust-comm.c #removed: buffers.c buffers.h @@ -23,6 +25,8 @@ libust_la_LDFLAGS = -no-undefined -version-info 0:0:0 libust_la_LIBADD = \ -lpthread \ -lrt \ - $(top_builddir)/snprintf/libustsnprintf.la + -luuid \ + $(top_builddir)/snprintf/libustsnprintf.la \ + $(top_builddir)/libringbuffer/libringbuffer.la libust_la_CFLAGS = -DUST_COMPONENT="libust" -fno-strict-aliasing diff --git a/libust/ltt-context.c b/libust/ltt-context.c index dd52654..fc0eb7e 100644 --- a/libust/ltt-context.c +++ b/libust/ltt-context.c @@ -8,13 +8,10 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include -#include -#include -#include #include -#include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ -#include "ltt-tracer.h" +#include +#include +#include /* * Note: as we append context information, the pointer location may change. @@ -25,7 +22,7 @@ struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p) struct lttng_ctx *ctx; if (!*ctx_p) { - *ctx_p = kzalloc(sizeof(struct lttng_ctx), GFP_KERNEL); + *ctx_p = zmalloc(sizeof(struct lttng_ctx)); if (!*ctx_p) return NULL; } @@ -34,19 +31,18 @@ struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p) struct lttng_ctx_field *new_fields; ctx->allocated_fields = max_t(size_t, 1, 2 * ctx->allocated_fields); - new_fields = kzalloc(ctx->allocated_fields * sizeof(struct lttng_ctx_field), GFP_KERNEL); + new_fields = zmalloc(ctx->allocated_fields * sizeof(struct lttng_ctx_field)); if (!new_fields) return NULL; if (ctx->fields) memcpy(new_fields, ctx->fields, sizeof(*ctx->fields) * ctx->nr_fields); - kfree(ctx->fields); + free(ctx->fields); ctx->fields = new_fields; } field = &ctx->fields[ctx->nr_fields]; ctx->nr_fields++; return field; } -EXPORT_SYMBOL_GPL(lttng_append_context); /* * Remove last context field. @@ -61,7 +57,6 @@ void lttng_remove_context_field(struct lttng_ctx **ctx_p, WARN_ON_ONCE(&ctx->fields[ctx->nr_fields] != field); memset(&ctx->fields[ctx->nr_fields], 0, sizeof(struct lttng_ctx_field)); } -EXPORT_SYMBOL_GPL(lttng_remove_context_field); void lttng_destroy_context(struct lttng_ctx *ctx) { @@ -73,6 +68,6 @@ void lttng_destroy_context(struct lttng_ctx *ctx) if (ctx->fields[i].destroy) ctx->fields[i].destroy(&ctx->fields[i]); } - kfree(ctx->fields); - kfree(ctx); + free(ctx->fields); + free(ctx); } diff --git a/libust/ltt-events.c b/libust/ltt-events.c index f048e27..e4ffc69 100644 --- a/libust/ltt-events.c +++ b/libust/ltt-events.c @@ -25,6 +25,7 @@ #include "ust/core.h" #include "ltt-tracer.h" #include "ust/wait.h" +#include "../libringbuffer/shm.h" static CDS_LIST_HEAD(sessions); static CDS_LIST_HEAD(ltt_transport_list); @@ -215,15 +216,15 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, goto nomem; chan->session = session; chan->id = session->free_chan_id++; - //chan->shmid = shmget(getpid(), shmlen, IPC_CREAT | IPC_EXCL | 0700); /* * Note: the channel creation op already writes into the packet * headers. Therefore the "chan" information used as input * should be already accessible. */ - chan->chan = transport->ops.channel_create("[lttng]", chan, buf_addr, + chan->handle = transport->ops.channel_create("[lttng]", chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, - read_timer_interval, shmid); + read_timer_interval); + chan->chan = shmp(chan->handle->header->chan); if (!chan->chan) goto create_error; chan->enabled = 1; @@ -247,7 +248,7 @@ active: static void _ltt_channel_destroy(struct ltt_channel *chan) { - chan->ops->channel_destroy(chan->chan); + chan->ops->channel_destroy(chan->handle); cds_list_del(&chan->list); lttng_destroy_context(chan->ctx); free(chan); diff --git a/libust/ltt-probes.c b/libust/ltt-probes.c index 789d8bd..5b3a0cb 100644 --- a/libust/ltt-probes.c +++ b/libust/ltt-probes.c @@ -8,13 +8,13 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include -#include -#include -#include +#include +#include +#include +#include #include -static LIST_HEAD(probe_list); +static CDS_LIST_HEAD(probe_list); static DEFINE_MUTEX(probe_mutex); static @@ -23,7 +23,7 @@ const struct lttng_event_desc *find_event(const char *name) struct lttng_probe_desc *probe_desc; int i; - list_for_each_entry(probe_desc, &probe_list, head) { + cds_list_for_each_entry(probe_desc, &probe_list, head) { for (i = 0; i < probe_desc->nr_events; i++) { if (!strcmp(probe_desc->event_desc[i].name, name)) return &probe_desc->event_desc[i]; @@ -37,7 +37,7 @@ int ltt_probe_register(struct lttng_probe_desc *desc) int ret = 0; int i; - mutex_lock(&probe_mutex); + pthread_mutex_lock(&probe_mutex); /* * TODO: This is O(N^2). Turn into a hash table when probe registration * overhead becomes an issue. @@ -48,51 +48,44 @@ int ltt_probe_register(struct lttng_probe_desc *desc) goto end; } } - list_add(&desc->head, &probe_list); + cds_list_add(&desc->head, &probe_list); end: - mutex_unlock(&probe_mutex); + pthread_mutex_unlock(&probe_mutex); return ret; } -EXPORT_SYMBOL_GPL(ltt_probe_register); void ltt_probe_unregister(struct lttng_probe_desc *desc) { - mutex_lock(&probe_mutex); - list_del(&desc->head); - mutex_unlock(&probe_mutex); + pthread_mutex_lock(&probe_mutex); + cds_list_del(&desc->head); + pthread_mutex_unlock(&probe_mutex); } -EXPORT_SYMBOL_GPL(ltt_probe_unregister); const struct lttng_event_desc *ltt_event_get(const char *name) { const struct lttng_event_desc *event; - int ret; - mutex_lock(&probe_mutex); + pthread_mutex_lock(&probe_mutex); event = find_event(name); - mutex_unlock(&probe_mutex); + pthread_mutex_unlock(&probe_mutex); if (!event) return NULL; - ret = try_module_get(event->owner); - WARN_ON_ONCE(!ret); return event; } -EXPORT_SYMBOL_GPL(ltt_event_get); void ltt_event_put(const struct lttng_event_desc *event) { - module_put(event->owner); } -EXPORT_SYMBOL_GPL(ltt_event_put); +#if 0 static void *tp_list_start(struct seq_file *m, loff_t *pos) { struct lttng_probe_desc *probe_desc; int iter = 0, i; - mutex_lock(&probe_mutex); - list_for_each_entry(probe_desc, &probe_list, head) { + pthread_mutex_lock(&probe_mutex); + cds_list_for_each_entry(probe_desc, &probe_list, head) { for (i = 0; i < probe_desc->nr_events; i++) { if (iter++ >= *pos) return (void *) &probe_desc->event_desc[i]; @@ -109,7 +102,7 @@ void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos) int iter = 0, i; (*ppos)++; - list_for_each_entry(probe_desc, &probe_list, head) { + cds_list_for_each_entry(probe_desc, &probe_list, head) { for (i = 0; i < probe_desc->nr_events; i++) { if (iter++ >= *ppos) return (void *) &probe_desc->event_desc[i]; @@ -122,7 +115,7 @@ void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos) static void tp_list_stop(struct seq_file *m, void *p) { - mutex_unlock(&probe_mutex); + pthread_mutex_unlock(&probe_mutex); } static @@ -160,3 +153,4 @@ const struct file_operations lttng_tracepoint_list_fops = { .llseek = seq_lseek, .release = seq_release, }; +#endif //0 diff --git a/libust/ltt-ring-buffer-client.h b/libust/ltt-ring-buffer-client.h index 4a9318c..2a187c7 100644 --- a/libust/ltt-ring-buffer-client.h +++ b/libust/ltt-ring-buffer-client.h @@ -368,22 +368,21 @@ static const struct lib_ring_buffer_config client_config = { }; static -struct channel *_channel_create(const char *name, +struct shm_handle *_channel_create(const char *name, struct ltt_channel *ltt_chan, void *buf_addr, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shmid) + unsigned int read_timer_interval) { return channel_create(&client_config, name, ltt_chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, - read_timer_interval, shmid); + read_timer_interval); } static -void ltt_channel_destroy(struct channel *chan) +void ltt_channel_destroy(struct shm_handle *handle) { - channel_destroy(chan); + channel_destroy(handle); } static diff --git a/libust/ltt-ring-buffer-metadata-client.h b/libust/ltt-ring-buffer-metadata-client.h index 52479b4..be9e4fb 100644 --- a/libust/ltt-ring-buffer-metadata-client.h +++ b/libust/ltt-ring-buffer-metadata-client.h @@ -149,22 +149,21 @@ static const struct lib_ring_buffer_config client_config = { }; static -struct channel *_channel_create(const char *name, +struct shm_handle *_channel_create(const char *name, struct ltt_channel *ltt_chan, void *buf_addr, size_t subbuf_size, size_t num_subbuf, unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shmid) + unsigned int read_timer_interval) { return channel_create(&client_config, name, ltt_chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, - read_timer_interval, shmid); + read_timer_interval); } static -void ltt_channel_destroy(struct channel *chan) +void ltt_channel_destroy(struct shm_handle *handle) { - channel_destroy(chan); + channel_destroy(handle); } static diff --git a/libust/ltt-tracer-core.h b/libust/ltt-tracer-core.h index 36d46b9..abab173 100644 --- a/libust/ltt-tracer-core.h +++ b/libust/ltt-tracer-core.h @@ -32,7 +32,7 @@ #include "usterr_signal_safe.h" #include "ust/bug.h" -#include "../libringbuffer/config.h" +#include struct ltt_session; struct ltt_channel; diff --git a/libust/trace_event.c b/libust/trace_event.c deleted file mode 100644 index 854a767..0000000 --- a/libust/trace_event.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2010 Nils Carlson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#define _LGPL_SOURCE -#include -#include -#include -#include -#include -#include - -#include "usterr_signal_safe.h" - -/* libraries that contain trace_events (struct trace_event_lib) */ -static CDS_LIST_HEAD(libs); -/* - * Nested mutex is not required here, but provide the same guaranteed - * for start/stop iteration vs nested ops as markers and tracepoints. - */ -static __thread int nested_mutex; -static DEFINE_MUTEX(trace_events_mutex); - -static -int trace_event_get_iter_range(struct trace_event * const **trace_event, - struct trace_event * const *begin, - struct trace_event * const *end); - -static -void lock_trace_events(void) -{ - if (!(nested_mutex++)) - pthread_mutex_lock(&trace_events_mutex); -} - -static -void unlock_trace_events(void) -{ - if (!(--nested_mutex)) - pthread_mutex_unlock(&trace_events_mutex); -} - -static -int lib_get_iter_trace_events(struct trace_event_iter *iter) -{ - struct trace_event_lib *iter_lib; - int found = 0; - - cds_list_for_each_entry(iter_lib, &libs, list) { - if (iter_lib < iter->lib) - continue; - else if (iter_lib > iter->lib) - iter->trace_event = NULL; - found = trace_event_get_iter_range(&iter->trace_event, - iter_lib->trace_events_start, - iter_lib->trace_events_start + iter_lib->trace_events_count); - if (found) { - iter->lib = iter_lib; - break; - } - } - return found; -} - -/** - * trace_event_get_iter_range - Get a next trace_event iterator given a range. - * @trace_event: current trace_events (in), next trace_event (out) - * @begin: beginning of the range - * @end: end of the range - * - * 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. - * Called with trace event mutex held. - */ -static -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; - while (*trace_event >= begin && *trace_event < end) { - if (!**trace_event) - (*trace_event)++; /* skip dummy */ - else - return 1; - } - return 0; -} - -static void trace_event_get_iter(struct trace_event_iter *iter) -{ - int found = 0; - - found = lib_get_iter_trace_events(iter); - - if (!found) - trace_event_iter_reset(iter); -} - -void trace_event_iter_start(struct trace_event_iter *iter) -{ - lock_trace_events(); - trace_event_get_iter(iter); -} - -/* - * Called with trace event mutex held. - */ -void trace_event_iter_next(struct trace_event_iter *iter) -{ - iter->trace_event++; - /* - * iter->trace_event may be invalid because we blindly incremented it. - * Make sure it is valid by marshalling on the trace_events, getting the - * trace_events from following modules if necessary. - */ - trace_event_get_iter(iter); -} - -void trace_event_iter_stop(struct trace_event_iter *iter) -{ - unlock_trace_events(); -} - -void trace_event_iter_reset(struct trace_event_iter *iter) -{ - iter->lib = NULL; - iter->trace_event = NULL; -} - -int trace_event_register_lib(struct trace_event * const *trace_events_start, - int trace_events_count) -{ - struct trace_event_lib *pl, *iter; - - pl = (struct trace_event_lib *) malloc(sizeof(struct trace_event_lib)); - - pl->trace_events_start = trace_events_start; - pl->trace_events_count = trace_events_count; - - lock_trace_events(); - /* - * We sort the libs by struct lib pointer address. - */ - cds_list_for_each_entry_reverse(iter, &libs, list) { - BUG_ON(iter == pl); /* Should never be in the list twice */ - if (iter < pl) { - /* We belong to the location right after iter. */ - cds_list_add(&pl->list, &iter->list); - goto lib_added; - } - } - /* We should be added at the head of the list */ - cds_list_add(&pl->list, &libs); -lib_added: - unlock_trace_events(); - - /* trace_events_count - 1: skip dummy */ - DBG("just registered a trace_events section from %p and having %d trace_events (minus dummy trace_event)", trace_events_start, trace_events_count); - - return 0; -} - -int trace_event_unregister_lib(struct trace_event * const *trace_events_start) -{ - struct trace_event_lib *lib; - - unlock_trace_events(); - cds_list_for_each_entry(lib, &libs, list) { - if(lib->trace_events_start == trace_events_start) { - struct trace_event_lib *lib2free = lib; - cds_list_del(&lib->list); - free(lib2free); - break; - } - } - unlock_trace_events(); - - return 0; -} diff --git a/tests/Makefile.am b/tests/Makefile.am index 8311980..4ab0b21 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,5 @@ -SUBDIRS = . hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests exit-fast +SUBDIRS = . hello +#SUBDIRS = . hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event register_test tracepoint libustctl_function_tests exit-fast dist_noinst_SCRIPTS = test_loop runtests trace_matches diff --git a/tests/hello/Makefile.am b/tests/hello/Makefile.am index bf7b471..e26d949 100644 --- a/tests/hello/Makefile.am +++ b/tests/hello/Makefile.am @@ -3,7 +3,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libust noinst_PROGRAMS = hello hello_SOURCES = hello.c tp.c tp.h hello_LDADD = $(top_builddir)/libust/libust.la \ - $(top_builddir)/libustctl/libustctl.la \ $(top_builddir)/libust-initializer.o noinst_SCRIPTS = run diff --git a/tests/hello/hello.c b/tests/hello/hello.c index bb44773..d30901a 100644 --- a/tests/hello/hello.c +++ b/tests/hello/hello.c @@ -4,8 +4,8 @@ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * License as published by the Free Software Foundation; version 2.1 of + * the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,15 +26,13 @@ #include #include -#include -#include #include "usterr.h" #include "tp.h" void inthandler(int sig) { - printf("in handler\n"); - exit(0); + printf("in SIGUSR1 handler\n"); + tracepoint(ust_tests_hello_tptest_sighandler); } int init_int_handler(void) @@ -54,7 +52,7 @@ int init_int_handler(void) /* Only defer ourselves. Also, try to restart interrupted * syscalls to disturb the traced program as little as possible. */ - result = sigaction(SIGINT, &act, NULL); + result = sigaction(SIGUSR1, &act, NULL); if (result == -1) { PERROR("sigaction"); return -1; @@ -63,7 +61,7 @@ int init_int_handler(void) return 0; } -int main() +int main(int argc, char **argv) { int i; @@ -72,22 +70,10 @@ int main() printf("Hello, World!\n"); sleep(1); + 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); + tracepoint(ust_tests_hello_tptest, i); usleep(100000); } - - if (scanf("%*s") == EOF) - PERROR("scanf failed"); - - ustctl_stop_trace(getpid(), "auto"); - ustctl_destroy_trace(getpid(), "auto"); - - DBG("TRACE STOPPED"); - if (scanf("%*s") == EOF) - PERROR("scanf failed"); - return 0; } diff --git a/tests/hello/tp.c b/tests/hello/tp.c index dfe06dd..a9ea5dc 100644 --- a/tests/hello/tp.c +++ b/tests/hello/tp.c @@ -1,11 +1,12 @@ /* - * Copyright (C) 2009 Pierre-Marc Fournier - * Copyright (C) 2011 Mathieu Desnoyers + * tp.c + * + * Copyright (c) 2011 Mathieu Desnoyers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * License as published by the Free Software Foundation; version 2.1 of + * the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,42 +15,8 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include "usterr.h" - #define TRACEPOINT_CREATE_PROBES #include "tp.h" - -struct hello_trace_struct { - char *message; -}; - -struct hello_trace_struct hello_struct = { - .message = "ehlo\n", -}; - -void tptest_probe(void *data, int anint) -{ - struct hello_trace_struct *hello; - hello = (struct hello_trace_struct *)data; - DBG("in tracepoint probe..."); - printf("this is the message: %s\n", hello->message); -} - -void tptest2_probe(void *data) -{ -} - -static void __attribute__((constructor)) init() -{ - DBG("connecting tracepoint...\n"); - /* - * Note: this is an internal API that will be used within - * TRACEPOINT_EVENT only eventually. - */ - __register_tracepoint(hello_tptest, tptest_probe, &hello_struct); - __register_tracepoint(hello_tptest2, tptest2_probe, &hello_struct); -} diff --git a/tests/hello/tp.h b/tests/hello/tp.h index e363971..606f0f1 100644 --- a/tests/hello/tp.h +++ b/tests/hello/tp.h @@ -1,8 +1,8 @@ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM tp +#undef TRACEPOINT_SYSTEM +#define TRACEPOINT_SYSTEM tp -#if !defined(_TRACE_TP_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_TP_H +#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_TP_H /* * Copyright (C) 2011 Mathieu Desnoyers @@ -24,20 +24,20 @@ #include -TRACEPOINT_EVENT(hello_tptest, +TRACEPOINT_EVENT(ust_tests_hello_tptest, TP_PROTO(int anint), TP_ARGS(anint), - TP_FIELDS()); + TP_FIELDS()) -TRACEPOINT_EVENT_NOARGS(hello_tptest2, - TP_FIELDS()); +TRACEPOINT_EVENT_NOARGS(ust_tests_hello_tptest_sighandler, + TP_FIELDS()) -#endif /* _TRACE_TP_H */ +#endif /* _TRACEPOINT_TP_H */ -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE tp +#undef TRACEPOINT_INCLUDE_PATH +#define TRACEPOINT_INCLUDE_PATH . +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE tp /* This part must be outside protection */ -#include +#include -- 2.34.1