From: Mathieu Desnoyers Date: Thu, 3 Nov 2011 16:16:04 +0000 (-0400) Subject: Move include/ust/ to include/lttng/ X-Git-Tag: v1.9.1~145 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4318ae1be57eb7983ab4857a7a8eeb4a030a8216;p=lttng-ust.git Move include/ust/ to include/lttng/ Keep all lttng project files under the same toplevel directory. Signed-off-by: Mathieu Desnoyers --- diff --git a/configure.ac b/configure.ac index 856894b2..be93880c 100644 --- a/configure.ac +++ b/configure.ac @@ -8,8 +8,8 @@ AC_CANONICAL_HOST AC_CONFIG_MACRO_DIR([config]) AM_INIT_AUTOMAKE([foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AC_CONFIG_SRCDIR([include/ust/tracepoint.h]) -AC_CONFIG_HEADERS([config.h include/ust/config.h]) +AC_CONFIG_SRCDIR([include/lttng/tracepoint.h]) +AC_CONFIG_HEADERS([config.h include/lttng/config.h]) AH_TEMPLATE([HAVE_EFFICIENT_UNALIGNED_ACCESS], [Use efficient unaligned access.]) # Compute minor/major version numbers major_version=`echo AC_PACKAGE_VERSION | sed 's/\..*//'` @@ -221,7 +221,7 @@ AC_CONFIG_FILES([ libustfork/Makefile snprintf/Makefile ust.pc - include/ust/version.h + include/lttng/version.h libustjava/Makefile ]) AC_OUTPUT diff --git a/include/Makefile.am b/include/Makefile.am index 4f376529..08fc038d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,37 +1,37 @@ nobase_include_HEADERS = \ - ust/marker.h \ - ust/tracepoint.h \ - ust/tracepoint-event.h \ - ust/lttng-tracepoint-event.h \ - ust/lttng-tracepoint-event-reset.h \ - ust/lttng-events.h \ - ust/lttng-ust-ctl.h \ - ust/version.h \ - ust/lttng-ust-abi.h \ - ust/lttng-ust-comm.h \ - ust/ringbuffer-abi.h \ - ust/lttng-tracer.h \ - ust/usterr-signal-safe.h \ - ust/config.h \ - ust/share.h \ - ust/ust.h \ - ust/core.h + lttng/marker.h \ + lttng/tracepoint.h \ + lttng/tracepoint-event.h \ + lttng/ust-tracepoint-event.h \ + lttng/ust-tracepoint-event-reset.h \ + lttng/ust-events.h \ + lttng/ust-ctl.h \ + lttng/version.h \ + lttng/ust-abi.h \ + lttng/ust-comm.h \ + lttng/ringbuffer-abi.h \ + lttng/ust-tracer.h \ + lttng/usterr-signal-safe.h \ + lttng/config.h \ + lttng/share.h \ + lttng/ust.h \ + lttng/core.h # note: usterr-signal-safe.h, core.h and share.h need namespace cleanup. noinst_HEADERS = \ usterr.h \ ust_snprintf.h \ - ust/compat.h \ - ust/marker-internal.h \ - ust/tracepoint-internal.h \ - ust/clock.h \ - ust/probe-internal.h \ - ust/kcompat/kcompat.h \ - ust/kcompat/jhash.h \ - ust/kcompat/compiler.h \ - ust/kcompat/types.h \ - ust/stringify.h \ - ust/wait.h \ - ust/ringbuffer-config.h \ - ust/processor.h + lttng/compat.h \ + lttng/marker-internal.h \ + lttng/tracepoint-internal.h \ + lttng/clock.h \ + lttng/probe-internal.h \ + lttng/kcompat/kcompat.h \ + lttng/kcompat/jhash.h \ + lttng/kcompat/compiler.h \ + lttng/kcompat/types.h \ + lttng/stringify.h \ + lttng/wait.h \ + lttng/ringbuffer-config.h \ + lttng/processor.h diff --git a/include/lttng/align.h b/include/lttng/align.h new file mode 100644 index 00000000..12fc61b9 --- /dev/null +++ b/include/lttng/align.h @@ -0,0 +1,51 @@ +#ifndef _UST_ALIGN_H +#define _UST_ALIGN_H + +/* + * lttng/align.h + * + * (C) Copyright 2010-2011 - Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include + +/* + * Align pointer on natural object alignment. + */ +#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj))) +#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) + +/** + * offset_align - Calculate the offset needed to align an object on its natural + * alignment towards higher addresses. + * @align_drift: object offset from an "alignment"-aligned address. + * @alignment: natural object alignment. Must be non-zero, power of 2. + * + * Returns the offset that must be added to align towards higher + * addresses. + */ +#define offset_align(align_drift, alignment) \ + ({ \ + BUILD_RUNTIME_BUG_ON((alignment) == 0 \ + || ((alignment) & ((alignment) - 1))); \ + (((alignment) - (align_drift)) & ((alignment) - 1)); \ + }) + +/** + * offset_align_floor - Calculate the offset needed to align an object + * on its natural alignment towards lower addresses. + * @align_drift: object offset from an "alignment"-aligned address. + * @alignment: natural object alignment. Must be non-zero, power of 2. + * + * Returns the offset that must be substracted to align towards lower addresses. + */ +#define offset_align_floor(align_drift, alignment) \ + ({ \ + BUILD_RUNTIME_BUG_ON((alignment) == 0 \ + || ((alignment) & ((alignment) - 1))); \ + (((align_drift) - (alignment)) & ((alignment) - 1); \ + }) + +#endif /* _UST_ALIGN_H */ diff --git a/include/lttng/bitfield.h b/include/lttng/bitfield.h new file mode 100644 index 00000000..df8ab0b2 --- /dev/null +++ b/include/lttng/bitfield.h @@ -0,0 +1,399 @@ +#ifndef _BABELTRACE_BITFIELD_H +#define _BABELTRACE_BITFIELD_H + +/* + * BabelTrace + * + * Bitfields read/write functions. + * + * Copyright 2010 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#include /* C99 5.2.4.2 Numerical limits */ +#include /* C99 5.2.4.2 Numerical limits */ +#include /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */ +#include + +/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */ +#define _bt_piecewise_rshift(_v, _shift) \ +({ \ + typeof(_v) ___v = (_v); \ + typeof(_shift) ___shift = (_shift); \ + unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ + unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ + \ + for (; sb; sb--) \ + ___v >>= sizeof(___v) * CHAR_BIT - 1; \ + ___v >>= final; \ +}) + +#define _bt_piecewise_lshift(_v, _shift) \ +({ \ + typeof(_v) ___v = (_v); \ + typeof(_shift) ___shift = (_shift); \ + unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ + unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ + \ + for (; sb; sb--) \ + ___v <<= sizeof(___v) * CHAR_BIT - 1; \ + ___v <<= final; \ +}) + +#define _bt_is_signed_type(type) (((type)(-1)) < 0) + +#define _bt_unsigned_cast(type, v) \ +({ \ + (sizeof(v) < sizeof(type)) ? \ + ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \ + (type) (v); \ +}) + +/* + * bt_bitfield_write - write integer to a bitfield in native endianness + * + * Save integer to the bitfield, which starts at the "start" bit, has "len" + * bits. + * The inside of a bitfield is from high bits to low bits. + * Uses native endianness. + * For unsigned "v", pad MSB with 0 if bitfield is larger than v. + * For signed "v", sign-extend v if bitfield is larger than v. + * + * On little endian, bytes are placed from the less significant to the most + * significant. Also, consecutive bitfields are placed from lower bits to higher + * bits. + * + * On big endian, bytes are places from most significant to less significant. + * Also, consecutive bitfields are placed from higher to lower bits. + */ + +#define _bt_bitfield_write_le(_ptr, type, _start, _length, _v) \ +do { \ + typeof(_v) __v = (_v); \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) \ + break; \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + /* Trim v high bits */ \ + if (__length < sizeof(__v) * CHAR_BIT) \ + __v &= ~((~(typeof(__v)) 0) << __length); \ + \ + /* We can now append v with a simple "or", shift it piece-wise */ \ + this_unit = start_unit; \ + if (start_unit == end_unit - 1) { \ + mask = ~((~(type) 0) << (__start % ts)); \ + if (end % ts) \ + mask |= (~(type) 0) << (end % ts); \ + cmask = (type) __v << (__start % ts); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + break; \ + } \ + if (__start % ts) { \ + cshift = __start % ts; \ + mask = ~((~(type) 0) << cshift); \ + cmask = (type) __v << cshift; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + __v = _bt_piecewise_rshift(__v, ts - cshift); \ + __start += ts - cshift; \ + this_unit++; \ + } \ + for (; this_unit < end_unit - 1; this_unit++) { \ + __ptr[this_unit] = (type) __v; \ + __v = _bt_piecewise_rshift(__v, ts); \ + __start += ts; \ + } \ + if (end % ts) { \ + mask = (~(type) 0) << (end % ts); \ + cmask = (type) __v; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + } else \ + __ptr[this_unit] = (type) __v; \ +} while (0) + +#define _bt_bitfield_write_be(_ptr, type, _start, _length, _v) \ +do { \ + typeof(_v) __v = (_v); \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) \ + break; \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + /* Trim v high bits */ \ + if (__length < sizeof(__v) * CHAR_BIT) \ + __v &= ~((~(typeof(__v)) 0) << __length); \ + \ + /* We can now append v with a simple "or", shift it piece-wise */ \ + this_unit = end_unit - 1; \ + if (start_unit == end_unit - 1) { \ + mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \ + if (__start % ts) \ + mask |= (~((type) 0)) << (ts - (__start % ts)); \ + cmask = (type) __v << ((ts - (end % ts)) % ts); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + break; \ + } \ + if (end % ts) { \ + cshift = end % ts; \ + mask = ~((~(type) 0) << (ts - cshift)); \ + cmask = (type) __v << (ts - cshift); \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + __v = _bt_piecewise_rshift(__v, cshift); \ + end -= cshift; \ + this_unit--; \ + } \ + for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \ + __ptr[this_unit] = (type) __v; \ + __v = _bt_piecewise_rshift(__v, ts); \ + end -= ts; \ + } \ + if (__start % ts) { \ + mask = (~(type) 0) << (ts - (__start % ts)); \ + cmask = (type) __v; \ + cmask &= ~mask; \ + __ptr[this_unit] &= mask; \ + __ptr[this_unit] |= cmask; \ + } else \ + __ptr[this_unit] = (type) __v; \ +} while (0) + +/* + * bt_bitfield_write - write integer to a bitfield in native endianness + * bt_bitfield_write_le - write integer to a bitfield in little endian + * bt_bitfield_write_be - write integer to a bitfield in big endian + */ + +#if (BYTE_ORDER == LITTLE_ENDIAN) + +#define bt_bitfield_write(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_le(ptr, type, _start, _length, _v) + +#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_le(ptr, type, _start, _length, _v) + +#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v) + +#elif (BYTE_ORDER == BIG_ENDIAN) + +#define bt_bitfield_write(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_be(ptr, type, _start, _length, _v) + +#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v) + +#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \ + _bt_bitfield_write_be(ptr, type, _start, _length, _v) + +#else /* (BYTE_ORDER == PDP_ENDIAN) */ + +#error "Byte order not supported" + +#endif + +#define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ +do { \ + typeof(*(_vptr)) *__vptr = (_vptr); \ + typeof(*__vptr) __v; \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) { \ + *__vptr = 0; \ + break; \ + } \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + this_unit = end_unit - 1; \ + if (_bt_is_signed_type(typeof(__v)) \ + && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \ + __v = ~(typeof(__v)) 0; \ + else \ + __v = 0; \ + if (start_unit == end_unit - 1) { \ + cmask = __ptr[this_unit]; \ + cmask >>= (__start % ts); \ + if ((end - __start) % ts) { \ + mask = ~((~(type) 0) << (end - __start)); \ + cmask &= mask; \ + } \ + __v = _bt_piecewise_lshift(__v, end - __start); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + *__vptr = __v; \ + break; \ + } \ + if (end % ts) { \ + cshift = end % ts; \ + mask = ~((~(type) 0) << cshift); \ + cmask = __ptr[this_unit]; \ + cmask &= mask; \ + __v = _bt_piecewise_lshift(__v, cshift); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + end -= cshift; \ + this_unit--; \ + } \ + for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \ + __v = _bt_piecewise_lshift(__v, ts); \ + __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ + end -= ts; \ + } \ + if (__start % ts) { \ + mask = ~((~(type) 0) << (ts - (__start % ts))); \ + cmask = __ptr[this_unit]; \ + cmask >>= (__start % ts); \ + cmask &= mask; \ + __v = _bt_piecewise_lshift(__v, ts - (__start % ts)); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + } else { \ + __v = _bt_piecewise_lshift(__v, ts); \ + __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ + } \ + *__vptr = __v; \ +} while (0) + +#define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ +do { \ + typeof(*(_vptr)) *__vptr = (_vptr); \ + typeof(*__vptr) __v; \ + type *__ptr = (void *) (_ptr); \ + unsigned long __start = (_start), __length = (_length); \ + type mask, cmask; \ + unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ + unsigned long start_unit, end_unit, this_unit; \ + unsigned long end, cshift; /* cshift is "complement shift" */ \ + \ + if (!__length) { \ + *__vptr = 0; \ + break; \ + } \ + \ + end = __start + __length; \ + start_unit = __start / ts; \ + end_unit = (end + (ts - 1)) / ts; \ + \ + this_unit = start_unit; \ + if (_bt_is_signed_type(typeof(__v)) \ + && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \ + __v = ~(typeof(__v)) 0; \ + else \ + __v = 0; \ + if (start_unit == end_unit - 1) { \ + cmask = __ptr[this_unit]; \ + cmask >>= (ts - (end % ts)) % ts; \ + if ((end - __start) % ts) { \ + mask = ~((~(type) 0) << (end - __start)); \ + cmask &= mask; \ + } \ + __v = _bt_piecewise_lshift(__v, end - __start); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + *__vptr = __v; \ + break; \ + } \ + if (__start % ts) { \ + cshift = __start % ts; \ + mask = ~((~(type) 0) << (ts - cshift)); \ + cmask = __ptr[this_unit]; \ + cmask &= mask; \ + __v = _bt_piecewise_lshift(__v, ts - cshift); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + __start += ts - cshift; \ + this_unit++; \ + } \ + for (; this_unit < end_unit - 1; this_unit++) { \ + __v = _bt_piecewise_lshift(__v, ts); \ + __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ + __start += ts; \ + } \ + if (end % ts) { \ + mask = ~((~(type) 0) << (end % ts)); \ + cmask = __ptr[this_unit]; \ + cmask >>= ts - (end % ts); \ + cmask &= mask; \ + __v = _bt_piecewise_lshift(__v, end % ts); \ + __v |= _bt_unsigned_cast(typeof(__v), cmask); \ + } else { \ + __v = _bt_piecewise_lshift(__v, ts); \ + __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ + } \ + *__vptr = __v; \ +} while (0) + +/* + * bt_bitfield_read - read integer from a bitfield in native endianness + * bt_bitfield_read_le - read integer from a bitfield in little endian + * bt_bitfield_read_be - read integer from a bitfield in big endian + */ + +#if (BYTE_ORDER == LITTLE_ENDIAN) + +#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) + +#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) + +#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_be(_ptr, unsigned char, _start, _length, _vptr) + +#elif (BYTE_ORDER == BIG_ENDIAN) + +#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) + +#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_le(_ptr, unsigned char, _start, _length, _vptr) + +#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ + _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) + +#else /* (BYTE_ORDER == PDP_ENDIAN) */ + +#error "Byte order not supported" + +#endif + +#endif /* _BABELTRACE_BITFIELD_H */ diff --git a/include/lttng/bug.h b/include/lttng/bug.h new file mode 100644 index 00000000..96007c3f --- /dev/null +++ b/include/lttng/bug.h @@ -0,0 +1,32 @@ +#ifndef _LTTNG_BUG_H +#define _LTTNG_BUG_H + +/* + * lib/bug.h + * + * (C) Copyright 2010-2011 - Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#define BUILD_BUG_ON(condition) \ + ((void) sizeof(char[-!!(condition)])) + +/** + * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime + * @condition: the condition which should be false. + * + * If the condition is a constant and true, the compiler will generate a build + * error. If the condition is not constant, a BUG will be triggered at runtime + * if the condition is ever true. If the condition is constant and false, no + * code is emitted. + */ +#define BUILD_RUNTIME_BUG_ON(condition) \ + do { \ + if (__builtin_constant_p(condition)) \ + BUILD_BUG_ON(condition); \ + else \ + BUG_ON(condition); \ + } while (0) + +#endif diff --git a/include/lttng/clock.h b/include/lttng/clock.h new file mode 100644 index 00000000..ebcd624f --- /dev/null +++ b/include/lttng/clock.h @@ -0,0 +1,63 @@ +/* + * 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; 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 + */ + +#ifndef _UST_CLOCK_H +#define _UST_CLOCK_H + +#include +#include +#include +#include +#include + +/* TRACE CLOCK */ + +/* + * Currently using the kernel MONOTONIC clock, waiting for kernel-side + * LTTng to implement mmap'd trace clock. + */ + +/* Choosing correct trace clock */ + +static __inline__ uint64_t trace_clock_read64(void) +{ + struct timespec ts; + uint64_t retval; + + 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) +{ + return 1000000000LL; +} +#endif /* #else #if __i386__ || __x86_64__ */ + +static __inline__ uint32_t trace_clock_freq_scale(void) +{ + return 1; +} + +#endif /* _UST_CLOCK_H */ diff --git a/include/lttng/compat.h b/include/lttng/compat.h new file mode 100644 index 00000000..c896e728 --- /dev/null +++ b/include/lttng/compat.h @@ -0,0 +1,35 @@ +#ifndef _UST_COMPAT_H +#define _UST_COMPAT_H + +/* + * 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. + * + * 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 + */ + +#include + +#ifdef __UCLIBC__ +#define __getcpu(cpu, node, cache) syscall(__NR_getcpu, cpu, node, cache) +static inline +int sched_getcpu(void) +{ + int c, s; + + s = __getcpu(&c, NULL, NULL); + return (s == -1) ? s : c; +} +#endif /* __UCLIBC__ */ +#endif /* _UST_COMPAT_H */ diff --git a/include/lttng/config.h.in b/include/lttng/config.h.in new file mode 100644 index 00000000..b619095f --- /dev/null +++ b/include/lttng/config.h.in @@ -0,0 +1,5 @@ +/* ust/config.h.in. Manually generated for control over the contained defs. */ + +/* Use efficient unaligned access. */ +#undef HAVE_EFFICIENT_UNALIGNED_ACCESS + diff --git a/include/lttng/core.h b/include/lttng/core.h new file mode 100644 index 00000000..5bd19829 --- /dev/null +++ b/include/lttng/core.h @@ -0,0 +1,171 @@ +#ifndef UST_CORE_H +#define UST_CORE_H + +/* + * 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; 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 + */ + +#include +#include +#include +#include + +/* ARRAYS */ + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + + +/* ALIGNMENT SHORTCUTS */ + +#include + +#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) +#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) +#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +/* ERROR OPS */ +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) caa_unlikely((x) >= (unsigned long)-MAX_ERRNO) + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + + +/* Min / Max */ + +#define min_t(type, x, y) ({ \ + type __min1 = (x); \ + type __min2 = (y); \ + __min1 < __min2 ? __min1: __min2; }) + +#define max_t(type, x, y) ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1: __max2; }) + + +/* MUTEXES */ + +#include + +#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; +#define DECLARE_MUTEX(m) extern pthread_mutex_t (m); + +/* MALLOCATION */ + +#include + +static inline +void *zmalloc(size_t len) +{ + return calloc(1, len); +} + +static inline +void *malloc_align(size_t len) +{ + return malloc(ALIGN(len, CAA_CACHE_LINE_SIZE)); +} + +static inline +void *zmalloc_align(size_t len) +{ + return calloc(1, ALIGN(len, CAA_CACHE_LINE_SIZE)); +} + +/* MATH */ + +#include +static inline unsigned int hweight32(unsigned int w) +{ + unsigned int res = w - ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res + (res >> 4)) & 0x0F0F0F0F; + res = res + (res >> 8); + return (res + (res >> 16)) & 0x000000FF; +} + +static __inline__ int get_count_order(unsigned int count) +{ + int order; + + order = fls(count) - 1; + if (count & (count - 1)) + order++; + return order; +} + +#define _ust_container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +#ifndef inline_memcpy +#define inline_memcpy memcpy +#endif + +#ifndef __same_type +#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + +#ifndef UST_VALGRIND + +static __inline__ int ust_get_cpu(void) +{ + int cpu; + + cpu = sched_getcpu(); + if (caa_likely(cpu >= 0)) + return cpu; + /* + * If getcpu(2) is not implemented in the Kernel use CPU 0 as fallback. + */ + return 0; +} + +#else /* #else #ifndef UST_VALGRIND */ + +static __inline__ int ust_get_cpu(void) +{ + /* + * Valgrind does not support the sched_getcpu() vsyscall. + * It causes it to detect a segfault in the program and stop it. + * So if we want to check libust with valgrind, we have to refrain + * from using this call. TODO: it would probably be better to return + * other values too, to better test it. + */ + return 0; +} + +#endif /* #else #ifndef UST_VALGRIND */ + +#endif /* UST_CORE_H */ diff --git a/include/lttng/kcompat/compiler.h b/include/lttng/kcompat/compiler.h new file mode 100644 index 00000000..f2fbd3e3 --- /dev/null +++ b/include/lttng/kcompat/compiler.h @@ -0,0 +1,42 @@ +/* + * compiler.h + * + * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca) + * + * 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. + * + * 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 + */ + +#ifndef KCOMPAT_COMPILER_H +#define KCOMPAT_COMPILER_H + +# define inline inline __attribute__((always_inline)) +# define __inline__ __inline__ __attribute__((always_inline)) +# define __inline __inline __attribute__((always_inline)) + +#ifndef __always_inline +#define __always_inline inline +#endif + +#define __pure __attribute__((pure)) +#define __aligned(x) __attribute__((aligned(x))) +#define __printf(a,b) __attribute__((format(printf,a,b))) +#define noinline __attribute__((noinline)) +#define __attribute_const__ __attribute__((__const__)) +#define __used __attribute__((used)) +#define __maybe_unused __attribute__((unused)) + +#define notrace __attribute__((no_instrument_function)) + +#endif /* KCOMPAT_COMPILER_H */ diff --git a/include/lttng/kcompat/jhash.h b/include/lttng/kcompat/jhash.h new file mode 100644 index 00000000..2635167b --- /dev/null +++ b/include/lttng/kcompat/jhash.h @@ -0,0 +1,84 @@ +#ifndef KCOMPAT_JHASH_H +#define KCOMPAT_JHASH_H + +/* jhash.h: Jenkins hash support. + * + * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net) + * + * http://burtleburtle.net/bob/hash/ + * + * These are the credits from Bob's sources: + * + * lookup2.c, by Bob Jenkins, December 1996, Public Domain. + * hash(), hash2(), hash3, and mix() are externally useful functions. + * Routines to test the hash are included if SELF_TEST is defined. + * You can use this free for any purpose. It has no warranty. + * + * Copyright (C) 2003 David S. Miller (davem@redhat.com) + * + * I've modified Bob's hash to be useful in the Linux kernel, and + * any bugs present are surely my fault. -DaveM + */ + +/* NOTE: Arguments are modified. */ +#define __jhash_mix(a, b, c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<<8); \ + c -= a; c -= b; c ^= (b>>13); \ + a -= b; a -= c; a ^= (c>>12); \ + b -= c; b -= a; b ^= (a<<16); \ + c -= a; c -= b; c ^= (b>>5); \ + a -= b; a -= c; a ^= (c>>3); \ + b -= c; b -= a; b ^= (a<<10); \ + c -= a; c -= b; c ^= (b>>15); \ +} + +/* The golden ration: an arbitrary value */ +#define JHASH_GOLDEN_RATIO 0x9e3779b9 + +/* The most generic version, hashes an arbitrary sequence + * of bytes. No alignment or length assumptions are made about + * the input key. + */ +static inline u32 jhash(const void *key, u32 length, u32 initval) +{ + u32 a, b, c, len; + const u8 *k = (const u8 *) key; + + len = length; + a = b = JHASH_GOLDEN_RATIO; + c = initval; + + while (len >= 12) { + a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24)); + b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24)); + c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24)); + + __jhash_mix(a,b,c); + + k += 12; + len -= 12; + } + + c += length; + switch (len) { + case 11: c += ((u32)k[10]<<24); + case 10: c += ((u32)k[9]<<16); + case 9 : c += ((u32)k[8]<<8); + case 8 : b += ((u32)k[7]<<24); + case 7 : b += ((u32)k[6]<<16); + case 6 : b += ((u32)k[5]<<8); + case 5 : b += k[4]; + case 4 : a += ((u32)k[3]<<24); + case 3 : a += ((u32)k[2]<<16); + case 2 : a += ((u32)k[1]<<8); + case 1 : a += k[0]; + }; + + __jhash_mix(a,b,c); + + return c; +} + +#endif /* KCOMPAT_JHASH_H */ diff --git a/include/lttng/kcompat/kcompat.h b/include/lttng/kcompat/kcompat.h new file mode 100644 index 00000000..3fdea648 --- /dev/null +++ b/include/lttng/kcompat/kcompat.h @@ -0,0 +1,63 @@ +/* + * kcompat.h + * + * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca) + * + * 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. + * + * 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 + */ + +#ifndef KCOMPAT_H +#define KCOMPAT_H + +#define __KERNEL__ +#define _LOOSE_KERNEL_NAMES + +#ifndef CONFIG_SMP +#define CONFIG_SMP 1 /* Needed for urcu, verify it's ok to remove it. */ +#endif + +#include +#include +#if __WORDSIZE == 32 +#define LIBKCOMPAT_X86_32 +#elif __WORDSIZE == 64 +#define LIBKCOMPAT_X86_64 +#else +#error "Unsupported" +#endif + +#ifdef LIBKCOMPAT_X86_32 +#define CONFIG_X86_32 +#define CONFIG_32BIT +#endif + +#ifdef LIBKCOMPAT_X86_64 +#define CONFIG_X86_64 +#define CONFIG_64BIT +#endif + +/* Standard libs */ +#include +#include + +/* Taken from userspace-rcu */ +#include + +/* Kernel libs */ +#include +#include +#include + +#endif /* KCOMPAT_H */ diff --git a/include/lttng/kcompat/types.h b/include/lttng/kcompat/types.h new file mode 100644 index 00000000..63f9ede0 --- /dev/null +++ b/include/lttng/kcompat/types.h @@ -0,0 +1,32 @@ +#ifndef _KCOMPAT_TYPES +#define _KCOMPAT_TYPES + +/* + * Kernel sourcecode compatibility layer + * + * Copyright (C) 2009 Novell Inc. + * + * Author: Jan Blunck + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + */ + +#include + +#ifdef __KERNEL__ +typedef __s8 s8; +typedef __u8 u8; + +typedef __s16 s16; +typedef __u16 u16; + +typedef __s32 s32; +typedef __u32 u32; + +typedef __s64 s64; +typedef __u64 u64; +#endif + +#endif /* _KCOMPAT_TYPES */ diff --git a/include/lttng/marker-internal.h b/include/lttng/marker-internal.h new file mode 100644 index 00000000..6a11e563 --- /dev/null +++ b/include/lttng/marker-internal.h @@ -0,0 +1,121 @@ +#ifndef _UST_MARKER_INTERNAL_H +#define _UST_MARKER_INTERNAL_H + +/* + * Code markup for dynamic and static tracing. (internal header) + * + * See Documentation/marker.txt. + * + * (C) Copyright 2006 Mathieu Desnoyers + * (C) Copyright 2009 Pierre-Marc Fournier + * (C) Copyright 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; + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include + +#define GET_UST_MARKER(name) (__ust_marker_def_##name) + +#define DEFINE_UST_MARKER(name, format) \ + _DEFINE_UST_MARKER(ust, name, NULL, NULL, format) + +#define DEFINE_UST_MARKER_TP(name, tp_name, tp_cb, format) \ + _DEFINE_UST_MARKER(ust, name, #tp_name, tp_cb, format) + +#define __ust_marker_tp(name, call_private, tp_name, tp_cb, \ + format, args...) \ + do { \ + void __check_tp_type(void) \ + { \ + register_trace_##tp_name(tp_cb, call_private); \ + } \ + DEFINE_UST_MARKER_TP(name, #tp_name, tp_cb, format); \ + __ust_marker_check_format(format, ## args); \ + (*__ust_marker_def_##name.call) \ + (&__ust_marker_def_##name, call_private, ## args); \ + } while (0) + +/** + * ust_marker_tp - Marker in a tracepoint callback + * @name: marker name, not quoted. + * @tp_name: tracepoint name, not quoted. + * @tp_cb: tracepoint callback. Should have an associated global symbol so it + * is not optimized away by the compiler (should not be static). + * @format: format string + * @args...: variable argument list + * + * Places a marker in a tracepoint callback. + */ +#define ust_marker_tp(name, tp_name, tp_cb, format, args...) \ + __ust_marker_tp(ust, name, NULL, tp_name, tp_cb, format, ## args) + +extern void ust_marker_compact_event_ids(void); + +/* + * Connect a probe to a marker. + * private data pointer must be a valid allocated memory address, or NULL. + */ +extern int ust_marker_probe_register(const char *channel, const char *name, + const char *format, ust_marker_probe_func *probe, void *probe_private); + +/* + * Returns the private data given to ust_marker_probe_register. + */ +extern int ust_marker_probe_unregister(const char *channel, const char *name, + ust_marker_probe_func *probe, void *probe_private); +/* + * Unregister a marker by providing the registered private data. + */ +extern int ust_marker_probe_unregister_private_data(ust_marker_probe_func *probe, + void *probe_private); + +extern void *ust_marker_get_private_data(const char *channel, const char *name, + ust_marker_probe_func *probe, int num); + +/* + * ust_marker_synchronize_unregister must be called between the last + * marker probe unregistration and the first one of + * - the end of library exit function + * - the free of any resource used by the probes + * to ensure the code and data are valid for any possibly running probes. + */ +#define ust_marker_synchronize_unregister() synchronize_rcu() + +struct ust_marker_iter { + struct ust_marker_lib *lib; + struct ust_marker * const *ust_marker; +}; + +extern void ust_marker_iter_start(struct ust_marker_iter *iter); +extern void ust_marker_iter_next(struct ust_marker_iter *iter); +extern void ust_marker_iter_stop(struct ust_marker_iter *iter); +extern void ust_marker_iter_reset(struct ust_marker_iter *iter); + +extern int is_ust_marker_enabled(const char *channel, const char *name); + +extern void ust_marker_set_new_ust_marker_cb(void (*cb)(struct ust_marker *)); +extern void init_ust_marker(void); + +void lock_ust_marker(void); +void unlock_ust_marker(void); + +#endif /* _UST_MARKER_INTERNAL_H */ diff --git a/include/lttng/marker.h b/include/lttng/marker.h new file mode 100644 index 00000000..8cfdcbdb --- /dev/null +++ b/include/lttng/marker.h @@ -0,0 +1,229 @@ +#ifndef _UST_MARKER_H +#define _UST_MARKER_H + +/* + * Code markup for dynamic and static tracing. + * + * See Documentation/marker.txt. + * + * (C) Copyright 2006 Mathieu Desnoyers + * (C) Copyright 2009 Pierre-Marc Fournier + * (C) Copyright 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; + * 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 + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ust_marker; +struct ust_marker_probe_array; + +/** + * ust_marker_probe_func - Type of a marker probe function + * @mdata: marker data + * @probe_private: probe private data + * @call_private: call site private data + * @fmt: format string + * @args: variable argument list pointer. Use a pointer to overcome C's + * inability to pass this around as a pointer in a portable manner in + * the callee otherwise. + * + * Type of marker probe functions. They receive the mdata and need to parse the + * format string to recover the variable argument list. + */ +typedef void ust_marker_probe_func(const struct ust_marker *mdata, + void *probe_private, void *call_private, + const char *fmt, va_list *args); + +struct ust_marker_probe_closure { + ust_marker_probe_func *func; /* Callback */ + void *probe_private; /* Private probe data */ +}; + +struct ust_marker { + const char *channel; /* Name of channel where to send data */ + const char *name; /* Marker name */ + const char *format; /* Marker format string, describing the + * variable argument list. + */ + char state; /* State. */ + char ptype; /* probe type : 0 : single, 1 : multi */ + /* Probe wrapper */ + uint16_t channel_id; /* Numeric channel identifier, dynamic */ + uint16_t event_id; /* Numeric event identifier, dynamic */ + void (*call)(const struct ust_marker *mdata, void *call_private, ...); + struct ust_marker_probe_closure single; + struct ust_marker_probe_array *multi; + const char *tp_name; /* Optional tracepoint name */ + void *tp_cb; /* Optional tracepoint callback */ +}; + +/* + * We keep the "channel" as internal field for marker.c *only*. It will be + * removed soon. + */ + +/* + * __ust_marker_ptrs section is not const (read-only) because it needs to be + * read-write to let the linker apply relocations and keep the object PIC. + */ +#define _DEFINE_UST_MARKER(channel, name, tp_name_str, tp_cb, format) \ + static const char __mstrtab_##channel##_##name[] \ + __attribute__((section("__ust_markers_strings"))) \ + = #channel "\0" #name "\0" format; \ + static struct ust_marker __ust_marker_def_##name \ + __attribute__((section("__ust_markers"))) = \ + { __mstrtab_##channel##_##name, \ + &__mstrtab_##channel##_##name[sizeof(#channel)], \ + &__mstrtab_##channel##_##name[sizeof(#channel) + \ + sizeof(#name)], \ + 0, 0, 0, 0, ust_marker_probe_cb, \ + { __ust_marker_empty_function, NULL}, \ + NULL, tp_name_str, tp_cb }; \ + static struct ust_marker * __ust_marker_ptr_##name \ + __attribute__((used, section("__ust_marker_ptrs"))) = \ + &__ust_marker_def_##name + +/* + * Make sure the alignment of the structure in the __ust_marker section will + * not add unwanted padding between the beginning of the section and the + * structure. Force alignment to the same alignment as the section start. + */ + +#define __ust_marker(channel, name, call_private, format, args...) \ + do { \ + _DEFINE_UST_MARKER(channel, name, NULL, NULL, format); \ + __ust_marker_check_format(format, ## args); \ + if (__builtin_expect(!!(__ust_marker_def_##name.state), 0)) \ + (__ust_marker_def_##name.call) \ + (&__ust_marker_def_##name, call_private,\ + ## args); \ + } while (0) + +/** + * ust_marker - Marker using code patching + * @name: marker name, not quoted. + * @format: format string + * @args...: variable argument list + * + * Places a marker at caller site. + */ +#define ust_marker(name, format, args...) \ + __ust_marker(ust, name, NULL, format, ## args) + +static inline __attribute__((deprecated)) +void __trace_mark_is_deprecated() +{ +} + +/** + * UST_MARKER_NOARGS - Format string for a marker with no argument. + */ +#define UST_MARKER_NOARGS " " + +/* To be used for string format validity checking with gcc */ +static inline +void __attribute__((format(printf, 1, 2))) + ___ust_marker_check_format(const char *fmt, ...) +{ +} + +#define __ust_marker_check_format(format, args...) \ + do { \ + if (0) \ + ___ust_marker_check_format(format, ## args); \ + } while (0) + +extern ust_marker_probe_func __ust_marker_empty_function; + +extern void ust_marker_probe_cb(const struct ust_marker *mdata, + void *call_private, ...); + +struct ust_marker_lib { + struct ust_marker * const *ust_marker_start; + int ust_marker_count; + struct cds_list_head list; +}; + +#define UST_MARKER_LIB \ + extern struct ust_marker * const __start___ust_marker_ptrs[] __attribute__((weak, visibility("hidden"))); \ + extern struct ust_marker * const __stop___ust_marker_ptrs[] __attribute__((weak, visibility("hidden"))); \ + static struct ust_marker * __ust_marker_ptr_dummy \ + __attribute__((used, section("__ust_marker_ptrs"))); \ + \ + static void __attribute__((constructor)) __ust_marker__init(void) \ + { \ + ust_marker_register_lib(__start___ust_marker_ptrs, \ + __stop___ust_marker_ptrs \ + - __start___ust_marker_ptrs); \ + } \ + \ + static void __attribute__((destructor)) __ust_marker__destroy(void) \ + { \ + ust_marker_unregister_lib(__start___ust_marker_ptrs); \ + } + +extern +int ust_marker_register_lib(struct ust_marker * const *ust_marker_start, + int ust_marker_count); +extern +int ust_marker_unregister_lib(struct ust_marker * const *ust_marker_start); + +/* + * trace_mark() -- DEPRECATED + * @channel: name prefix, not quoted. Ignored. + * @name: marker name, not quoted. + * @format: format string + * @args...: variable argument list + * + * Kept as a compatibility API and is *DEPRECATED* in favor of + * ust_marker(). + */ +#define trace_mark(channel, name, format, args...) \ + __trace_mark_is_deprecated(); \ + ust_marker(name, format, ## args) + +static inline __attribute__((deprecated)) +void __MARKER_LIB_IS_DEPRECATED() +{ +} + +/* + * MARKER_LIB is kept for backward compatibility and is *DEPRECATED*. + * Use UST_MARKER_LIB instead. + */ +#define MARKER_LIB \ + __MARKER_LIB_IS_DEPRECATED(); \ + UST_MARKER_LIB + +/** + * MARKER_NOARGS - Compatibility API. *DEPRECATED*. Use + * UST_MARKER_NOARGS instead. + */ +#define MARK_NOARGS UST_MARKER_NOARGS + +#ifdef __cplusplus +} +#endif + +#endif /* _UST_MARKER_H */ diff --git a/include/lttng/probe-internal.h b/include/lttng/probe-internal.h new file mode 100644 index 00000000..a4f3a0e5 --- /dev/null +++ b/include/lttng/probe-internal.h @@ -0,0 +1,51 @@ +#ifndef _UST_PROBE_H +#define _UST_PROBE_H + +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * + * 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. + * + * 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 + * + */ + +/* Maximum number of callbacks per marker */ +#define LTT_NR_CALLBACKS 10 + +struct ltt_serialize_closure; +struct ust_buffer; + +typedef size_t (*ltt_serialize_cb)(struct ust_buffer *buf, size_t buf_offset, + struct ltt_serialize_closure *closure, + void *serialize_private, + unsigned int stack_pos_ctx, + int *largest_align, + const char *fmt, va_list *args); + +struct ltt_available_probe { + const char *name; /* probe name */ + const char *format; + ust_marker_probe_func *probe_func; + ltt_serialize_cb callbacks[LTT_NR_CALLBACKS]; + struct cds_list_head node; /* registered probes list */ +}; + +extern int ltt_probe_register(struct ltt_available_probe *pdata); +extern int ltt_probe_unregister(struct ltt_available_probe *pdata); +extern int ltt_ust_marker_connect(const char *channel, const char *mname, + const char *pname); +extern int ltt_ust_marker_disconnect(const char *channel, const char *mname, + const char *pname); + +#endif /* _UST_PROBE_H */ diff --git a/include/lttng/processor.h b/include/lttng/processor.h new file mode 100644 index 00000000..e3407bab --- /dev/null +++ b/include/lttng/processor.h @@ -0,0 +1,88 @@ +/* Copyright (C) 2009 Pierre-Marc Fournier + * + * 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. + * + * 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 + */ + +#ifndef UST_PROCESSOR_H +#define UST_PROCESSOR_H + +#define ____cacheline_aligned __attribute__((aligned(CAA_CACHE_LINE_SIZE))) + +#ifdef __i386 + +static inline int fls(int x) +{ + int r; + asm("bsrl %1,%0\n\t" + "cmovzl %2,%0" + : "=&r" (r) : "rm" (x), "rm" (-1)); + return r + 1; +} + +#elif defined(__x86_64) + +static inline int fls(int x) +{ + int r; + asm("bsrl %1,%0\n\t" + "cmovzl %2,%0" + : "=&r" (r) : "rm" (x), "rm" (-1)); + return r + 1; +} + +#elif defined(__PPC__) + +static __inline__ int fls(unsigned int x) +{ + int lz; + + asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); + return 32 - lz; +} + +#else /* arch-agnostic */ + +static __inline__ int fls(unsigned int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xFFFF0000U)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xFF000000U)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xF0000000U)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xC0000000U)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000U)) { + x <<= 1; + r -= 1; + } + return r; +} + +#endif + +#endif /* UST_PROCESSOR_H */ diff --git a/include/lttng/ringbuffer-abi.h b/include/lttng/ringbuffer-abi.h new file mode 100644 index 00000000..25bc194b --- /dev/null +++ b/include/lttng/ringbuffer-abi.h @@ -0,0 +1,67 @@ +#ifndef _UST_RING_BUFFER_ABI_H +#define _UST_RING_BUFFER_ABI_H + +/* + * ust/ringbuffer-abi.h + * + * (C) Copyright 2005-2010 - Mathieu Desnoyers + * + * Wait-free ring buffer ABI. + * + * Author: + * Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#define _UST_CMD(minor) (minor) +#define _UST_CMDR(minor, type) (minor) +#define _UST_CMDW(minor, type) (minor) + +/* + * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and + * consume sub-buffers sequentially. + * + * Reading sub-buffers without consuming them can be performed with: + * + * RING_BUFFER_SNAPSHOT + * RING_BUFFER_SNAPSHOT_GET_CONSUMED + * RING_BUFFER_SNAPSHOT_GET_PRODUCED + * + * to get the offset range to consume, and then by passing each sub-buffer + * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it + * with RING_BUFFER_PUT_SUBBUF. + * + * Note that the "snapshot" API can be used to read the sub-buffer in reverse + * order, which is useful for flight recorder snapshots. + */ + +/* Get a snapshot of the current ring buffer producer and consumer positions */ +#define RING_BUFFER_SNAPSHOT _UST_CMD(0x00) +/* Get the consumer position (iteration start) */ +#define RING_BUFFER_SNAPSHOT_GET_CONSUMED _UST_CMDR(0x01, unsigned long) +/* Get the producer position (iteration end) */ +#define RING_BUFFER_SNAPSHOT_GET_PRODUCED _UST_CMDR(0x02, unsigned long) +/* Get exclusive read access to the specified sub-buffer position */ +#define RING_BUFFER_GET_SUBBUF _UST_CMDW(0x03, unsigned long) +/* Release exclusive sub-buffer access */ +#define RING_BUFFER_PUT_SUBBUF _UST_CMD(0x04) + +/* Get exclusive read access to the next sub-buffer that can be read. */ +#define RING_BUFFER_GET_NEXT_SUBBUF _UST_CMD(0x05) +/* Release exclusive sub-buffer access, move consumer forward. */ +#define RING_BUFFER_PUT_NEXT_SUBBUF _UST_CMD(0x06) +/* returns the size of the current sub-buffer, without padding (for mmap). */ +#define RING_BUFFER_GET_SUBBUF_SIZE _UST_CMDR(0x07, unsigned long) +/* returns the size of the current sub-buffer, with padding (for splice). */ +#define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _UST_CMDR(0x08, unsigned long) +/* returns the maximum size for sub-buffers. */ +#define RING_BUFFER_GET_MAX_SUBBUF_SIZE _UST_CMDR(0x09, unsigned long) +/* returns the length to mmap. */ +#define RING_BUFFER_GET_MMAP_LEN _UST_CMDR(0x0A, unsigned long) +/* returns the offset of the subbuffer belonging to the mmap reader. */ +#define RING_BUFFER_GET_MMAP_READ_OFFSET _UST_CMDR(0x0B, unsigned long) +/* flush the current sub-buffer */ +#define RING_BUFFER_FLUSH _UST_CMD(0x0C) + +#endif /* _UST_RING_BUFFER_ABI_H */ diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h new file mode 100644 index 00000000..4fa57750 --- /dev/null +++ b/include/lttng/ringbuffer-config.h @@ -0,0 +1,309 @@ +#ifndef _LINUX_RING_BUFFER_CONFIG_H +#define _LINUX_RING_BUFFER_CONFIG_H + +/* + * linux/ringbuffer/config.h + * + * Copyright (C) 2010 - Mathieu Desnoyers + * + * Ring buffer configuration header. Note: after declaring the standard inline + * functions, clients should also include linux/ringbuffer/api.h. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include "lttng/ust-tracer.h" +#include "lttng/usterr-signal-safe.h" +#include "lttng/kcompat/kcompat.h" +#include "lttng/align.h" + +struct lttng_ust_lib_ring_buffer; +struct channel; +struct lttng_ust_lib_ring_buffer_config; +struct lttng_ust_lib_ring_buffer_ctx; +struct lttng_ust_shm_handle *handle; + +/* + * Ring buffer client callbacks. Only used by slow path, never on fast path. + * For the fast path, record_header_size(), ring_buffer_clock_read() should be + * provided as inline functions too. These may simply return 0 if not used by + * the client. + */ +struct lttng_ust_lib_ring_buffer_client_cb { + /* Mandatory callbacks */ + + /* A static inline version is also required for fast path */ + u64 (*ring_buffer_clock_read) (struct channel *chan); + size_t (*record_header_size) (const struct lttng_ust_lib_ring_buffer_config *config, + struct channel *chan, size_t offset, + size_t *pre_header_padding, + struct lttng_ust_lib_ring_buffer_ctx *ctx); + + /* Slow path only, at subbuffer switch */ + size_t (*subbuffer_header_size) (void); + void (*buffer_begin) (struct lttng_ust_lib_ring_buffer *buf, u64 tsc, + unsigned int subbuf_idx, + struct lttng_ust_shm_handle *handle); + void (*buffer_end) (struct lttng_ust_lib_ring_buffer *buf, u64 tsc, + unsigned int subbuf_idx, unsigned long data_size, + struct lttng_ust_shm_handle *handle); + + /* Optional callbacks (can be set to NULL) */ + + /* Called at buffer creation/finalize */ + int (*buffer_create) (struct lttng_ust_lib_ring_buffer *buf, void *priv, + int cpu, const char *name, + struct lttng_ust_shm_handle *handle); + /* + * Clients should guarantee that no new reader handle can be opened + * after finalize. + */ + void (*buffer_finalize) (struct lttng_ust_lib_ring_buffer *buf, + void *priv, int cpu, + struct lttng_ust_shm_handle *handle); + + /* + * Extract header length, payload length and timestamp from event + * record. Used by buffer iterators. Timestamp is only used by channel + * iterator. + */ + void (*record_get) (const struct lttng_ust_lib_ring_buffer_config *config, + struct channel *chan, struct lttng_ust_lib_ring_buffer *buf, + size_t offset, size_t *header_len, + size_t *payload_len, u64 *timestamp, + struct lttng_ust_shm_handle *handle); +}; + +/* + * Ring buffer instance configuration. + * + * Declare as "static const" within the client object to ensure the inline fast + * paths can be optimized. + * + * alloc/sync pairs: + * + * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_PER_CPU : + * Per-cpu buffers with per-cpu synchronization. Tracing must be performed + * with preemption disabled (lib_ring_buffer_get_cpu() and + * lib_ring_buffer_put_cpu()). + * + * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_GLOBAL : + * Per-cpu buffer with global synchronization. Tracing can be performed with + * preemption enabled, statistically stays on the local buffers. + * + * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_PER_CPU : + * Should only be used for buffers belonging to a single thread or protected + * by mutual exclusion by the client. Note that periodical sub-buffer switch + * should be disabled in this kind of configuration. + * + * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_GLOBAL : + * Global shared buffer with global synchronization. + * + * wakeup: + * + * RING_BUFFER_WAKEUP_BY_TIMER uses per-cpu deferrable timers to poll the + * buffers and wake up readers if data is ready. Mainly useful for tracers which + * don't want to call into the wakeup code on the tracing path. Use in + * combination with "read_timer_interval" channel_create() argument. + * + * RING_BUFFER_WAKEUP_BY_WRITER directly wakes up readers when a subbuffer is + * ready to read. Lower latencies before the reader is woken up. Mainly suitable + * for drivers. + * + * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client + * has the responsibility to perform wakeups. + */ +struct lttng_ust_lib_ring_buffer_config { + enum { + RING_BUFFER_ALLOC_PER_CPU, + RING_BUFFER_ALLOC_GLOBAL, + } alloc; + enum { + RING_BUFFER_SYNC_PER_CPU, /* Wait-free */ + RING_BUFFER_SYNC_GLOBAL, /* Lock-free */ + } sync; + enum { + RING_BUFFER_OVERWRITE, /* Overwrite when buffer full */ + RING_BUFFER_DISCARD, /* Discard when buffer full */ + } mode; + enum { + RING_BUFFER_SPLICE, + RING_BUFFER_MMAP, + RING_BUFFER_READ, /* TODO */ + RING_BUFFER_ITERATOR, + RING_BUFFER_NONE, + } output; + enum { + RING_BUFFER_PAGE, + RING_BUFFER_VMAP, /* TODO */ + RING_BUFFER_STATIC, /* TODO */ + } backend; + enum { + RING_BUFFER_NO_OOPS_CONSISTENCY, + RING_BUFFER_OOPS_CONSISTENCY, + } oops; + enum { + RING_BUFFER_IPI_BARRIER, + RING_BUFFER_NO_IPI_BARRIER, + } ipi; + enum { + RING_BUFFER_WAKEUP_BY_TIMER, /* wake up performed by timer */ + RING_BUFFER_WAKEUP_BY_WRITER, /* + * writer wakes up reader, + * not lock-free + * (takes spinlock). + */ + } wakeup; + /* + * tsc_bits: timestamp bits saved at each record. + * 0 and 64 disable the timestamp compression scheme. + */ + unsigned int tsc_bits; + struct lttng_ust_lib_ring_buffer_client_cb cb; +}; + +/* + * ring buffer context + * + * Context passed to lib_ring_buffer_reserve(), lib_ring_buffer_commit(), + * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and + * lib_ring_buffer_write(). + */ +struct lttng_ust_lib_ring_buffer_ctx { + /* input received by lib_ring_buffer_reserve(), saved here. */ + struct channel *chan; /* channel */ + void *priv; /* client private data */ + struct lttng_ust_shm_handle *handle; /* shared-memory handle */ + size_t data_size; /* size of payload */ + int largest_align; /* + * alignment of the largest element + * in the payload + */ + int cpu; /* processor id */ + + /* output from lib_ring_buffer_reserve() */ + struct lttng_ust_lib_ring_buffer *buf; /* + * buffer corresponding to processor id + * for this channel + */ + size_t slot_size; /* size of the reserved slot */ + unsigned long buf_offset; /* offset following the record header */ + unsigned long pre_offset; /* + * Initial offset position _before_ + * the record is written. Positioned + * prior to record header alignment + * padding. + */ + u64 tsc; /* time-stamp counter value */ + unsigned int rflags; /* reservation flags */ +}; + +/** + * lib_ring_buffer_ctx_init - initialize ring buffer context + * @ctx: ring buffer context to initialize + * @chan: channel + * @priv: client private data + * @data_size: size of record data payload + * @largest_align: largest alignment within data payload types + * @cpu: processor id + */ +static inline +void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx, + struct channel *chan, void *priv, + size_t data_size, int largest_align, + int cpu, struct lttng_ust_shm_handle *handle) +{ + ctx->chan = chan; + ctx->priv = priv; + ctx->data_size = data_size; + ctx->largest_align = largest_align; + ctx->cpu = cpu; + ctx->rflags = 0; + ctx->handle = handle; +} + +/* + * Reservation flags. + * + * RING_BUFFER_RFLAG_FULL_TSC + * + * This flag is passed to record_header_size() and to the primitive used to + * write the record header. It indicates that the full 64-bit time value is + * needed in the record header. If this flag is not set, the record header needs + * only to contain "tsc_bits" bit of time value. + * + * Reservation flags can be added by the client, starting from + * "(RING_BUFFER_FLAGS_END << 0)". It can be used to pass information from + * record_header_size() to lib_ring_buffer_write_record_header(). + */ +#define RING_BUFFER_RFLAG_FULL_TSC (1U << 0) +#define RING_BUFFER_RFLAG_END (1U << 1) + +/* + * We need to define RING_BUFFER_ALIGN_ATTR so it is known early at + * compile-time. We have to duplicate the "config->align" information and the + * definition here because config->align is used both in the slow and fast + * paths, but RING_BUFFER_ALIGN_ATTR is only available for the client code. + */ +#ifdef RING_BUFFER_ALIGN + +# define RING_BUFFER_ALIGN_ATTR /* Default arch alignment */ + +/* + * Calculate the offset needed to align the type. + * size_of_type must be non-zero. + */ +static inline +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) +{ + return offset_align(align_drift, size_of_type); +} + +#else + +# define RING_BUFFER_ALIGN_ATTR __attribute__((packed)) + +/* + * Calculate the offset needed to align the type. + * size_of_type must be non-zero. + */ +static inline +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) +{ + return 0; +} + +#endif + +/** + * lib_ring_buffer_align_ctx - Align context offset on "alignment" + * @ctx: ring buffer context. + */ +static inline +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx, + size_t alignment) +{ + ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset, + alignment); +} + +/* + * lib_ring_buffer_check_config() returns 0 on success. + * Used internally to check for valid configurations at channel creation. + */ +static inline +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config, + unsigned int switch_timer_interval, + unsigned int read_timer_interval) +{ + if (config->alloc == RING_BUFFER_ALLOC_GLOBAL + && config->sync == RING_BUFFER_SYNC_PER_CPU + && switch_timer_interval) + return -EINVAL; + return 0; +} + +#include + +#endif /* _LINUX_RING_BUFFER_CONFIG_H */ diff --git a/include/lttng/share.h b/include/lttng/share.h new file mode 100644 index 00000000..cecfaa17 --- /dev/null +++ b/include/lttng/share.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * + * 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. + * + * 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 + */ + +#ifndef UST_SHARE_H +#define UST_SHARE_H + +/* write() */ +#include + +/* send() */ +#include +#include + +#include + +/* + * This write is patient because it restarts if it was incomplete. + */ + +static __inline__ ssize_t patient_write(int fd, const void *buf, size_t count) +{ + const char *bufc = (const char *) buf; + int result; + + for(;;) { + result = write(fd, bufc, count); + if (result == -1 && errno == EINTR) { + continue; + } + if (result <= 0) { + return result; + } + count -= result; + bufc += result; + + if (count == 0) { + break; + } + } + + return bufc-(const char *)buf; +} + +static __inline__ ssize_t patient_send(int fd, const void *buf, size_t count, int flags) +{ + const char *bufc = (const char *) buf; + int result; + + for(;;) { + result = send(fd, bufc, count, flags); + if (result == -1 && errno == EINTR) { + continue; + } + if (result <= 0) { + return result; + } + count -= result; + bufc += result; + + if (count == 0) { + break; + } + } + + return bufc - (const char *) buf; +} + +#endif /* UST_SHARE_H */ diff --git a/include/lttng/stringify.h b/include/lttng/stringify.h new file mode 100644 index 00000000..b8dfd90c --- /dev/null +++ b/include/lttng/stringify.h @@ -0,0 +1,29 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H +/* + * Copyright (C) 2009 Zhaolei + * + * 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 + */ + +/* Indirect stringification. Doing two levels allows the parameter to be a + * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) + +#endif /* !__LINUX_STRINGIFY_H */ diff --git a/include/lttng/tracepoint-event.h b/include/lttng/tracepoint-event.h new file mode 100644 index 00000000..65120d4b --- /dev/null +++ b/include/lttng/tracepoint-event.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2009 Steven Rostedt + * 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; + * 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 + * + * + * Trace files that want to automate creationg of all tracepoints defined + * in their file should include this file. The following are macros that the + * trace file may define: + * + * TRACEPOINT_SYSTEM defines the system the tracepoint is for: + * < [com_company_]project_[component_] > + * + * 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". + * + * TRACEPOINT_INCLUDE_PATH if the path is something other than within + * the system's include/tracepoint/ path, then this macro can define + * the path to use. This path is relative to tracepoint-event.h, or + * to the include search path. Trick: Use a + * #define TRACEPOINT_INCLUDE_PATH . + * combined with -Ipath_to_header as compiler argument to allow + * searching for a header within your project build tree. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef TRACEPOINT_CREATE_PROBES + +/* Prevent recursion */ +#undef TRACEPOINT_CREATE_PROBES + +#ifndef __tp_stringify +#define __tp_stringify_1(x...) #x +#define __tp_stringify(x...) __tp_stringify_1(x) +#endif + +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_NOARGS +#define TRACEPOINT_EVENT_NOARGS(name, fields) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_INCLUDE +#undef __TRACEPOINT_INCLUDE + +#ifndef TRACEPOINT_INCLUDE_FILE +# define TRACEPOINT_INCLUDE_FILE TRACEPOINT_SYSTEM +# define UNDEF_TRACEPOINT_INCLUDE_FILE +#endif + +#ifndef TRACEPOINT_INCLUDE_PATH +# define __TRACEPOINT_INCLUDE(system) +# define UNDEF_TRACEPOINT_INCLUDE_PATH +#else +# define __TRACEPOINT_INCLUDE(system) \ + __tp_stringify(TRACEPOINT_INCLUDE_PATH/system.h) +#endif + +# define TRACEPOINT_INCLUDE(system) __TRACEPOINT_INCLUDE(system) + +/* Let the trace headers be reread */ +#define TRACEPOINT_HEADER_MULTI_READ + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) + +#include + +#undef TRACEPOINT_EVENT +#undef TRACEPOINT_EVENT_CLASS +#undef TRACEPOINT_EVENT_INSTANCE +#undef TRACEPOINT_EVENT_NOARGS +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#undef TRACEPOINT_HEADER_MULTI_READ + +/* Only undef what we defined in this file */ +#ifdef UNDEF_TRACEPOINT_INCLUDE_FILE +# undef TRACEPOINT_INCLUDE_FILE +# undef UNDEF_TRACEPOINT_INCLUDE_FILE +#endif + +#ifdef UNDEF_TRACEPOINT_INCLUDE_PATH +# undef TRACEPOINT_INCLUDE_PATH +# undef UNDEF_TRACEPOINT_INCLUDE_PATH +#endif + +/* We may be processing more files */ +#define TRACEPOINT_CREATE_PROBES + +#endif /* TRACEPOINT_CREATE_PROBES */ + +#ifdef __cplusplus +} +#endif diff --git a/include/lttng/tracepoint-internal.h b/include/lttng/tracepoint-internal.h new file mode 100644 index 00000000..928eb4f3 --- /dev/null +++ b/include/lttng/tracepoint-internal.h @@ -0,0 +1,87 @@ +#ifndef _UST_TRACEPOINT_INTERNAL_H +#define _UST_TRACEPOINT_INTERNAL_H + +/* + * tracepoint-internal.h + * + * Tracepoint internal header. + * + * Copyright (C) 2008 Mathieu Desnoyers + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2009 Steven Rostedt + * + * 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 + * + * Heavily inspired from the Linux Kernel Markers. + * + * Ported to userspace by Pierre-Marc Fournier. + */ + +#include +#include +#include +#include + +struct tracepoint_lib { + struct tracepoint * const *tracepoints_start; + int tracepoints_count; + struct cds_list_head list; +}; + +extern int tracepoint_probe_register_noupdate(const char *name, void *probe, + void *data); +extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe, + void *data); +extern void tracepoint_probe_update_all(void); + +struct tracepoint_iter { + struct tracepoint_lib *lib; + struct tracepoint * const *tracepoint; +}; + +extern void tracepoint_iter_start(struct tracepoint_iter *iter); +extern void tracepoint_iter_next(struct tracepoint_iter *iter); +extern void tracepoint_iter_stop(struct tracepoint_iter *iter); +extern void tracepoint_iter_reset(struct tracepoint_iter *iter); +extern int tracepoint_get_iter_range(struct tracepoint * const **tracepoint, + struct tracepoint * const *begin, struct tracepoint * const *end); + +/* + * tracepoint_synchronize_unregister must be called between the last tracepoint + * probe unregistration and the end of module exit to make sure there is no + * caller executing a probe when it is freed. + */ +static inline void tracepoint_synchronize_unregister(void) +{ + synchronize_rcu(); +} + +struct trace_event_iter { + struct trace_event_lib *lib; + struct trace_event * const *trace_event; +}; + +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_stop(struct trace_event_iter *iter); +extern void trace_event_iter_reset(struct trace_event_iter *iter); + +extern void trace_event_update_process(void); +extern int is_trace_event_enabled(const char *channel, const char *name); + +extern void init_tracepoint(void); +extern void exit_tracepoint(void); + +#endif /* _UST_TRACEPOINT_INTERNAL_H */ diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h new file mode 100644 index 00000000..e39a3849 --- /dev/null +++ b/include/lttng/tracepoint.h @@ -0,0 +1,423 @@ +#ifndef _UST_TRACEPOINT_H +#define _UST_TRACEPOINT_H + +/* + * Copyright (C) 2008-2011 Mathieu Desnoyers + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2009 Steven Rostedt + * + * 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 + * + * Heavily inspired from the Linux Kernel Markers. + * + * Ported to userspace by Pierre-Marc Fournier. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct tracepoint_probe { + void *func; + void *data; +}; + +struct tracepoint { + const char *name; /* Tracepoint name */ + char state; /* State. */ + struct tracepoint_probe *probes; +}; + +/* + * Tracepoints should be added to the instrumented code using the + * "tracepoint()" macro. + */ +#define tracepoint(name, args...) __trace_##name(args) + +/* + * it_func[0] is never NULL because there is at least one element in the array + * when the array itself is non NULL. + */ +#define __DO_TRACE(tp, proto, args) \ + do { \ + struct tracepoint_probe *__tp_it_probe_ptr; \ + void *__tp_it_func; \ + void *__tp_cb_data; \ + \ + rcu_read_lock(); \ + __tp_it_probe_ptr = rcu_dereference((tp)->probes); \ + if (__tp_it_probe_ptr) { \ + do { \ + __tp_it_func = __tp_it_probe_ptr->func; \ + __tp_cb_data = __tp_it_probe_ptr->data; \ + URCU_FORCE_CAST(void(*)(proto), __tp_it_func)(args); \ + } while ((++__tp_it_probe_ptr)->func); \ + } \ + rcu_read_unlock(); \ + } while (0) + +#define TP_PARAMS(args...) args +#define TP_PROTO(args...) args +#define TP_ARGS(args...) args + +#define __CHECK_TRACE(name, proto, args) \ + do { \ + if (caa_unlikely(__tracepoint_##name.state)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(proto), TP_ARGS(args)); \ + } while (0) + +/* + * Make sure the alignment of the structure in the __tracepoints section will + * not add unwanted padding between the beginning of the section and the + * structure. Force alignment to the same alignment as the section start. + */ +#define __DECLARE_TRACEPOINT(name, proto, args, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void __trace_##name(proto) \ + { \ + __CHECK_TRACE(name, TP_PROTO(data_proto), \ + TP_ARGS(data_args)); \ + } \ + static inline int \ + __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)\ + { \ + return __tracepoint_probe_unregister(#name, (void *)probe, \ + data); \ + } + +/* + * The need for the _DECLARE_TRACEPOINT_NOARGS() is to handle the prototype + * (void). "void" is a special value in a function prototype and can + * not be combined with other arguments. Since the DECLARE_TRACEPOINT() + * macro adds a data element at the beginning of the prototype, + * we need a way to differentiate "(void *data, proto)" from + * "(void *data, void)". The second prototype is invalid. + * + * DECLARE_TRACEPOINT_NOARGS() passes "void" as the tracepoint prototype + * and "void *__tp_cb_data" as the callback prototype. + * + * DECLARE_TRACEPOINT() passes "proto" as the tracepoint protoype and + * "void *__tp_cb_data, proto" as the callback prototype. + */ +#define _DECLARE_TRACEPOINT_NOARGS(name) \ + __DECLARE_TRACEPOINT(name, void, , void *__tp_cb_data, __tp_cb_data) + +#define _DECLARE_TRACEPOINT(name, proto, args) \ + __DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args), \ + TP_PARAMS(void *__tp_cb_data, proto), \ + TP_PARAMS(__tp_cb_data, args)) + +/* + * __tracepoints_ptrs section is not const (read-only) to let the linker update + * the pointer, allowing PIC code. + */ +#define _DEFINE_TRACEPOINT(name) \ + static const char __tpstrtab_##name[] \ + __attribute__((section("__tracepoints_strings"))) = #name; \ + struct tracepoint __tracepoint_##name \ + __attribute__((section("__tracepoints"))) = \ + { __tpstrtab_##name, 0, NULL }; \ + static struct tracepoint * __tracepoint_ptr_##name \ + __attribute__((used, section("__tracepoints_ptrs"))) = \ + &__tracepoint_##name; + + +#define __register_tracepoint(name, probe, data) \ + __register_trace_##name(probe, data) +#define __unregister_tracepoint(name, probe, data) \ + __unregister_trace_##name(probe, data) + +/* + * Connect a probe to a tracepoint. + * Internal API. + */ +extern +int __tracepoint_probe_register(const char *name, void *probe, void *data); + +/* + * Disconnect a probe from a tracepoint. + * Internal API. + */ +extern +int __tracepoint_probe_unregister(const char *name, void *probe, void *data); + +extern +int tracepoint_register_lib(struct tracepoint * const *tracepoints_start, + int tracepoints_count); +extern +int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); + +/* + * These weak symbols, the constructor, and destructor take care of + * registering only _one_ instance of the tracepoints per shared-ojbect + * (or for the whole main program). + */ +extern struct tracepoint * const __start___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); +extern struct tracepoint * const __stop___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); +int __tracepoint_registered + __attribute__((weak, visibility("hidden"))); + +static void __attribute__((constructor)) __tracepoints__init(void) +{ + if (__tracepoint_registered++) + return; + tracepoint_register_lib(__start___tracepoints_ptrs, + __stop___tracepoints_ptrs - + __start___tracepoints_ptrs); +} + +static void __attribute__((destructor)) __tracepoints__destroy(void) +{ + if (--__tracepoint_registered) + return; + tracepoint_unregister_lib(__start___tracepoints_ptrs); +} + +#ifndef TRACEPOINT_EVENT +/* + * Usage of the TRACEPOINT_EVENT macro: + * + * In short, an example: + * + * TRACEPOINT_EVENT(< [com_company_]project_[component_]event >, + * TP_PROTO(int arg0, void *arg1, char *string, size_t strlen, + * long *arg4, size_t arg4_len), + * TP_ARGS(arg0, arg1, string, strlen, arg4, arg4_len), + * TP_FIELDS( + * + * * Integer, printed in base 10 * + * ctf_integer(int, field_a, arg0) + * + * * Integer, printed with 0x base 16 * + * ctf_integer_hex(unsigned long, field_d, arg1) + * + * * Array Sequence, printed as UTF8-encoded array of bytes * + * ctf_array_text(char, field_b, string, FIXED_LEN) + * ctf_sequence_text(char, field_c, string, size_t, strlen) + * + * * String, printed as UTF8-encoded string * + * ctf_string(field_e, string) + * + * * Array sequence of signed integer values * + * ctf_array(long, field_f, arg4, FIXED_LEN4) + * ctf_sequence(long, field_g, arg4, size_t, arg4_len) + * ) + * ) + * + * In more detail: + * + * We define a tracepoint, its arguments, and its 'fast binary record' + * layout. + * + * Firstly, name your tracepoint via TRACEPOINT_EVENT(name, + * + * The name should be a proper C99 identifier. + * The "name" MUST follow these rules to ensure no namespace clash + * occurs: + * + * For projects (applications and libraries) for which an entity + * specific to the project controls the source code and thus its + * tracepoints (typically with a scope larger than a single company): + * + * either: + * project_component_event + * or: + * project_event + * + * Where "project" is the name of the project, + * "component" is the name of the project component (which may + * include several levels of sub-components, e.g. + * ...component_subcomponent_...) where the tracepoint is located + * (optional), + * "event" is the name of the tracepoint event. + * + * For projects issued from a single company wishing to advertise that + * the company controls the source code and thus the tracepoints, the + * "com_" prefix should be used: + * + * either: + * com_company_project_component_event + * or: + * com_company_project_event + * + * Where "company" is the name of the company, + * "project" is the name of the project, + * "component" is the name of the project component (which may + * include several levels of sub-components, e.g. + * ...component_subcomponent_...) where the tracepoint is located + * (optional), + * "event" is the name of the tracepoint event. + * + * + * As an example, let's consider a user-space application "someproject" + * that would have an internal thread scheduler: + * + * TRACEPOINT_EVENT(someproject_sched_switch, + * + * * + * * A function has a regular function arguments + * * prototype, declare it via TP_PROTO(): + * * + * + * TP_PROTO(struct rq *rq, struct task_struct *prev, + * struct task_struct *next), + * + * * + * * Define the call signature of the 'function'. + * * (Design sidenote: we use this instead of a + * * TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.) + * * + * + * TP_ARGS(rq, prev, next), + * + * * + * * Fast binary tracing: define the trace record via + * * TP_FIELDS(). You can think about it like a + * * regular C structure local variable definition. + * * + * * This is how the trace record is structured and will + * * be saved into the ring buffer. These are the fields + * * that will be exposed to readers. + * * + * * ctf_integer(pid_t, prev_pid, prev->pid) is equivalent + * * to a standard declaraton: + * * + * * pid_t prev_pid; + * * + * * followed by an assignment: + * * + * * prev_pid = prev->pid; + * * + * * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) is + * * equivalent to: + * * + * * char prev_comm[TASK_COMM_LEN]; + * * + * * followed by an assignment: + * * + * * memcpy(prev_comm, prev->comm, TASK_COMM_LEN); + * * + * + * TP_FIELDS( + * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) + * ctf_integer(pid_t, prev_pid, prev->pid) + * ctf_integer(int, prev_prio, prev->prio) + * ctf_array(char, next_comm, next->comm, TASK_COMM_LEN) + * ctf_integer(pid_t, next_pid, next->pid) + * ctf_integer(int, next_prio, next->prio) + * ) + * ) + * + * Do _NOT_ add comma (,) nor semicolon (;) after the TRACEPOINT_EVENT + * declaration. + * + * The TRACEPOINT_SYSTEM must be defined when declaring a + * TRACEPOINT_EVENT. See ust/tracepoint-event.h for information about + * usage of other macros controlling TRACEPOINT_EVENT. + */ + +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) + +#define TRACEPOINT_EVENT_CLASS(name, proto, args, fields) +#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ + _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) + +/* + * Declaration of tracepoints that take 0 argument. + */ +#define TRACEPOINT_EVENT_NOARGS(name, fields) \ + _DECLARE_TRACEPOINT_NOARGS(name) + +#define TRACEPOINT_EVENT_CLASS_NOARGS(name, fields) +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ + _DECLARE_TRACEPOINT_NOARGS(name) + +#endif /* #ifndef TRACEPOINT_EVENT */ + +#ifndef TRACEPOINT_LOGLEVEL + +/* + * Tracepoint Loglevel Declaration Facility + * + * This is a place-holder the tracepoint loglevel declaration, + * overridden by the tracer implementation. + * + * Typical use of these loglevels: + * + * 1) Declare the mapping between loglevel names and an integer values + * within TRACEPOINT_LOGLEVEL_ENUM, using TP_LOGLEVEL for each tuple. + * Do _NOT_ add comma (,) nor semicolon (;) between the + * TRACEPOINT_LOGLEVEL_ENUM entries. Do _NOT_ add comma (,) nor + * semicolon (;) after the TRACEPOINT_LOGLEVEL_ENUM declaration. The + * name should be a proper C99 identifier. + * + * TRACEPOINT_LOGLEVEL_ENUM( + * TP_LOGLEVEL( < loglevel_name >, < value > ) + * TP_LOGLEVEL( < loglevel_name >, < value > ) + * ... + * ) + * + * e.g.: + * + * TRACEPOINT_LOGLEVEL_ENUM( + * TP_LOGLEVEL(LOG_EMERG, 0) + * TP_LOGLEVEL(LOG_ALERT, 1) + * TP_LOGLEVEL(LOG_CRIT, 2) + * TP_LOGLEVEL(LOG_ERR, 3) + * TP_LOGLEVEL(LOG_WARNING, 4) + * TP_LOGLEVEL(LOG_NOTICE, 5) + * TP_LOGLEVEL(LOG_INFO, 6) + * TP_LOGLEVEL(LOG_DEBUG, 7) + * ) + * + * 2) Then, declare tracepoint loglevels for tracepoints. A + * TRACEPOINT_EVENT should be declared prior to the the + * TRACEPOINT_LOGLEVEL for a given tracepoint name. The first field + * is the name of the tracepoint, the second field is the loglevel + * name. + * + * TRACEPOINT_LOGLEVEL(< [com_company_]project_[component_]event >, + * < loglevel_name >) + * + * The TRACEPOINT_SYSTEM must be defined when declaring a + * TRACEPOINT_LOGLEVEL_ENUM and TRACEPOINT_LOGLEVEL. The tracepoint + * loglevel enumeration apply to the entire TRACEPOINT_SYSTEM. Only one + * tracepoint loglevel enumeration should be declared per tracepoint + * system. + */ + +#define TRACEPOINT_LOGLEVEL_ENUM() +#define TRACEPOINT_LOGLEVEL(name, loglevel) + +#endif /* #ifndef TRACEPOINT_LOGLEVEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _UST_TRACEPOINT_H */ diff --git a/include/lttng/ust-abi.h b/include/lttng/ust-abi.h new file mode 100644 index 00000000..ced2929a --- /dev/null +++ b/include/lttng/ust-abi.h @@ -0,0 +1,158 @@ +#ifndef _LTTNG_UST_ABI_H +#define _LTTNG_UST_ABI_H + +/* + * lttng/ust-abi.h + * + * Copyright 2010-2011 (c) - Mathieu Desnoyers + * + * LTTng-UST ABI header + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include + +#define LTTNG_UST_SYM_NAME_LEN 128 + +#define LTTNG_UST_COMM_VERSION_MAJOR 0 +#define LTTNG_UST_COMM_VERSION_MINOR 1 + +enum lttng_ust_instrumentation { + LTTNG_UST_TRACEPOINT = 0, + LTTNG_UST_PROBE = 1, + LTTNG_UST_FUNCTION = 2, +}; + +enum lttng_ust_output { + LTTNG_UST_MMAP = 0, +}; + +struct lttng_ust_tracer_version { + uint32_t version; + uint32_t patchlevel; + uint32_t sublevel; +}; + +struct lttng_ust_channel { + int overwrite; /* 1: overwrite, 0: discard */ + uint64_t subbuf_size; /* in bytes */ + uint64_t num_subbuf; + unsigned int switch_timer_interval; /* usecs */ + unsigned int read_timer_interval; /* usecs */ + enum lttng_ust_output output; /* output mode */ + /* The following fields are used internally within UST. */ + int shm_fd; + int wait_fd; + uint64_t memory_map_size; +}; + +/* + * This structure is only used internally within UST. It is not per-se + * part of the communication between sessiond and UST. + */ +struct lttng_ust_stream { + int shm_fd; + int wait_fd; + uint64_t memory_map_size; +}; + +struct lttng_ust_event { + char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ + enum lttng_ust_instrumentation instrumentation; + /* Per instrumentation type configuration */ + union { + } u; +}; + +enum lttng_ust_context_type { + LTTNG_UST_CONTEXT_VTID = 0, + LTTNG_UST_CONTEXT_VPID = 1, + LTTNG_UST_CONTEXT_PTHREAD_ID = 2, + LTTNG_UST_CONTEXT_PROCNAME = 3, +}; + +struct lttng_ust_context { + enum lttng_ust_context_type ctx; + union { + } u; +}; + +/* + * Tracer channel attributes. + */ +struct lttng_ust_channel_attr { + int overwrite; /* 1: overwrite, 0: discard */ + uint64_t subbuf_size; /* bytes */ + uint64_t num_subbuf; /* power of 2 */ + unsigned int switch_timer_interval; /* usec */ + unsigned int read_timer_interval; /* usec */ + enum lttng_ust_output output; /* splice, mmap */ +}; + +struct lttng_ust_object_data { + int handle; + int shm_fd; + int wait_fd; + uint64_t memory_map_size; +}; + +#define _UST_CMD(minor) (minor) +#define _UST_CMDR(minor, type) (minor) +#define _UST_CMDW(minor, type) (minor) + +/* Handled by object descriptor */ +#define LTTNG_UST_RELEASE _UST_CMD(0x1) + +/* Handled by object cmd */ + +/* LTTng-UST commands */ +#define LTTNG_UST_SESSION _UST_CMD(0x40) +#define LTTNG_UST_TRACER_VERSION \ + _UST_CMDR(0x41, struct lttng_ust_tracer_version) +#define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42) +#define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43) +#define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44) + +/* Session FD commands */ +#define LTTNG_UST_METADATA \ + _UST_CMDW(0x50, struct lttng_ust_channel) +#define LTTNG_UST_CHANNEL \ + _UST_CMDW(0x51, struct lttng_ust_channel) +#define LTTNG_UST_SESSION_START _UST_CMD(0x52) +#define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) + +/* Channel FD commands */ +#define LTTNG_UST_STREAM _UST_CMD(0x60) +#define LTTNG_UST_EVENT \ + _UST_CMDW(0x61, struct lttng_ust_event) + +/* Event and Channel FD commands */ +#define LTTNG_UST_CONTEXT \ + _UST_CMDW(0x70, struct lttng_ust_context) +#define LTTNG_UST_FLUSH_BUFFER \ + _UST_CMD(0x71) + +/* Event, Channel and Session commands */ +#define LTTNG_UST_ENABLE _UST_CMD(0x80) +#define LTTNG_UST_DISABLE _UST_CMD(0x81) + +#define LTTNG_UST_ROOT_HANDLE 0 + +struct lttng_ust_obj; + +struct lttng_ust_objd_ops { + long (*cmd)(int objd, unsigned int cmd, unsigned long arg); + int (*release)(int objd); +}; + +/* Create root handle. Always ID 0. */ +int lttng_abi_create_root_handle(void); + +const struct lttng_ust_objd_ops *objd_ops(int id); +int lttng_ust_objd_unref(int id); + +void lttng_ust_abi_exit(void); +void lttng_ust_events_exit(void); + +#endif /* _LTTNG_UST_ABI_H */ diff --git a/include/lttng/ust-comm.h b/include/lttng/ust-comm.h new file mode 100644 index 00000000..5fa417ee --- /dev/null +++ b/include/lttng/ust-comm.h @@ -0,0 +1,174 @@ +#ifndef _LTTNG_UST_COMM_H +#define _LTTNG_UST_COMM_H + +/* + * Copyright (C) 2011 - David Goulet + * Julien Desfossez + * Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; only version 2 + * of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * This header is meant for liblttng and libust internal use ONLY. + * These declarations should NOT be considered stable API. + */ + +#include +#include +#include + +/* + * Default timeout the application waits for the sessiond to send its + * "register done" command. Can be overridden with the environment + * variable "UST_REGISTER_TIMEOUT". Note that if the sessiond is not + * found, the application proceeds directly without any delay. + */ +#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000 + +#define LTTNG_RUNDIR "/var/run/lttng" + +/* Default unix socket path */ +#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond" +#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond" +#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond" +#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond" + +#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait" +#define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u" + +/* Queue size of listen(2) */ +#define LTTNG_UST_COMM_MAX_LISTEN 10 + +/* Get the error code index from 0. USTCOMM_ERR starts at 1000. + */ +#define USTCOMM_ERR_INDEX(code) (code - USTCOMM_ERR) + +/* + * ustcomm error code. + */ +enum ustcomm_return_code { + USTCOMM_OK = 0, /* Ok */ + /* Range 1 to 999 used for standard error numbers (errno.h) */ + USTCOMM_ERR = 1000, /* Unknown Error */ + USTCOMM_UND, /* Undefine command */ + USTCOMM_NOT_IMPLEMENTED, /* Command not implemented */ + USTCOMM_UNKNOWN_DOMAIN, /* Tracing domain not known */ + USTCOMM_ALLOC_FAIL, /* Trace allocation fail */ + USTCOMM_NO_SESSION, /* No session found */ + USTCOMM_CREATE_FAIL, /* Create trace fail */ + USTCOMM_SESSION_FAIL, /* Create session fail */ + USTCOMM_START_FAIL, /* Start tracing fail */ + USTCOMM_STOP_FAIL, /* Stop tracing fail */ + USTCOMM_LIST_FAIL, /* Listing apps fail */ + USTCOMM_NO_APPS, /* No traceable application */ + USTCOMM_SESS_NOT_FOUND, /* Session name not found */ + USTCOMM_NO_TRACE, /* No trace exist */ + USTCOMM_FATAL, /* Session daemon had a fatal error */ + USTCOMM_NO_TRACEABLE, /* Error for non traceable app */ + USTCOMM_SELECT_SESS, /* Must select a session */ + USTCOMM_EXIST_SESS, /* Session name already exist */ + USTCOMM_NO_EVENT, /* No event found */ + USTCOMM_KERN_NA, /* Kernel tracer unavalable */ + USTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */ + USTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */ + USTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */ + USTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */ + USTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */ + USTCOMM_KERN_CHAN_ENABLE_FAIL, /* Kernel enable channel failed */ + USTCOMM_KERN_CONTEXT_FAIL, /* Kernel add context failed */ + USTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */ + USTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */ + USTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */ + USTCOMM_KERN_START_FAIL, /* Kernel start trace failed */ + USTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */ + USTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */ + USTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */ + USTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */ + USTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */ + USTCOMM_KERN_NO_SESSION, /* No kernel session found */ + USTCOMM_KERN_LIST_FAIL, /* Kernel listing events failed */ + USTCONSUMER_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */ + USTCONSUMER_SUCCESS_RECV_FD, /* success on receiving fds */ + USTCONSUMER_ERROR_RECV_FD, /* error on receiving fds */ + USTCONSUMER_POLL_ERROR, /* Error in polling thread in kconsumerd */ + USTCONSUMER_POLL_NVAL, /* Poll on closed fd */ + USTCONSUMER_POLL_HUP, /* All fds have hungup */ + USTCONSUMER_EXIT_SUCCESS, /* kconsumerd exiting normally */ + USTCONSUMER_EXIT_FAILURE, /* kconsumerd exiting on error */ + USTCONSUMER_OUTFD_ERROR, /* error opening the tracefile */ + USTCONSUMER_SPLICE_EBADF, /* EBADF from splice(2) */ + USTCONSUMER_SPLICE_EINVAL, /* EINVAL from splice(2) */ + USTCONSUMER_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ + USTCONSUMER_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ + /* MUST be last element */ + USTCOMM_NR, /* Last element */ +}; + +/* + * Data structure for the commands sent from sessiond to UST. + */ +struct ustcomm_ust_msg { + uint32_t handle; + uint32_t cmd; + union { + struct lttng_ust_channel channel; + struct lttng_ust_stream stream; + struct lttng_ust_event event; + struct lttng_ust_context context; + struct lttng_ust_tracer_version version; + } u; +}; + +/* + * Data structure for the response from UST to the session daemon. + * cmd_type is sent back in the reply for validation. + */ +struct ustcomm_ust_reply { + uint32_t handle; + uint32_t cmd; + uint32_t ret_code; /* enum enum ustcomm_return_code */ + uint32_t ret_val; /* return value */ + union { + struct { + uint64_t memory_map_size; + } channel; + struct { + uint64_t memory_map_size; + } stream; + struct lttng_ust_tracer_version version; + } u; +}; + +extern int ustcomm_create_unix_sock(const char *pathname); +extern int ustcomm_connect_unix_sock(const char *pathname); +extern int ustcomm_accept_unix_sock(int sock); +extern int ustcomm_listen_unix_sock(int sock); +extern int ustcomm_close_unix_sock(int sock); +/* Send fd(s) over a unix socket. */ +extern ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, + size_t nb_fd, size_t len); +extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len); +extern ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len); +extern const char *ustcomm_get_readable_code(int code); +extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum); +extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur, + uint32_t expected_handle, uint32_t expected_cmd); +extern int ustcomm_send_app_cmd(int sock, + struct ustcomm_ust_msg *lum, + struct ustcomm_ust_reply *lur); +int ustcomm_recv_fd(int sock); + +#endif /* _LTTNG_UST_COMM_H */ diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h new file mode 100644 index 00000000..fc6671d4 --- /dev/null +++ b/include/lttng/ust-ctl.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2011 - Julien Desfossez + * Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; only version 2 + * of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _LTTNG_UST_CTL_H +#define _LTTNG_UST_CTL_H + +#include + +int ustctl_register_done(int sock); +int ustctl_create_session(int sock); +int ustctl_open_metadata(int sock, int session_handle, + struct lttng_ust_channel_attr *chops, + struct lttng_ust_object_data **metadata_data); +int ustctl_create_channel(int sock, int session_handle, + struct lttng_ust_channel_attr *chops, + struct lttng_ust_object_data **channel_data); +int ustctl_create_stream(int sock, struct lttng_ust_object_data *channel_data, + struct lttng_ust_object_data **stream_data); +int ustctl_create_event(int sock, struct lttng_ust_event *ev, + struct lttng_ust_object_data *channel_data, + struct lttng_ust_object_data **event_data); +int ustctl_add_context(int sock, struct lttng_ust_context *ctx, + struct lttng_ust_object_data *obj_data, + struct lttng_ust_object_data **context_data); + +int ustctl_enable(int sock, struct lttng_ust_object_data *object); +int ustctl_disable(int sock, struct lttng_ust_object_data *object); +int ustctl_start_session(int sock, int handle); +int ustctl_stop_session(int sock, int handle); + +int ustctl_tracepoint_list(int sock); /* not implemented yet */ +int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); +int ustctl_wait_quiescent(int sock); + +/* Flush each buffers in this channel */ +int ustctl_flush_buffer(int sock, struct lttng_ust_object_data *channel_data); + +/* not implemented yet */ +struct lttng_ust_calibrate; +int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate); + +/* + * Map channel lttng_ust_shm_handle and add streams. Typically performed by the + * consumer to map the objects into its memory space. + */ +struct lttng_ust_shm_handle *ustctl_map_channel(struct lttng_ust_object_data *chan_data); +int ustctl_add_stream(struct lttng_ust_shm_handle *lttng_ust_shm_handle, + struct lttng_ust_object_data *stream_data); +/* + * Note: the lttng_ust_object_data from which the lttng_ust_shm_handle is derived can only + * be released after unmapping the handle. + */ +void ustctl_unmap_channel(struct lttng_ust_shm_handle *lttng_ust_shm_handle); + +/* Buffer operations */ + +struct lttng_ust_shm_handle; +struct lttng_ust_lib_ring_buffer; + +/* Open/close stream buffers for read */ +struct lttng_ust_lib_ring_buffer *ustctl_open_stream_read(struct lttng_ust_shm_handle *handle, + int cpu); +void ustctl_close_stream_read(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); + +/* For mmap mode, readable without "get" operation */ +int ustctl_get_mmap_len(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, + unsigned long *len); +int ustctl_get_max_subbuf_size(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, + unsigned long *len); + +/* + * For mmap mode, operate on the current packet (between get/put or + * get_next/put_next). + */ +void *ustctl_get_mmap_base(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); +int ustctl_get_mmap_read_offset(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *off); +int ustctl_get_subbuf_size(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *len); +int ustctl_get_padded_subbuf_size(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *len); +int ustctl_get_next_subbuf(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); +int ustctl_put_next_subbuf(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); + +/* snapshot */ + +int ustctl_snapshot(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); +int ustctl_snapshot_get_consumed(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); +int ustctl_snapshot_get_produced(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); +int ustctl_get_subbuf(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); +int ustctl_put_subbuf(struct lttng_ust_shm_handle *handle, + struct lttng_ust_lib_ring_buffer *buf); + +/* Release object created by members of this API */ +void release_object(int sock, struct lttng_ust_object_data *data); + +#endif /* _LTTNG_UST_CTL_H */ diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h new file mode 100644 index 00000000..95af893a --- /dev/null +++ b/include/lttng/ust-events.h @@ -0,0 +1,331 @@ +#ifndef _UST_LTTNG_EVENTS_H +#define _UST_LTTNG_EVENTS_H + +/* + * ust/lttng-events.h + * + * Copyright 2010 (c) - Mathieu Desnoyers + * + * Holds LTTng per-session event registry. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct ltt_channel; +struct ltt_session; +struct lttng_ust_lib_ring_buffer_ctx; + +/* Type description */ + +/* Update the astract_types name table in lttng-types.c along with this enum */ +enum abstract_types { + atype_integer, + atype_enum, + atype_array, + atype_sequence, + atype_string, + atype_float, + NR_ABSTRACT_TYPES, +}; + +/* Update the string_encodings name table in lttng-types.c along with this enum */ +enum lttng_string_encodings { + lttng_encode_none = 0, + lttng_encode_UTF8 = 1, + lttng_encode_ASCII = 2, + NR_STRING_ENCODINGS, +}; + +struct lttng_enum_entry { + unsigned long long start, end; /* start and end are inclusive */ + const char *string; +}; + +#define __type_integer(_type, _byte_order, _base, _encoding) \ + { \ + .atype = atype_integer, \ + .u.basic.integer = \ + { \ + .size = sizeof(_type) * CHAR_BIT, \ + .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, \ + }, \ + } \ + +struct lttng_integer_type { + unsigned int size; /* in bits */ + unsigned short alignment; /* in bits */ + unsigned int signedness:1; + unsigned int reverse_byte_order:1; + unsigned int base; /* 2, 8, 10, 16, for pretty print */ + enum lttng_string_encodings encoding; +}; + +/* + * Only float and double are supported. long double is not supported at + * the moment. + */ +#define _float_mant_dig(_type) \ + (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ + : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ + : 0)) + +#define __type_float(_type) \ + { \ + .atype = atype_float, \ + .u.basic._float = \ + { \ + .exp_dig = sizeof(_type) * CHAR_BIT \ + - _float_mant_dig(_type), \ + .mant_dig = _float_mant_dig(_type), \ + .alignment = lttng_alignof(_type) * CHAR_BIT, \ + .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \ + }, \ + } \ + +struct lttng_float_type { + unsigned int exp_dig; /* exponent digits, in bits */ + unsigned int mant_dig; /* mantissa digits, in bits */ + unsigned short alignment; /* in bits */ + unsigned int reverse_byte_order:1; +}; + +union _lttng_basic_type { + struct lttng_integer_type integer; + struct { + const char *name; + } enumeration; + struct { + enum lttng_string_encodings encoding; + } string; + struct lttng_float_type _float; +}; + +struct lttng_basic_type { + enum abstract_types atype; + union { + union _lttng_basic_type basic; + } u; +}; + +struct lttng_type { + enum abstract_types atype; + union { + union _lttng_basic_type basic; + struct { + struct lttng_basic_type elem_type; + unsigned int length; /* num. elems. */ + } array; + struct { + struct lttng_basic_type length_type; + struct lttng_basic_type elem_type; + } sequence; + } u; +}; + +struct lttng_enum { + const char *name; + struct lttng_type container_type; + const struct lttng_enum_entry *entries; + unsigned int len; +}; + +/* Event field description */ + +struct lttng_event_field { + const char *name; + struct lttng_type type; +}; + +struct lttng_ctx_field { + struct lttng_event_field event_field; + size_t (*get_size)(size_t offset); + void (*record)(struct lttng_ctx_field *field, + struct lttng_ust_lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan); + union { + } u; + void (*destroy)(struct lttng_ctx_field *field); +}; + +struct lttng_ctx { + struct lttng_ctx_field *fields; + unsigned int nr_fields; + unsigned int allocated_fields; +}; + +struct lttng_event_desc { + const char *name; + void *probe_callback; + const struct lttng_event_ctx *ctx; /* context */ + const struct lttng_event_field *fields; /* event payload */ + unsigned int nr_fields; +}; + +struct lttng_probe_desc { + const struct lttng_event_desc *event_desc; + unsigned int nr_events; + struct cds_list_head head; /* chain registered probes */ +}; + +struct ust_pending_probe; + +/* + * ltt_event structure is referred to by the tracing fast path. It must be + * kept small. + */ +struct ltt_event { + unsigned int id; + struct ltt_channel *chan; + int enabled; + const struct lttng_event_desc *desc; + void *filter; + struct lttng_ctx *ctx; + enum lttng_ust_instrumentation instrumentation; + union { + } u; + struct cds_list_head list; /* Event list */ + struct ust_pending_probe *pending_probe; + int metadata_dumped:1; +}; + +struct channel; +struct lttng_ust_shm_handle; + +struct ltt_channel_ops { + struct ltt_channel *(*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 *shm_fd, int *wait_fd, + uint64_t *memory_map_size); + void (*channel_destroy)(struct ltt_channel *ltt_chan); + struct lttng_ust_lib_ring_buffer *(*buffer_read_open)(struct channel *chan, + struct lttng_ust_shm_handle *handle, + int *shm_fd, int *wait_fd, + uint64_t *memory_map_size); + void (*buffer_read_close)(struct lttng_ust_lib_ring_buffer *buf, + struct lttng_ust_shm_handle *handle); + int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, + uint32_t event_id); + void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); + void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, const void *src, + size_t len); + /* + * packet_avail_size returns the available size in the current + * packet. Note that the size returned is only a hint, since it + * may change due to concurrent writes. + */ + size_t (*packet_avail_size)(struct channel *chan, + struct lttng_ust_shm_handle *handle); + //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan); + //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); + int (*is_finalized)(struct channel *chan); + int (*is_disabled)(struct channel *chan); + int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); +}; + +struct ltt_channel { + unsigned int id; + struct channel *chan; /* Channel buffers */ + int enabled; + struct lttng_ctx *ctx; + /* Event ID management */ + struct ltt_session *session; + int objd; /* Object associated to channel */ + unsigned int free_event_id; /* Next event ID to allocate */ + unsigned int used_event_id; /* Max allocated event IDs */ + struct cds_list_head list; /* Channel list */ + struct ltt_channel_ops *ops; + int header_type; /* 0: unset, 1: compact, 2: large */ + struct lttng_ust_shm_handle *handle; /* shared-memory handle */ + int metadata_dumped:1; +}; + +struct ltt_session { + int active; /* Is trace session active ? */ + int been_active; /* Has trace session been active ? */ + int objd; /* Object associated to session */ + struct ltt_channel *metadata; /* Metadata channel */ + struct cds_list_head chan; /* Channel list head */ + struct cds_list_head events; /* Event list head */ + struct cds_list_head list; /* Session list */ + unsigned int free_chan_id; /* Next chan ID to allocate */ + uuid_t uuid; /* Trace session unique ID */ + int metadata_dumped:1; +}; + +struct ltt_transport { + char *name; + struct cds_list_head node; + struct ltt_channel_ops ops; +}; + +struct ltt_session *ltt_session_create(void); +int ltt_session_enable(struct ltt_session *session); +int ltt_session_disable(struct ltt_session *session); +void ltt_session_destroy(struct ltt_session *session); + +struct ltt_channel *ltt_channel_create(struct ltt_session *session, + const char *transport_name, + void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval, + int *shm_fd, int *wait_fd, + uint64_t *memory_map_size); +struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, + int overwrite, void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval, + int *shm_fd, int *wait_fd, + uint64_t *memory_map_size); + +struct ltt_event *ltt_event_create(struct ltt_channel *chan, + struct lttng_ust_event *event_param, + void *filter); + +int ltt_channel_enable(struct ltt_channel *channel); +int ltt_channel_disable(struct ltt_channel *channel); +int ltt_event_enable(struct ltt_event *event); +int ltt_event_disable(struct ltt_event *event); + +void ltt_transport_register(struct ltt_transport *transport); +void ltt_transport_unregister(struct ltt_transport *transport); + +void synchronize_trace(void); + +int ltt_probe_register(struct lttng_probe_desc *desc); +void ltt_probe_unregister(struct lttng_probe_desc *desc); +int pending_probe_fix_events(const struct lttng_event_desc *desc); +const struct lttng_event_desc *ltt_event_get(const char *name); +void ltt_event_put(const struct lttng_event_desc *desc); +int ltt_probes_init(void); +void ltt_probes_exit(void); +int lttng_find_context(struct lttng_ctx *ctx, const char *name); +struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p); +void lttng_remove_context_field(struct lttng_ctx **ctx_p, + struct lttng_ctx_field *field); +void lttng_destroy_context(struct lttng_ctx *ctx); +int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx); +int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); +void lttng_context_vtid_reset(void); +void lttng_context_vpid_reset(void); + +#endif /* _UST_LTTNG_EVENTS_H */ diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h new file mode 100644 index 00000000..9485ee0e --- /dev/null +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -0,0 +1,46 @@ +/* + * lttng/ust-tracepoint-events-reset.h + * + * Copyright (C) 2010-2011 Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +/* Reset macros used within TRACEPOINT_EVENT to "nothing" */ + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) + +#undef ctf_float +#define ctf_float(_type, _item, _src) + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) + +#undef ctf_string +#define ctf_string(_item, _src) + +#undef TP_PROTO +#define TP_PROTO(args...) + +#undef TP_ARGS +#define TP_ARGS(args...) + +#undef TP_FIELDS +#define TP_FIELDS(args...) + +#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/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h new file mode 100644 index 00000000..b9abbd31 --- /dev/null +++ b/include/lttng/ust-tracepoint-event.h @@ -0,0 +1,520 @@ +/* + * Copyright (C) 2009 Steven Rostedt + * 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; + * 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 + */ + +#include +#include +#include +#include +#include + +/* + * Macro declarations used for all stages. + */ + +#undef ctf_integer +#define ctf_integer(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10) + +#undef ctf_integer_hex +#define ctf_integer_hex(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16) + +#undef ctf_integer_network +#define ctf_integer_network(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10) + +#undef ctf_integer_network_hex +#define ctf_integer_network_hex(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16) + +/* ctf_float is redefined at each step */ + +#undef ctf_array +#define ctf_array(_type, _item, _src, _length) \ + ctf_array_encoded(_type, _item, _src, _length, none) + +#undef ctf_array_text +#define ctf_array_text(_type, _item, _src, _length) \ + ctf_array_encoded(_type, _item, _src, _length, UTF8) + +#undef ctf_sequence +#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ + ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, none) + +#undef ctf_sequence_text +#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ + ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, UTF8) + +/* ctf_string is redefined at each step */ + +/* + * TRACEPOINT_EVENT_CLASS can be used to add a generic function handlers + * for events. That is, if all events have the same parameters and just + * have distinct trace points. Each tracepoint can be defined with + * TRACEPOINT_EVENT_INSTANCE and that will map the + * TRACEPOINT_EVENT_CLASS to the tracepoint. + * + * TRACEPOINT_EVENT is a one to one mapping between tracepoint and + * template. + */ + +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + TRACEPOINT_EVENT_CLASS(name, \ + TP_PARAMS(proto), \ + TP_PARAMS(args), \ + 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])) + +#define _tp_max_t(type, x, y) \ + ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1: __max2; \ + }) + + +/* + * Stage 1 of the trace events. + * + * Create event field type metadata section. + * Each event produce an array of fields. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + { \ + .name = #_item, \ + .type = __type_integer(_type, _byte_order, _base, none),\ + }, + +#undef ctf_float +#define ctf_float(_type, _item, _src) \ + { \ + .name = #_item, \ + .type = __type_float(_type), \ + }, + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_array, \ + .u.array = \ + { \ + .length = _length, \ + .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ + }, \ + }, \ + }, + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, _encoding) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_sequence, \ + .u.sequence = \ + { \ + .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ + .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ + }, \ + }, \ + }, + +#undef ctf_string +#define ctf_string(_item, _src) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_string, \ + .u.basic.string.encoding = lttng_encode_UTF8, \ + }, \ + }, + +#undef TP_FIELDS +#define TP_FIELDS(args...) args /* Only one used in this phase */ + +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ + static const struct lttng_event_field __event_fields___##_name[] = { \ + _fields \ + }; + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ + TRACEPOINT_EVENT_CLASS_NOARGS(_name, TP_PARAMS(_fields)) + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) + +/* + * Stage 2 of the trace events. + * + * Create probe callback prototypes. + */ + +/* 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) \ +static void __event_probe__##_name(void *__data, _proto); + +#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. + * + * Create an array of events. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#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 = _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___, TRACEPOINT_SYSTEM)[] = { +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) +}; + +#undef TP_ID1 +#undef TP_ID + + +/* + * Stage 4 of the trace events. + * + * Create a toplevel descriptor for the whole probe. + */ + +#define TP_ID1(_token, _system) _token##_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___, TRACEPOINT_SYSTEM) = { + .event_desc = TP_ID(__event_desc___, TRACEPOINT_SYSTEM), + .nr_events = _TP_ARRAY_SIZE(TP_ID(__event_desc___, TRACEPOINT_SYSTEM)), +}; + +#undef TP_ID1 +#undef TP_ID + +/* + * Stage 5 of the trace events. + * + * Create static inline function that calculates event size. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + __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, lttng_alignof(_type)); \ + __event_len += sizeof(_type); + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ + __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, lttng_alignof(_length_type)); \ + __event_len += sizeof(_length_type); \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ + __dynamic_len[__dynamic_len_idx] = (_src_length); \ + __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ + __dynamic_len_idx++; + +#undef ctf_string +#define ctf_string(_item, _src) \ + __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ +{ \ + 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. + * + * Create static inline function that calculates event payload alignment. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); + +#undef ctf_float +#define ctf_float(_type, _item, _src) \ + __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ + __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 = _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) + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static inline size_t __event_get_align__##_name(_proto) \ +{ \ + size_t __event_align = 1; \ + _fields \ + return __event_align; \ +} + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) + + +/* + * Stage 7 of the trace events. + * + * Create the probe function : call even size calculation and write event data + * into the buffer. + * + * We use both the field and assignment macros to write the fields in the order + * defined in the field declaration. The field declarations control the + * execution order, jumping to the appropriate assignment block. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + { \ + _type __tmp = (_src); \ + lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ + __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ + } + +#undef ctf_float +#define ctf_float(_type, _item, _src) \ + { \ + _type __tmp = (_src); \ + 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, _encoding) \ + lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ + __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) \ + { \ + _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ + 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, lttng_alignof(_type)); \ + __chan->ops->event_write(&__ctx, _src, \ + sizeof(_type) * __get_dynamic_len(dest)); + +#undef ctf_string +#define ctf_string(_item, _src) \ + lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ + __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest)); + +/* Beware: this get len actually consumes the len value */ +#undef __get_dynamic_len +#define __get_dynamic_len(field) __dynamic_len[__dynamic_len_idx++] + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_ARGS +#define TP_ARGS(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static void __event_probe__##_name(void *__data, _proto) \ +{ \ + struct ltt_event *__event = __data; \ + struct ltt_channel *__chan = __event->chan; \ + struct lttng_ust_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 (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ + return; \ + if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ + return; \ + if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ + return; \ + __event_len = __event_get_size__##_name(__dynamic_len, _args); \ + __event_align = __event_get_align__##_name(_args); \ + lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ + __event_align, -1, __chan->handle); \ + __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ + if (__ret < 0) \ + return; \ + _fields \ + __chan->ops->event_commit(&__ctx); \ +} + +#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 lttng_ust_lib_ring_buffer_ctx __ctx; \ + size_t __event_len, __event_align; \ + int __ret; \ + \ + if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ + return; \ + if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ + return; \ + if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ + return; \ + __event_len = 0; \ + __event_align = 1; \ + lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ + __event_align, -1, __chan->handle); \ + __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ + if (__ret < 0) \ + return; \ + _fields \ + __chan->ops->event_commit(&__ctx); \ +} + +#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) + +#undef __get_dynamic_len + +/* + * Stage 8 of the trace events. + * + * Register/unregister probes at module load/unload. + */ + +/* 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__, TRACEPOINT_SYSTEM)(void) +{ + int ret; + + ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); + assert(!ret); +} + +static void __attribute__((destructor)) +TP_ID(__lttng_events_exit__, TRACEPOINT_SYSTEM)(void) +{ + ltt_probe_unregister(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); +} + +#undef TP_ID1 +#undef TP_ID diff --git a/include/lttng/ust-tracer.h b/include/lttng/ust-tracer.h new file mode 100644 index 00000000..234e75c0 --- /dev/null +++ b/include/lttng/ust-tracer.h @@ -0,0 +1,47 @@ +#ifndef _LTTNG_TRACER_H +#define _LTTNG_TRACER_H + +/* + * Copyright (C) 2005-2011 Mathieu Desnoyers + * + * This contains the core definitions for the Linux Trace Toolkit. + * + * 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 + */ + +#include + +#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS +/* Align data on its natural alignment */ +#define RING_BUFFER_ALIGN +#endif + +#define LTTNG_UST_VERSION 0 +#define LTTNG_UST_PATCHLEVEL 9 +#define LTTNG_UST_SUBLEVEL 1 + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + +#ifdef RING_BUFFER_ALIGN +#define lttng_alignof(type) __alignof__(type) +#else +#define lttng_alignof(type) 1 +#endif + +#define lttng_is_signed_type(type) (((type)(-1)) < 0) + +#endif /* _LTTNG_TRACER_CORE_H */ diff --git a/include/lttng/ust.h b/include/lttng/ust.h new file mode 100644 index 00000000..593598b4 --- /dev/null +++ b/include/lttng/ust.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 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; 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 + */ + +#ifndef _UST_H +#define _UST_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ust_fork_info { + sigset_t orig_sigs; +} ust_fork_info_t; + +extern void ust_before_fork(ust_fork_info_t *fork_info); +extern void ust_after_fork_parent(ust_fork_info_t *fork_info); +extern void ust_after_fork_child(ust_fork_info_t *fork_info); + +#ifdef __cplusplus +} +#endif + +#endif /* _UST_H */ diff --git a/include/lttng/usterr-signal-safe.h b/include/lttng/usterr-signal-safe.h new file mode 100644 index 00000000..894149a3 --- /dev/null +++ b/include/lttng/usterr-signal-safe.h @@ -0,0 +1,159 @@ +#ifndef _USTERR_SIGNAL_SAFE_H +#define _USTERR_SIGNAL_SAFE_H + +/* + * Copyright (C) 2009 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; 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 + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +enum ust_loglevel { + UST_LOGLEVEL_UNKNOWN = 0, + UST_LOGLEVEL_NORMAL, + UST_LOGLEVEL_DEBUG, +}; + +extern volatile enum ust_loglevel ust_loglevel; +void init_usterr(void); + +static inline int ust_debug(void) +{ + return ust_loglevel == UST_LOGLEVEL_DEBUG; +} + +#ifndef UST_COMPONENT +//#error UST_COMPONENT is undefined +#define UST_COMPONENT libust +#endif + +/* To stringify the expansion of a define */ +#define UST_XSTR(d) UST_STR(d) +#define UST_STR(s) #s + +#define USTERR_MAX_LEN 512 + +/* 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. + */ + +extern int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...) + __attribute__ ((format (printf, 3, 4))); + +static inline void __attribute__ ((format (printf, 1, 2))) + __check_ust_safe_fmt(const char *fmt, ...) +{ +} + +#define sigsafe_print_err(fmt, args...) \ +{ \ + /* Can't use dynamic allocation. Limit ourselves to USTERR_MAX_LEN chars. */ \ + char ____buf[USTERR_MAX_LEN]; \ + int ____saved_errno; \ + \ + /* Save the errno. */ \ + ____saved_errno = errno; \ + \ + ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \ + \ + /* Add end of string in case of buffer overflow. */ \ + ____buf[sizeof(____buf) - 1] = 0; \ + \ + patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \ + /* \ + * Can't print errors because we are in the error printing code \ + * path. \ + */ \ + \ + /* Restore errno, in order to be async-signal safe. */ \ + errno = ____saved_errno; \ +} + +#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__ ":" UST_XSTR(__LINE__) ")\n", \ + (long) getpid(), \ + (long) syscall(SYS_gettid), \ + ## args, __func__); \ + fflush(stderr); \ + } while(0) + +#ifdef UST_DEBUG +# define DBG(fmt, args...) ERRMSG(fmt, ## args) +# define DBG_raw(fmt, args...) \ + do { \ + sigsafe_print_err(fmt, ## args); \ + fflush(stderr); \ + } while(0) +#else +# define DBG(fmt, args...) \ + do { \ + if (ust_debug()) \ + ERRMSG(fmt, ## args); \ + } while (0) +# define DBG_raw(fmt, args...) \ + do { \ + if (ust_debug()) { \ + sigsafe_print_err(fmt, ## args); \ + fflush(stderr); \ + } \ + } while(0) +#endif +#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args) +#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args) +#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args) + +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) +#define PERROR(call, args...)\ + do { \ + char buf[200] = "Error in strerror_r()"; \ + strerror_r(errno, buf, sizeof(buf)); \ + ERRMSG("Error: " call ": %s", ## args, buf); \ + } while(0); +#else +#define PERROR(call, args...)\ + do { \ + char *buf; \ + char tmp[200]; \ + buf = strerror_r(errno, tmp, sizeof(tmp)); \ + ERRMSG("Error: " call ": %s", ## args, buf); \ + } while(0); +#endif + +#define BUG_ON(condition) \ + do { \ + if (caa_unlikely(condition)) \ + ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \ + } while(0) +#define WARN_ON(condition) \ + do { \ + if (caa_unlikely(condition)) \ + WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \ + } while(0) +#define WARN_ON_ONCE(condition) WARN_ON(condition) + +#endif /* _USTERR_SIGNAL_SAFE_H */ diff --git a/include/lttng/vatomic.h b/include/lttng/vatomic.h new file mode 100644 index 00000000..a477d4c9 --- /dev/null +++ b/include/lttng/vatomic.h @@ -0,0 +1,74 @@ +#ifndef _LINUX_RING_BUFFER_VATOMIC_H +#define _LINUX_RING_BUFFER_VATOMIC_H + +/* + * linux/ringbuffer/vatomic.h + * + * Copyright (C) 2010 - Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include + +/* + * Same data type (long) accessed differently depending on configuration. + * v field is for non-atomic access (protected by mutual exclusion). + * In the fast-path, the ring_buffer_config structure is constant, so the + * compiler can statically select the appropriate branch. + * local_t is used for per-cpu and per-thread buffers. + * atomic_long_t is used for globally shared buffers. + */ +union v_atomic { + long a; /* accessed through uatomic */ + long v; +}; + +static inline +long v_read(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) +{ + assert(config->sync != RING_BUFFER_SYNC_PER_CPU); + return uatomic_read(&v_a->a); +} + +static inline +void v_set(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a, + long v) +{ + assert(config->sync != RING_BUFFER_SYNC_PER_CPU); + uatomic_set(&v_a->a, v); +} + +static inline +void v_add(const struct lttng_ust_lib_ring_buffer_config *config, long v, union v_atomic *v_a) +{ + assert(config->sync != RING_BUFFER_SYNC_PER_CPU); + uatomic_add(&v_a->a, v); +} + +static inline +void v_inc(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) +{ + assert(config->sync != RING_BUFFER_SYNC_PER_CPU); + uatomic_inc(&v_a->a); +} + +/* + * Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer. + */ +static inline +void _v_dec(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) +{ + --v_a->v; +} + +static inline +long v_cmpxchg(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a, + long old, long _new) +{ + assert(config->sync != RING_BUFFER_SYNC_PER_CPU); + return uatomic_cmpxchg(&v_a->a, old, _new); +} + +#endif /* _LINUX_RING_BUFFER_VATOMIC_H */ diff --git a/include/lttng/version.h.in b/include/lttng/version.h.in new file mode 100644 index 00000000..d65b9209 --- /dev/null +++ b/include/lttng/version.h.in @@ -0,0 +1,28 @@ +#ifndef _UST_VERSION_H +#define _UST_VERSION_H + +/* + * ust/version.h.in. Contains the UST versions + * + * (C) Copyright 2011 Yannick Brosseau + * + * 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 UST_MAJOR_VERSION @MAJOR_VERSION@ +#define UST_MINOR_VERSION @MINOR_VERSION@ +#define UST_VERSION @PACKAGE_VERSION@ + +#endif /* _UST_VERSION_H */ diff --git a/include/lttng/wait.h b/include/lttng/wait.h new file mode 100644 index 00000000..6cc0e373 --- /dev/null +++ b/include/lttng/wait.h @@ -0,0 +1,50 @@ +#ifndef _UST_WAIT_H +#define _UST_WAIT_H + +/* + * 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; 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 + */ + +#include + +/* + * Wait until "cond" gets true or timeout (in ms). + */ +#define wait_cond_interruptible_timeout(_cond, _timeout) \ + ({ \ + int __ret = 0, __pollret; \ + int __timeout = _timeout; \ + \ + for (;;) { \ + if (_cond) \ + break; \ + if (__timeout <= 0) { \ + __ret = -ETIMEDOUT; \ + break; \ + } \ + __pollret = poll(NULL, 0, 10); /* wait 10ms */ \ + if (__pollret < 0) { \ + __ret = -errno; \ + break; \ + } \ + __timeout -= 10; \ + } \ + __ret; \ + }) + + +#endif /* _UST_WAIT_H */ diff --git a/include/ust/align.h b/include/ust/align.h deleted file mode 100644 index cd713cc2..00000000 --- a/include/ust/align.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _UST_ALIGN_H -#define _UST_ALIGN_H - -/* - * ust/align.h - * - * (C) Copyright 2010-2011 - Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include - -/* - * Align pointer on natural object alignment. - */ -#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj))) -#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) - -/** - * offset_align - Calculate the offset needed to align an object on its natural - * alignment towards higher addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be added to align towards higher - * addresses. - */ -#define offset_align(align_drift, alignment) \ - ({ \ - BUILD_RUNTIME_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((alignment) - (align_drift)) & ((alignment) - 1)); \ - }) - -/** - * offset_align_floor - Calculate the offset needed to align an object - * on its natural alignment towards lower addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be substracted to align towards lower addresses. - */ -#define offset_align_floor(align_drift, alignment) \ - ({ \ - BUILD_RUNTIME_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((align_drift) - (alignment)) & ((alignment) - 1); \ - }) - -#endif /* _UST_ALIGN_H */ diff --git a/include/ust/bitfield.h b/include/ust/bitfield.h deleted file mode 100644 index df8ab0b2..00000000 --- a/include/ust/bitfield.h +++ /dev/null @@ -1,399 +0,0 @@ -#ifndef _BABELTRACE_BITFIELD_H -#define _BABELTRACE_BITFIELD_H - -/* - * BabelTrace - * - * Bitfields read/write functions. - * - * Copyright 2010 - Mathieu Desnoyers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -#include /* C99 5.2.4.2 Numerical limits */ -#include /* C99 5.2.4.2 Numerical limits */ -#include /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */ -#include - -/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */ -#define _bt_piecewise_rshift(_v, _shift) \ -({ \ - typeof(_v) ___v = (_v); \ - typeof(_shift) ___shift = (_shift); \ - unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ - unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ - \ - for (; sb; sb--) \ - ___v >>= sizeof(___v) * CHAR_BIT - 1; \ - ___v >>= final; \ -}) - -#define _bt_piecewise_lshift(_v, _shift) \ -({ \ - typeof(_v) ___v = (_v); \ - typeof(_shift) ___shift = (_shift); \ - unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \ - unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \ - \ - for (; sb; sb--) \ - ___v <<= sizeof(___v) * CHAR_BIT - 1; \ - ___v <<= final; \ -}) - -#define _bt_is_signed_type(type) (((type)(-1)) < 0) - -#define _bt_unsigned_cast(type, v) \ -({ \ - (sizeof(v) < sizeof(type)) ? \ - ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \ - (type) (v); \ -}) - -/* - * bt_bitfield_write - write integer to a bitfield in native endianness - * - * Save integer to the bitfield, which starts at the "start" bit, has "len" - * bits. - * The inside of a bitfield is from high bits to low bits. - * Uses native endianness. - * For unsigned "v", pad MSB with 0 if bitfield is larger than v. - * For signed "v", sign-extend v if bitfield is larger than v. - * - * On little endian, bytes are placed from the less significant to the most - * significant. Also, consecutive bitfields are placed from lower bits to higher - * bits. - * - * On big endian, bytes are places from most significant to less significant. - * Also, consecutive bitfields are placed from higher to lower bits. - */ - -#define _bt_bitfield_write_le(_ptr, type, _start, _length, _v) \ -do { \ - typeof(_v) __v = (_v); \ - type *__ptr = (void *) (_ptr); \ - unsigned long __start = (_start), __length = (_length); \ - type mask, cmask; \ - unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ - unsigned long start_unit, end_unit, this_unit; \ - unsigned long end, cshift; /* cshift is "complement shift" */ \ - \ - if (!__length) \ - break; \ - \ - end = __start + __length; \ - start_unit = __start / ts; \ - end_unit = (end + (ts - 1)) / ts; \ - \ - /* Trim v high bits */ \ - if (__length < sizeof(__v) * CHAR_BIT) \ - __v &= ~((~(typeof(__v)) 0) << __length); \ - \ - /* We can now append v with a simple "or", shift it piece-wise */ \ - this_unit = start_unit; \ - if (start_unit == end_unit - 1) { \ - mask = ~((~(type) 0) << (__start % ts)); \ - if (end % ts) \ - mask |= (~(type) 0) << (end % ts); \ - cmask = (type) __v << (__start % ts); \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - break; \ - } \ - if (__start % ts) { \ - cshift = __start % ts; \ - mask = ~((~(type) 0) << cshift); \ - cmask = (type) __v << cshift; \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - __v = _bt_piecewise_rshift(__v, ts - cshift); \ - __start += ts - cshift; \ - this_unit++; \ - } \ - for (; this_unit < end_unit - 1; this_unit++) { \ - __ptr[this_unit] = (type) __v; \ - __v = _bt_piecewise_rshift(__v, ts); \ - __start += ts; \ - } \ - if (end % ts) { \ - mask = (~(type) 0) << (end % ts); \ - cmask = (type) __v; \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - } else \ - __ptr[this_unit] = (type) __v; \ -} while (0) - -#define _bt_bitfield_write_be(_ptr, type, _start, _length, _v) \ -do { \ - typeof(_v) __v = (_v); \ - type *__ptr = (void *) (_ptr); \ - unsigned long __start = (_start), __length = (_length); \ - type mask, cmask; \ - unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ - unsigned long start_unit, end_unit, this_unit; \ - unsigned long end, cshift; /* cshift is "complement shift" */ \ - \ - if (!__length) \ - break; \ - \ - end = __start + __length; \ - start_unit = __start / ts; \ - end_unit = (end + (ts - 1)) / ts; \ - \ - /* Trim v high bits */ \ - if (__length < sizeof(__v) * CHAR_BIT) \ - __v &= ~((~(typeof(__v)) 0) << __length); \ - \ - /* We can now append v with a simple "or", shift it piece-wise */ \ - this_unit = end_unit - 1; \ - if (start_unit == end_unit - 1) { \ - mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \ - if (__start % ts) \ - mask |= (~((type) 0)) << (ts - (__start % ts)); \ - cmask = (type) __v << ((ts - (end % ts)) % ts); \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - break; \ - } \ - if (end % ts) { \ - cshift = end % ts; \ - mask = ~((~(type) 0) << (ts - cshift)); \ - cmask = (type) __v << (ts - cshift); \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - __v = _bt_piecewise_rshift(__v, cshift); \ - end -= cshift; \ - this_unit--; \ - } \ - for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \ - __ptr[this_unit] = (type) __v; \ - __v = _bt_piecewise_rshift(__v, ts); \ - end -= ts; \ - } \ - if (__start % ts) { \ - mask = (~(type) 0) << (ts - (__start % ts)); \ - cmask = (type) __v; \ - cmask &= ~mask; \ - __ptr[this_unit] &= mask; \ - __ptr[this_unit] |= cmask; \ - } else \ - __ptr[this_unit] = (type) __v; \ -} while (0) - -/* - * bt_bitfield_write - write integer to a bitfield in native endianness - * bt_bitfield_write_le - write integer to a bitfield in little endian - * bt_bitfield_write_be - write integer to a bitfield in big endian - */ - -#if (BYTE_ORDER == LITTLE_ENDIAN) - -#define bt_bitfield_write(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_le(ptr, type, _start, _length, _v) - -#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_le(ptr, type, _start, _length, _v) - -#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v) - -#elif (BYTE_ORDER == BIG_ENDIAN) - -#define bt_bitfield_write(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_be(ptr, type, _start, _length, _v) - -#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v) - -#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \ - _bt_bitfield_write_be(ptr, type, _start, _length, _v) - -#else /* (BYTE_ORDER == PDP_ENDIAN) */ - -#error "Byte order not supported" - -#endif - -#define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ -do { \ - typeof(*(_vptr)) *__vptr = (_vptr); \ - typeof(*__vptr) __v; \ - type *__ptr = (void *) (_ptr); \ - unsigned long __start = (_start), __length = (_length); \ - type mask, cmask; \ - unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ - unsigned long start_unit, end_unit, this_unit; \ - unsigned long end, cshift; /* cshift is "complement shift" */ \ - \ - if (!__length) { \ - *__vptr = 0; \ - break; \ - } \ - \ - end = __start + __length; \ - start_unit = __start / ts; \ - end_unit = (end + (ts - 1)) / ts; \ - \ - this_unit = end_unit - 1; \ - if (_bt_is_signed_type(typeof(__v)) \ - && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \ - __v = ~(typeof(__v)) 0; \ - else \ - __v = 0; \ - if (start_unit == end_unit - 1) { \ - cmask = __ptr[this_unit]; \ - cmask >>= (__start % ts); \ - if ((end - __start) % ts) { \ - mask = ~((~(type) 0) << (end - __start)); \ - cmask &= mask; \ - } \ - __v = _bt_piecewise_lshift(__v, end - __start); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - *__vptr = __v; \ - break; \ - } \ - if (end % ts) { \ - cshift = end % ts; \ - mask = ~((~(type) 0) << cshift); \ - cmask = __ptr[this_unit]; \ - cmask &= mask; \ - __v = _bt_piecewise_lshift(__v, cshift); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - end -= cshift; \ - this_unit--; \ - } \ - for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \ - __v = _bt_piecewise_lshift(__v, ts); \ - __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ - end -= ts; \ - } \ - if (__start % ts) { \ - mask = ~((~(type) 0) << (ts - (__start % ts))); \ - cmask = __ptr[this_unit]; \ - cmask >>= (__start % ts); \ - cmask &= mask; \ - __v = _bt_piecewise_lshift(__v, ts - (__start % ts)); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - } else { \ - __v = _bt_piecewise_lshift(__v, ts); \ - __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ - } \ - *__vptr = __v; \ -} while (0) - -#define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ -do { \ - typeof(*(_vptr)) *__vptr = (_vptr); \ - typeof(*__vptr) __v; \ - type *__ptr = (void *) (_ptr); \ - unsigned long __start = (_start), __length = (_length); \ - type mask, cmask; \ - unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \ - unsigned long start_unit, end_unit, this_unit; \ - unsigned long end, cshift; /* cshift is "complement shift" */ \ - \ - if (!__length) { \ - *__vptr = 0; \ - break; \ - } \ - \ - end = __start + __length; \ - start_unit = __start / ts; \ - end_unit = (end + (ts - 1)) / ts; \ - \ - this_unit = start_unit; \ - if (_bt_is_signed_type(typeof(__v)) \ - && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \ - __v = ~(typeof(__v)) 0; \ - else \ - __v = 0; \ - if (start_unit == end_unit - 1) { \ - cmask = __ptr[this_unit]; \ - cmask >>= (ts - (end % ts)) % ts; \ - if ((end - __start) % ts) { \ - mask = ~((~(type) 0) << (end - __start)); \ - cmask &= mask; \ - } \ - __v = _bt_piecewise_lshift(__v, end - __start); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - *__vptr = __v; \ - break; \ - } \ - if (__start % ts) { \ - cshift = __start % ts; \ - mask = ~((~(type) 0) << (ts - cshift)); \ - cmask = __ptr[this_unit]; \ - cmask &= mask; \ - __v = _bt_piecewise_lshift(__v, ts - cshift); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - __start += ts - cshift; \ - this_unit++; \ - } \ - for (; this_unit < end_unit - 1; this_unit++) { \ - __v = _bt_piecewise_lshift(__v, ts); \ - __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ - __start += ts; \ - } \ - if (end % ts) { \ - mask = ~((~(type) 0) << (end % ts)); \ - cmask = __ptr[this_unit]; \ - cmask >>= ts - (end % ts); \ - cmask &= mask; \ - __v = _bt_piecewise_lshift(__v, end % ts); \ - __v |= _bt_unsigned_cast(typeof(__v), cmask); \ - } else { \ - __v = _bt_piecewise_lshift(__v, ts); \ - __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\ - } \ - *__vptr = __v; \ -} while (0) - -/* - * bt_bitfield_read - read integer from a bitfield in native endianness - * bt_bitfield_read_le - read integer from a bitfield in little endian - * bt_bitfield_read_be - read integer from a bitfield in big endian - */ - -#if (BYTE_ORDER == LITTLE_ENDIAN) - -#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) - -#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) - -#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_be(_ptr, unsigned char, _start, _length, _vptr) - -#elif (BYTE_ORDER == BIG_ENDIAN) - -#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) - -#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_le(_ptr, unsigned char, _start, _length, _vptr) - -#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \ - _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) - -#else /* (BYTE_ORDER == PDP_ENDIAN) */ - -#error "Byte order not supported" - -#endif - -#endif /* _BABELTRACE_BITFIELD_H */ diff --git a/include/ust/bug.h b/include/ust/bug.h deleted file mode 100644 index 96007c3f..00000000 --- a/include/ust/bug.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _LTTNG_BUG_H -#define _LTTNG_BUG_H - -/* - * lib/bug.h - * - * (C) Copyright 2010-2011 - Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#define BUILD_BUG_ON(condition) \ - ((void) sizeof(char[-!!(condition)])) - -/** - * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime - * @condition: the condition which should be false. - * - * If the condition is a constant and true, the compiler will generate a build - * error. If the condition is not constant, a BUG will be triggered at runtime - * if the condition is ever true. If the condition is constant and false, no - * code is emitted. - */ -#define BUILD_RUNTIME_BUG_ON(condition) \ - do { \ - if (__builtin_constant_p(condition)) \ - BUILD_BUG_ON(condition); \ - else \ - BUG_ON(condition); \ - } while (0) - -#endif diff --git a/include/ust/clock.h b/include/ust/clock.h deleted file mode 100644 index ae44beca..00000000 --- a/include/ust/clock.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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; 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 - */ - -#ifndef _UST_CLOCK_H -#define _UST_CLOCK_H - -#include -#include -#include -#include -#include - -/* TRACE CLOCK */ - -/* - * Currently using the kernel MONOTONIC clock, waiting for kernel-side - * LTTng to implement mmap'd trace clock. - */ - -/* Choosing correct trace clock */ - -static __inline__ uint64_t trace_clock_read64(void) -{ - struct timespec ts; - uint64_t retval; - - 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) -{ - return 1000000000LL; -} -#endif /* #else #if __i386__ || __x86_64__ */ - -static __inline__ uint32_t trace_clock_freq_scale(void) -{ - return 1; -} - -#endif /* _UST_CLOCK_H */ diff --git a/include/ust/compat.h b/include/ust/compat.h deleted file mode 100644 index c896e728..00000000 --- a/include/ust/compat.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _UST_COMPAT_H -#define _UST_COMPAT_H - -/* - * 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. - * - * 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 - */ - -#include - -#ifdef __UCLIBC__ -#define __getcpu(cpu, node, cache) syscall(__NR_getcpu, cpu, node, cache) -static inline -int sched_getcpu(void) -{ - int c, s; - - s = __getcpu(&c, NULL, NULL); - return (s == -1) ? s : c; -} -#endif /* __UCLIBC__ */ -#endif /* _UST_COMPAT_H */ diff --git a/include/ust/config.h.in b/include/ust/config.h.in deleted file mode 100644 index b619095f..00000000 --- a/include/ust/config.h.in +++ /dev/null @@ -1,5 +0,0 @@ -/* ust/config.h.in. Manually generated for control over the contained defs. */ - -/* Use efficient unaligned access. */ -#undef HAVE_EFFICIENT_UNALIGNED_ACCESS - diff --git a/include/ust/core.h b/include/ust/core.h deleted file mode 100644 index 4e75c515..00000000 --- a/include/ust/core.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef UST_CORE_H -#define UST_CORE_H - -/* - * 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; 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 - */ - -#include -#include -#include -#include - -/* ARRAYS */ - -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - - -/* ALIGNMENT SHORTCUTS */ - -#include - -#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) -#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) -#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) -#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) -#define PAGE_MASK (~(PAGE_SIZE-1)) - -/* ERROR OPS */ -#define MAX_ERRNO 4095 - -#define IS_ERR_VALUE(x) caa_unlikely((x) >= (unsigned long)-MAX_ERRNO) - -static inline void *ERR_PTR(long error) -{ - return (void *) error; -} - -static inline long PTR_ERR(const void *ptr) -{ - return (long) ptr; -} - -static inline long IS_ERR(const void *ptr) -{ - return IS_ERR_VALUE((unsigned long)ptr); -} - - -/* Min / Max */ - -#define min_t(type, x, y) ({ \ - type __min1 = (x); \ - type __min2 = (y); \ - __min1 < __min2 ? __min1: __min2; }) - -#define max_t(type, x, y) ({ \ - type __max1 = (x); \ - type __max2 = (y); \ - __max1 > __max2 ? __max1: __max2; }) - - -/* MUTEXES */ - -#include - -#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; -#define DECLARE_MUTEX(m) extern pthread_mutex_t (m); - -/* MALLOCATION */ - -#include - -static inline -void *zmalloc(size_t len) -{ - return calloc(1, len); -} - -static inline -void *malloc_align(size_t len) -{ - return malloc(ALIGN(len, CAA_CACHE_LINE_SIZE)); -} - -static inline -void *zmalloc_align(size_t len) -{ - return calloc(1, ALIGN(len, CAA_CACHE_LINE_SIZE)); -} - -/* MATH */ - -#include -static inline unsigned int hweight32(unsigned int w) -{ - unsigned int res = w - ((w >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res + (res >> 4)) & 0x0F0F0F0F; - res = res + (res >> 8); - return (res + (res >> 16)) & 0x000000FF; -} - -static __inline__ int get_count_order(unsigned int count) -{ - int order; - - order = fls(count) - 1; - if (count & (count - 1)) - order++; - return order; -} - -#define _ust_container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - -#ifndef inline_memcpy -#define inline_memcpy memcpy -#endif - -#ifndef __same_type -#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -#endif - -#ifndef UST_VALGRIND - -static __inline__ int ust_get_cpu(void) -{ - int cpu; - - cpu = sched_getcpu(); - if (caa_likely(cpu >= 0)) - return cpu; - /* - * If getcpu(2) is not implemented in the Kernel use CPU 0 as fallback. - */ - return 0; -} - -#else /* #else #ifndef UST_VALGRIND */ - -static __inline__ int ust_get_cpu(void) -{ - /* - * Valgrind does not support the sched_getcpu() vsyscall. - * It causes it to detect a segfault in the program and stop it. - * So if we want to check libust with valgrind, we have to refrain - * from using this call. TODO: it would probably be better to return - * other values too, to better test it. - */ - return 0; -} - -#endif /* #else #ifndef UST_VALGRIND */ - -#endif /* UST_CORE_H */ diff --git a/include/ust/kcompat/compiler.h b/include/ust/kcompat/compiler.h deleted file mode 100644 index f2fbd3e3..00000000 --- a/include/ust/kcompat/compiler.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * compiler.h - * - * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca) - * - * 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. - * - * 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 - */ - -#ifndef KCOMPAT_COMPILER_H -#define KCOMPAT_COMPILER_H - -# define inline inline __attribute__((always_inline)) -# define __inline__ __inline__ __attribute__((always_inline)) -# define __inline __inline __attribute__((always_inline)) - -#ifndef __always_inline -#define __always_inline inline -#endif - -#define __pure __attribute__((pure)) -#define __aligned(x) __attribute__((aligned(x))) -#define __printf(a,b) __attribute__((format(printf,a,b))) -#define noinline __attribute__((noinline)) -#define __attribute_const__ __attribute__((__const__)) -#define __used __attribute__((used)) -#define __maybe_unused __attribute__((unused)) - -#define notrace __attribute__((no_instrument_function)) - -#endif /* KCOMPAT_COMPILER_H */ diff --git a/include/ust/kcompat/jhash.h b/include/ust/kcompat/jhash.h deleted file mode 100644 index 2635167b..00000000 --- a/include/ust/kcompat/jhash.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef KCOMPAT_JHASH_H -#define KCOMPAT_JHASH_H - -/* jhash.h: Jenkins hash support. - * - * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net) - * - * http://burtleburtle.net/bob/hash/ - * - * These are the credits from Bob's sources: - * - * lookup2.c, by Bob Jenkins, December 1996, Public Domain. - * hash(), hash2(), hash3, and mix() are externally useful functions. - * Routines to test the hash are included if SELF_TEST is defined. - * You can use this free for any purpose. It has no warranty. - * - * Copyright (C) 2003 David S. Miller (davem@redhat.com) - * - * I've modified Bob's hash to be useful in the Linux kernel, and - * any bugs present are surely my fault. -DaveM - */ - -/* NOTE: Arguments are modified. */ -#define __jhash_mix(a, b, c) \ -{ \ - a -= b; a -= c; a ^= (c>>13); \ - b -= c; b -= a; b ^= (a<<8); \ - c -= a; c -= b; c ^= (b>>13); \ - a -= b; a -= c; a ^= (c>>12); \ - b -= c; b -= a; b ^= (a<<16); \ - c -= a; c -= b; c ^= (b>>5); \ - a -= b; a -= c; a ^= (c>>3); \ - b -= c; b -= a; b ^= (a<<10); \ - c -= a; c -= b; c ^= (b>>15); \ -} - -/* The golden ration: an arbitrary value */ -#define JHASH_GOLDEN_RATIO 0x9e3779b9 - -/* The most generic version, hashes an arbitrary sequence - * of bytes. No alignment or length assumptions are made about - * the input key. - */ -static inline u32 jhash(const void *key, u32 length, u32 initval) -{ - u32 a, b, c, len; - const u8 *k = (const u8 *) key; - - len = length; - a = b = JHASH_GOLDEN_RATIO; - c = initval; - - while (len >= 12) { - a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24)); - b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24)); - c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24)); - - __jhash_mix(a,b,c); - - k += 12; - len -= 12; - } - - c += length; - switch (len) { - case 11: c += ((u32)k[10]<<24); - case 10: c += ((u32)k[9]<<16); - case 9 : c += ((u32)k[8]<<8); - case 8 : b += ((u32)k[7]<<24); - case 7 : b += ((u32)k[6]<<16); - case 6 : b += ((u32)k[5]<<8); - case 5 : b += k[4]; - case 4 : a += ((u32)k[3]<<24); - case 3 : a += ((u32)k[2]<<16); - case 2 : a += ((u32)k[1]<<8); - case 1 : a += k[0]; - }; - - __jhash_mix(a,b,c); - - return c; -} - -#endif /* KCOMPAT_JHASH_H */ diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h deleted file mode 100644 index be8d9269..00000000 --- a/include/ust/kcompat/kcompat.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * kcompat.h - * - * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca) - * - * 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. - * - * 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 - */ - -#ifndef KCOMPAT_H -#define KCOMPAT_H - -#define __KERNEL__ -#define _LOOSE_KERNEL_NAMES - -#ifndef CONFIG_SMP -#define CONFIG_SMP 1 /* Needed for urcu, verify it's ok to remove it. */ -#endif - -#include -#include -#if __WORDSIZE == 32 -#define LIBKCOMPAT_X86_32 -#elif __WORDSIZE == 64 -#define LIBKCOMPAT_X86_64 -#else -#error "Unsupported" -#endif - -#ifdef LIBKCOMPAT_X86_32 -#define CONFIG_X86_32 -#define CONFIG_32BIT -#endif - -#ifdef LIBKCOMPAT_X86_64 -#define CONFIG_X86_64 -#define CONFIG_64BIT -#endif - -/* Standard libs */ -#include -#include - -/* Taken from userspace-rcu */ -#include - -/* Kernel libs */ -#include -#include -#include - -#endif /* KCOMPAT_H */ diff --git a/include/ust/kcompat/types.h b/include/ust/kcompat/types.h deleted file mode 100644 index 63f9ede0..00000000 --- a/include/ust/kcompat/types.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _KCOMPAT_TYPES -#define _KCOMPAT_TYPES - -/* - * Kernel sourcecode compatibility layer - * - * Copyright (C) 2009 Novell Inc. - * - * Author: Jan Blunck - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1 as - * published by the Free Software Foundation. - */ - -#include - -#ifdef __KERNEL__ -typedef __s8 s8; -typedef __u8 u8; - -typedef __s16 s16; -typedef __u16 u16; - -typedef __s32 s32; -typedef __u32 u32; - -typedef __s64 s64; -typedef __u64 u64; -#endif - -#endif /* _KCOMPAT_TYPES */ diff --git a/include/ust/lttng-events.h b/include/ust/lttng-events.h deleted file mode 100644 index e028f6b2..00000000 --- a/include/ust/lttng-events.h +++ /dev/null @@ -1,331 +0,0 @@ -#ifndef _UST_LTTNG_EVENTS_H -#define _UST_LTTNG_EVENTS_H - -/* - * ust/lttng-events.h - * - * Copyright 2010 (c) - Mathieu Desnoyers - * - * Holds LTTng per-session event registry. - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include -#include -#include -#include -#include -#include -#include - -struct ltt_channel; -struct ltt_session; -struct lttng_ust_lib_ring_buffer_ctx; - -/* Type description */ - -/* Update the astract_types name table in lttng-types.c along with this enum */ -enum abstract_types { - atype_integer, - atype_enum, - atype_array, - atype_sequence, - atype_string, - atype_float, - NR_ABSTRACT_TYPES, -}; - -/* Update the string_encodings name table in lttng-types.c along with this enum */ -enum lttng_string_encodings { - lttng_encode_none = 0, - lttng_encode_UTF8 = 1, - lttng_encode_ASCII = 2, - NR_STRING_ENCODINGS, -}; - -struct lttng_enum_entry { - unsigned long long start, end; /* start and end are inclusive */ - const char *string; -}; - -#define __type_integer(_type, _byte_order, _base, _encoding) \ - { \ - .atype = atype_integer, \ - .u.basic.integer = \ - { \ - .size = sizeof(_type) * CHAR_BIT, \ - .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, \ - }, \ - } \ - -struct lttng_integer_type { - unsigned int size; /* in bits */ - unsigned short alignment; /* in bits */ - unsigned int signedness:1; - unsigned int reverse_byte_order:1; - unsigned int base; /* 2, 8, 10, 16, for pretty print */ - enum lttng_string_encodings encoding; -}; - -/* - * Only float and double are supported. long double is not supported at - * the moment. - */ -#define _float_mant_dig(_type) \ - (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \ - : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \ - : 0)) - -#define __type_float(_type) \ - { \ - .atype = atype_float, \ - .u.basic._float = \ - { \ - .exp_dig = sizeof(_type) * CHAR_BIT \ - - _float_mant_dig(_type), \ - .mant_dig = _float_mant_dig(_type), \ - .alignment = lttng_alignof(_type) * CHAR_BIT, \ - .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \ - }, \ - } \ - -struct lttng_float_type { - unsigned int exp_dig; /* exponent digits, in bits */ - unsigned int mant_dig; /* mantissa digits, in bits */ - unsigned short alignment; /* in bits */ - unsigned int reverse_byte_order:1; -}; - -union _lttng_basic_type { - struct lttng_integer_type integer; - struct { - const char *name; - } enumeration; - struct { - enum lttng_string_encodings encoding; - } string; - struct lttng_float_type _float; -}; - -struct lttng_basic_type { - enum abstract_types atype; - union { - union _lttng_basic_type basic; - } u; -}; - -struct lttng_type { - enum abstract_types atype; - union { - union _lttng_basic_type basic; - struct { - struct lttng_basic_type elem_type; - unsigned int length; /* num. elems. */ - } array; - struct { - struct lttng_basic_type length_type; - struct lttng_basic_type elem_type; - } sequence; - } u; -}; - -struct lttng_enum { - const char *name; - struct lttng_type container_type; - const struct lttng_enum_entry *entries; - unsigned int len; -}; - -/* Event field description */ - -struct lttng_event_field { - const char *name; - struct lttng_type type; -}; - -struct lttng_ctx_field { - struct lttng_event_field event_field; - size_t (*get_size)(size_t offset); - void (*record)(struct lttng_ctx_field *field, - struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct ltt_channel *chan); - union { - } u; - void (*destroy)(struct lttng_ctx_field *field); -}; - -struct lttng_ctx { - struct lttng_ctx_field *fields; - unsigned int nr_fields; - unsigned int allocated_fields; -}; - -struct lttng_event_desc { - const char *name; - void *probe_callback; - const struct lttng_event_ctx *ctx; /* context */ - const struct lttng_event_field *fields; /* event payload */ - unsigned int nr_fields; -}; - -struct lttng_probe_desc { - const struct lttng_event_desc *event_desc; - unsigned int nr_events; - struct cds_list_head head; /* chain registered probes */ -}; - -struct ust_pending_probe; - -/* - * ltt_event structure is referred to by the tracing fast path. It must be - * kept small. - */ -struct ltt_event { - unsigned int id; - struct ltt_channel *chan; - int enabled; - const struct lttng_event_desc *desc; - void *filter; - struct lttng_ctx *ctx; - enum lttng_ust_instrumentation instrumentation; - union { - } u; - struct cds_list_head list; /* Event list */ - struct ust_pending_probe *pending_probe; - int metadata_dumped:1; -}; - -struct channel; -struct lttng_ust_shm_handle; - -struct ltt_channel_ops { - struct ltt_channel *(*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 *shm_fd, int *wait_fd, - uint64_t *memory_map_size); - void (*channel_destroy)(struct ltt_channel *ltt_chan); - struct lttng_ust_lib_ring_buffer *(*buffer_read_open)(struct channel *chan, - struct lttng_ust_shm_handle *handle, - int *shm_fd, int *wait_fd, - uint64_t *memory_map_size); - void (*buffer_read_close)(struct lttng_ust_lib_ring_buffer *buf, - struct lttng_ust_shm_handle *handle); - int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx, - uint32_t event_id); - void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx); - void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, const void *src, - size_t len); - /* - * packet_avail_size returns the available size in the current - * packet. Note that the size returned is only a hint, since it - * may change due to concurrent writes. - */ - size_t (*packet_avail_size)(struct channel *chan, - struct lttng_ust_shm_handle *handle); - //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan); - //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); - int (*is_finalized)(struct channel *chan); - int (*is_disabled)(struct channel *chan); - int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); -}; - -struct ltt_channel { - unsigned int id; - struct channel *chan; /* Channel buffers */ - int enabled; - struct lttng_ctx *ctx; - /* Event ID management */ - struct ltt_session *session; - int objd; /* Object associated to channel */ - unsigned int free_event_id; /* Next event ID to allocate */ - unsigned int used_event_id; /* Max allocated event IDs */ - struct cds_list_head list; /* Channel list */ - struct ltt_channel_ops *ops; - int header_type; /* 0: unset, 1: compact, 2: large */ - struct lttng_ust_shm_handle *handle; /* shared-memory handle */ - int metadata_dumped:1; -}; - -struct ltt_session { - int active; /* Is trace session active ? */ - int been_active; /* Has trace session been active ? */ - int objd; /* Object associated to session */ - struct ltt_channel *metadata; /* Metadata channel */ - struct cds_list_head chan; /* Channel list head */ - struct cds_list_head events; /* Event list head */ - struct cds_list_head list; /* Session list */ - unsigned int free_chan_id; /* Next chan ID to allocate */ - uuid_t uuid; /* Trace session unique ID */ - int metadata_dumped:1; -}; - -struct ltt_transport { - char *name; - struct cds_list_head node; - struct ltt_channel_ops ops; -}; - -struct ltt_session *ltt_session_create(void); -int ltt_session_enable(struct ltt_session *session); -int ltt_session_disable(struct ltt_session *session); -void ltt_session_destroy(struct ltt_session *session); - -struct ltt_channel *ltt_channel_create(struct ltt_session *session, - const char *transport_name, - void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shm_fd, int *wait_fd, - uint64_t *memory_map_size); -struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, - int overwrite, void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shm_fd, int *wait_fd, - uint64_t *memory_map_size); - -struct ltt_event *ltt_event_create(struct ltt_channel *chan, - struct lttng_ust_event *event_param, - void *filter); - -int ltt_channel_enable(struct ltt_channel *channel); -int ltt_channel_disable(struct ltt_channel *channel); -int ltt_event_enable(struct ltt_event *event); -int ltt_event_disable(struct ltt_event *event); - -void ltt_transport_register(struct ltt_transport *transport); -void ltt_transport_unregister(struct ltt_transport *transport); - -void synchronize_trace(void); - -int ltt_probe_register(struct lttng_probe_desc *desc); -void ltt_probe_unregister(struct lttng_probe_desc *desc); -int pending_probe_fix_events(const struct lttng_event_desc *desc); -const struct lttng_event_desc *ltt_event_get(const char *name); -void ltt_event_put(const struct lttng_event_desc *desc); -int ltt_probes_init(void); -void ltt_probes_exit(void); -int lttng_find_context(struct lttng_ctx *ctx, const char *name); -struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p); -void lttng_remove_context_field(struct lttng_ctx **ctx_p, - struct lttng_ctx_field *field); -void lttng_destroy_context(struct lttng_ctx *ctx); -int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); -int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx); -int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); -void lttng_context_vtid_reset(void); -void lttng_context_vpid_reset(void); - -#endif /* _UST_LTTNG_EVENTS_H */ diff --git a/include/ust/lttng-tracepoint-event-reset.h b/include/ust/lttng-tracepoint-event-reset.h deleted file mode 100644 index b765c812..00000000 --- a/include/ust/lttng-tracepoint-event-reset.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * lttng-tracepoint-events-reset.h - * - * Copyright (C) 2010-2011 Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. - */ - -/* Reset macros used within TRACEPOINT_EVENT to "nothing" */ - -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) - -#undef ctf_float -#define ctf_float(_type, _item, _src) - -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) - -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) - -#undef ctf_string -#define ctf_string(_item, _src) - -#undef TP_PROTO -#define TP_PROTO(args...) - -#undef TP_ARGS -#define TP_ARGS(args...) - -#undef TP_FIELDS -#define TP_FIELDS(args...) - -#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 deleted file mode 100644 index 46d8b933..00000000 --- a/include/ust/lttng-tracepoint-event.h +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (C) 2009 Steven Rostedt - * 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; - * 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 - */ - -#include -#include -#include -#include -#include - -/* - * Macro declarations used for all stages. - */ - -#undef ctf_integer -#define ctf_integer(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10) - -#undef ctf_integer_hex -#define ctf_integer_hex(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16) - -#undef ctf_integer_network -#define ctf_integer_network(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10) - -#undef ctf_integer_network_hex -#define ctf_integer_network_hex(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16) - -/* ctf_float is redefined at each step */ - -#undef ctf_array -#define ctf_array(_type, _item, _src, _length) \ - ctf_array_encoded(_type, _item, _src, _length, none) - -#undef ctf_array_text -#define ctf_array_text(_type, _item, _src, _length) \ - ctf_array_encoded(_type, _item, _src, _length, UTF8) - -#undef ctf_sequence -#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ - ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, none) - -#undef ctf_sequence_text -#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ - ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, UTF8) - -/* ctf_string is redefined at each step */ - -/* - * TRACEPOINT_EVENT_CLASS can be used to add a generic function handlers - * for events. That is, if all events have the same parameters and just - * have distinct trace points. Each tracepoint can be defined with - * TRACEPOINT_EVENT_INSTANCE and that will map the - * TRACEPOINT_EVENT_CLASS to the tracepoint. - * - * TRACEPOINT_EVENT is a one to one mapping between tracepoint and - * template. - */ - -#undef TRACEPOINT_EVENT -#define TRACEPOINT_EVENT(name, proto, args, fields) \ - TRACEPOINT_EVENT_CLASS(name, \ - TP_PARAMS(proto), \ - TP_PARAMS(args), \ - 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])) - -#define _tp_max_t(type, x, y) \ - ({ \ - type __max1 = (x); \ - type __max2 = (y); \ - __max1 > __max2 ? __max1: __max2; \ - }) - - -/* - * Stage 1 of the trace events. - * - * Create event field type metadata section. - * Each event produce an array of fields. - */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -/* Named field types must be defined in lttng-types.h */ - -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - { \ - .name = #_item, \ - .type = __type_integer(_type, _byte_order, _base, none),\ - }, - -#undef ctf_float -#define ctf_float(_type, _item, _src) \ - { \ - .name = #_item, \ - .type = __type_float(_type), \ - }, - -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_array, \ - .u.array = \ - { \ - .length = _length, \ - .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ - }, \ - }, \ - }, - -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, _encoding) \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_sequence, \ - .u.sequence = \ - { \ - .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ - .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ - }, \ - }, \ - }, - -#undef ctf_string -#define ctf_string(_item, _src) \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_string, \ - .u.basic.string.encoding = lttng_encode_UTF8, \ - }, \ - }, - -#undef TP_FIELDS -#define TP_FIELDS(args...) args /* Only one used in this phase */ - -#undef TRACEPOINT_EVENT_CLASS_NOARGS -#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \ - static const struct lttng_event_field __event_fields___##_name[] = { \ - _fields \ - }; - -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ - TRACEPOINT_EVENT_CLASS_NOARGS(_name, TP_PARAMS(_fields)) - -#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) - -/* - * Stage 2 of the trace events. - * - * Create probe callback prototypes. - */ - -/* 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) \ -static void __event_probe__##_name(void *__data, _proto); - -#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. - * - * Create an array of events. - */ - -/* Named field types must be defined in lttng-types.h */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -#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 = _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___, TRACEPOINT_SYSTEM)[] = { -#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) -}; - -#undef TP_ID1 -#undef TP_ID - - -/* - * Stage 4 of the trace events. - * - * Create a toplevel descriptor for the whole probe. - */ - -#define TP_ID1(_token, _system) _token##_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___, TRACEPOINT_SYSTEM) = { - .event_desc = TP_ID(__event_desc___, TRACEPOINT_SYSTEM), - .nr_events = _TP_ARRAY_SIZE(TP_ID(__event_desc___, TRACEPOINT_SYSTEM)), -}; - -#undef TP_ID1 -#undef TP_ID - -/* - * Stage 5 of the trace events. - * - * Create static inline function that calculates event size. - */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -/* Named field types must be defined in lttng-types.h */ - -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - __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, lttng_alignof(_type)); \ - __event_len += sizeof(_type); - -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ - __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, lttng_alignof(_length_type)); \ - __event_len += sizeof(_length_type); \ - __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ - __dynamic_len[__dynamic_len_idx] = (_src_length); \ - __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ - __dynamic_len_idx++; - -#undef ctf_string -#define ctf_string(_item, _src) \ - __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; - -#undef TP_PROTO -#define TP_PROTO(args...) args - -#undef TP_FIELDS -#define TP_FIELDS(args...) args - -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ -static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ -{ \ - 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. - * - * Create static inline function that calculates event payload alignment. - */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -/* Named field types must be defined in lttng-types.h */ - -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); - -#undef ctf_float -#define ctf_float(_type, _item, _src) \ - __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); - -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ - __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 = _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) - -#undef TP_PROTO -#define TP_PROTO(args...) args - -#undef TP_FIELDS -#define TP_FIELDS(args...) args - -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ -static inline size_t __event_get_align__##_name(_proto) \ -{ \ - size_t __event_align = 1; \ - _fields \ - return __event_align; \ -} - -#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) - - -/* - * Stage 7 of the trace events. - * - * Create the probe function : call even size calculation and write event data - * into the buffer. - * - * We use both the field and assignment macros to write the fields in the order - * defined in the field declaration. The field declarations control the - * execution order, jumping to the appropriate assignment block. - */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ - { \ - _type __tmp = (_src); \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ - __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ - } - -#undef ctf_float -#define ctf_float(_type, _item, _src) \ - { \ - _type __tmp = (_src); \ - 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, _encoding) \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ - __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); - -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) \ - { \ - _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ - 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, lttng_alignof(_type)); \ - __chan->ops->event_write(&__ctx, _src, \ - sizeof(_type) * __get_dynamic_len(dest)); - -#undef ctf_string -#define ctf_string(_item, _src) \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ - __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest)); - -/* Beware: this get len actually consumes the len value */ -#undef __get_dynamic_len -#define __get_dynamic_len(field) __dynamic_len[__dynamic_len_idx++] - -#undef TP_PROTO -#define TP_PROTO(args...) args - -#undef TP_ARGS -#define TP_ARGS(args...) args - -#undef TP_FIELDS -#define TP_FIELDS(args...) args - -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ -static void __event_probe__##_name(void *__data, _proto) \ -{ \ - struct ltt_event *__event = __data; \ - struct ltt_channel *__chan = __event->chan; \ - struct lttng_ust_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 (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ - return; \ - if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ - return; \ - if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ - return; \ - __event_len = __event_get_size__##_name(__dynamic_len, _args); \ - __event_align = __event_get_align__##_name(_args); \ - lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ - __event_align, -1, __chan->handle); \ - __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ - if (__ret < 0) \ - return; \ - _fields \ - __chan->ops->event_commit(&__ctx); \ -} - -#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 lttng_ust_lib_ring_buffer_ctx __ctx; \ - size_t __event_len, __event_align; \ - int __ret; \ - \ - if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \ - return; \ - if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \ - return; \ - if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \ - return; \ - __event_len = 0; \ - __event_align = 1; \ - lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ - __event_align, -1, __chan->handle); \ - __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ - if (__ret < 0) \ - return; \ - _fields \ - __chan->ops->event_commit(&__ctx); \ -} - -#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) - -#undef __get_dynamic_len - -/* - * Stage 8 of the trace events. - * - * Register/unregister probes at module load/unload. - */ - -/* 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__, TRACEPOINT_SYSTEM)(void) -{ - int ret; - - ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); - assert(!ret); -} - -static void __attribute__((destructor)) -TP_ID(__lttng_events_exit__, TRACEPOINT_SYSTEM)(void) -{ - ltt_probe_unregister(&TP_ID(__probe_desc___, TRACEPOINT_SYSTEM)); -} - -#undef TP_ID1 -#undef TP_ID diff --git a/include/ust/lttng-tracer.h b/include/ust/lttng-tracer.h deleted file mode 100644 index f2bdbf51..00000000 --- a/include/ust/lttng-tracer.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _LTTNG_TRACER_H -#define _LTTNG_TRACER_H - -/* - * Copyright (C) 2005-2011 Mathieu Desnoyers - * - * This contains the core definitions for the Linux Trace Toolkit. - * - * 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 - */ - -#include - -#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS -/* Align data on its natural alignment */ -#define RING_BUFFER_ALIGN -#endif - -#define LTTNG_UST_VERSION 0 -#define LTTNG_UST_PATCHLEVEL 9 -#define LTTNG_UST_SUBLEVEL 1 - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -#ifdef RING_BUFFER_ALIGN -#define lttng_alignof(type) __alignof__(type) -#else -#define lttng_alignof(type) 1 -#endif - -#define lttng_is_signed_type(type) (((type)(-1)) < 0) - -#endif /* _LTTNG_TRACER_CORE_H */ diff --git a/include/ust/lttng-ust-abi.h b/include/ust/lttng-ust-abi.h deleted file mode 100644 index d2b3340f..00000000 --- a/include/ust/lttng-ust-abi.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef _LTTNG_UST_ABI_H -#define _LTTNG_UST_ABI_H - -/* - * lttng-ust-abi.h - * - * Copyright 2010-2011 (c) - Mathieu Desnoyers - * - * LTTng-UST ABI header - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include - -#define LTTNG_UST_SYM_NAME_LEN 128 - -#define LTTNG_UST_COMM_VERSION_MAJOR 0 -#define LTTNG_UST_COMM_VERSION_MINOR 1 - -enum lttng_ust_instrumentation { - LTTNG_UST_TRACEPOINT = 0, - LTTNG_UST_PROBE = 1, - LTTNG_UST_FUNCTION = 2, -}; - -enum lttng_ust_output { - LTTNG_UST_MMAP = 0, -}; - -struct lttng_ust_tracer_version { - uint32_t version; - uint32_t patchlevel; - uint32_t sublevel; -}; - -struct lttng_ust_channel { - int overwrite; /* 1: overwrite, 0: discard */ - uint64_t subbuf_size; /* in bytes */ - uint64_t num_subbuf; - unsigned int switch_timer_interval; /* usecs */ - unsigned int read_timer_interval; /* usecs */ - enum lttng_ust_output output; /* output mode */ - /* The following fields are used internally within UST. */ - int shm_fd; - int wait_fd; - uint64_t memory_map_size; -}; - -/* - * This structure is only used internally within UST. It is not per-se - * part of the communication between sessiond and UST. - */ -struct lttng_ust_stream { - int shm_fd; - int wait_fd; - uint64_t memory_map_size; -}; - -struct lttng_ust_event { - char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ - enum lttng_ust_instrumentation instrumentation; - /* Per instrumentation type configuration */ - union { - } u; -}; - -enum lttng_ust_context_type { - LTTNG_UST_CONTEXT_VTID = 0, - LTTNG_UST_CONTEXT_VPID = 1, - LTTNG_UST_CONTEXT_PTHREAD_ID = 2, - LTTNG_UST_CONTEXT_PROCNAME = 3, -}; - -struct lttng_ust_context { - enum lttng_ust_context_type ctx; - union { - } u; -}; - -/* - * Tracer channel attributes. - */ -struct lttng_ust_channel_attr { - int overwrite; /* 1: overwrite, 0: discard */ - uint64_t subbuf_size; /* bytes */ - uint64_t num_subbuf; /* power of 2 */ - unsigned int switch_timer_interval; /* usec */ - unsigned int read_timer_interval; /* usec */ - enum lttng_ust_output output; /* splice, mmap */ -}; - -struct lttng_ust_object_data { - int handle; - int shm_fd; - int wait_fd; - uint64_t memory_map_size; -}; - -#define _UST_CMD(minor) (minor) -#define _UST_CMDR(minor, type) (minor) -#define _UST_CMDW(minor, type) (minor) - -/* Handled by object descriptor */ -#define LTTNG_UST_RELEASE _UST_CMD(0x1) - -/* Handled by object cmd */ - -/* LTTng-UST commands */ -#define LTTNG_UST_SESSION _UST_CMD(0x40) -#define LTTNG_UST_TRACER_VERSION \ - _UST_CMDR(0x41, struct lttng_ust_tracer_version) -#define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42) -#define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43) -#define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44) - -/* Session FD commands */ -#define LTTNG_UST_METADATA \ - _UST_CMDW(0x50, struct lttng_ust_channel) -#define LTTNG_UST_CHANNEL \ - _UST_CMDW(0x51, struct lttng_ust_channel) -#define LTTNG_UST_SESSION_START _UST_CMD(0x52) -#define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) - -/* Channel FD commands */ -#define LTTNG_UST_STREAM _UST_CMD(0x60) -#define LTTNG_UST_EVENT \ - _UST_CMDW(0x61, struct lttng_ust_event) - -/* Event and Channel FD commands */ -#define LTTNG_UST_CONTEXT \ - _UST_CMDW(0x70, struct lttng_ust_context) -#define LTTNG_UST_FLUSH_BUFFER \ - _UST_CMD(0x71) - -/* Event, Channel and Session commands */ -#define LTTNG_UST_ENABLE _UST_CMD(0x80) -#define LTTNG_UST_DISABLE _UST_CMD(0x81) - -#define LTTNG_UST_ROOT_HANDLE 0 - -struct lttng_ust_obj; - -struct lttng_ust_objd_ops { - long (*cmd)(int objd, unsigned int cmd, unsigned long arg); - int (*release)(int objd); -}; - -/* Create root handle. Always ID 0. */ -int lttng_abi_create_root_handle(void); - -const struct lttng_ust_objd_ops *objd_ops(int id); -int lttng_ust_objd_unref(int id); - -void lttng_ust_abi_exit(void); -void lttng_ust_events_exit(void); - -#endif /* _LTTNG_UST_ABI_H */ diff --git a/include/ust/lttng-ust-comm.h b/include/ust/lttng-ust-comm.h deleted file mode 100644 index 614890d4..00000000 --- a/include/ust/lttng-ust-comm.h +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef _LTTNG_UST_COMM_H -#define _LTTNG_UST_COMM_H - -/* - * Copyright (C) 2011 - David Goulet - * Julien Desfossez - * Mathieu Desnoyers - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* - * This header is meant for liblttng and libust internal use ONLY. - * These declarations should NOT be considered stable API. - */ - -#include -#include -#include - -/* - * Default timeout the application waits for the sessiond to send its - * "register done" command. Can be overridden with the environment - * variable "UST_REGISTER_TIMEOUT". Note that if the sessiond is not - * found, the application proceeds directly without any delay. - */ -#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000 - -#define LTTNG_RUNDIR "/var/run/lttng" - -/* Default unix socket path */ -#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond" -#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond" -#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond" -#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond" - -#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait" -#define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u" - -/* Queue size of listen(2) */ -#define LTTNG_UST_COMM_MAX_LISTEN 10 - -/* Get the error code index from 0. USTCOMM_ERR starts at 1000. - */ -#define USTCOMM_ERR_INDEX(code) (code - USTCOMM_ERR) - -/* - * ustcomm error code. - */ -enum ustcomm_return_code { - USTCOMM_OK = 0, /* Ok */ - /* Range 1 to 999 used for standard error numbers (errno.h) */ - USTCOMM_ERR = 1000, /* Unknown Error */ - USTCOMM_UND, /* Undefine command */ - USTCOMM_NOT_IMPLEMENTED, /* Command not implemented */ - USTCOMM_UNKNOWN_DOMAIN, /* Tracing domain not known */ - USTCOMM_ALLOC_FAIL, /* Trace allocation fail */ - USTCOMM_NO_SESSION, /* No session found */ - USTCOMM_CREATE_FAIL, /* Create trace fail */ - USTCOMM_SESSION_FAIL, /* Create session fail */ - USTCOMM_START_FAIL, /* Start tracing fail */ - USTCOMM_STOP_FAIL, /* Stop tracing fail */ - USTCOMM_LIST_FAIL, /* Listing apps fail */ - USTCOMM_NO_APPS, /* No traceable application */ - USTCOMM_SESS_NOT_FOUND, /* Session name not found */ - USTCOMM_NO_TRACE, /* No trace exist */ - USTCOMM_FATAL, /* Session daemon had a fatal error */ - USTCOMM_NO_TRACEABLE, /* Error for non traceable app */ - USTCOMM_SELECT_SESS, /* Must select a session */ - USTCOMM_EXIST_SESS, /* Session name already exist */ - USTCOMM_NO_EVENT, /* No event found */ - USTCOMM_KERN_NA, /* Kernel tracer unavalable */ - USTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */ - USTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */ - USTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */ - USTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */ - USTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */ - USTCOMM_KERN_CHAN_ENABLE_FAIL, /* Kernel enable channel failed */ - USTCOMM_KERN_CONTEXT_FAIL, /* Kernel add context failed */ - USTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */ - USTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */ - USTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */ - USTCOMM_KERN_START_FAIL, /* Kernel start trace failed */ - USTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */ - USTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */ - USTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */ - USTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */ - USTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */ - USTCOMM_KERN_NO_SESSION, /* No kernel session found */ - USTCOMM_KERN_LIST_FAIL, /* Kernel listing events failed */ - USTCONSUMER_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */ - USTCONSUMER_SUCCESS_RECV_FD, /* success on receiving fds */ - USTCONSUMER_ERROR_RECV_FD, /* error on receiving fds */ - USTCONSUMER_POLL_ERROR, /* Error in polling thread in kconsumerd */ - USTCONSUMER_POLL_NVAL, /* Poll on closed fd */ - USTCONSUMER_POLL_HUP, /* All fds have hungup */ - USTCONSUMER_EXIT_SUCCESS, /* kconsumerd exiting normally */ - USTCONSUMER_EXIT_FAILURE, /* kconsumerd exiting on error */ - USTCONSUMER_OUTFD_ERROR, /* error opening the tracefile */ - USTCONSUMER_SPLICE_EBADF, /* EBADF from splice(2) */ - USTCONSUMER_SPLICE_EINVAL, /* EINVAL from splice(2) */ - USTCONSUMER_SPLICE_ENOMEM, /* ENOMEM from splice(2) */ - USTCONSUMER_SPLICE_ESPIPE, /* ESPIPE from splice(2) */ - /* MUST be last element */ - USTCOMM_NR, /* Last element */ -}; - -/* - * Data structure for the commands sent from sessiond to UST. - */ -struct ustcomm_ust_msg { - uint32_t handle; - uint32_t cmd; - union { - struct lttng_ust_channel channel; - struct lttng_ust_stream stream; - struct lttng_ust_event event; - struct lttng_ust_context context; - struct lttng_ust_tracer_version version; - } u; -}; - -/* - * Data structure for the response from UST to the session daemon. - * cmd_type is sent back in the reply for validation. - */ -struct ustcomm_ust_reply { - uint32_t handle; - uint32_t cmd; - uint32_t ret_code; /* enum enum ustcomm_return_code */ - uint32_t ret_val; /* return value */ - union { - struct { - uint64_t memory_map_size; - } channel; - struct { - uint64_t memory_map_size; - } stream; - struct lttng_ust_tracer_version version; - } u; -}; - -extern int ustcomm_create_unix_sock(const char *pathname); -extern int ustcomm_connect_unix_sock(const char *pathname); -extern int ustcomm_accept_unix_sock(int sock); -extern int ustcomm_listen_unix_sock(int sock); -extern int ustcomm_close_unix_sock(int sock); -/* Send fd(s) over a unix socket. */ -extern ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds, - size_t nb_fd, size_t len); -extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len); -extern ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len); -extern const char *ustcomm_get_readable_code(int code); -extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum); -extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur, - uint32_t expected_handle, uint32_t expected_cmd); -extern int ustcomm_send_app_cmd(int sock, - struct ustcomm_ust_msg *lum, - struct ustcomm_ust_reply *lur); -int ustcomm_recv_fd(int sock); - -#endif /* _LTTNG_UST_COMM_H */ diff --git a/include/ust/lttng-ust-ctl.h b/include/ust/lttng-ust-ctl.h deleted file mode 100644 index de5eeafe..00000000 --- a/include/ust/lttng-ust-ctl.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2011 - Julien Desfossez - * Mathieu Desnoyers - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LTTNG_UST_CTL_H -#define _LTTNG_UST_CTL_H - -#include - -int ustctl_register_done(int sock); -int ustctl_create_session(int sock); -int ustctl_open_metadata(int sock, int session_handle, - struct lttng_ust_channel_attr *chops, - struct lttng_ust_object_data **metadata_data); -int ustctl_create_channel(int sock, int session_handle, - struct lttng_ust_channel_attr *chops, - struct lttng_ust_object_data **channel_data); -int ustctl_create_stream(int sock, struct lttng_ust_object_data *channel_data, - struct lttng_ust_object_data **stream_data); -int ustctl_create_event(int sock, struct lttng_ust_event *ev, - struct lttng_ust_object_data *channel_data, - struct lttng_ust_object_data **event_data); -int ustctl_add_context(int sock, struct lttng_ust_context *ctx, - struct lttng_ust_object_data *obj_data, - struct lttng_ust_object_data **context_data); - -int ustctl_enable(int sock, struct lttng_ust_object_data *object); -int ustctl_disable(int sock, struct lttng_ust_object_data *object); -int ustctl_start_session(int sock, int handle); -int ustctl_stop_session(int sock, int handle); - -int ustctl_tracepoint_list(int sock); /* not implemented yet */ -int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); -int ustctl_wait_quiescent(int sock); - -/* Flush each buffers in this channel */ -int ustctl_flush_buffer(int sock, struct lttng_ust_object_data *channel_data); - -/* not implemented yet */ -struct lttng_ust_calibrate; -int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate); - -/* - * Map channel lttng_ust_shm_handle and add streams. Typically performed by the - * consumer to map the objects into its memory space. - */ -struct lttng_ust_shm_handle *ustctl_map_channel(struct lttng_ust_object_data *chan_data); -int ustctl_add_stream(struct lttng_ust_shm_handle *lttng_ust_shm_handle, - struct lttng_ust_object_data *stream_data); -/* - * Note: the lttng_ust_object_data from which the lttng_ust_shm_handle is derived can only - * be released after unmapping the handle. - */ -void ustctl_unmap_channel(struct lttng_ust_shm_handle *lttng_ust_shm_handle); - -/* Buffer operations */ - -struct lttng_ust_shm_handle; -struct lttng_ust_lib_ring_buffer; - -/* Open/close stream buffers for read */ -struct lttng_ust_lib_ring_buffer *ustctl_open_stream_read(struct lttng_ust_shm_handle *handle, - int cpu); -void ustctl_close_stream_read(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); - -/* For mmap mode, readable without "get" operation */ -int ustctl_get_mmap_len(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, - unsigned long *len); -int ustctl_get_max_subbuf_size(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, - unsigned long *len); - -/* - * For mmap mode, operate on the current packet (between get/put or - * get_next/put_next). - */ -void *ustctl_get_mmap_base(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); -int ustctl_get_mmap_read_offset(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *off); -int ustctl_get_subbuf_size(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *len); -int ustctl_get_padded_subbuf_size(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *len); -int ustctl_get_next_subbuf(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); -int ustctl_put_next_subbuf(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); - -/* snapshot */ - -int ustctl_snapshot(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); -int ustctl_snapshot_get_consumed(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); -int ustctl_snapshot_get_produced(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); -int ustctl_get_subbuf(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf, unsigned long *pos); -int ustctl_put_subbuf(struct lttng_ust_shm_handle *handle, - struct lttng_ust_lib_ring_buffer *buf); - -/* Release object created by members of this API */ -void release_object(int sock, struct lttng_ust_object_data *data); - -#endif /* _LTTNG_UST_CTL_H */ diff --git a/include/ust/marker-internal.h b/include/ust/marker-internal.h deleted file mode 100644 index 6a11e563..00000000 --- a/include/ust/marker-internal.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _UST_MARKER_INTERNAL_H -#define _UST_MARKER_INTERNAL_H - -/* - * Code markup for dynamic and static tracing. (internal header) - * - * See Documentation/marker.txt. - * - * (C) Copyright 2006 Mathieu Desnoyers - * (C) Copyright 2009 Pierre-Marc Fournier - * (C) Copyright 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; - * 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 - */ - -#include -#include -#include -#include -#include -#include -#include - -#define GET_UST_MARKER(name) (__ust_marker_def_##name) - -#define DEFINE_UST_MARKER(name, format) \ - _DEFINE_UST_MARKER(ust, name, NULL, NULL, format) - -#define DEFINE_UST_MARKER_TP(name, tp_name, tp_cb, format) \ - _DEFINE_UST_MARKER(ust, name, #tp_name, tp_cb, format) - -#define __ust_marker_tp(name, call_private, tp_name, tp_cb, \ - format, args...) \ - do { \ - void __check_tp_type(void) \ - { \ - register_trace_##tp_name(tp_cb, call_private); \ - } \ - DEFINE_UST_MARKER_TP(name, #tp_name, tp_cb, format); \ - __ust_marker_check_format(format, ## args); \ - (*__ust_marker_def_##name.call) \ - (&__ust_marker_def_##name, call_private, ## args); \ - } while (0) - -/** - * ust_marker_tp - Marker in a tracepoint callback - * @name: marker name, not quoted. - * @tp_name: tracepoint name, not quoted. - * @tp_cb: tracepoint callback. Should have an associated global symbol so it - * is not optimized away by the compiler (should not be static). - * @format: format string - * @args...: variable argument list - * - * Places a marker in a tracepoint callback. - */ -#define ust_marker_tp(name, tp_name, tp_cb, format, args...) \ - __ust_marker_tp(ust, name, NULL, tp_name, tp_cb, format, ## args) - -extern void ust_marker_compact_event_ids(void); - -/* - * Connect a probe to a marker. - * private data pointer must be a valid allocated memory address, or NULL. - */ -extern int ust_marker_probe_register(const char *channel, const char *name, - const char *format, ust_marker_probe_func *probe, void *probe_private); - -/* - * Returns the private data given to ust_marker_probe_register. - */ -extern int ust_marker_probe_unregister(const char *channel, const char *name, - ust_marker_probe_func *probe, void *probe_private); -/* - * Unregister a marker by providing the registered private data. - */ -extern int ust_marker_probe_unregister_private_data(ust_marker_probe_func *probe, - void *probe_private); - -extern void *ust_marker_get_private_data(const char *channel, const char *name, - ust_marker_probe_func *probe, int num); - -/* - * ust_marker_synchronize_unregister must be called between the last - * marker probe unregistration and the first one of - * - the end of library exit function - * - the free of any resource used by the probes - * to ensure the code and data are valid for any possibly running probes. - */ -#define ust_marker_synchronize_unregister() synchronize_rcu() - -struct ust_marker_iter { - struct ust_marker_lib *lib; - struct ust_marker * const *ust_marker; -}; - -extern void ust_marker_iter_start(struct ust_marker_iter *iter); -extern void ust_marker_iter_next(struct ust_marker_iter *iter); -extern void ust_marker_iter_stop(struct ust_marker_iter *iter); -extern void ust_marker_iter_reset(struct ust_marker_iter *iter); - -extern int is_ust_marker_enabled(const char *channel, const char *name); - -extern void ust_marker_set_new_ust_marker_cb(void (*cb)(struct ust_marker *)); -extern void init_ust_marker(void); - -void lock_ust_marker(void); -void unlock_ust_marker(void); - -#endif /* _UST_MARKER_INTERNAL_H */ diff --git a/include/ust/marker.h b/include/ust/marker.h deleted file mode 100644 index 8cfdcbdb..00000000 --- a/include/ust/marker.h +++ /dev/null @@ -1,229 +0,0 @@ -#ifndef _UST_MARKER_H -#define _UST_MARKER_H - -/* - * Code markup for dynamic and static tracing. - * - * See Documentation/marker.txt. - * - * (C) Copyright 2006 Mathieu Desnoyers - * (C) Copyright 2009 Pierre-Marc Fournier - * (C) Copyright 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; - * 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 - */ - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct ust_marker; -struct ust_marker_probe_array; - -/** - * ust_marker_probe_func - Type of a marker probe function - * @mdata: marker data - * @probe_private: probe private data - * @call_private: call site private data - * @fmt: format string - * @args: variable argument list pointer. Use a pointer to overcome C's - * inability to pass this around as a pointer in a portable manner in - * the callee otherwise. - * - * Type of marker probe functions. They receive the mdata and need to parse the - * format string to recover the variable argument list. - */ -typedef void ust_marker_probe_func(const struct ust_marker *mdata, - void *probe_private, void *call_private, - const char *fmt, va_list *args); - -struct ust_marker_probe_closure { - ust_marker_probe_func *func; /* Callback */ - void *probe_private; /* Private probe data */ -}; - -struct ust_marker { - const char *channel; /* Name of channel where to send data */ - const char *name; /* Marker name */ - const char *format; /* Marker format string, describing the - * variable argument list. - */ - char state; /* State. */ - char ptype; /* probe type : 0 : single, 1 : multi */ - /* Probe wrapper */ - uint16_t channel_id; /* Numeric channel identifier, dynamic */ - uint16_t event_id; /* Numeric event identifier, dynamic */ - void (*call)(const struct ust_marker *mdata, void *call_private, ...); - struct ust_marker_probe_closure single; - struct ust_marker_probe_array *multi; - const char *tp_name; /* Optional tracepoint name */ - void *tp_cb; /* Optional tracepoint callback */ -}; - -/* - * We keep the "channel" as internal field for marker.c *only*. It will be - * removed soon. - */ - -/* - * __ust_marker_ptrs section is not const (read-only) because it needs to be - * read-write to let the linker apply relocations and keep the object PIC. - */ -#define _DEFINE_UST_MARKER(channel, name, tp_name_str, tp_cb, format) \ - static const char __mstrtab_##channel##_##name[] \ - __attribute__((section("__ust_markers_strings"))) \ - = #channel "\0" #name "\0" format; \ - static struct ust_marker __ust_marker_def_##name \ - __attribute__((section("__ust_markers"))) = \ - { __mstrtab_##channel##_##name, \ - &__mstrtab_##channel##_##name[sizeof(#channel)], \ - &__mstrtab_##channel##_##name[sizeof(#channel) + \ - sizeof(#name)], \ - 0, 0, 0, 0, ust_marker_probe_cb, \ - { __ust_marker_empty_function, NULL}, \ - NULL, tp_name_str, tp_cb }; \ - static struct ust_marker * __ust_marker_ptr_##name \ - __attribute__((used, section("__ust_marker_ptrs"))) = \ - &__ust_marker_def_##name - -/* - * Make sure the alignment of the structure in the __ust_marker section will - * not add unwanted padding between the beginning of the section and the - * structure. Force alignment to the same alignment as the section start. - */ - -#define __ust_marker(channel, name, call_private, format, args...) \ - do { \ - _DEFINE_UST_MARKER(channel, name, NULL, NULL, format); \ - __ust_marker_check_format(format, ## args); \ - if (__builtin_expect(!!(__ust_marker_def_##name.state), 0)) \ - (__ust_marker_def_##name.call) \ - (&__ust_marker_def_##name, call_private,\ - ## args); \ - } while (0) - -/** - * ust_marker - Marker using code patching - * @name: marker name, not quoted. - * @format: format string - * @args...: variable argument list - * - * Places a marker at caller site. - */ -#define ust_marker(name, format, args...) \ - __ust_marker(ust, name, NULL, format, ## args) - -static inline __attribute__((deprecated)) -void __trace_mark_is_deprecated() -{ -} - -/** - * UST_MARKER_NOARGS - Format string for a marker with no argument. - */ -#define UST_MARKER_NOARGS " " - -/* To be used for string format validity checking with gcc */ -static inline -void __attribute__((format(printf, 1, 2))) - ___ust_marker_check_format(const char *fmt, ...) -{ -} - -#define __ust_marker_check_format(format, args...) \ - do { \ - if (0) \ - ___ust_marker_check_format(format, ## args); \ - } while (0) - -extern ust_marker_probe_func __ust_marker_empty_function; - -extern void ust_marker_probe_cb(const struct ust_marker *mdata, - void *call_private, ...); - -struct ust_marker_lib { - struct ust_marker * const *ust_marker_start; - int ust_marker_count; - struct cds_list_head list; -}; - -#define UST_MARKER_LIB \ - extern struct ust_marker * const __start___ust_marker_ptrs[] __attribute__((weak, visibility("hidden"))); \ - extern struct ust_marker * const __stop___ust_marker_ptrs[] __attribute__((weak, visibility("hidden"))); \ - static struct ust_marker * __ust_marker_ptr_dummy \ - __attribute__((used, section("__ust_marker_ptrs"))); \ - \ - static void __attribute__((constructor)) __ust_marker__init(void) \ - { \ - ust_marker_register_lib(__start___ust_marker_ptrs, \ - __stop___ust_marker_ptrs \ - - __start___ust_marker_ptrs); \ - } \ - \ - static void __attribute__((destructor)) __ust_marker__destroy(void) \ - { \ - ust_marker_unregister_lib(__start___ust_marker_ptrs); \ - } - -extern -int ust_marker_register_lib(struct ust_marker * const *ust_marker_start, - int ust_marker_count); -extern -int ust_marker_unregister_lib(struct ust_marker * const *ust_marker_start); - -/* - * trace_mark() -- DEPRECATED - * @channel: name prefix, not quoted. Ignored. - * @name: marker name, not quoted. - * @format: format string - * @args...: variable argument list - * - * Kept as a compatibility API and is *DEPRECATED* in favor of - * ust_marker(). - */ -#define trace_mark(channel, name, format, args...) \ - __trace_mark_is_deprecated(); \ - ust_marker(name, format, ## args) - -static inline __attribute__((deprecated)) -void __MARKER_LIB_IS_DEPRECATED() -{ -} - -/* - * MARKER_LIB is kept for backward compatibility and is *DEPRECATED*. - * Use UST_MARKER_LIB instead. - */ -#define MARKER_LIB \ - __MARKER_LIB_IS_DEPRECATED(); \ - UST_MARKER_LIB - -/** - * MARKER_NOARGS - Compatibility API. *DEPRECATED*. Use - * UST_MARKER_NOARGS instead. - */ -#define MARK_NOARGS UST_MARKER_NOARGS - -#ifdef __cplusplus -} -#endif - -#endif /* _UST_MARKER_H */ diff --git a/include/ust/probe-internal.h b/include/ust/probe-internal.h deleted file mode 100644 index a4f3a0e5..00000000 --- a/include/ust/probe-internal.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _UST_PROBE_H -#define _UST_PROBE_H - -/* - * Copyright (C) 2009 Pierre-Marc Fournier - * - * 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. - * - * 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 - * - */ - -/* Maximum number of callbacks per marker */ -#define LTT_NR_CALLBACKS 10 - -struct ltt_serialize_closure; -struct ust_buffer; - -typedef size_t (*ltt_serialize_cb)(struct ust_buffer *buf, size_t buf_offset, - struct ltt_serialize_closure *closure, - void *serialize_private, - unsigned int stack_pos_ctx, - int *largest_align, - const char *fmt, va_list *args); - -struct ltt_available_probe { - const char *name; /* probe name */ - const char *format; - ust_marker_probe_func *probe_func; - ltt_serialize_cb callbacks[LTT_NR_CALLBACKS]; - struct cds_list_head node; /* registered probes list */ -}; - -extern int ltt_probe_register(struct ltt_available_probe *pdata); -extern int ltt_probe_unregister(struct ltt_available_probe *pdata); -extern int ltt_ust_marker_connect(const char *channel, const char *mname, - const char *pname); -extern int ltt_ust_marker_disconnect(const char *channel, const char *mname, - const char *pname); - -#endif /* _UST_PROBE_H */ diff --git a/include/ust/processor.h b/include/ust/processor.h deleted file mode 100644 index e3407bab..00000000 --- a/include/ust/processor.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2009 Pierre-Marc Fournier - * - * 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. - * - * 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 - */ - -#ifndef UST_PROCESSOR_H -#define UST_PROCESSOR_H - -#define ____cacheline_aligned __attribute__((aligned(CAA_CACHE_LINE_SIZE))) - -#ifdef __i386 - -static inline int fls(int x) -{ - int r; - asm("bsrl %1,%0\n\t" - "cmovzl %2,%0" - : "=&r" (r) : "rm" (x), "rm" (-1)); - return r + 1; -} - -#elif defined(__x86_64) - -static inline int fls(int x) -{ - int r; - asm("bsrl %1,%0\n\t" - "cmovzl %2,%0" - : "=&r" (r) : "rm" (x), "rm" (-1)); - return r + 1; -} - -#elif defined(__PPC__) - -static __inline__ int fls(unsigned int x) -{ - int lz; - - asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); - return 32 - lz; -} - -#else /* arch-agnostic */ - -static __inline__ int fls(unsigned int x) -{ - int r = 32; - - if (!x) - return 0; - if (!(x & 0xFFFF0000U)) { - x <<= 16; - r -= 16; - } - if (!(x & 0xFF000000U)) { - x <<= 8; - r -= 8; - } - if (!(x & 0xF0000000U)) { - x <<= 4; - r -= 4; - } - if (!(x & 0xC0000000U)) { - x <<= 2; - r -= 2; - } - if (!(x & 0x80000000U)) { - x <<= 1; - r -= 1; - } - return r; -} - -#endif - -#endif /* UST_PROCESSOR_H */ diff --git a/include/ust/ringbuffer-abi.h b/include/ust/ringbuffer-abi.h deleted file mode 100644 index 25bc194b..00000000 --- a/include/ust/ringbuffer-abi.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _UST_RING_BUFFER_ABI_H -#define _UST_RING_BUFFER_ABI_H - -/* - * ust/ringbuffer-abi.h - * - * (C) Copyright 2005-2010 - Mathieu Desnoyers - * - * Wait-free ring buffer ABI. - * - * Author: - * Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#define _UST_CMD(minor) (minor) -#define _UST_CMDR(minor, type) (minor) -#define _UST_CMDW(minor, type) (minor) - -/* - * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and - * consume sub-buffers sequentially. - * - * Reading sub-buffers without consuming them can be performed with: - * - * RING_BUFFER_SNAPSHOT - * RING_BUFFER_SNAPSHOT_GET_CONSUMED - * RING_BUFFER_SNAPSHOT_GET_PRODUCED - * - * to get the offset range to consume, and then by passing each sub-buffer - * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it - * with RING_BUFFER_PUT_SUBBUF. - * - * Note that the "snapshot" API can be used to read the sub-buffer in reverse - * order, which is useful for flight recorder snapshots. - */ - -/* Get a snapshot of the current ring buffer producer and consumer positions */ -#define RING_BUFFER_SNAPSHOT _UST_CMD(0x00) -/* Get the consumer position (iteration start) */ -#define RING_BUFFER_SNAPSHOT_GET_CONSUMED _UST_CMDR(0x01, unsigned long) -/* Get the producer position (iteration end) */ -#define RING_BUFFER_SNAPSHOT_GET_PRODUCED _UST_CMDR(0x02, unsigned long) -/* Get exclusive read access to the specified sub-buffer position */ -#define RING_BUFFER_GET_SUBBUF _UST_CMDW(0x03, unsigned long) -/* Release exclusive sub-buffer access */ -#define RING_BUFFER_PUT_SUBBUF _UST_CMD(0x04) - -/* Get exclusive read access to the next sub-buffer that can be read. */ -#define RING_BUFFER_GET_NEXT_SUBBUF _UST_CMD(0x05) -/* Release exclusive sub-buffer access, move consumer forward. */ -#define RING_BUFFER_PUT_NEXT_SUBBUF _UST_CMD(0x06) -/* returns the size of the current sub-buffer, without padding (for mmap). */ -#define RING_BUFFER_GET_SUBBUF_SIZE _UST_CMDR(0x07, unsigned long) -/* returns the size of the current sub-buffer, with padding (for splice). */ -#define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _UST_CMDR(0x08, unsigned long) -/* returns the maximum size for sub-buffers. */ -#define RING_BUFFER_GET_MAX_SUBBUF_SIZE _UST_CMDR(0x09, unsigned long) -/* returns the length to mmap. */ -#define RING_BUFFER_GET_MMAP_LEN _UST_CMDR(0x0A, unsigned long) -/* returns the offset of the subbuffer belonging to the mmap reader. */ -#define RING_BUFFER_GET_MMAP_READ_OFFSET _UST_CMDR(0x0B, unsigned long) -/* flush the current sub-buffer */ -#define RING_BUFFER_FLUSH _UST_CMD(0x0C) - -#endif /* _UST_RING_BUFFER_ABI_H */ diff --git a/include/ust/ringbuffer-config.h b/include/ust/ringbuffer-config.h deleted file mode 100644 index 1d4ce67d..00000000 --- a/include/ust/ringbuffer-config.h +++ /dev/null @@ -1,309 +0,0 @@ -#ifndef _LINUX_RING_BUFFER_CONFIG_H -#define _LINUX_RING_BUFFER_CONFIG_H - -/* - * linux/ringbuffer/config.h - * - * Copyright (C) 2010 - Mathieu Desnoyers - * - * Ring buffer configuration header. Note: after declaring the standard inline - * functions, clients should also include linux/ringbuffer/api.h. - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include -#include "ust/lttng-tracer.h" -#include "ust/usterr-signal-safe.h" -#include "ust/kcompat/kcompat.h" -#include "ust/align.h" - -struct lttng_ust_lib_ring_buffer; -struct channel; -struct lttng_ust_lib_ring_buffer_config; -struct lttng_ust_lib_ring_buffer_ctx; -struct lttng_ust_shm_handle *handle; - -/* - * Ring buffer client callbacks. Only used by slow path, never on fast path. - * For the fast path, record_header_size(), ring_buffer_clock_read() should be - * provided as inline functions too. These may simply return 0 if not used by - * the client. - */ -struct lttng_ust_lib_ring_buffer_client_cb { - /* Mandatory callbacks */ - - /* A static inline version is also required for fast path */ - u64 (*ring_buffer_clock_read) (struct channel *chan); - size_t (*record_header_size) (const struct lttng_ust_lib_ring_buffer_config *config, - struct channel *chan, size_t offset, - size_t *pre_header_padding, - struct lttng_ust_lib_ring_buffer_ctx *ctx); - - /* Slow path only, at subbuffer switch */ - size_t (*subbuffer_header_size) (void); - void (*buffer_begin) (struct lttng_ust_lib_ring_buffer *buf, u64 tsc, - unsigned int subbuf_idx, - struct lttng_ust_shm_handle *handle); - void (*buffer_end) (struct lttng_ust_lib_ring_buffer *buf, u64 tsc, - unsigned int subbuf_idx, unsigned long data_size, - struct lttng_ust_shm_handle *handle); - - /* Optional callbacks (can be set to NULL) */ - - /* Called at buffer creation/finalize */ - int (*buffer_create) (struct lttng_ust_lib_ring_buffer *buf, void *priv, - int cpu, const char *name, - struct lttng_ust_shm_handle *handle); - /* - * Clients should guarantee that no new reader handle can be opened - * after finalize. - */ - void (*buffer_finalize) (struct lttng_ust_lib_ring_buffer *buf, - void *priv, int cpu, - struct lttng_ust_shm_handle *handle); - - /* - * Extract header length, payload length and timestamp from event - * record. Used by buffer iterators. Timestamp is only used by channel - * iterator. - */ - void (*record_get) (const struct lttng_ust_lib_ring_buffer_config *config, - struct channel *chan, struct lttng_ust_lib_ring_buffer *buf, - size_t offset, size_t *header_len, - size_t *payload_len, u64 *timestamp, - struct lttng_ust_shm_handle *handle); -}; - -/* - * Ring buffer instance configuration. - * - * Declare as "static const" within the client object to ensure the inline fast - * paths can be optimized. - * - * alloc/sync pairs: - * - * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_PER_CPU : - * Per-cpu buffers with per-cpu synchronization. Tracing must be performed - * with preemption disabled (lib_ring_buffer_get_cpu() and - * lib_ring_buffer_put_cpu()). - * - * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_GLOBAL : - * Per-cpu buffer with global synchronization. Tracing can be performed with - * preemption enabled, statistically stays on the local buffers. - * - * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_PER_CPU : - * Should only be used for buffers belonging to a single thread or protected - * by mutual exclusion by the client. Note that periodical sub-buffer switch - * should be disabled in this kind of configuration. - * - * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_GLOBAL : - * Global shared buffer with global synchronization. - * - * wakeup: - * - * RING_BUFFER_WAKEUP_BY_TIMER uses per-cpu deferrable timers to poll the - * buffers and wake up readers if data is ready. Mainly useful for tracers which - * don't want to call into the wakeup code on the tracing path. Use in - * combination with "read_timer_interval" channel_create() argument. - * - * RING_BUFFER_WAKEUP_BY_WRITER directly wakes up readers when a subbuffer is - * ready to read. Lower latencies before the reader is woken up. Mainly suitable - * for drivers. - * - * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client - * has the responsibility to perform wakeups. - */ -struct lttng_ust_lib_ring_buffer_config { - enum { - RING_BUFFER_ALLOC_PER_CPU, - RING_BUFFER_ALLOC_GLOBAL, - } alloc; - enum { - RING_BUFFER_SYNC_PER_CPU, /* Wait-free */ - RING_BUFFER_SYNC_GLOBAL, /* Lock-free */ - } sync; - enum { - RING_BUFFER_OVERWRITE, /* Overwrite when buffer full */ - RING_BUFFER_DISCARD, /* Discard when buffer full */ - } mode; - enum { - RING_BUFFER_SPLICE, - RING_BUFFER_MMAP, - RING_BUFFER_READ, /* TODO */ - RING_BUFFER_ITERATOR, - RING_BUFFER_NONE, - } output; - enum { - RING_BUFFER_PAGE, - RING_BUFFER_VMAP, /* TODO */ - RING_BUFFER_STATIC, /* TODO */ - } backend; - enum { - RING_BUFFER_NO_OOPS_CONSISTENCY, - RING_BUFFER_OOPS_CONSISTENCY, - } oops; - enum { - RING_BUFFER_IPI_BARRIER, - RING_BUFFER_NO_IPI_BARRIER, - } ipi; - enum { - RING_BUFFER_WAKEUP_BY_TIMER, /* wake up performed by timer */ - RING_BUFFER_WAKEUP_BY_WRITER, /* - * writer wakes up reader, - * not lock-free - * (takes spinlock). - */ - } wakeup; - /* - * tsc_bits: timestamp bits saved at each record. - * 0 and 64 disable the timestamp compression scheme. - */ - unsigned int tsc_bits; - struct lttng_ust_lib_ring_buffer_client_cb cb; -}; - -/* - * ring buffer context - * - * Context passed to lib_ring_buffer_reserve(), lib_ring_buffer_commit(), - * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and - * lib_ring_buffer_write(). - */ -struct lttng_ust_lib_ring_buffer_ctx { - /* input received by lib_ring_buffer_reserve(), saved here. */ - struct channel *chan; /* channel */ - void *priv; /* client private data */ - struct lttng_ust_shm_handle *handle; /* shared-memory handle */ - size_t data_size; /* size of payload */ - int largest_align; /* - * alignment of the largest element - * in the payload - */ - int cpu; /* processor id */ - - /* output from lib_ring_buffer_reserve() */ - struct lttng_ust_lib_ring_buffer *buf; /* - * buffer corresponding to processor id - * for this channel - */ - size_t slot_size; /* size of the reserved slot */ - unsigned long buf_offset; /* offset following the record header */ - unsigned long pre_offset; /* - * Initial offset position _before_ - * the record is written. Positioned - * prior to record header alignment - * padding. - */ - u64 tsc; /* time-stamp counter value */ - unsigned int rflags; /* reservation flags */ -}; - -/** - * lib_ring_buffer_ctx_init - initialize ring buffer context - * @ctx: ring buffer context to initialize - * @chan: channel - * @priv: client private data - * @data_size: size of record data payload - * @largest_align: largest alignment within data payload types - * @cpu: processor id - */ -static inline -void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct channel *chan, void *priv, - size_t data_size, int largest_align, - int cpu, struct lttng_ust_shm_handle *handle) -{ - ctx->chan = chan; - ctx->priv = priv; - ctx->data_size = data_size; - ctx->largest_align = largest_align; - ctx->cpu = cpu; - ctx->rflags = 0; - ctx->handle = handle; -} - -/* - * Reservation flags. - * - * RING_BUFFER_RFLAG_FULL_TSC - * - * This flag is passed to record_header_size() and to the primitive used to - * write the record header. It indicates that the full 64-bit time value is - * needed in the record header. If this flag is not set, the record header needs - * only to contain "tsc_bits" bit of time value. - * - * Reservation flags can be added by the client, starting from - * "(RING_BUFFER_FLAGS_END << 0)". It can be used to pass information from - * record_header_size() to lib_ring_buffer_write_record_header(). - */ -#define RING_BUFFER_RFLAG_FULL_TSC (1U << 0) -#define RING_BUFFER_RFLAG_END (1U << 1) - -/* - * We need to define RING_BUFFER_ALIGN_ATTR so it is known early at - * compile-time. We have to duplicate the "config->align" information and the - * definition here because config->align is used both in the slow and fast - * paths, but RING_BUFFER_ALIGN_ATTR is only available for the client code. - */ -#ifdef RING_BUFFER_ALIGN - -# define RING_BUFFER_ALIGN_ATTR /* Default arch alignment */ - -/* - * Calculate the offset needed to align the type. - * size_of_type must be non-zero. - */ -static inline -unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) -{ - return offset_align(align_drift, size_of_type); -} - -#else - -# define RING_BUFFER_ALIGN_ATTR __attribute__((packed)) - -/* - * Calculate the offset needed to align the type. - * size_of_type must be non-zero. - */ -static inline -unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) -{ - return 0; -} - -#endif - -/** - * lib_ring_buffer_align_ctx - Align context offset on "alignment" - * @ctx: ring buffer context. - */ -static inline -void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx, - size_t alignment) -{ - ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset, - alignment); -} - -/* - * lib_ring_buffer_check_config() returns 0 on success. - * Used internally to check for valid configurations at channel creation. - */ -static inline -int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config, - unsigned int switch_timer_interval, - unsigned int read_timer_interval) -{ - if (config->alloc == RING_BUFFER_ALLOC_GLOBAL - && config->sync == RING_BUFFER_SYNC_PER_CPU - && switch_timer_interval) - return -EINVAL; - return 0; -} - -#include - -#endif /* _LINUX_RING_BUFFER_CONFIG_H */ diff --git a/include/ust/share.h b/include/ust/share.h deleted file mode 100644 index cecfaa17..00000000 --- a/include/ust/share.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2009 Pierre-Marc Fournier - * - * 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. - * - * 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 - */ - -#ifndef UST_SHARE_H -#define UST_SHARE_H - -/* write() */ -#include - -/* send() */ -#include -#include - -#include - -/* - * This write is patient because it restarts if it was incomplete. - */ - -static __inline__ ssize_t patient_write(int fd, const void *buf, size_t count) -{ - const char *bufc = (const char *) buf; - int result; - - for(;;) { - result = write(fd, bufc, count); - if (result == -1 && errno == EINTR) { - continue; - } - if (result <= 0) { - return result; - } - count -= result; - bufc += result; - - if (count == 0) { - break; - } - } - - return bufc-(const char *)buf; -} - -static __inline__ ssize_t patient_send(int fd, const void *buf, size_t count, int flags) -{ - const char *bufc = (const char *) buf; - int result; - - for(;;) { - result = send(fd, bufc, count, flags); - if (result == -1 && errno == EINTR) { - continue; - } - if (result <= 0) { - return result; - } - count -= result; - bufc += result; - - if (count == 0) { - break; - } - } - - return bufc - (const char *) buf; -} - -#endif /* UST_SHARE_H */ diff --git a/include/ust/stringify.h b/include/ust/stringify.h deleted file mode 100644 index b8dfd90c..00000000 --- a/include/ust/stringify.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __LINUX_STRINGIFY_H -#define __LINUX_STRINGIFY_H -/* - * Copyright (C) 2009 Zhaolei - * - * 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 - */ - -/* Indirect stringification. Doing two levels allows the parameter to be a - * macro itself. For example, compile with -DFOO=bar, __stringify(FOO) - * converts to "bar". - */ - -#define __stringify_1(x...) #x -#define __stringify(x...) __stringify_1(x) - -#endif /* !__LINUX_STRINGIFY_H */ diff --git a/include/ust/tracepoint-event.h b/include/ust/tracepoint-event.h deleted file mode 100644 index b4bd59cb..00000000 --- a/include/ust/tracepoint-event.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2009 Steven Rostedt - * 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; - * 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 - * - * - * Trace files that want to automate creationg of all tracepoints defined - * in their file should include this file. The following are macros that the - * trace file may define: - * - * TRACEPOINT_SYSTEM defines the system the tracepoint is for: - * < [com_company_]project_[component_] > - * - * 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". - * - * TRACEPOINT_INCLUDE_PATH if the path is something other than within - * the system's include/tracepoint/ path, then this macro can define - * the path to use. This path is relative to tracepoint-event.h, or - * to the include search path. Trick: Use a - * #define TRACEPOINT_INCLUDE_PATH . - * combined with -Ipath_to_header as compiler argument to allow - * searching for a header within your project build tree. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef TRACEPOINT_CREATE_PROBES - -/* Prevent recursion */ -#undef TRACEPOINT_CREATE_PROBES - -#ifndef __tp_stringify -#define __tp_stringify_1(x...) #x -#define __tp_stringify(x...) __tp_stringify_1(x) -#endif - -#undef TRACEPOINT_EVENT -#define TRACEPOINT_EVENT(name, proto, args, fields) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_INSTANCE -#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_NOARGS -#define TRACEPOINT_EVENT_NOARGS(name, fields) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_INCLUDE -#undef __TRACEPOINT_INCLUDE - -#ifndef TRACEPOINT_INCLUDE_FILE -# define TRACEPOINT_INCLUDE_FILE TRACEPOINT_SYSTEM -# define UNDEF_TRACEPOINT_INCLUDE_FILE -#endif - -#ifndef TRACEPOINT_INCLUDE_PATH -# define __TRACEPOINT_INCLUDE(system) -# define UNDEF_TRACEPOINT_INCLUDE_PATH -#else -# define __TRACEPOINT_INCLUDE(system) \ - __tp_stringify(TRACEPOINT_INCLUDE_PATH/system.h) -#endif - -# define TRACEPOINT_INCLUDE(system) __TRACEPOINT_INCLUDE(system) - -/* Let the trace headers be reread */ -#define TRACEPOINT_HEADER_MULTI_READ - -#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) - -#include - -#undef TRACEPOINT_EVENT -#undef TRACEPOINT_EVENT_CLASS -#undef TRACEPOINT_EVENT_INSTANCE -#undef TRACEPOINT_EVENT_NOARGS -#undef TRACEPOINT_EVENT_CLASS_NOARGS -#undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#undef TRACEPOINT_HEADER_MULTI_READ - -/* Only undef what we defined in this file */ -#ifdef UNDEF_TRACEPOINT_INCLUDE_FILE -# undef TRACEPOINT_INCLUDE_FILE -# undef UNDEF_TRACEPOINT_INCLUDE_FILE -#endif - -#ifdef UNDEF_TRACEPOINT_INCLUDE_PATH -# undef TRACEPOINT_INCLUDE_PATH -# undef UNDEF_TRACEPOINT_INCLUDE_PATH -#endif - -/* We may be processing more files */ -#define TRACEPOINT_CREATE_PROBES - -#endif /* TRACEPOINT_CREATE_PROBES */ - -#ifdef __cplusplus -} -#endif diff --git a/include/ust/tracepoint-internal.h b/include/ust/tracepoint-internal.h deleted file mode 100644 index 93d89257..00000000 --- a/include/ust/tracepoint-internal.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _UST_TRACEPOINT_INTERNAL_H -#define _UST_TRACEPOINT_INTERNAL_H - -/* - * tracepoint-internal.h - * - * Tracepoint internal header. - * - * Copyright (C) 2008 Mathieu Desnoyers - * Copyright (C) 2009 Pierre-Marc Fournier - * Copyright (C) 2009 Steven Rostedt - * - * 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 - * - * Heavily inspired from the Linux Kernel Markers. - * - * Ported to userspace by Pierre-Marc Fournier. - */ - -#include -#include -#include -#include - -struct tracepoint_lib { - struct tracepoint * const *tracepoints_start; - int tracepoints_count; - struct cds_list_head list; -}; - -extern int tracepoint_probe_register_noupdate(const char *name, void *probe, - void *data); -extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe, - void *data); -extern void tracepoint_probe_update_all(void); - -struct tracepoint_iter { - struct tracepoint_lib *lib; - struct tracepoint * const *tracepoint; -}; - -extern void tracepoint_iter_start(struct tracepoint_iter *iter); -extern void tracepoint_iter_next(struct tracepoint_iter *iter); -extern void tracepoint_iter_stop(struct tracepoint_iter *iter); -extern void tracepoint_iter_reset(struct tracepoint_iter *iter); -extern int tracepoint_get_iter_range(struct tracepoint * const **tracepoint, - struct tracepoint * const *begin, struct tracepoint * const *end); - -/* - * tracepoint_synchronize_unregister must be called between the last tracepoint - * probe unregistration and the end of module exit to make sure there is no - * caller executing a probe when it is freed. - */ -static inline void tracepoint_synchronize_unregister(void) -{ - synchronize_rcu(); -} - -struct trace_event_iter { - struct trace_event_lib *lib; - struct trace_event * const *trace_event; -}; - -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_stop(struct trace_event_iter *iter); -extern void trace_event_iter_reset(struct trace_event_iter *iter); - -extern void trace_event_update_process(void); -extern int is_trace_event_enabled(const char *channel, const char *name); - -extern void init_tracepoint(void); -extern void exit_tracepoint(void); - -#endif /* _UST_TRACEPOINT_INTERNAL_H */ diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h deleted file mode 100644 index e39a3849..00000000 --- a/include/ust/tracepoint.h +++ /dev/null @@ -1,423 +0,0 @@ -#ifndef _UST_TRACEPOINT_H -#define _UST_TRACEPOINT_H - -/* - * Copyright (C) 2008-2011 Mathieu Desnoyers - * Copyright (C) 2009 Pierre-Marc Fournier - * Copyright (C) 2009 Steven Rostedt - * - * 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 - * - * Heavily inspired from the Linux Kernel Markers. - * - * Ported to userspace by Pierre-Marc Fournier. - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct tracepoint_probe { - void *func; - void *data; -}; - -struct tracepoint { - const char *name; /* Tracepoint name */ - char state; /* State. */ - struct tracepoint_probe *probes; -}; - -/* - * Tracepoints should be added to the instrumented code using the - * "tracepoint()" macro. - */ -#define tracepoint(name, args...) __trace_##name(args) - -/* - * it_func[0] is never NULL because there is at least one element in the array - * when the array itself is non NULL. - */ -#define __DO_TRACE(tp, proto, args) \ - do { \ - struct tracepoint_probe *__tp_it_probe_ptr; \ - void *__tp_it_func; \ - void *__tp_cb_data; \ - \ - rcu_read_lock(); \ - __tp_it_probe_ptr = rcu_dereference((tp)->probes); \ - if (__tp_it_probe_ptr) { \ - do { \ - __tp_it_func = __tp_it_probe_ptr->func; \ - __tp_cb_data = __tp_it_probe_ptr->data; \ - URCU_FORCE_CAST(void(*)(proto), __tp_it_func)(args); \ - } while ((++__tp_it_probe_ptr)->func); \ - } \ - rcu_read_unlock(); \ - } while (0) - -#define TP_PARAMS(args...) args -#define TP_PROTO(args...) args -#define TP_ARGS(args...) args - -#define __CHECK_TRACE(name, proto, args) \ - do { \ - if (caa_unlikely(__tracepoint_##name.state)) \ - __DO_TRACE(&__tracepoint_##name, \ - TP_PROTO(proto), TP_ARGS(args)); \ - } while (0) - -/* - * Make sure the alignment of the structure in the __tracepoints section will - * not add unwanted padding between the beginning of the section and the - * structure. Force alignment to the same alignment as the section start. - */ -#define __DECLARE_TRACEPOINT(name, proto, args, data_proto, data_args) \ - extern struct tracepoint __tracepoint_##name; \ - static inline void __trace_##name(proto) \ - { \ - __CHECK_TRACE(name, TP_PROTO(data_proto), \ - TP_ARGS(data_args)); \ - } \ - static inline int \ - __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)\ - { \ - return __tracepoint_probe_unregister(#name, (void *)probe, \ - data); \ - } - -/* - * The need for the _DECLARE_TRACEPOINT_NOARGS() is to handle the prototype - * (void). "void" is a special value in a function prototype and can - * not be combined with other arguments. Since the DECLARE_TRACEPOINT() - * macro adds a data element at the beginning of the prototype, - * we need a way to differentiate "(void *data, proto)" from - * "(void *data, void)". The second prototype is invalid. - * - * DECLARE_TRACEPOINT_NOARGS() passes "void" as the tracepoint prototype - * and "void *__tp_cb_data" as the callback prototype. - * - * DECLARE_TRACEPOINT() passes "proto" as the tracepoint protoype and - * "void *__tp_cb_data, proto" as the callback prototype. - */ -#define _DECLARE_TRACEPOINT_NOARGS(name) \ - __DECLARE_TRACEPOINT(name, void, , void *__tp_cb_data, __tp_cb_data) - -#define _DECLARE_TRACEPOINT(name, proto, args) \ - __DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args), \ - TP_PARAMS(void *__tp_cb_data, proto), \ - TP_PARAMS(__tp_cb_data, args)) - -/* - * __tracepoints_ptrs section is not const (read-only) to let the linker update - * the pointer, allowing PIC code. - */ -#define _DEFINE_TRACEPOINT(name) \ - static const char __tpstrtab_##name[] \ - __attribute__((section("__tracepoints_strings"))) = #name; \ - struct tracepoint __tracepoint_##name \ - __attribute__((section("__tracepoints"))) = \ - { __tpstrtab_##name, 0, NULL }; \ - static struct tracepoint * __tracepoint_ptr_##name \ - __attribute__((used, section("__tracepoints_ptrs"))) = \ - &__tracepoint_##name; - - -#define __register_tracepoint(name, probe, data) \ - __register_trace_##name(probe, data) -#define __unregister_tracepoint(name, probe, data) \ - __unregister_trace_##name(probe, data) - -/* - * Connect a probe to a tracepoint. - * Internal API. - */ -extern -int __tracepoint_probe_register(const char *name, void *probe, void *data); - -/* - * Disconnect a probe from a tracepoint. - * Internal API. - */ -extern -int __tracepoint_probe_unregister(const char *name, void *probe, void *data); - -extern -int tracepoint_register_lib(struct tracepoint * const *tracepoints_start, - int tracepoints_count); -extern -int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); - -/* - * These weak symbols, the constructor, and destructor take care of - * registering only _one_ instance of the tracepoints per shared-ojbect - * (or for the whole main program). - */ -extern struct tracepoint * const __start___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); -extern struct tracepoint * const __stop___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); -int __tracepoint_registered - __attribute__((weak, visibility("hidden"))); - -static void __attribute__((constructor)) __tracepoints__init(void) -{ - if (__tracepoint_registered++) - return; - tracepoint_register_lib(__start___tracepoints_ptrs, - __stop___tracepoints_ptrs - - __start___tracepoints_ptrs); -} - -static void __attribute__((destructor)) __tracepoints__destroy(void) -{ - if (--__tracepoint_registered) - return; - tracepoint_unregister_lib(__start___tracepoints_ptrs); -} - -#ifndef TRACEPOINT_EVENT -/* - * Usage of the TRACEPOINT_EVENT macro: - * - * In short, an example: - * - * TRACEPOINT_EVENT(< [com_company_]project_[component_]event >, - * TP_PROTO(int arg0, void *arg1, char *string, size_t strlen, - * long *arg4, size_t arg4_len), - * TP_ARGS(arg0, arg1, string, strlen, arg4, arg4_len), - * TP_FIELDS( - * - * * Integer, printed in base 10 * - * ctf_integer(int, field_a, arg0) - * - * * Integer, printed with 0x base 16 * - * ctf_integer_hex(unsigned long, field_d, arg1) - * - * * Array Sequence, printed as UTF8-encoded array of bytes * - * ctf_array_text(char, field_b, string, FIXED_LEN) - * ctf_sequence_text(char, field_c, string, size_t, strlen) - * - * * String, printed as UTF8-encoded string * - * ctf_string(field_e, string) - * - * * Array sequence of signed integer values * - * ctf_array(long, field_f, arg4, FIXED_LEN4) - * ctf_sequence(long, field_g, arg4, size_t, arg4_len) - * ) - * ) - * - * In more detail: - * - * We define a tracepoint, its arguments, and its 'fast binary record' - * layout. - * - * Firstly, name your tracepoint via TRACEPOINT_EVENT(name, - * - * The name should be a proper C99 identifier. - * The "name" MUST follow these rules to ensure no namespace clash - * occurs: - * - * For projects (applications and libraries) for which an entity - * specific to the project controls the source code and thus its - * tracepoints (typically with a scope larger than a single company): - * - * either: - * project_component_event - * or: - * project_event - * - * Where "project" is the name of the project, - * "component" is the name of the project component (which may - * include several levels of sub-components, e.g. - * ...component_subcomponent_...) where the tracepoint is located - * (optional), - * "event" is the name of the tracepoint event. - * - * For projects issued from a single company wishing to advertise that - * the company controls the source code and thus the tracepoints, the - * "com_" prefix should be used: - * - * either: - * com_company_project_component_event - * or: - * com_company_project_event - * - * Where "company" is the name of the company, - * "project" is the name of the project, - * "component" is the name of the project component (which may - * include several levels of sub-components, e.g. - * ...component_subcomponent_...) where the tracepoint is located - * (optional), - * "event" is the name of the tracepoint event. - * - * - * As an example, let's consider a user-space application "someproject" - * that would have an internal thread scheduler: - * - * TRACEPOINT_EVENT(someproject_sched_switch, - * - * * - * * A function has a regular function arguments - * * prototype, declare it via TP_PROTO(): - * * - * - * TP_PROTO(struct rq *rq, struct task_struct *prev, - * struct task_struct *next), - * - * * - * * Define the call signature of the 'function'. - * * (Design sidenote: we use this instead of a - * * TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.) - * * - * - * TP_ARGS(rq, prev, next), - * - * * - * * Fast binary tracing: define the trace record via - * * TP_FIELDS(). You can think about it like a - * * regular C structure local variable definition. - * * - * * This is how the trace record is structured and will - * * be saved into the ring buffer. These are the fields - * * that will be exposed to readers. - * * - * * ctf_integer(pid_t, prev_pid, prev->pid) is equivalent - * * to a standard declaraton: - * * - * * pid_t prev_pid; - * * - * * followed by an assignment: - * * - * * prev_pid = prev->pid; - * * - * * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) is - * * equivalent to: - * * - * * char prev_comm[TASK_COMM_LEN]; - * * - * * followed by an assignment: - * * - * * memcpy(prev_comm, prev->comm, TASK_COMM_LEN); - * * - * - * TP_FIELDS( - * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) - * ctf_integer(pid_t, prev_pid, prev->pid) - * ctf_integer(int, prev_prio, prev->prio) - * ctf_array(char, next_comm, next->comm, TASK_COMM_LEN) - * ctf_integer(pid_t, next_pid, next->pid) - * ctf_integer(int, next_prio, next->prio) - * ) - * ) - * - * Do _NOT_ add comma (,) nor semicolon (;) after the TRACEPOINT_EVENT - * declaration. - * - * The TRACEPOINT_SYSTEM must be defined when declaring a - * TRACEPOINT_EVENT. See ust/tracepoint-event.h for information about - * usage of other macros controlling TRACEPOINT_EVENT. - */ - -#define TRACEPOINT_EVENT(name, proto, args, fields) \ - _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) - -#define TRACEPOINT_EVENT_CLASS(name, proto, args, fields) -#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ - _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) - -/* - * Declaration of tracepoints that take 0 argument. - */ -#define TRACEPOINT_EVENT_NOARGS(name, fields) \ - _DECLARE_TRACEPOINT_NOARGS(name) - -#define TRACEPOINT_EVENT_CLASS_NOARGS(name, fields) -#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ - _DECLARE_TRACEPOINT_NOARGS(name) - -#endif /* #ifndef TRACEPOINT_EVENT */ - -#ifndef TRACEPOINT_LOGLEVEL - -/* - * Tracepoint Loglevel Declaration Facility - * - * This is a place-holder the tracepoint loglevel declaration, - * overridden by the tracer implementation. - * - * Typical use of these loglevels: - * - * 1) Declare the mapping between loglevel names and an integer values - * within TRACEPOINT_LOGLEVEL_ENUM, using TP_LOGLEVEL for each tuple. - * Do _NOT_ add comma (,) nor semicolon (;) between the - * TRACEPOINT_LOGLEVEL_ENUM entries. Do _NOT_ add comma (,) nor - * semicolon (;) after the TRACEPOINT_LOGLEVEL_ENUM declaration. The - * name should be a proper C99 identifier. - * - * TRACEPOINT_LOGLEVEL_ENUM( - * TP_LOGLEVEL( < loglevel_name >, < value > ) - * TP_LOGLEVEL( < loglevel_name >, < value > ) - * ... - * ) - * - * e.g.: - * - * TRACEPOINT_LOGLEVEL_ENUM( - * TP_LOGLEVEL(LOG_EMERG, 0) - * TP_LOGLEVEL(LOG_ALERT, 1) - * TP_LOGLEVEL(LOG_CRIT, 2) - * TP_LOGLEVEL(LOG_ERR, 3) - * TP_LOGLEVEL(LOG_WARNING, 4) - * TP_LOGLEVEL(LOG_NOTICE, 5) - * TP_LOGLEVEL(LOG_INFO, 6) - * TP_LOGLEVEL(LOG_DEBUG, 7) - * ) - * - * 2) Then, declare tracepoint loglevels for tracepoints. A - * TRACEPOINT_EVENT should be declared prior to the the - * TRACEPOINT_LOGLEVEL for a given tracepoint name. The first field - * is the name of the tracepoint, the second field is the loglevel - * name. - * - * TRACEPOINT_LOGLEVEL(< [com_company_]project_[component_]event >, - * < loglevel_name >) - * - * The TRACEPOINT_SYSTEM must be defined when declaring a - * TRACEPOINT_LOGLEVEL_ENUM and TRACEPOINT_LOGLEVEL. The tracepoint - * loglevel enumeration apply to the entire TRACEPOINT_SYSTEM. Only one - * tracepoint loglevel enumeration should be declared per tracepoint - * system. - */ - -#define TRACEPOINT_LOGLEVEL_ENUM() -#define TRACEPOINT_LOGLEVEL(name, loglevel) - -#endif /* #ifndef TRACEPOINT_LOGLEVEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _UST_TRACEPOINT_H */ diff --git a/include/ust/ust.h b/include/ust/ust.h deleted file mode 100644 index 593598b4..00000000 --- a/include/ust/ust.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 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; 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 - */ - -#ifndef _UST_H -#define _UST_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ust_fork_info { - sigset_t orig_sigs; -} ust_fork_info_t; - -extern void ust_before_fork(ust_fork_info_t *fork_info); -extern void ust_after_fork_parent(ust_fork_info_t *fork_info); -extern void ust_after_fork_child(ust_fork_info_t *fork_info); - -#ifdef __cplusplus -} -#endif - -#endif /* _UST_H */ diff --git a/include/ust/usterr-signal-safe.h b/include/ust/usterr-signal-safe.h deleted file mode 100644 index 998d8d89..00000000 --- a/include/ust/usterr-signal-safe.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef _USTERR_SIGNAL_SAFE_H -#define _USTERR_SIGNAL_SAFE_H - -/* - * Copyright (C) 2009 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; 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 - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include - -enum ust_loglevel { - UST_LOGLEVEL_UNKNOWN = 0, - UST_LOGLEVEL_NORMAL, - UST_LOGLEVEL_DEBUG, -}; - -extern volatile enum ust_loglevel ust_loglevel; -void init_usterr(void); - -static inline int ust_debug(void) -{ - return ust_loglevel == UST_LOGLEVEL_DEBUG; -} - -#ifndef UST_COMPONENT -//#error UST_COMPONENT is undefined -#define UST_COMPONENT libust -#endif - -/* To stringify the expansion of a define */ -#define UST_XSTR(d) UST_STR(d) -#define UST_STR(s) #s - -#define USTERR_MAX_LEN 512 - -/* 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. - */ - -extern int ust_safe_snprintf(char *str, size_t n, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); - -static inline void __attribute__ ((format (printf, 1, 2))) - __check_ust_safe_fmt(const char *fmt, ...) -{ -} - -#define sigsafe_print_err(fmt, args...) \ -{ \ - /* Can't use dynamic allocation. Limit ourselves to USTERR_MAX_LEN chars. */ \ - char ____buf[USTERR_MAX_LEN]; \ - int ____saved_errno; \ - \ - /* Save the errno. */ \ - ____saved_errno = errno; \ - \ - ust_safe_snprintf(____buf, sizeof(____buf), fmt, ## args); \ - \ - /* Add end of string in case of buffer overflow. */ \ - ____buf[sizeof(____buf) - 1] = 0; \ - \ - patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \ - /* \ - * Can't print errors because we are in the error printing code \ - * path. \ - */ \ - \ - /* Restore errno, in order to be async-signal safe. */ \ - errno = ____saved_errno; \ -} - -#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__ ":" UST_XSTR(__LINE__) ")\n", \ - (long) getpid(), \ - (long) syscall(SYS_gettid), \ - ## args, __func__); \ - fflush(stderr); \ - } while(0) - -#ifdef UST_DEBUG -# define DBG(fmt, args...) ERRMSG(fmt, ## args) -# define DBG_raw(fmt, args...) \ - do { \ - sigsafe_print_err(fmt, ## args); \ - fflush(stderr); \ - } while(0) -#else -# define DBG(fmt, args...) \ - do { \ - if (ust_debug()) \ - ERRMSG(fmt, ## args); \ - } while (0) -# define DBG_raw(fmt, args...) \ - do { \ - if (ust_debug()) { \ - sigsafe_print_err(fmt, ## args); \ - fflush(stderr); \ - } \ - } while(0) -#endif -#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args) -#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args) -#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args) - -#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) -#define PERROR(call, args...)\ - do { \ - char buf[200] = "Error in strerror_r()"; \ - strerror_r(errno, buf, sizeof(buf)); \ - ERRMSG("Error: " call ": %s", ## args, buf); \ - } while(0); -#else -#define PERROR(call, args...)\ - do { \ - char *buf; \ - char tmp[200]; \ - buf = strerror_r(errno, tmp, sizeof(tmp)); \ - ERRMSG("Error: " call ": %s", ## args, buf); \ - } while(0); -#endif - -#define BUG_ON(condition) \ - do { \ - if (caa_unlikely(condition)) \ - ERR("condition not respected (BUG) on line %s:%d", __FILE__, __LINE__); \ - } while(0) -#define WARN_ON(condition) \ - do { \ - if (caa_unlikely(condition)) \ - WARN("condition not respected on line %s:%d", __FILE__, __LINE__); \ - } while(0) -#define WARN_ON_ONCE(condition) WARN_ON(condition) - -#endif /* _USTERR_SIGNAL_SAFE_H */ diff --git a/include/ust/vatomic.h b/include/ust/vatomic.h deleted file mode 100644 index a477d4c9..00000000 --- a/include/ust/vatomic.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _LINUX_RING_BUFFER_VATOMIC_H -#define _LINUX_RING_BUFFER_VATOMIC_H - -/* - * linux/ringbuffer/vatomic.h - * - * Copyright (C) 2010 - Mathieu Desnoyers - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include -#include - -/* - * Same data type (long) accessed differently depending on configuration. - * v field is for non-atomic access (protected by mutual exclusion). - * In the fast-path, the ring_buffer_config structure is constant, so the - * compiler can statically select the appropriate branch. - * local_t is used for per-cpu and per-thread buffers. - * atomic_long_t is used for globally shared buffers. - */ -union v_atomic { - long a; /* accessed through uatomic */ - long v; -}; - -static inline -long v_read(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) -{ - assert(config->sync != RING_BUFFER_SYNC_PER_CPU); - return uatomic_read(&v_a->a); -} - -static inline -void v_set(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a, - long v) -{ - assert(config->sync != RING_BUFFER_SYNC_PER_CPU); - uatomic_set(&v_a->a, v); -} - -static inline -void v_add(const struct lttng_ust_lib_ring_buffer_config *config, long v, union v_atomic *v_a) -{ - assert(config->sync != RING_BUFFER_SYNC_PER_CPU); - uatomic_add(&v_a->a, v); -} - -static inline -void v_inc(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) -{ - assert(config->sync != RING_BUFFER_SYNC_PER_CPU); - uatomic_inc(&v_a->a); -} - -/* - * Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer. - */ -static inline -void _v_dec(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a) -{ - --v_a->v; -} - -static inline -long v_cmpxchg(const struct lttng_ust_lib_ring_buffer_config *config, union v_atomic *v_a, - long old, long _new) -{ - assert(config->sync != RING_BUFFER_SYNC_PER_CPU); - return uatomic_cmpxchg(&v_a->a, old, _new); -} - -#endif /* _LINUX_RING_BUFFER_VATOMIC_H */ diff --git a/include/ust/version.h.in b/include/ust/version.h.in deleted file mode 100644 index d65b9209..00000000 --- a/include/ust/version.h.in +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _UST_VERSION_H -#define _UST_VERSION_H - -/* - * ust/version.h.in. Contains the UST versions - * - * (C) Copyright 2011 Yannick Brosseau - * - * 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 UST_MAJOR_VERSION @MAJOR_VERSION@ -#define UST_MINOR_VERSION @MINOR_VERSION@ -#define UST_VERSION @PACKAGE_VERSION@ - -#endif /* _UST_VERSION_H */ diff --git a/include/ust/wait.h b/include/ust/wait.h deleted file mode 100644 index 6cc0e373..00000000 --- a/include/ust/wait.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _UST_WAIT_H -#define _UST_WAIT_H - -/* - * 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; 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 - */ - -#include - -/* - * Wait until "cond" gets true or timeout (in ms). - */ -#define wait_cond_interruptible_timeout(_cond, _timeout) \ - ({ \ - int __ret = 0, __pollret; \ - int __timeout = _timeout; \ - \ - for (;;) { \ - if (_cond) \ - break; \ - if (__timeout <= 0) { \ - __ret = -ETIMEDOUT; \ - break; \ - } \ - __pollret = poll(NULL, 0, 10); /* wait 10ms */ \ - if (__pollret < 0) { \ - __ret = -errno; \ - break; \ - } \ - __timeout -= 10; \ - } \ - __ret; \ - }) - - -#endif /* _UST_WAIT_H */ diff --git a/include/usterr.h b/include/usterr.h index 5f839cb6..820d4f03 100644 --- a/include/usterr.h +++ b/include/usterr.h @@ -27,9 +27,8 @@ #include #include -#include - -#include "share.h" +#include +#include "lttng/share.h" enum ust_loglevel { UST_LOGLEVEL_UNKNOWN = 0, diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 96589600..2903d575 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -29,7 +29,7 @@ #include #include -#include +#include /* * Human readable error message. diff --git a/libringbuffer/api.h b/libringbuffer/api.h index 2f153268..25474e77 100644 --- a/libringbuffer/api.h +++ b/libringbuffer/api.h @@ -13,7 +13,7 @@ #include "backend.h" #include "frontend.h" -#include +#include /* * ring_buffer_frontend_api.h contains static inline functions that depend on diff --git a/libringbuffer/backend.h b/libringbuffer/backend.h index 45ab53d0..69c47ab6 100644 --- a/libringbuffer/backend.h +++ b/libringbuffer/backend.h @@ -16,7 +16,7 @@ #include -#include "ust/core.h" +#include "lttng/core.h" /* Internal helpers */ #include "backend_internal.h" diff --git a/libringbuffer/backend_internal.h b/libringbuffer/backend_internal.h index c0721d15..e3192be7 100644 --- a/libringbuffer/backend_internal.h +++ b/libringbuffer/backend_internal.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include "backend_types.h" #include "frontend_types.h" #include "shm.h" diff --git a/libringbuffer/frontend_api.h b/libringbuffer/frontend_api.h index 0868a4bb..24f94acf 100644 --- a/libringbuffer/frontend_api.h +++ b/libringbuffer/frontend_api.h @@ -18,7 +18,7 @@ */ #include "frontend.h" -#include "ust/core.h" +#include "lttng/core.h" #include #include diff --git a/libringbuffer/frontend_internal.h b/libringbuffer/frontend_internal.h index 4b4135bb..dcf86b77 100644 --- a/libringbuffer/frontend_internal.h +++ b/libringbuffer/frontend_internal.h @@ -18,7 +18,7 @@ #include -#include +#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 84593260..7d9166e0 100644 --- a/libringbuffer/frontend_types.h +++ b/libringbuffer/frontend_types.h @@ -21,10 +21,10 @@ #include #include -#include "ust/core.h" +#include "lttng/core.h" -#include -#include +#include +#include #include "backend_types.h" #include "shm_internal.h" diff --git a/libringbuffer/ring_buffer_abi.c b/libringbuffer/ring_buffer_abi.c index 420a4e99..ed52b718 100644 --- a/libringbuffer/ring_buffer_abi.c +++ b/libringbuffer/ring_buffer_abi.c @@ -10,7 +10,7 @@ #include "backend.h" #include "frontend.h" -#include +#include static int put_ulong(unsigned long val, unsigned long arg) { diff --git a/libringbuffer/ring_buffer_backend.c b/libringbuffer/ring_buffer_backend.c index 50cb1938..f2169aa7 100644 --- a/libringbuffer/ring_buffer_backend.c +++ b/libringbuffer/ring_buffer_backend.c @@ -8,9 +8,9 @@ #include -#include "ust/core.h" +#include "lttng/core.h" -#include +#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 82194bf8..310e0b93 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -46,7 +46,7 @@ #include #include "smp.h" -#include +#include #include "backend.h" #include "frontend.h" #include "shm.h" diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index fd0919fa..fc7fbfb2 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include struct shm_object_table *shm_object_table_create(size_t max_nb_obj) { diff --git a/libringbuffer/shm.h b/libringbuffer/shm.h index 6cac7295..e8fc8d70 100644 --- a/libringbuffer/shm.h +++ b/libringbuffer/shm.h @@ -10,8 +10,8 @@ */ #include -#include -#include "ust/core.h" +#include +#include "lttng/core.h" #include "shm_types.h" /* diff --git a/libringbuffer/smp.c b/libringbuffer/smp.c index 3f86ac86..f9dbd75a 100644 --- a/libringbuffer/smp.c +++ b/libringbuffer/smp.c @@ -1,5 +1,5 @@ /* - * libust/smp.c + * libringbuffer/smp.c * * Copyright 2011 (c) - Mathieu Desnoyers * @@ -7,7 +7,7 @@ */ #include -#include "ust/core.h" +#include "lttng/core.h" #include "usterr.h" #include #include "smp.h" diff --git a/libringbuffer/smp.h b/libringbuffer/smp.h index dd326d83..755c65fc 100644 --- a/libringbuffer/smp.h +++ b/libringbuffer/smp.h @@ -9,7 +9,7 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include +#include /* * 4kB of per-cpu data available. Enough to hold the control structures, diff --git a/libust/ltt-context.c b/libust/ltt-context.c index 7f8351ec..90747a55 100644 --- a/libust/ltt-context.c +++ b/libust/ltt-context.c @@ -8,9 +8,9 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include -#include -#include +#include +#include +#include #include #include diff --git a/libust/ltt-events.c b/libust/ltt-events.c index f48d72b6..68531bcd 100644 --- a/libust/ltt-events.c +++ b/libust/ltt-events.c @@ -18,20 +18,20 @@ #include #include #include -#include +#include #include #include #include -#include -#include -#include "ust/core.h" +#include +#include +#include "lttng/core.h" #include "ltt-tracer.h" #include "ltt-tracer-core.h" -#include "ust/wait.h" +#include "lttng/wait.h" #include "../libringbuffer/shm.h" typedef u32 uint32_t; -#include +#include /* * The sessions mutex is the centralized mutex across UST tracing diff --git a/libust/ltt-probes.c b/libust/ltt-probes.c index 04392d8e..66ee971c 100644 --- a/libust/ltt-probes.c +++ b/libust/ltt-probes.c @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include "ltt-tracer-core.h" diff --git a/libust/ltt-ring-buffer-client.h b/libust/ltt-ring-buffer-client.h index 6c6433cd..a1bc8c32 100644 --- a/libust/ltt-ring-buffer-client.h +++ b/libust/ltt-ring-buffer-client.h @@ -9,9 +9,9 @@ */ #include -#include -#include "ust/bitfield.h" -#include "ust/clock.h" +#include +#include "lttng/bitfield.h" +#include "lttng/clock.h" #include "ltt-tracer.h" #include "../libringbuffer/frontend_types.h" diff --git a/libust/ltt-ring-buffer-metadata-client.h b/libust/ltt-ring-buffer-metadata-client.h index 77093488..d1a83d53 100644 --- a/libust/ltt-ring-buffer-metadata-client.h +++ b/libust/ltt-ring-buffer-metadata-client.h @@ -9,8 +9,8 @@ */ #include -#include -#include "ust/bitfield.h" +#include +#include "lttng/bitfield.h" #include "ltt-tracer.h" #include "../libringbuffer/frontend_types.h" diff --git a/libust/ltt-tracer-core.h b/libust/ltt-tracer-core.h index fe2ecb9e..20ed0c0e 100644 --- a/libust/ltt-tracer-core.h +++ b/libust/ltt-tracer-core.h @@ -21,14 +21,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include +#include +#include +#include #include -#include -#include "ust/bug.h" +#include +#include "lttng/bug.h" -#include +#include struct ltt_session; struct ltt_channel; diff --git a/libust/ltt-tracer.h b/libust/ltt-tracer.h index 45da9c59..6ab80e7c 100644 --- a/libust/ltt-tracer.h +++ b/libust/ltt-tracer.h @@ -25,9 +25,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "ltt-tracer-core.h" /* Number of bytes to log with a read/write event */ diff --git a/libust/lttng-context-procname.c b/libust/lttng-context-procname.c index c1f1ced9..b9bae82e 100644 --- a/libust/lttng-context-procname.c +++ b/libust/lttng-context-procname.c @@ -8,9 +8,9 @@ */ #include -#include -#include -#include +#include +#include +#include #include #define PROCNAME_LEN 17 /* includes \0 */ diff --git a/libust/lttng-context-pthread-id.c b/libust/lttng-context-pthread-id.c index 991df22b..62eda808 100644 --- a/libust/lttng-context-pthread-id.c +++ b/libust/lttng-context-pthread-id.c @@ -8,9 +8,9 @@ */ #include -#include -#include -#include +#include +#include +#include static size_t pthread_id_get_size(size_t offset) diff --git a/libust/lttng-context-vpid.c b/libust/lttng-context-vpid.c index 1fc8aadb..db76747a 100644 --- a/libust/lttng-context-vpid.c +++ b/libust/lttng-context-vpid.c @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __linux__ static inline diff --git a/libust/lttng-context-vtid.c b/libust/lttng-context-vtid.c index 25e2febf..6f7e078d 100644 --- a/libust/lttng-context-vtid.c +++ b/libust/lttng-context-vtid.c @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __linux__ #include diff --git a/libust/lttng-ust-abi.c b/libust/lttng-ust-abi.c index ccfac129..6d17c200 100644 --- a/libust/lttng-ust-abi.c +++ b/libust/lttng-ust-abi.c @@ -24,12 +24,12 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include +#include #include #include -#include -#include -#include "ust/core.h" +#include +#include +#include "lttng/core.h" #include "ltt-tracer.h" /* diff --git a/libust/lttng-ust-comm.c b/libust/lttng-ust-comm.c index 3327e10b..1246c654 100644 --- a/libust/lttng-ust-comm.c +++ b/libust/lttng-ust-comm.c @@ -38,13 +38,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "ltt-tracer-core.h" /* diff --git a/libust/probes/lttng-probe-ust.h b/libust/probes/lttng-probe-ust.h index ba7ff3a1..3394d086 100644 --- a/libust/probes/lttng-probe-ust.h +++ b/libust/probes/lttng-probe-ust.h @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include TRACEPOINT_EVENT(lttng_metadata, @@ -48,4 +48,4 @@ TRACEPOINT_EVENT(lttng_metadata, #endif /* _TRACEPOINT_LTTNG_UST_H */ /* This part must be outside protection */ -#include +#include diff --git a/libust/tracepoint.c b/libust/tracepoint.c index 1a184636..8bf87528 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -21,15 +21,15 @@ #define _LGPL_SOURCE #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include -#include +#include #include "ltt-tracer-core.h" /* Set to 1 to enable tracepoint debug output */ diff --git a/libust/ust-core.c b/libust/ust-core.c index cb87b745..b5cc8cf8 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/libustctl/ustctl.c b/libustctl/ustctl.c index db9aa0c8..6f3d1ed9 100644 --- a/libustctl/ustctl.c +++ b/libustctl/ustctl.c @@ -18,10 +18,10 @@ */ #include -#include -#include -#include -#include +#include +#include +#include +#include #include "../libringbuffer/backend.h" #include "../libringbuffer/frontend.h" diff --git a/libustfork/ustfork.c b/libustfork/ustfork.c index b16d4150..5e6acba1 100644 --- a/libustfork/ustfork.c +++ b/libustfork/ustfork.c @@ -26,7 +26,7 @@ #include #include "usterr.h" -#include +#include struct user_desc; diff --git a/tests/fork/ust_tests_fork.h b/tests/fork/ust_tests_fork.h index 7d87bb59..27e6b47e 100644 --- a/tests/fork/ust_tests_fork.h +++ b/tests/fork/ust_tests_fork.h @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include TRACEPOINT_EVENT_NOARGS(ust_tests_fork_before_fork, @@ -53,4 +53,4 @@ TRACEPOINT_EVENT_NOARGS(ust_tests_fork_after_exec, #define TRACEPOINT_INCLUDE_FILE ust_tests_fork /* This part must be outside protection */ -#include +#include diff --git a/tests/hello/ust_tests_hello.h b/tests/hello/ust_tests_hello.h index 9e5043dd..5ad67f48 100644 --- a/tests/hello/ust_tests_hello.h +++ b/tests/hello/ust_tests_hello.h @@ -26,7 +26,7 @@ extern "C" { * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include TRACEPOINT_EVENT(ust_tests_hello_tptest, TP_PROTO(int anint, int netint, long *values, @@ -64,7 +64,7 @@ TRACEPOINT_EVENT_NOARGS(ust_tests_hello_tptest_sighandler, #define TRACEPOINT_INCLUDE_FILE ust_tests_hello /* This part must be outside protection */ -#include +#include #ifdef __cplusplus } diff --git a/tests/ust-basic-tracing/ust-basic-tracing.c b/tests/ust-basic-tracing/ust-basic-tracing.c index 49a0a3af..43628bd4 100644 --- a/tests/ust-basic-tracing/ust-basic-tracing.c +++ b/tests/ust-basic-tracing/ust-basic-tracing.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include "../../libringbuffer/backend.h" #include "../../libringbuffer/frontend.h" diff --git a/tests/ust-multi-test/ust-multi-test.c b/tests/ust-multi-test/ust-multi-test.c index d0ff9277..541ed44b 100644 --- a/tests/ust-multi-test/ust-multi-test.c +++ b/tests/ust-multi-test/ust-multi-test.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include <../../libringbuffer/backend.h> #include <../../libringbuffer/frontend.h>