From 1dbfff0c0126804b07e9c11ba2307f65a95a650b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 10 Aug 2011 11:13:06 -0400 Subject: [PATCH] Build TRACEPOINT_EVENT integer type Signed-off-by: Mathieu Desnoyers --- include/Makefile.am | 11 +++-- include/ust/lttng-events.h | 12 +++--- include/ust/lttng-tracepoint-event.h | 41 +++++++++++-------- include/{ => ust}/share.h | 0 .../usterr-signal-safe.h} | 11 +++-- libringbuffer/frontend_types.h | 2 +- libringbuffer/shm.h | 2 +- libust/buffers.c | 2 +- libust/ltt-context.c | 2 +- libust/ltt-events.c | 14 +++---- libust/ltt-ring-buffer-client.h | 26 ++++++------ libust/ltt-tracer-core.h | 10 ++--- libust/ltt-tracer.h | 14 ------- libust/lttng-ust-abi.c | 2 +- libust/tracepoint.c | 2 +- libust/ust-core.c | 2 +- tests/hello/tp.h | 8 ++-- 17 files changed, 77 insertions(+), 84 deletions(-) rename include/{ => ust}/share.h (100%) rename include/{usterr_signal_safe.h => ust/usterr-signal-safe.h} (96%) diff --git a/include/Makefile.am b/include/Makefile.am index 93853642..856be021 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -7,16 +7,19 @@ nobase_include_HEADERS = \ ust/lttng-events.h \ ust/version.h \ ust/lttng-ust-abi.h \ - ust/ringbuffer-abi.h + ust/ringbuffer-abi.h \ + ust/lttng-tracer.h \ + ust/usterr-signal-safe.h \ + ust/core.h \ + ust/share.h + +# note: usterr-signal-safe.h, core.h and share.h need namespace cleanup. noinst_HEADERS = \ - share.h \ usterr.h \ ust_snprintf.h \ - usterr_signal_safe.h \ ust/compat.h \ ust/config.h \ - ust/core.h \ ust/marker-internal.h \ ust/tracepoint-internal.h \ ust/clock.h \ diff --git a/include/ust/lttng-events.h b/include/ust/lttng-events.h index 5ca156b7..b15182c8 100644 --- a/include/ust/lttng-events.h +++ b/include/ust/lttng-events.h @@ -15,12 +15,10 @@ #include #include #include +#include #include #include -#undef is_signed_type -#define is_signed_type(type) (((type)(-1)) < 0) - struct ltt_channel; struct ltt_session; struct lib_ring_buffer_ctx; @@ -57,8 +55,8 @@ struct lttng_enum_entry { .u.basic.integer = \ { \ .size = sizeof(_type) * CHAR_BIT, \ - .alignment = ltt_alignof(_type) * CHAR_BIT, \ - .signedness = is_signed_type(_type), \ + .alignment = lttng_alignof(_type) * CHAR_BIT, \ + .signedness = lttng_is_signed_type(_type), \ .reverse_byte_order = _byte_order != __BYTE_ORDER, \ .base = _base, \ .encoding = lttng_encode_##_encoding, \ @@ -88,8 +86,8 @@ struct lttng_integer_type { .exp_dig = sizeof(_type) * CHAR_BIT \ - _float_mant_dig(_type), \ .mant_dig = _float_mant_dig(_type), \ - .alignment = ltt_alignof(_type) * CHAR_BIT, \ - .signedness = is_signed_type(_type), \ + .alignment = lttng_alignof(_type) * CHAR_BIT, \ + .signedness = lttng_is_signed_type(_type), \ .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \ }, \ } \ diff --git a/include/ust/lttng-tracepoint-event.h b/include/ust/lttng-tracepoint-event.h index c006ffd3..70d7c653 100644 --- a/include/ust/lttng-tracepoint-event.h +++ b/include/ust/lttng-tracepoint-event.h @@ -20,6 +20,7 @@ #include #include #include +#include #include /* @@ -90,6 +91,14 @@ /* Helpers */ #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define _tp_max_t(type, x, y) \ + ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1: __max2; \ + }) + + /* * Stage 1 of the trace events. * @@ -169,7 +178,7 @@ #undef TRACEPOINT_EVENT_CLASS #define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ - TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) + TRACEPOINT_EVENT_CLASS_NOARGS(_name, TP_PARAMS(_fields)) #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) @@ -261,25 +270,25 @@ static struct lttng_probe_desc TP_ID(__probe_desc___, TRACEPOINT_SYSTEM) = { #undef ctf_integer_ext #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type); #undef ctf_float #define ctf_float(_type, _item, _src) \ - __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type); #undef ctf_array_encoded #define ctf_array_encoded(_type, _item, _src, _length) \ - __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type) * (_length); #undef ctf_sequence_encoded #define ctf_sequence_encoded(_type, _item, _src, _length_type, \ _src_length, _encoding) \ - __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_length_type)); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \ __event_len += sizeof(_length_type); \ - __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __dynamic_len[__dynamic_len_idx] = (_length); \ __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ __dynamic_len_idx++; @@ -335,21 +344,21 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len) \ #undef ctf_integer_ext #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef ctf_float #define ctf_float(_type, _item, _src) \ - __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef ctf_array_encoded #define ctf_array_encoded(_type, _item, _src, _length) \ - __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef ctf_sequence_encoded #define ctf_sequence_encoded(_type, _item, _src, _length_type, \ _src_length, _encoding) \ - __event_align = max_t(size_t, __event_align, ltt_alignof(_length_type)); \ - __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \ + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef ctf_string #define ctf_string(_item, _src) @@ -399,7 +408,7 @@ static inline size_t __event_get_align__##_name(void) \ #define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ { \ _type __tmp = (_src); \ - lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__tmp)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(__tmp)); \ __chan->ops->event_write(&ctx, &__tmp, sizeof(__tmp)); \ } @@ -407,13 +416,13 @@ static inline size_t __event_get_align__##_name(void) \ #define ctf_float(_type, _item, _src) \ { \ _type __tmp = (_src); \ - lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__tmp)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(__tmp)); \ __chan->ops->event_write(&ctx, &__tmp, sizeof(__tmp)); \ } #undef ctf_array_encoded #define ctf_array_encoded(_type, _item, _src, _length) \ - lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_type)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_type)); \ __chan->ops->event_write(&ctx, _src, _length); #undef ctf_sequence_encoded @@ -421,10 +430,10 @@ static inline size_t __event_get_align__##_name(void) \ _src_length, _encoding) \ { \ _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ - lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_length_type)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_length_type)); \ __chan->ops->event_write(&ctx, &__tmpl, sizeof(_length_type)); \ } \ - lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_type)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_type)); \ __chan->ops->event_write(&ctx, _src, \ sizeof(_type) * __get_sequence_len(dest)); diff --git a/include/share.h b/include/ust/share.h similarity index 100% rename from include/share.h rename to include/ust/share.h diff --git a/include/usterr_signal_safe.h b/include/ust/usterr-signal-safe.h similarity index 96% rename from include/usterr_signal_safe.h rename to include/ust/usterr-signal-safe.h index 77f9d5fc..483e7f54 100644 --- a/include/usterr_signal_safe.h +++ b/include/ust/usterr-signal-safe.h @@ -29,7 +29,7 @@ #include -#include "share.h" +#include enum ust_loglevel { UST_LOGLEVEL_UNKNOWN = 0, @@ -51,8 +51,8 @@ static inline int ust_debug(void) #endif /* To stringify the expansion of a define */ -#define XSTR(d) STR(d) -#define STR(s) #s +#define UST_XSTR(d) UST_STR(d) +#define UST_STR(s) #s /* We sometimes print in the tracing path, and tracing can occur in * signal handlers, so we must use a print method which is signal safe. @@ -90,11 +90,11 @@ static inline void __attribute__ ((format (printf, 1, 2))) errno = ____saved_errno; \ } -#define UST_STR_COMPONENT XSTR(UST_COMPONENT) +#define UST_STR_COMPONENT UST_XSTR(UST_COMPONENT) #define ERRMSG(fmt, args...) \ do { \ - sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" XSTR(__LINE__) ")\n", \ + sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \ (long) getpid(), \ (long) syscall(SYS_gettid), \ ## args, __func__); \ @@ -155,5 +155,4 @@ static inline void __attribute__ ((format (printf, 1, 2))) } while(0) #define WARN_ON_ONCE(condition) WARN_ON(condition) - #endif /* _USTERR_SIGNAL_SAFE_H */ diff --git a/libringbuffer/frontend_types.h b/libringbuffer/frontend_types.h index 59611f2f..28179dfc 100644 --- a/libringbuffer/frontend_types.h +++ b/libringbuffer/frontend_types.h @@ -23,7 +23,7 @@ #include "ust/core.h" -#include "usterr_signal_safe.h" +#include #include #include "backend_types.h" #include "shm.h" diff --git a/libringbuffer/shm.h b/libringbuffer/shm.h index 4e9ced19..71624e39 100644 --- a/libringbuffer/shm.h +++ b/libringbuffer/shm.h @@ -10,8 +10,8 @@ */ #include +#include #include "ust/core.h" -#include "usterr_signal_safe.h" #define SHM_MAGIC 0x54335433 #define SHM_MAJOR 0 diff --git a/libust/buffers.c b/libust/buffers.c index c4eddb06..5e67d544 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -40,7 +40,7 @@ #include "channels.h" #include "tracer.h" #include "tracercore.h" -#include "usterr_signal_safe.h" +#include struct ltt_reserve_switch_offsets { long begin, end, old; diff --git a/libust/ltt-context.c b/libust/ltt-context.c index fc0eb7ef..83aa2975 100644 --- a/libust/ltt-context.c +++ b/libust/ltt-context.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include /* * Note: as we append context information, the pointer location may change. diff --git a/libust/ltt-events.c b/libust/ltt-events.c index e4ffc69a..ece959b3 100644 --- a/libust/ltt-events.c +++ b/libust/ltt-events.c @@ -21,7 +21,7 @@ #include #include #include -#include "usterr_signal_safe.h" +#include #include "ust/core.h" #include "ltt-tracer.h" #include "ust/wait.h" @@ -753,8 +753,8 @@ int _ltt_event_header_declare(struct ltt_session *session) " } extended;\n" " } v;\n" "} align(%u);\n\n", - ltt_alignof(uint32_t) * CHAR_BIT, - ltt_alignof(uint16_t) * CHAR_BIT + lttng_alignof(uint32_t) * CHAR_BIT, + lttng_alignof(uint16_t) * CHAR_BIT ); } @@ -805,10 +805,10 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) " uint32_t stream_id;\n" " };\n" "};\n\n", - ltt_alignof(uint8_t) * CHAR_BIT, - ltt_alignof(uint16_t) * CHAR_BIT, - ltt_alignof(uint32_t) * CHAR_BIT, - ltt_alignof(uint64_t) * CHAR_BIT, + lttng_alignof(uint8_t) * CHAR_BIT, + lttng_alignof(uint16_t) * CHAR_BIT, + lttng_alignof(uint32_t) * CHAR_BIT, + lttng_alignof(uint64_t) * CHAR_BIT, CTF_VERSION_MAJOR, CTF_VERSION_MINOR, uuid_s, diff --git a/libust/ltt-ring-buffer-client.h b/libust/ltt-ring-buffer-client.h index 2a187c71..dce34aa2 100644 --- a/libust/ltt-ring-buffer-client.h +++ b/libust/ltt-ring-buffer-client.h @@ -105,7 +105,7 @@ unsigned char record_header_size(const struct lib_ring_buffer_config *config, switch (ltt_chan->header_type) { case 1: /* compact */ - padding = lib_ring_buffer_align(offset, ltt_alignof(uint32_t)); + padding = lib_ring_buffer_align(offset, lttng_alignof(uint32_t)); offset += padding; if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTT_RFLAG_EXTENDED))) { offset += sizeof(uint32_t); /* id and timestamp */ @@ -113,24 +113,24 @@ unsigned char record_header_size(const struct lib_ring_buffer_config *config, /* Minimum space taken by 5-bit id */ offset += sizeof(uint8_t); /* Align extended struct on largest member */ - offset += lib_ring_buffer_align(offset, ltt_alignof(uint64_t)); + offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t)); offset += sizeof(uint32_t); /* id */ - offset += lib_ring_buffer_align(offset, ltt_alignof(uint64_t)); + offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t)); offset += sizeof(uint64_t); /* timestamp */ } break; case 2: /* large */ - padding = lib_ring_buffer_align(offset, ltt_alignof(uint16_t)); + padding = lib_ring_buffer_align(offset, lttng_alignof(uint16_t)); offset += padding; offset += sizeof(uint16_t); if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTT_RFLAG_EXTENDED))) { - offset += lib_ring_buffer_align(offset, ltt_alignof(uint32_t)); + offset += lib_ring_buffer_align(offset, lttng_alignof(uint32_t)); offset += sizeof(uint32_t); /* timestamp */ } else { /* Align extended struct on largest member */ - offset += lib_ring_buffer_align(offset, ltt_alignof(uint64_t)); + offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t)); offset += sizeof(uint32_t); /* id */ - offset += lib_ring_buffer_align(offset, ltt_alignof(uint64_t)); + offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t)); offset += sizeof(uint64_t); /* timestamp */ } break; @@ -188,7 +188,7 @@ void ltt_write_event_header(const struct lib_ring_buffer_config *config, uint16_t id = event_id; lib_ring_buffer_write(config, ctx, &id, sizeof(id)); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint32_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t)); lib_ring_buffer_write(config, ctx, ×tamp, sizeof(timestamp)); break; } @@ -228,9 +228,9 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config, bt_bitfield_write(&id, uint8_t, 0, 5, 31); lib_ring_buffer_write(config, ctx, &id, sizeof(id)); /* Align extended struct on largest member */ - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint64_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t)); lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id)); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint64_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t)); lib_ring_buffer_write(config, ctx, ×tamp, sizeof(timestamp)); } break; @@ -241,7 +241,7 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config, uint16_t id = event_id; lib_ring_buffer_write(config, ctx, &id, sizeof(id)); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint32_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t)); lib_ring_buffer_write(config, ctx, ×tamp, sizeof(timestamp)); } else { uint16_t id = 65535; @@ -249,9 +249,9 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config, lib_ring_buffer_write(config, ctx, &id, sizeof(id)); /* Align extended struct on largest member */ - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint64_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t)); lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id)); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(uint64_t)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t)); lib_ring_buffer_write(config, ctx, ×tamp, sizeof(timestamp)); } break; diff --git a/libust/ltt-tracer-core.h b/libust/ltt-tracer-core.h index abab1734..c7936827 100644 --- a/libust/ltt-tracer-core.h +++ b/libust/ltt-tracer-core.h @@ -23,15 +23,11 @@ #include #include +#include #include - -#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -/* Align data on its natural alignment */ -#define RING_BUFFER_ALIGN -#endif - -#include "usterr_signal_safe.h" +#include #include "ust/bug.h" + #include struct ltt_session; diff --git a/libust/ltt-tracer.h b/libust/ltt-tracer.h index a79c5f76..f7768393 100644 --- a/libust/ltt-tracer.h +++ b/libust/ltt-tracer.h @@ -30,24 +30,10 @@ #include #include "ltt-tracer-core.h" -#define LTTNG_UST_VERSION 0 -#define LTTNG_UST_PATCHLEVEL 9 -#define LTTNG_UST_SUBLEVEL 1 - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - /* Number of bytes to log with a read/write event */ #define LTT_LOG_RW_SIZE 32L #define LTT_MAX_SMALL_SIZE 0xFFFFU -#ifdef RING_BUFFER_ALIGN -#define ltt_alignof(type) __alignof__(type) -#else -#define ltt_alignof(type) 1 -#endif - /* Tracer properties */ #define CTF_MAGIC_NUMBER 0xC1FC1FC1 #define TSDL_MAGIC_NUMBER 0x75D11D57 diff --git a/libust/lttng-ust-abi.c b/libust/lttng-ust-abi.c index ad582c05..3674dcc3 100644 --- a/libust/lttng-ust-abi.c +++ b/libust/lttng-ust-abi.c @@ -28,7 +28,7 @@ #include #include #include -#include "usterr_signal_safe.h" +#include #include "ust/core.h" #include "ltt-tracer.h" diff --git a/libust/tracepoint.c b/libust/tracepoint.c index 67619a85..6eb40ea2 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -28,7 +28,7 @@ #include #include -#include "usterr_signal_safe.h" +#include extern struct tracepoint * const __start___tracepoints_ptrs[] __attribute__((visibility("hidden"))); diff --git a/libust/ust-core.c b/libust/ust-core.c index 7791ffb0..cb87b745 100644 --- a/libust/ust-core.c +++ b/libust/ust-core.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include volatile enum ust_loglevel ust_loglevel; diff --git a/tests/hello/tp.h b/tests/hello/tp.h index 606f0f13..7fa16e90 100644 --- a/tests/hello/tp.h +++ b/tests/hello/tp.h @@ -25,9 +25,11 @@ #include TRACEPOINT_EVENT(ust_tests_hello_tptest, - TP_PROTO(int anint), - TP_ARGS(anint), - TP_FIELDS()) + TP_PROTO(int anint), + TP_ARGS(anint), + TP_FIELDS( + ctf_integer(int, intfield, anint) + )) TRACEPOINT_EVENT_NOARGS(ust_tests_hello_tptest_sighandler, TP_FIELDS()) -- 2.34.1